VectorizedReduction.jl Documentation

Functions

VectorizedReduction.vallMethod
vall([p=identity,] A::AbstractArray; dims=:)

Identical to non-keyword args version; slightly less performant due to use of kwargs.

source
VectorizedReduction.vallMethod
vall([p=identity,] A::AbstractArray, dims=:)

Determine whether predicate p returns true for all elements over the given dims. If p is omitted, test whether all values along the given dims are true (in which case A should be AbstractArray{Bool}).

Usage Recommendation

If A is reasonably small, vall may be faster than all; however, as the size of A grows, the probability of all element returning false inevitably increases (it is repeated Bernoulli sampling, thus, even with a very small success probability, a large number of tries makes may yield a scenario where the break of all wins out). Consequently, the probability of individual elements being true should determine choice – if one suspects a reasonable success probability, then all may be preferable, depending on the size A. More testing is needed to determine potential breakpoints.

Additional Notes

This function suffers from the same issue as vfindmax and friends – reductions which include the first dimension with max masks are not yet supported by LoopVectorization. Notably, this function still works as intended for any reduction which does not involve the first dimension.

source
VectorizedReduction.vanyMethod
vany([p=identity,] A::AbstractArray; dims=:)

Identical to non-keyword args version; slightly less performant due to use of kwargs.

source
VectorizedReduction.vanyMethod
vany([p=identity,] A::AbstractArray, dims=:)

Determine whether predicate p returns true for any elements over the given dims. If p is omitted, test whether any values along the given dims are true (in which case A should be AbstractArray{Bool}).

Usage Recommendation

If A is reasonably small, vany may be faster than any; however, as the size of A grows, the probability of any element returning true inevitably increases (it is repeated Bernoulli sampling, thus, even with a very small success probability, a large number of tries makes may yield a scenario where the break of any wins out). Consequently, the probability of individual elements being true should determine choice – if one suspects a reasonable success probability, then any may be preferable, depending on the size A. More testing is needed to determine potential breakpoints.

Additional Notes

This function suffers from the same issue as vfindmax and friends – reductions which include the first dimension with zero masks are not yet supported by LoopVectorization. Notably, this function still works as intended for any reduction which does not involve the first dimension.

source
VectorizedReduction.vargmaxMethod
vargmax(f, A; dims)
vargmax(A; dims)

Identical to non-keywords args version; slightly less performant due to use of kwargs.

source
VectorizedReduction.vargmaxMethod
vargmax(f, A::AbstractArray, dims=:)

Return the index of the argument which maximizes f over the dimensions dims, which may be ::Int, ::NTuple{M, Int} where {M} or ::Colon. Expands upon the functionality provided in Julia Base.

Additional Notes

Due to the current limitations of LoopVectorization, searches over the first dimension of an array are not well-supported. A workaround is possible by reshaping A but the resultant performance is often only on par with argmax. As a temporary convenience, vargmax1 is provided for explicit uses of the re-shaping strategy, though the user is cautioned as to the performance problems.

source
VectorizedReduction.vargmaxMethod
vargmax(f, As::Vararg{AbstractArray, N}; dims=:) where {N}

Return the index of the arguments which maximize f : ℝᴺ → ℝ over the dimensions dims. This expands upon the functionality which exists in Julia Base.

source
VectorizedReduction.vargminMethod
vargmin(f, A; dims)
vargmin(A; dims)

Identical to non-keywords args version; slightly less performant due to use of kwargs.

source
VectorizedReduction.vargminMethod
vargmin(f, A::AbstractArray, dims=:)

Return the index of the argument which minimizes f over the dimensions dims, which may be ::Int, ::NTuple{M, Int} where {M} or ::Colon. Expands upon the functionality provided in Julia Base.

Additional Notes

Due to the current limitations of LoopVectorization, searches over the first dimension of an array are not well-supported. A workaround is possible by reshaping A but the resultant performance is often only on par with argmin. As a temporary convenience, vargmin1 is provided for explicit uses of the re-shaping strategy, though the user is cautioned as to the performance problems.

