warp.sparse#
Sparse linear algebra operations for Block Sparse Row (BSR) matrices.
This module provides GPU-accelerated sparse matrix operations for simulation, including matrix-matrix multiplication, matrix-vector multiplication, addition, scaling, and transpose operations. BSR format supports arbitrary block sizes, with Compressed Sparse Row (CSR) format supported as a special case using 1x1 blocks.
The BsrMatrix class supports operator overloading for intuitive matrix operations
(+, -, *, @), and lower-level functions are available for fine-grained
control over memory allocations.
- Usage:
This module must be explicitly imported:
import warp.sparse
See also
Sparse Matrices for detailed examples and usage patterns.
API#
Untyped base class for BSR and CSR matrices. |
|
Opaque structure for persisting |
|
Opaque structure for persisting |
|
Copy the content of the |
|
Perform the sparse matrix addition |
|
Returns the index of the block at block-coordinates (row, col), or -1 if no such block exists. |
|
Return a copy of matrix |
|
Create and return a block-diagonal BSR matrix from an given block value or array of block values. |
|
Constructs a BSR matrix with values defined by coordinate-oriented (COO) triplets. |
|
Return the array of blocks that constitute the diagonal of a sparse matrix. |
|
Create and return a square identity matrix. |
|
Perform the sparse matrix-matrix multiplication |
|
Perform the sparse matrix-vector product |
|
Returns the index of the row containing a given block, or -1 if no such row exists. |
|
Perform the operation |
|
Set |
|
Fill a BSR matrix with values defined by coordinate-oriented (COO) triplets, discarding existing blocks. |
|
Set |
|
Assign the transposed matrix |
|
Set a BSR matrix to zero, possibly changing its size. |
|
Return a copy of the transposed matrix |
|
Construct and return an empty BSR or CSR matrix with the given shape. |