Skip to content

qttools.utils.sparse_utils#

source module qttools.utils.sparse_utils

Functions

source product_sparsity_pattern(*matrices: sparse.spmatrix)tuple[NDArray, NDArray]

Computes the sparsity pattern of the product of a sequence of matrices.

Parameters

  • matrices : sparse.spmatrix A sequence of sparse matrices.

Returns

  • rows : NDArray The row indices of the sparsity pattern.

  • cols : NDArray The column indices of the sparsity pattern.

source tocsr_dict(matrix: DSDBSparse)dict[tuple[int, int], sparse.csr_matrix]

Converts a DSDBSparse matrix to a dictionary of CSR blocks.

source product_sparsity_pattern_dsdbsparse(*matrices: DSDBSparse, in_num_diag: int = 3, out_num_diag: int = None, start_block: int = 0, end_block: int = None, spillover: bool = False)tuple[NDArray, NDArray]

Computes the sparsity pattern of the product of a sequence of DSDBSparse matrices.

NOTE: the enough boundary layers need to be periodic for this to be correct.#

Parameters

  • matrices : sparse.spmatrix A sequence of sparse matrices.

Returns

  • rows : NDArray The row indices of the sparsity pattern.

  • cols : NDArray The column indices of the sparsity pattern.