source
VectorizedReduction.vargminMethod
vargmin(f, As::Vararg{AbstractArray, N}; dims=:) where {N}

Return the index of the arguments which minimize f : ℝᴺ → ℝ over the dimensions dims. This expands upon the functionality which exists in Julia Base.

source
VectorizedReduction.vcountMethod
vcount([f=identity,] A::AbstractArray; dims=:)

Identical to non-keyword args version; slightly less performant due to use of kwargs.

source
VectorizedReduction.vcountMethod
vcount([f=identity,] A::AbstractArray, dims=:)

Count the number of elements in A for which f return true over the given dims. If f is omitted, count the number of true elements in A (which should be AbstractArray{Bool}).

source
VectorizedReduction.vcounteqMethod
vcounteq(x::AbstractArray, y::AbstractArray; dims=:)

Count the number of elements for which xᵢ == yᵢ returns true on the vectors corresponding to the slices along the dimension dims.

See also: vcountne

source
VectorizedReduction.vcountneMethod
vcountne(x::AbstractArray, y::AbstractArray; dims=:)

Count the number of elements for which xᵢ != yᵢ returns true on the vectors corresponding to the slices along the dimension dims.

See also: vcounteq

source
VectorizedReduction.vfindmaxMethod
vfindmax(f, A; dims) -> (f(x), index)
vfindmax(A; dims) -> (x, index)

Identical to non-keywords args version; slightly less performant due to use of kwargs.

source
VectorizedReduction.vfindmaxMethod
vfindmax(f, A::AbstractArray, dims=:) -> (f(x), index)

Return the value and the index of the argument which maximizes f over the dimensions dims, which may be ::Int, ::NTuple{M, Int} where {M} or ::Colon. Expands upon the functionality provided in Julia (v1.8) Base.

Additional Notes

Due to the current limitations of LoopVectorization, searches over the first dimension of an array are not well-supported. A workaround is possible by reshaping A but the resultant performance is often only on par with findmax. As a temporary convenience, vfindmax1 is provided for explicit uses of the re-shaping strategy, though the user is cautioned as to the performance problems.

Warning

NaN values are not handled!

source
VectorizedReduction.vfindmaxMethod
vfindmax(f, As::Vararg{AbstractArray, N}; dims=:) where {N} -> (f(x,y,z,...), index)

Return the value and index of the arguments which maximize f : ℝᴺ → ℝ over the dimensions dims. This expands upon the functionality which exists in Julia Base.

source
VectorizedReduction.vfindminMethod
vfindmin(f, A; dims) -> (f(x), index)
vfindmin(A; dims) -> (x, index)

Identical to non-keywords args versions; slightly less performant due to use of kwargs.

source
VectorizedReduction.vfindminMethod
vfindmin(f, A::AbstractArray, dims=:) -> (f(x), index)

Return the value and the index of the argument which minimizes f over the dimensions dims, which may be ::Int, ::NTuple{M, Int} where {M} or ::Colon. Expands upon the functionality provided in Julia (v1.8) Base.

Additional Notes

Due to the current limitations of LoopVectorization, searches over the first dimension of an array are not well-supported. A workaround is possible by reshaping A but the resultant performance is often only on par with findmin. As a temporary convenience, vfindmin1 is provided for explicit uses of the re-shaping strategy, though the user is cautioned as to the performance problems.

Warning

NaN values are not handled!

source
VectorizedReduction.vfindminMethod
vfindmin(f, As::Vararg{AbstractArray, N}; dims=:) where {N} -> (f(x,y,z,...), index)

Return the value and index of the arguments which minimize f : ℝᴺ → ℝ over the dimensions dims. This expands upon the functionality which exists in Julia Base.

source
VectorizedReduction.vlogsoftmaxMethod
vlogsoftmax(A::AbstractArray)

Compute the log of the softmax function, treating the entire array as a single vector. Care is taken to ensure that the computation will not overflow/underflow, but the caller should be aware that +Inf and NaN are not handled.

