One of the indices of the SC-rules selects the trial-wave-function's indices and these are multiplied by the sparse-matrix's data entry only to be segmented summed over the over index. Above Ψ ′ [J SC ] sums over like indices, the segment-sum, this is also explicitly implemented by popular python libraries, e.g. in JAX, , the desired function is jax.ops.segment_sum.