sparse_sum#

caf.distribute.array_utils.sparse_sum(sparse_array: COO, axis: Iterable[int] | int) COO#
caf.distribute.array_utils.sparse_sum(sparse_array: COO, axis=None) float

Faster sum for a sparse.COO matrix.

Converts the sum to a 2D operation and then optimises functionality for 2D matrices, avoiding sparse.COO N-dimensional code.

Parameters:
  • sparse_array – The sparse array to sum.

  • axis – The axis to sum sparse_array across.

Returns:

The sum of sparse_matrix elements over the given axis

Return type:

sum