See also: vsoftmax

source
VectorizedReduction.vlogsoftmaxMethod
vlogsoftmax(A::AbstractArray, dims)

Compute the log of the softmax function, treating each slice of A specified by dims as if it were a single vector; dims may be ::Int, ::NTuple{M, Int} where {M} or ::Colon. Avoids overflow/underflow, but +Inf and NaN are not handled.

source
VectorizedReduction.vlogsumexpMethod
vlogsumexp(A::AbstractArray)

Compute the log of the sum of exponentials of each element of A. Care is taken to ensure that the computation will not overflow/underflow, but the caller should be aware that +Inf and NaN are not handled.

source
VectorizedReduction.vlogsumexpMethod
vlogsumexp(A::AbstractArray, dims)

Compute the log of the sum of exponentials of each element of A along the dimensions dims, which may be ::Int, ::NTuple{M, Int} where {M} or ::Colon. Avoids overflow/underflow, but +Inf and NaN are not handled.

source
VectorizedReduction.vmapreducethenMethod
vmapreducethen(f, op, g, A::AbstractArray; dims=:, init)

Apply function f to each element of A, reduce the result over the dimensions dims using the binary function op, then apply g to the result. Equivalent to g.(mapreduce(f, op, A, dims=dims, init=init)) but avoids the intermediate implied by said expression while also fusing the post-transform g such that the output array is populated in a single pass.

The reduction necessitates an initial value init which may be <:Number or a function which accepts a single type argument (e.g. zero); init is optional for binary operators +, *, min, and max.

Examples

julia> vmapreducethen(abs2, +, √, [1 2; 3 4], dims=1)    # L₂-norm; see `vnorm`
1×2 Matrix{Float64}:
 3.16228  4.47214

julia> vmapreducethen(abs2, +, √, [1 2; 3 4], dims=2, init=1000.0)
2×1 Matrix{Float64}:
 31.701734968294716
 32.01562118716424

julia> vmapreducethen(exp, +, log, [5 6; 7 8], dims=1)    # LSE, but recommend `vlogsumexp`
1×2 Matrix{Float64}:
 7.12693  8.12693
source
VectorizedReduction.vmapreducethenMethod
vmapreducethen(f, op, g, As::Vararg{AbstractArray, N}; dims=:, init) where {N}

Version of mapreducethen wherein f : ℝᴺ → ℝ, then g : ℝ → ℝ, with reduction over the dimensions dims.

Examples

julia> x, y, z = [1 2; 3 4], [5 6; 7 8], [9 10; 11 12];

julia> vmapreducethen((a, b) -> abs2(a - b), +, √, x, y, dims=2)    # Euclidean distance
2×1 Matrix{Float64}:
 5.656854249492381
 5.656854249492381

julia> vmapreducethen(*, *, exp, x, y, z, dims=2, init=-1.0)
2×1 Matrix{Float64}:
 0.0
 0.0
source
VectorizedReduction.vmaxadMethod
vmaxad(x::AbstractArray, y::AbstractArray; dims=:)

Compute the maximum absolute deviation between the vectors corresponding to the slices along the dimension dims.

See also: vmeanad

source
VectorizedReduction.vmeanadMethod
vmeanad(x::AbstractArray, y::AbstractArray; dims=:)

Compute the mean absolute deviation between the vectors corresponding to the slices along the dimension dims.

See also: vmaxad

source
VectorizedReduction.vminkowskiMethod
vminkowski(x::AbstractArray, y::AbstractArray, p::Real; dims=:)

Compute the Minkowski distance between the vectors corresponding to the slices along the dimensions dims.

p can assume any numeric value (even though not all values produce a mathematically valid vector norm). vminkowski(x, y, Inf) returns the largest value in abs.(x .- y), whereas vminkowski(x, y, -Inf) returns the smallest.

See also: vmanhattan, veuclidean, vchebyshev

source
VectorizedReduction.vmseMethod
vmse(x::AbstractArray, y::AbstractArray; dims=:)

