VectorizedReduction.jl Documentation

Functions

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

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

source
VectorizedReduction.vall — Method
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.vany — Method
vany([p=identity,] A::AbstractArray; dims=:)

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

source
VectorizedReduction.vany — Method
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.vargmax — Method
vargmax(f, A; dims)
vargmax(A; dims)

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

source
VectorizedReduction.vargmax — Method
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.vargmax — Method
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.vargmin — Method
vargmin(f, A; dims)
vargmin(A; dims)

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

source
VectorizedReduction.vargmin — Method
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.vargmin — Method
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.vcount — Method
vcount([f=identity,] A::AbstractArray; dims=:)

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

source
VectorizedReduction.vcount — Method
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.vcounteq — Method
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.vcountne — Method
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.vfindmax — Method
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.vfindmax — Method
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.vfindmax — Method
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.vfindmin — Method
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.vfindmin — Method
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.vfindmin — Method
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.vlogsoftmax — Method
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.vlogsoftmax — Method
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.vlogsumexp — Method
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.vlogsumexp — Method
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.vmapreducethen — Method
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.vmapreducethen — Method
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.vmaxad — Method
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.vmeanad — Method
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.vminkowski — Method
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.vmse — Method
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.vnorm — Function
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.vrmse — Method
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.vsoftmax — Method
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.vsoftmax — Method
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.vtall — Method
vtall([p=identity,] A::AbstractArray; dims=:)

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

source
VectorizedReduction.vtall — Method
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.vtany — Method
vtany([p=identity,] A::AbstractArray; dims=:)

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

source
VectorizedReduction.vtany — Method
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.vtargmax — Method
vtargmax(f, A; dims)
vtargmax(A; dims)

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

source
VectorizedReduction.vtargmax — Method
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.vtargmax — Method
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.vtargmin — Method
vtargmin(f, A; dims)
vtargmin(A; dims)

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

source
VectorizedReduction.vtargmin — Method
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.vtargmin — Method
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.vtcount — Method
vtcount([f=identity,] A::AbstractArray; dims=:)

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

source
VectorizedReduction.vtcount — Method
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.vtcounteq — Method
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.vtcountne — Method
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.vtextrema — Method
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.vtextrema — Method
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.vtfindmax — Method
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.vtfindmax — Method
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.vtfindmax — Method
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.vtfindmin — Method
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.vtfindmin — Method
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.vtfindmin — Method
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.vtlogsoftmax — Method
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.vtlogsoftmax — Method
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.vtlogsumexp — Method
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.vtlogsumexp — Method
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.vtmapreduce — Method
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.vtmapreduce — Method
vtmapreduce(f, op, init, As::Vararg{AbstractArray, N}; dims=:, init) where {N}

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

source
VectorizedReduction.vtmapreducethen — Method
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.vtmapreducethen — Method
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.vtmapreducethen — Method
vtmapreducethen(f, op, g, init, As::Tuple{Vararg{AbstractArray}}, dims=:)

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

source
VectorizedReduction.vtmaxad — Method
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.vtmaximum — Method
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.vtmaximum — Method
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.vtmeanad — Method
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.vtminimum — Method
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.vtminimum — Method
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.vtminkowski — Method
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.vtmse — Method
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.vtnorm — Function
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.vtprod — Method
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.vtrmse — Method
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.vtsoftmax — Method
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.vtsoftmax — Method
vtsoftmax(A::AbstractArray; dims=:)

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

source
VectorizedReduction.vtsoftmax — Method
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.vtsum — Method
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.vvextrema — Method
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.vvextrema — Method
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.vvmapreduce — Method
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.vvmapreduce — Method
vvmapreduce(f, op, init, As::Vararg{AbstractArray, N}) where {N}

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

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

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

source
VectorizedReduction.vvmaximum — Method
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.vvmaximum — Method
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.vvminimum — Method
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.vvminimum — Method
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.vvprod — Method
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.vvsum — Method
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