pub struct BsrMatrix<T> { /* private fields */ }
Expand description
Block Sparse Row (BSR) matrix
A sparse matrix format that stores blocks in compressed sparse row format, making it efficient for block-structured matrices.
Implementations§
Source§impl<T> BsrMatrix<T>
impl<T> BsrMatrix<T>
Sourcepub fn new(
shape: (usize, usize),
block_size: (usize, usize),
) -> SparseResult<Self>
pub fn new( shape: (usize, usize), block_size: (usize, usize), ) -> SparseResult<Self>
Create a new BSR matrix
§Arguments
shape
- Tuple containing the matrix dimensions (rows, cols)block_size
- Tuple containing the block dimensions (r, c)
§Returns
- A new empty BSR matrix
§Examples
use scirs2_sparse::bsr::BsrMatrix;
// Create a 6x6 sparse matrix with 2x2 blocks
let matrix = BsrMatrix::<f64>::new((6, 6), (2, 2)).unwrap();
Sourcepub fn from_blocks(
data: Vec<Vec<Vec<T>>>,
indices: Vec<Vec<usize>>,
indptr: Vec<usize>,
shape: (usize, usize),
block_size: (usize, usize),
) -> SparseResult<Self>
pub fn from_blocks( data: Vec<Vec<Vec<T>>>, indices: Vec<Vec<usize>>, indptr: Vec<usize>, shape: (usize, usize), block_size: (usize, usize), ) -> SparseResult<Self>
Sourcepub fn block_size(&self) -> (usize, usize)
pub fn block_size(&self) -> (usize, usize)
Get the block size
Sourcepub fn nnz_blocks(&self) -> usize
pub fn nnz_blocks(&self) -> usize
Get the number of non-zero blocks in the matrix
Auto Trait Implementations§
impl<T> Freeze for BsrMatrix<T>
impl<T> RefUnwindSafe for BsrMatrix<T>where
T: RefUnwindSafe,
impl<T> Send for BsrMatrix<T>where
T: Send,
impl<T> Sync for BsrMatrix<T>where
T: Sync,
impl<T> Unpin for BsrMatrix<T>where
T: Unpin,
impl<T> UnwindSafe for BsrMatrix<T>where
T: UnwindSafe,
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
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more