Compute the mean squared error between the vectors corresponding to the slices along the dimension dims.

See also: vrmse

source
VectorizedReduction.vnormFunction
vnorm(A::AbstractArray, p::Real=2; dims=:)

Compute the p-norm of A along the dimensions dims as if the corresponding slices were vectors.

p can assume any numeric value (even though not all values produce a mathematically valid vector norm). vnorm(A, Inf) returns the largest value in abs.(A), whereas vnorm(A, -Inf) returns the smallest; vnorm(A, 0) matches the behavior of LinearAlgebra.norm(A, 0).

See also: vtnorm

source
VectorizedReduction.vrmseMethod
vrmse(x::AbstractArray, y::AbstractArray; dims=:)

Compute the square root of the mean squared error between the vectors corresponding to the slices along the dimension dims. More efficient than sqrt.(vmse(...)) as the sqrt operation is performed at the point of generation, thereby eliminating the full traversal which would otherwise occur.

See also: vmse

source
VectorizedReduction.vsoftmaxMethod
vsoftmax(A::AbstractArray)

Compute the softmax function, treating the entire array as a single vector. Care is taken to ensure that the computation will not overflow/underflow, but the caller should be aware that +Inf and NaN are not handled.

See also: vlogsoftmax

source
VectorizedReduction.vsoftmaxMethod
vsoftmax(A::AbstractArray, dims)

Compute the softmax function, treating each slice of A specified by dims as if it were a single vector; dims may be ::Int, ::NTuple{M, Int} where {M} or ::Colon. Avoids overflow/underflow, but +Inf and NaN are not handled.

source
VectorizedReduction.vtallMethod
vtall([p=identity,] A::AbstractArray; dims=:)

Identical to non-keyword args version; slightly less performant due to use of kwargs.

source
VectorizedReduction.vtallMethod
vtall([p=identity,] A::AbstractArray, dims=:)

Determine whether predicate p returns true for all elements over the given dims. If p is omitted, test whether all values along the given dims are true (in which case A should be AbstractArray{Bool}). Threaded.

Additional Notes

This function suffers from the same issue as vfindmax and friends – reductions which include the first dimension with max masks are not yet supported by LoopVectorization. Notably, this function still works as intended for any reduction which does not involve the first dimension.

source
VectorizedReduction.vtanyMethod
vtany([p=identity,] A::AbstractArray; dims=:)

Identical to non-keyword args version; slightly less performant due to use of kwargs.

source
VectorizedReduction.vtanyMethod
vtany([p=identity,] A::AbstractArray, dims=:)

Determine whether predicate p returns true for any elements over the given dims. If p is omitted, test whether any values along the given dims are true (in which case A should be AbstractArray{Bool}). Threaded.

Additional Notes

This function suffers from the same issue as vfindmax and friends – reductions which include the first dimension with zero masks are not yet supported by LoopVectorization. Notably, this function still works as intended for any reduction which does not involve the first dimension.

source
VectorizedReduction.vtargmaxMethod
vtargmax(f, A; dims)
vtargmax(A; dims)

Identical to non-keywords args version; slightly less performant due to use of kwargs. Threaded.

source
VectorizedReduction.vtargmaxMethod
vtargmax(f, A::AbstractArray, dims=:)

Return the index of the argument which maximizes f over the dimensions dims, which may be ::Int, ::NTuple{M, Int} where {M} or ::Colon. Threaded.

See also: vargmax

source
VectorizedReduction.vtargmaxMethod
vargmax(f, As::Vararg{AbstractArray, N}; dims=:) where {N}

Return the index of the arguments which maximize f : ℝᴺ → ℝ over the dimensions dims. Threaded.

source
VectorizedReduction.vtargminMethod
vtargmin(f, A; dims)
vtargmin(A; dims)

Identical to non-keywords args version; slightly less performant due to use of kwargs. Threaded.

source
VectorizedReduction.vtargminMethod
vtargmin(f, A::AbstractArray, dims=:)

