pub struct BsrMatrix { /* private fields */ }Expand description
Block Sparse Row matrix.
A matrix of shape (block_rows * block_size) × (block_cols * block_size),
where non-zero blocks are stored in CSR-of-blocks layout.
Implementations§
Source§impl BsrMatrix
impl BsrMatrix
Sourcepub fn new(
block_rows: usize,
block_cols: usize,
block_size: usize,
offsets: Vec<u32>,
col_indices: Vec<u32>,
values: Vec<f32>,
) -> Result<Self, SparseError>
pub fn new( block_rows: usize, block_cols: usize, block_size: usize, offsets: Vec<u32>, col_indices: Vec<u32>, values: Vec<f32>, ) -> Result<Self, SparseError>
Create a new BSR matrix.
§Arguments
block_rows,block_cols: number of block rows/columnsblock_size: dimension of each square blockoffsets: CSR-style row offsets for blockscol_indices: block column indicesvalues: dense block data (row-major per block)
§Errors
Returns error if structure is invalid.
Sourcepub fn from_dense(
data: &[f32],
rows: usize,
cols: usize,
block_size: usize,
) -> Self
pub fn from_dense( data: &[f32], rows: usize, cols: usize, block_size: usize, ) -> Self
Create BSR from a dense matrix.
Pads the matrix if dimensions aren’t divisible by block_size. Only stores blocks with at least one non-zero element.
Sourcepub fn nnz_blocks(&self) -> usize
pub fn nnz_blocks(&self) -> usize
Number of non-zero blocks.
Sourcepub fn block_size(&self) -> usize
pub fn block_size(&self) -> usize
Block size.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for BsrMatrix
impl RefUnwindSafe for BsrMatrix
impl Send for BsrMatrix
impl Sync for BsrMatrix
impl Unpin for BsrMatrix
impl UnsafeUnpin for BsrMatrix
impl UnwindSafe for BsrMatrix
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more