Skip to main content

sum_with

Function sum_with 

Source
pub fn sum_with<T, D>(
    a: &Array<T, D>,
    axis: Option<usize>,
    initial: Option<T>,
    where_mask: Option<&Array<bool, IxDyn>>,
) -> Result<Array<T, IxDyn>, FerrayError>
where T: Element + Add<Output = T> + Copy, D: Dimension,
Expand description

Sum reduction with initial and where parameters.

Equivalent to np.sum(a, axis=axis, initial=initial, where=where_mask).

initial defaults to T::zero() when None. where_mask, when provided, must be broadcast-compatible with a.shape() (#565). Callers with typed masks (e.g. Array<bool, Ix1>) should call .to_dyn() before passing. Positions where the broadcast mask is false are skipped.

§Errors

  • FerrayError::AxisOutOfBounds if axis is out of range.
  • FerrayError::ShapeMismatch if where_mask is not broadcast-compatible with a.shape().