Return the index of the argument which minimizes f over the dimensions dims, which may be ::Int, ::NTuple{M, Int} where {M} or ::Colon. Threaded.

See also: vargmin

source
VectorizedReduction.vtargminMethod
vargmin(f, As::Vararg{AbstractArray, N}; dims=:) where {N}

Return the index of the arguments which minimize f : ℝᴺ → ℝ over the dimensions dims. Threaded.

source
VectorizedReduction.vtcountMethod
vtcount([f=identity,] A::AbstractArray; dims=:)

Identical to non-keyword args version; slightly less performant due to use of kwargs. Threaded.

source
VectorizedReduction.vtcountMethod
vtcount([f=identity,] A::AbstractArray, dims=:)

Count the number of elements in A for which f return true over the given dims. If f is omitted, count the number of true elements in A (which should be AbstractArray{Bool}). Threaded.

source
VectorizedReduction.vtcounteqMethod
vtcounteq(x::AbstractArray, y::AbstractArray; dims=:)

Count the number of elements for which xᵢ == yᵢ returns true on the vectors corresponding to the slices along the dimension dims. Threaded.

See also: vtcountne

source
VectorizedReduction.vtcountneMethod
vtcountne(x::AbstractArray, y::AbstractArray; dims=:)

Count the number of elements for which xᵢ != yᵢ returns true on the vectors corresponding to the slices along the dimension dims. Threaded.

See also: vtcounteq

source
VectorizedReduction.vtextremaMethod
vtextrema([f=identity], A::AbstractArray, dims=:)

Compute the minimum and maximum values by calling f on each element of of A over the given dims. Threaded.

source
VectorizedReduction.vtextremaMethod
vtextrema([f=identity], A::AbstractArray; [dims=:], [init=(mn,mx)])

Compute the minimum and maximum values by calling f on each element of of A over the given dims, with the mn and mn initialized by the respective arguments of the 2-tuple init, which can be any combination of values (<:Number) or functions which accept a single type argument. Threaded.

Warning

NaN values are not handled!

Examples

julia> A = reshape(Vector(1:2:16), (2,2,2))
2×2×2 Array{Int64, 3}:
[:, :, 1] =
 1  5
 3  7

[:, :, 2] =
  9  13
 11  15

julia> vtextrema(abs2, A, dims=(1,2), init=(typemax, 100))
1×1×2 Array{Tuple{Int64, Int64}, 3}:
[:, :, 1] =
 (1, 100)

[:, :, 2] =
 (81, 225)

julia> vtextrema(abs2, A, init=(typemax, 100))
(1, 225)
source
VectorizedReduction.vtfindmaxMethod
vtfindmax(f, A; dims) -> (f(x), index)
vtfindmax(A; dims) -> (x, index)

Identical to non-keywords args version; slightly less performant due to use of kwargs. Threaded.

source
VectorizedReduction.vtfindmaxMethod
vtfindmax(f, A::AbstractArray, dims=:) -> (f(x), index)

Return the value and the index of the argument which maximizes f over the dimensions dims, which may be ::Int, ::NTuple{M, Int} where {M} or ::Colon. Threaded.

See also: vfindmax

Warning

NaN values are not handled!

source
VectorizedReduction.vtfindmaxMethod
vtfindmax(f, As::Vararg{AbstractArray, N}; dims=:) where {N} -> (f(x,y,z,...), index)

Return the value and index of the arguments which maximize f : ℝᴺ → ℝ over the dimensions dims. Threaded.

source
VectorizedReduction.vtfindminMethod
vtfindmin(f, A; dims) -> (f(x), index)
vtfindmin(A; dims) -> (x, index)

Identical to non-keywords args version; slightly less performant due to use of kwargs. Threaded.

source
VectorizedReduction.vtfindminMethod
vtfindmin(f, A::AbstractArray, dims=:) -> (f(x), index)

Return the value and the index of the argument which minimizes f over the dimensions dims, which may be ::Int, ::NTuple{M, Int} where {M} or ::Colon. Threaded.

