klyn.math.NDArray.sum
method
public sum(axes as IList<Long>, keepDims as Boolean = false, where as Boolean[] = null, ignoreNaN as Boolean = false, result as NDArray<T> = null) as NDArray<T>
Description

Sum over several axes, preserving the source numeric element type. Floating types accumulate in Double before one final storage conversion. Integer arithmetic follows the ordinary fixed-width sum contract.

Parameters
ParameterDescription
axesDistinct positive/negative axes to reduce.
keepDimsRetain reduced axes with length one.
whereOptional flat Boolean selection mask.
ignoreNaNSkip NaNs; otherwise propagate them for floating input.
resultOptional non-aliased output tensor of the expected shape/type.
Returns

Reduced tensor; an all-masked slice has sum zero.

Throws
  • IndexException for invalid axes.
  • ValueException for duplicate axes or invalid mask/destination shape.
Example

totals = data.sum(axes=[0l, 2l], keepDims=true)