vt::sum#

template<typename T, size_t N>
Tensor<T, 0> vt::sum(const Tensor<T, N> &tensor)#

Returns the sum of the tensor elements.

Template Parameters:
  • T – Data type of the tensor.

  • N – Number of dimensions of the tensor.

Parameters:

tensor – The tensor object.

Returns:

Tensor<T, 0>: The result tensor.

template<size_t N>
Tensor<int, 0> vt::sum(const Tensor<bool, N> &tensor)#

Returns the sum of how many elements are true in the tensor.

Template Parameters:

N – Number of dimensions of the tensor.

Parameters:

tensor – The tensor object.

Returns:

Tensor<T, 0>: The result tensor.

template<typename T, size_t N>
Tensor<T, N - 1> vt::sum(const Tensor<T, N> &tensor, int axis)#

Sum the tensor elements along the given axis. The current implementation is not optimized. The performance could improve if a reduce algorithm is applied along the axis.

Template Parameters:
  • T – Data type of the tensor.

  • N – Number of dimensions of the tensor.

Parameters:
  • tensor – The tensor object.

  • axis – The axis to sum.

Returns:

Tensor<T, N-1>: The result tensor.

template<size_t N>
Tensor<int, N - 1> vt::sum(const Tensor<bool, N> &tensor, int axis)#

Sum of how many elements are true along the given axis. The current implementation is not optimized. The performance could improve if a reduce algorithm is applied along the axis.

Template Parameters:

N – Number of dimensions of the tensor.

Parameters:
  • tensor – The tensor object.

  • axis – The axis to sum.

Returns:

Tensor<int, N-1>: The result tensor.