See also: vfindmin

Warning

NaN values are not handled!

source
VectorizedReduction.vtfindminMethod
vtfindmin(f, As::Vararg{AbstractArray, N}; dims=:) where {N} -> (f(x,y,z,...), index)

Return the value and index of the arguments which minimize f : ℝᴺ → ℝ over the dimensions dims. Threaded.

source
VectorizedReduction.vtlogsoftmaxMethod
vtlogsoftmax(A::AbstractArray, dims)

Compute the log of the softmax function, treating each slice of A specified by dims as if it were a single vector; dims may be ::Int, ::NTuple{M, Int} where {M} or ::Colon. Threaded. Avoids overflow/underflow, but +Inf and NaN are not handled.

source
VectorizedReduction.vtlogsoftmaxMethod
vtlogsoftmax(A::AbstractArray)

Compute the log of the softmax function, treating the entire array as a single vector. Threaded. Care is taken to ensure that the computation will not overflow/underflow, but the caller should be aware that +Inf and NaN are not handled.

See also: vtsoftmax

source
VectorizedReduction.vtlogsumexpMethod
vtlogsumexp(A::AbstractArray)

Compute the log of the sum of exponentials of each element of A. Threaded. Care is taken to ensure that the computation will not overflow/underflow, but the caller should be aware that +Inf and NaN are not handled.

source
VectorizedReduction.vtlogsumexpMethod
vtlogsumexp(A::AbstractArray, dims)

Compute the log of the sum of exponentials of each element of A along the dimensions dims, which may be ::Int, ::NTuple{M, Int} where {M} or ::Colon. Threaded. Avoids overflow/underflow, but +Inf and NaN are not handled.

source
VectorizedReduction.vtmapreduceMethod
vtmapreduce(f, op, init, A::AbstractArray, dims=:)

Apply function f to each element of A, then reduce the result over the dimensions dims using the binary function op. Threaded. See vvmapreduce for description of dims. init need not be provided when op is one of +, *, min, max.

See also: vtsum, vtprod, vtminimum, vtmaximum

source
VectorizedReduction.vtmapreduceMethod
vtmapreduce(f, op, init, As::Vararg{AbstractArray, N}; dims=:, init) where {N}

Version for f : ℝᴺ → ℝ, with reduction over dims. Threaded.

source
VectorizedReduction.vtmapreducethenMethod
vtmapreducethen(f, op, g, A::AbstractArray; dims=:, init)

Apply function f to each element of A, reduce the result over the dimensions dims using the binary function op, then apply g to the result. Equivalent to g.(mapreduce(f, op, A, dims=dims, init=init)) but avoids the intermediate implied by said expression while also fusing the post-transform g such that the output array is populated in a single pass. Threaded.

The reduction necessitates an initial value init which may be <:Number or a function which accepts a single type argument (e.g. zero); init is optional for binary operators +, *, min, and max.

Examples

julia> vtmapreducethen(abs2, +, √, [1 2; 3 4], dims=1)    # L₂-norm; see `vnorm`
1×2 Matrix{Float64}:
 3.16228  4.47214

julia> vtmapreducethen(abs2, +, √, [1 2; 3 4], dims=2, init=1000.0)
2×1 Matrix{Float64}:
 31.701734968294716
 32.01562118716424

julia> vtmapreducethen(exp, +, log, [5 6; 7 8], dims=1)    # LSE, but recommend `vlogsumexp`
1×2 Matrix{Float64}:
 7.12693  8.12693
source
VectorizedReduction.vtmapreducethenMethod
vtmapreducethen(f, op, g, init, As::Vararg{AbstractArray, N}) where {N}

Version of mapreducethen for f : ℝᴺ → ℝ, then g : ℝ → ℝ, with reduction occurring over all dimensions.

source
VectorizedReduction.vtmapreducethenMethod
vtmapreducethen(f, op, g, init, As::Tuple{Vararg{AbstractArray}}, dims=:)

