e3x.ops.indexed.indexed_sum

e3x.ops.indexed.indexed_sum(inputs, keepdims=None, *, adj_idx=None, where=None, dst_idx=None, num_segments=None, indices_are_sorted=False, **_)[source]

Performs a sum over inputs according to sparse or dense index lists.

Parameters:
  • inputs (<class 'Num[Array, '_*indexable_by_relevant_idx']'>) – Inputs to perform the sum over.

  • keepdims (Optional[bool], default: None) – Whether to keep the dimensions of the inputs (so that outputs can be broadcasted to the shape of the inputs). In the case of dense index lists, one axis will be reduced to size 1, in the case of sparse index lists, the shape of inputs and outputs will be the same.

  • adj_idx (Optional[Integer[Array, '... N M']], default: None) – Adjacency indices.

  • where (Optional[Bool[Array, '... N M']], default: None) – Mask to specify which values to sum over, required for dense index lists.

  • dst_idx (Optional[Integer[Array, '... P']], default: None) – Destination indices.

  • num_segments (Optional[int], default: None) – Number of segments after summation, required for sparse index lists.

  • indices_are_sorted (bool, default: False) – If True, dst_idx is assumed to be sorted, which may increase performance (only used for sparse index lists).

Return type:

<class 'Num[Array, '_*input_shape_indexed_by_relevant_idx']'>

Returns:

An array with the results of the summation.

Raises:
  • RuntimeError – If neither dense nor sparse index lists are provided, or if both are provided.

  • ValueError – If inputs are not floating point or integer dtype.