Fork me on GitHub
Arraymancer Technical reference Tutorial Spellbook (How-To's) Under the hood

Module aggregate

Procs

proc sum[T](t: Tensor[T]): T
Compute the sum of all elements   Source Edit
proc sum[T](t: Tensor[T]; axis: int): Tensor[T] {.
noInit
.}
Compute the sum of all elements along an axis   Source Edit
proc product[T](t: Tensor[T]): T
Compute the product of all elements   Source Edit
proc product[T](t: Tensor[T]; axis: int): Tensor[T] {.
noInit
.}
Compute the product along an axis   Source Edit
proc mean[T: SomeInteger](t: Tensor[T]): T {.
inline
.}

Compute the mean of all elements

Warning ⚠: Since input is integer, output will also be integer (using integer division)

  Source Edit
proc mean[T: SomeInteger](t: Tensor[T]; axis: int): Tensor[T] {.
noInit, inline
.}

Compute the mean along an axis

Warning ⚠: Since input is integer, output will also be integer (using integer division)

  Source Edit
proc mean[T: SomeReal](t: Tensor[T]): T {.
inline
.}
Compute the mean of all elements   Source Edit
proc mean[T: SomeReal](t: Tensor[T]; axis: int): Tensor[T] {.
noInit, inline
.}
Compute the mean along an axis   Source Edit
proc min[T](t: Tensor[T]): T
Compute the min of all elements   Source Edit
proc min[T](t: Tensor[T]; axis: int): Tensor[T] {.
noInit
.}
Compute the min along an axis   Source Edit
proc max[T](t: Tensor[T]): T
Compute the max of all elements   Source Edit
proc max[T](t: Tensor[T]; axis: int): Tensor[T] {.
noInit
.}
Compute the max along an axis   Source Edit
proc variance[T: SomeReal](t: Tensor[T]): T
Compute the sample variance of all elements The normalization is by (n-1), also known as Bessel's correction, which partially correct the bias of estimating a population variance from a sample of this population.   Source Edit
proc variance[T: SomeReal](t: Tensor[T]; axis: int): Tensor[T] {.
noInit
.}
Compute the variance of all elements The normalization is by the (n-1), like in the formal definition   Source Edit
proc std[T: SomeReal](t: Tensor[T]): T {.
inline
.}
Compute the standard deviation of all elements The normalization is by the (n-1), like in the formal definition   Source Edit
proc std[T: SomeReal](t: Tensor[T]; axis: int): Tensor[T] {.
noInit, inline
.}
Compute the standard deviation of all elements The normalization is by the (n-1), like in the formal definition   Source Edit
proc argmax_max[T](t: Tensor[T]; axis: int): tuple[indices: Tensor[int],
    maxes: Tensor[T]] {.
noInit
.}
Returns (indices, maxes) along an axis
Input:
  • A tensor
  • An axis (int)
Returns:
  • A tuple of tensors (indices, maxes) along this axis
Example:
let a = [[0, 4, 7],
         [1, 9, 5],
         [3, 4, 1]].toTensor
assert argmax(a, 0).indices == [[2, 1, 0]].toTensor
assert argmax(a, 1).indices == [[2],
                                [1],
                                [1]].toTensor
  Source Edit
proc argmax[T](t: Tensor[T]; axis: int): Tensor[int] {.
inline
.}
Returns the index of the maximum along an axis
Input:
  • A tensor
  • An axis (int)
Returns:
  • A tensor of index of the maximums along this axis
Example:
let a = [[0, 4, 7],
         [1, 9, 5],
         [3, 4, 1]].toTensor
assert argmax(a, 0) == [[2, 1, 0]].toTensor
assert argmax(a, 1) == [[2],
                        [1],
                        [1]].toTensor
  Source Edit