Version of mapreducethen for f : ℝᴺ → ℝ, then g : ℝ → ℝ, with reduction over given dims.

source
VectorizedReduction.vtmaxadMethod
vtmaxad(x::AbstractArray, y::AbstractArray; dims=:)

Compute the maximum absolute deviation between the vectors corresponding to the slices along the dimension dims. Threaded.

See also: vtmeanad

source
VectorizedReduction.vtmaximumMethod
vtmaximum(f, A; dims=:, init=typemin)

Compute the maximum value of calling f on each element of A over the given dims, with the max initialized by init, which may be a value <:Number or a function which accepts a single type argument.

source
VectorizedReduction.vtmaximumMethod
vtmaximum(f, A::AbstractArray, dims=:)

Compute the maximum value by calling f on each element of A over the given dims.

Warning

NaN values are not handled!

source
VectorizedReduction.vtmeanadMethod
vtmeanad(x::AbstractArray, y::AbstractArray; dims=:)

Compute the mean absolute deviation between the vectors corresponding to the slices along the dimension dims. Threaded.

See also: vtmaxad

source
VectorizedReduction.vtminimumMethod
vtminimum(f, A; dims=:, init=typemax)

Compute the minimum value of calling f on each element of A over the given dims, with the min initialized by init, which may be a value <:Number or a function which accepts a single type argument.

source
VectorizedReduction.vtminimumMethod
vtminimum(f, A::AbstractArray, dims=:)

Compute the minimum value by calling f on each element of A over the given dims.

Warning

NaN values are not handled!

source
VectorizedReduction.vtminkowskiMethod
vtminkowski(x::AbstractArray, y::AbstractArray, p::Real; dims=:)

Compute the Minkowski distance between the vectors corresponding to the slices along the dimensions dims. Threaded.

p can assume any numeric value (even though not all values produce a mathematically valid vector norm). vtminkowski(x, y, Inf) returns the largest value in abs.(x .- y), whereas vtminkowski(x, y, -Inf) returns the smallest.

See also: vtmanhattan, vteuclidean, vtchebyshev

source
VectorizedReduction.vtmseMethod
vtmse(x::AbstractArray, y::AbstractArray; dims=:)

Compute the mean squared error between the vectors corresponding to the slices along the dimension dims. Threaded.

See also: vtrmse

source
VectorizedReduction.vtnormFunction
vtnorm(A::AbstractArray, p::Real=2; dims=:)

Compute the p-norm of A along the dimensions dims as if the corresponding slices were vectors. Threaded.

p can assume any numeric value (even though not all values produce a mathematically valid vector norm). vtnorm(A, Inf) returns the largest value in abs.(A), whereas vtnorm(A, -Inf) returns the smallest; vnorm(A, 0) matches the behavior of LinearAlgebra.norm(A, 0).

See also: vnorm

source
VectorizedReduction.vtprodMethod
vtprod(f, A; dims=:, init=one)

Multiply the results of calling f on each element of A over the given dims, with the product initialized by init, which may be a value <:Number or a function which accepts a single type argument.

source
VectorizedReduction.vtrmseMethod
vtrmse(x::AbstractArray, y::AbstractArray; dims=:)

Compute the square root of the mean squared error between the vectors corresponding to the slices along the dimension dims. More efficient than sqrt.(vmse(...)) as the sqrt operation is performed at the point of generation, thereby eliminating the full traversal which would otherwise occur. Threaded.

See also: vtmse

source
VectorizedReduction.vtsoftmaxMethod
vtsoftmax(A::AbstractArray)

Compute the softmax function, treating the entire array as a single vector. Threaded. Care is taken to ensure that the computation will not overflow/underflow, but the caller should be aware that +Inf and NaN are not handled.

See also: vtlogsoftmax

source
VectorizedReduction.vtsoftmaxMethod
vtsoftmax(A::AbstractArray; dims=:)

Identical to non-keyword args version; slightly less performant due to use of kwargs. Threaded.

source
VectorizedReduction.vtsoftmaxMethod
vtsoftmax(A::AbstractArray, dims)

