finesse.cymath.sparsemath module

Sparse matrix math tools.

class finesse.cymath.sparsemath.CSRMatrix(ndarray[double complex,ndim=2])[source]

Bases: object

A complex value Compressed Sparse Row (CSR) matrix. This is a useful format for storing a sparse matrix for fast matrix vector products.

This class wraps the csr_matrix structure which is pure C and so can be passed to functions that do not need the GIL.

Parameters

Anp.ndarray[complex, ndim=2]

A dense matrix to convert into a sparse format

col_index[source]

Column index for each non-zero element

cols[source]

Number of columns in matrix

multiply(self, ndarray x)[source]

Compute y = M @ x

nnz[source]

Number of non-zero elements

row_ptr[source]

Index in values and col_index where each row starts

rows[source]

Number of rows in matrix

values[source]

Sparse matrix non-zero values

zcsrgecmv(self, ndarray x, ndarray y)[source]

Complex (z) valued CSR (csr) general (ge) hermitiain conjugate vector (c) matrix (m) vector (v) product.

\[z = y^{\mathrm{H}} \cdot M \cdot x \]

Parameters

xarray

1D, size self.cols

yarray

1D, size self.rows

zcsrgevmv(self, ndarray x, ndarray y)[source]

Complex (z) valued CSR (csr) general (ge) transpose vector (v) matrix (m) vector (v) product.

\[z = y^{\mathrm{T}} \cdot M \cdot x \]

Parameters

xarray

1D, size self.cols

yarray

1D, size self.rows