pygsti.tools.matrixtools.csr_sum

Contents

pygsti.tools.matrixtools.csr_sum#

csr_sum(data, coeffs, csr_mxs, csr_sum_indices)#

Accelerated summation of several CSR-format sparse matrices.

csr_sum_indices() precomputes the necessary indices for summing directly into the data-array of a destination CSR sparse matrix. If data is the data-array of matrix D (for “destination”), then this method performs:

D += sum_i( coeff[i] * csr_mxs[i] )

Note that D is not returned; the sum is done internally into D’s data-array.

Parameters:
  • data (numpy.ndarray) – The data-array of the destination CSR-matrix.

  • coeffs (iterable) – The weight coefficients which multiply each summed matrix.

  • csr_mxs (iterable) – A list of CSR matrix objects whose data-array is given by obj.data (e.g. a SciPy CSR sparse matrix).

  • csr_sum_indices (list) – A list of precomputed index arrays as returned by csr_sum_indices().

Return type:

None