Compute the softmax function, treating each slice of A specified by dims as if it were a single vector; dims may be ::Int, ::NTuple{M, Int} where {M} or ::Colon. Threaded. Avoids overflow/underflow, but +Inf and NaN are not handled.

source
VectorizedReduction.vtsumMethod
vtsum(f, A; dims=:, init=zero)

Sum the results of calling f on each element of A over the given dims, with the sum initialized by init, which may be a value <:Number or a function which accepts a single type argument.

source
VectorizedReduction.vvextremaMethod
vvextrema([f=identity], A::AbstractArray, dims=:)

Compute the minimum and maximum values by calling f on each element of of A over the given dims.

source
VectorizedReduction.vvextremaMethod
vvextrema([f=identity], A::AbstractArray; [dims=:], [init=(mn,mx)])

Compute the minimum and maximum values by calling f on each element of of A over the given dims, with the mn and mx initialized by the respective arguments of the 2-tuple init, which can be any combination of values (<:Number) or functions which accept a single type argument.

Warning

NaN values are not handled!

Examples

julia> A = reshape(Vector(1:2:16), (2,2,2))
2×2×2 Array{Int64, 3}:
[:, :, 1] =
 1  5
 3  7

[:, :, 2] =
  9  13
 11  15

julia> vvextrema(abs2, A, dims=(1,2), init=(typemax, 100))
1×1×2 Array{Tuple{Int64, Int64}, 3}:
[:, :, 1] =
 (1, 100)

[:, :, 2] =
 (81, 225)

julia> vvextrema(abs2, A, init=(typemax, 100))
(1, 225)
source
VectorizedReduction.vvmapreduceMethod
vvmapreduce(f, op, init, A::AbstractArray, dims=:)

Apply function f to each element of A, then reduce the result over the dimensions dims using the binary function op. The reduction necessitates an initial value init which may be <:Number or a function which accepts a single type argument (e.g. zero); init is optional for binary operators +, *, min, and max. dims may be ::Int, ::NTuple{M, Int} where {M} or ::Colon.

See also: vvsum, vvprod, vvminimum, vvmaximum

source
VectorizedReduction.vvmapreduceMethod
vvmapreduce(f, op, init, As::Vararg{AbstractArray, N}) where {N}

Version of mapreduce for f : ℝᴺ → ℝ, with reduction occurring over all dimensions.

source
VectorizedReduction.vvmapreduceMethod
vvmapreduce(f, op, init, As::Tuple{Vararg{AbstractArray}}, dims=:)

Version of mapreduce for f : ℝᴺ → ℝ, with reduction over given dims.

source
VectorizedReduction.vvmaximumMethod
vvmaximum(f, A; dims=:, init=typemin)

Compute the maximum value of calling f on each element of A over the given dims, with the max initialized by init, which may be a value <:Number or a function which accepts a single type argument.

source
VectorizedReduction.vvmaximumMethod
vvmaximum(f, A::AbstractArray, dims=:)

Compute the maximum value by calling f on each element of A over the given dims.

Warning

NaN values are not handled!

source
VectorizedReduction.vvminimumMethod
vvminimum(f, A; dims=:, init=typemax)

Compute the minimum value of calling f on each element of A over the given dims, with the min initialized by init, which may be a value <:Number or a function which accepts a single type argument.

source
VectorizedReduction.vvminimumMethod
vvminimum(f, A::AbstractArray, dims=:)

Compute the minimum value by calling f on each element of A over the given dims.

Warning

NaN values are not handled!

source
VectorizedReduction.vvprodMethod
vvprod(f, A; dims=:, init=one)

Multiply the results of calling f on each element of A over the given dims, with the product initialized by init, which may be a value <:Number or a function which accepts a single type argument.

source
VectorizedReduction.vvsumMethod
vvsum(f, A; dims=:, init=zero)

Sum the results of calling f on each element of A over the given dims, with the sum initialized by init, which may be a value <:Number or a function which accepts a single type argument.

source

Index