pub struct BlockDiagonalMatrix<A>{ /* private fields */ }
Expand description
Block diagonal matrix with efficient storage and operations
Stores only the blocks along the diagonal, enabling O(sum of block sizes) storage instead of O(n²) for the full matrix.
Implementations§
Source§impl<A> BlockDiagonalMatrix<A>
impl<A> BlockDiagonalMatrix<A>
Sourcepub fn new(blocks: Vec<Array2<A>>) -> LinalgResult<Self>
pub fn new(blocks: Vec<Array2<A>>) -> LinalgResult<Self>
Create a new block diagonal matrix from a list of square blocks
Sourcepub fn from_views(blocks: Vec<ArrayView2<'_, A>>) -> LinalgResult<Self>
pub fn from_views(blocks: Vec<ArrayView2<'_, A>>) -> LinalgResult<Self>
Create a block diagonal matrix from a list of array views
Sourcepub fn num_blocks(&self) -> usize
pub fn num_blocks(&self) -> usize
Get the number of blocks
Sourcepub fn block_mut(&mut self, index: usize) -> Option<&mut Array2<A>>
pub fn block_mut(&mut self, index: usize) -> Option<&mut Array2<A>>
Get a mutable reference to a specific block
Sourcepub fn block_offset(&self, index: usize) -> Option<usize>
pub fn block_offset(&self, index: usize) -> Option<usize>
Get the starting offset for a specific block
Sourcepub fn solve(&self, b: &ArrayView1<'_, A>) -> LinalgResult<Array1<A>>
pub fn solve(&self, b: &ArrayView1<'_, A>) -> LinalgResult<Array1<A>>
Solve the linear system Ax = b using block-wise operations
Sourcepub fn determinant(&self) -> LinalgResult<A>
pub fn determinant(&self) -> LinalgResult<A>
Compute the determinant as the product of block determinants
Sourcepub fn inverse(&self) -> LinalgResult<Self>
pub fn inverse(&self) -> LinalgResult<Self>
Compute the inverse as a block diagonal matrix of block inverses
Trait Implementations§
Source§impl<A> Clone for BlockDiagonalMatrix<A>
impl<A> Clone for BlockDiagonalMatrix<A>
Source§fn clone(&self) -> BlockDiagonalMatrix<A>
fn clone(&self) -> BlockDiagonalMatrix<A>
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moreSource§impl<A> Debug for BlockDiagonalMatrix<A>
impl<A> Debug for BlockDiagonalMatrix<A>
Source§impl<A> SpecializedMatrix<A> for BlockDiagonalMatrix<A>
impl<A> SpecializedMatrix<A> for BlockDiagonalMatrix<A>
Source§fn matvec(&self, x: &ArrayView1<'_, A>) -> LinalgResult<Array1<A>>
fn matvec(&self, x: &ArrayView1<'_, A>) -> LinalgResult<Array1<A>>
Perform matrix-vector multiplication: A * x
Source§fn matvec_transpose(&self, x: &ArrayView1<'_, A>) -> LinalgResult<Array1<A>>
fn matvec_transpose(&self, x: &ArrayView1<'_, A>) -> LinalgResult<Array1<A>>
Perform transposed matrix-vector multiplication: A^T * x
Source§fn to_dense(&self) -> LinalgResult<Array2<A>>
fn to_dense(&self) -> LinalgResult<Array2<A>>
Convert to a dense matrix representation
Source§fn to_operator(&self) -> LinalgResult<LinearOperator<A>>
fn to_operator(&self) -> LinalgResult<LinearOperator<A>>
Convert to a matrix-free operator
Auto Trait Implementations§
impl<A> Freeze for BlockDiagonalMatrix<A>
impl<A> RefUnwindSafe for BlockDiagonalMatrix<A>where
A: RefUnwindSafe,
impl<A> Send for BlockDiagonalMatrix<A>
impl<A> Sync for BlockDiagonalMatrix<A>
impl<A> Unpin for BlockDiagonalMatrix<A>
impl<A> UnwindSafe for BlockDiagonalMatrix<A>where
A: RefUnwindSafe,
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> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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