sfepy.linalg.sparse module¶
Some sparse matrix utilities missing in scipy.

sfepy.linalg.sparse.
compose_sparse
(blocks, row_sizes=None, col_sizes=None)[source]¶ Compose sparse matrices into a global sparse matrix.
 Parameters
 blockssequence of sequences
The sequence of sequences of equal lengths  the individual sparse matrix blocks. The integer 0 can be used to mark an allzero block, if its size can be determined from the other blocks.
 row_sizessequence, optional
The required row sizes of the blocks. It can be either a sequence of nonnegative integers, or a sequence of slices with nonnegative limits. In any case the sizes have to be compatible with the true block sizes. This allows to extend the matrix shape as needed and to specify sizes of allzero blocks.
 col_sizessequence, optional
The required column sizes of the blocks. See row_sizes.
 Returns
 mtxcoo_matrix
The sparse matrix (COO format) composed from the given blocks.
Examples
Stokeslike problem matrix.
>>> import scipy.sparse as sp >>> A = sp.csr_matrix([[1, 0], [0, 1]]) >>> B = sp.coo_matrix([[1, 1]]) >>> K = compose_sparse([[A, B.T], [B, 0]]) >>> print K.todense() [[1 0 1] [0 1 1] [1 1 0]]

sfepy.linalg.sparse.
infinity_norm
(mtx)[source]¶ Infinity norm of a sparse matrix (maximum absolute row sum).
 Parameters
 mtxspmatrix or array
The sparse matrix.
 Returns
 normfloat
Infinity norm of the matrix.
See also
scipy.linalg.norm
dense matrix norms
Notes
This serves as an upper bound on spectral radius.
CSR and CSC avoid copying indices and indptr arrays.
inspired by PyAMG