dsdbcoo#
Includes the distributed block-accessible COO matrix data structure.
Classes:
-
DSDBCOO–A Distributed Stack of Distributed Block-accessible COO matrices.
DSDBCOO
#
DSDBCOO(dtype: dtype[generic], rows: NDArray, cols: NDArray, block_sizes: NDArray, local_stack_shape: tuple | int, global_stack_shape: tuple | int, symmetry: str | None = None)
Bases: DSDBSparse
A Distributed Stack of Distributed Block-accessible COO matrices.
Note
It is the caller's responsibility to ensure that the data is distributed correctly across the ranks.
Parameters:
-
dtype(dtype[generic]) –The data type of the matrix.
-
rows(NDArray) –The local row indices of the COO matrix.
-
cols(NDArray) –The local column indices of the COO matrix.
-
block_sizes(NDArray) –The size of each block in the sparse matrix.
-
local_stack_shape(tuple or int) –The local shape of the stack. If this is an integer, it is interpreted as a one-dimensional stack.
-
global_stack_shape(tuple or int) –The global shape of the stack. If this is an integer, it is interpreted as a one-dimensional stack.
-
symmetry(str | None, default:None) –The symmetry of the matrix. This can be "symmetric", "hermitian", "skew-symmetric", "skew-hermitian", or None. Default is None.
Methods:
-
block_sizes–Sets new block sizes for the matrix.
-
spy–Returns the row and column indices of the non-zero elements.
-
symmetrize–Symmetrizes the matrix with a given symmetry.
-
empty_like–Creates a new DSDBCOO matrix with the same shape and
-
from_sparray–Constructs a DSDBCOO matrix from a sparse matrix.
-
to_dense–Converts the local data to a dense array.
block_sizes
#
Sets new block sizes for the matrix.
Parameters:
-
block_sizes(NDArray) –The new block sizes.
spy
#
spy() -> tuple[NDArray, NDArray]
Returns the row and column indices of the non-zero elements.
This is essentially the same as converting the sparsity pattern to coordinate format. The returned sparsity pattern is not sorted.
Note
In the block distributed case, this returns the local sparsity pattern.
Returns:
-
rows(NDArray) –Row indices of the non-zero elements.
-
cols(NDArray) –Column indices of the non-zero elements.
symmetrize
#
symmetrize(symmetry: str) -> None
Symmetrizes the matrix with a given symmetry.
Note
This assumes that the matrix's sparsity pattern is symmetric.
Parameters:
-
symmetry(str) –The symmetry to enforce. This can be "symmetric", "hermitian", "skew-symmetric", or "skew-hermitian".
empty_like
classmethod
#
from_sparray
classmethod
#
from_sparray(sparray: spmatrix, block_sizes: NDArray, global_stack_shape: tuple, symmetry: str | None = None, dtype: dtype[generic] = complex128, allocate: bool = True) -> DSDBCOO
Constructs a DSDBCOO matrix from a sparse matrix.
This essentially distributed the matrix across the stack and block communicators.
Parameters:
-
sparray(spmatrix) –The sparse matrix from which to use the sparsity pattern.
-
block_sizes(NDArray) –The block sizes of the block-sparse matrix.
-
global_stack_shape(tuple) –The global shape of the stack.
-
symmetry(str | None, default:None) –The symmetry of the matrix. This can be "symmetric", "hermitian", "skew-symmetric", "skew-hermitian", or None. Default is None.
-
dtype(dtype, default:complex128) –The data type of the matrix. Default is
xp.complex128. -
allocate(bool, default:True) –Whether to allocate the data of the resulting matrix. Default is True.
Returns:
-
DSDBCOO–The new DSDBCOO matrix.
to_dense
#
Converts the local data to a dense array.
This is dumb, unless used for testing and debugging.
Warning
This creates a very large dense matrix.
Returns:
-
arr(NDArray) –The dense array of shape
(*local_stack_shape, *shape).