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. Matrices may use compact row storage or padded row-capacity storage with explicit active row counts.
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 |
|
Return the active block index in a capacity-aware BSR matrix, or -1 if no such block exists. |
|
Compress the active blocks of |
|
Return a copy of matrix |
|
Create and return a block-diagonal BSR matrix from an given block value or array of block values. |
|
Construct 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 |
|
Return the row containing an active block in a capacity-aware BSR matrix, 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. |
|
Sparse operation status code for insufficient padded row capacity. |
|
Sparse operation status code for success. |