pub struct BandedArray<T>{ /* private fields */ }
Expand description
Banded array format for sparse matrices
The BandedArray format stores only the non-zero bands of a matrix. The data is stored in a 2D array where each row represents a diagonal and each column represents the matrix row.
For a matrix with lower bandwidth kl
and upper bandwidth ku
,
the data array has shape (kl + ku + 1, n)
where n
is the number
of matrix rows.
Implementations§
Source§impl<T> BandedArray<T>
impl<T> BandedArray<T>
Sourcepub fn new(
data: Array2<T>,
kl: usize,
ku: usize,
shape: (usize, usize),
) -> SparseResult<Self>
pub fn new( data: Array2<T>, kl: usize, ku: usize, shape: (usize, usize), ) -> SparseResult<Self>
Create a new banded array
Sourcepub fn zeros(shape: (usize, usize), kl: usize, ku: usize) -> Self
pub fn zeros(shape: (usize, usize), kl: usize, ku: usize) -> Self
Create a new zero banded array
Sourcepub fn from_triplets(
rows: &[usize],
cols: &[usize],
data: &[T],
shape: (usize, usize),
kl: usize,
ku: usize,
) -> SparseResult<Self>
pub fn from_triplets( rows: &[usize], cols: &[usize], data: &[T], shape: (usize, usize), kl: usize, ku: usize, ) -> SparseResult<Self>
Create from triplet format (row, col, data)
Sourcepub fn tridiagonal(diag: &[T], lower: &[T], upper: &[T]) -> SparseResult<Self>
pub fn tridiagonal(diag: &[T], lower: &[T], upper: &[T]) -> SparseResult<Self>
Create tridiagonal matrix
Sourcepub fn is_in_band(&self, row: usize, col: usize) -> bool
pub fn is_in_band(&self, row: usize, col: usize) -> bool
Check if an element is within the band structure
Sourcepub fn set_unchecked(&mut self, row: usize, col: usize, value: T)
pub fn set_unchecked(&mut self, row: usize, col: usize, value: T)
Set an element (unchecked for performance)
Sourcepub fn set_direct(
&mut self,
row: usize,
col: usize,
value: T,
) -> SparseResult<()>
pub fn set_direct( &mut self, row: usize, col: usize, value: T, ) -> SparseResult<()>
Set an element with bounds and band checking
Sourcepub fn solve(&self, b: &ArrayView1<'_, T>) -> SparseResult<Array1<T>>
pub fn solve(&self, b: &ArrayView1<'_, T>) -> SparseResult<Array1<T>>
Solve a banded linear system using LU decomposition
Sourcepub fn lu_decomposition(
&self,
) -> SparseResult<(BandedArray<T>, BandedArray<T>, Vec<usize>)>
pub fn lu_decomposition( &self, ) -> SparseResult<(BandedArray<T>, BandedArray<T>, Vec<usize>)>
LU decomposition for banded matrices
Sourcepub fn forward_substitution(
&self,
b: &ArrayView1<'_, T>,
) -> SparseResult<Array1<T>>
pub fn forward_substitution( &self, b: &ArrayView1<'_, T>, ) -> SparseResult<Array1<T>>
Forward substitution for lower triangular banded matrix
Sourcepub fn back_substitution(
&self,
b: &ArrayView1<'_, T>,
) -> SparseResult<Array1<T>>
pub fn back_substitution( &self, b: &ArrayView1<'_, T>, ) -> SparseResult<Array1<T>>
Back substitution for upper triangular banded matrix
Sourcepub fn matvec(&self, x: &ArrayView1<'_, T>) -> SparseResult<Array1<T>>
pub fn matvec(&self, x: &ArrayView1<'_, T>) -> SparseResult<Array1<T>>
Matrix-vector multiplication optimized for banded structure
Source§impl<T> BandedArray<T>
impl<T> BandedArray<T>
Sourcepub fn matmul(&self, other: &BandedMatrix<T>) -> SparseResult<BandedMatrix<T>>
pub fn matmul(&self, other: &BandedMatrix<T>) -> SparseResult<BandedMatrix<T>>
Matrix multiplication (for legacy API compatibility)
Sourcepub fn from_dense(dense: &Array2<T>, kl: usize, ku: usize) -> SparseResult<Self>
pub fn from_dense(dense: &Array2<T>, kl: usize, ku: usize) -> SparseResult<Self>
Create banded matrix from dense array
Trait Implementations§
Source§impl<T> Clone for BandedArray<T>
impl<T> Clone for BandedArray<T>
Source§fn clone(&self) -> BandedArray<T>
fn clone(&self) -> BandedArray<T>
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moreSource§impl<T> Debug for BandedArray<T>
impl<T> Debug for BandedArray<T>
Source§impl<T> SparseArray<T> for BandedArray<T>
impl<T> SparseArray<T> for BandedArray<T>
Source§fn find(&self) -> (Array1<usize>, Array1<usize>, Array1<T>)
fn find(&self) -> (Array1<usize>, Array1<usize>, Array1<T>)
Source§fn dot(
&self,
other: &dyn SparseArray<T>,
) -> SparseResult<Box<dyn SparseArray<T>>>
fn dot( &self, other: &dyn SparseArray<T>, ) -> SparseResult<Box<dyn SparseArray<T>>>
Source§fn to_coo(&self) -> SparseResult<Box<dyn SparseArray<T>>>
fn to_coo(&self) -> SparseResult<Box<dyn SparseArray<T>>>
Source§fn to_csr(&self) -> SparseResult<Box<dyn SparseArray<T>>>
fn to_csr(&self) -> SparseResult<Box<dyn SparseArray<T>>>
Source§fn to_csc(&self) -> SparseResult<Box<dyn SparseArray<T>>>
fn to_csc(&self) -> SparseResult<Box<dyn SparseArray<T>>>
Source§fn to_dok(&self) -> SparseResult<Box<dyn SparseArray<T>>>
fn to_dok(&self) -> SparseResult<Box<dyn SparseArray<T>>>
Source§fn to_lil(&self) -> SparseResult<Box<dyn SparseArray<T>>>
fn to_lil(&self) -> SparseResult<Box<dyn SparseArray<T>>>
Source§fn to_dia(&self) -> SparseResult<Box<dyn SparseArray<T>>>
fn to_dia(&self) -> SparseResult<Box<dyn SparseArray<T>>>
Source§fn to_bsr(&self) -> SparseResult<Box<dyn SparseArray<T>>>
fn to_bsr(&self) -> SparseResult<Box<dyn SparseArray<T>>>
Source§fn add(
&self,
other: &dyn SparseArray<T>,
) -> SparseResult<Box<dyn SparseArray<T>>>
fn add( &self, other: &dyn SparseArray<T>, ) -> SparseResult<Box<dyn SparseArray<T>>>
Source§fn sub(
&self,
other: &dyn SparseArray<T>,
) -> SparseResult<Box<dyn SparseArray<T>>>
fn sub( &self, other: &dyn SparseArray<T>, ) -> SparseResult<Box<dyn SparseArray<T>>>
Source§fn mul(
&self,
other: &dyn SparseArray<T>,
) -> SparseResult<Box<dyn SparseArray<T>>>
fn mul( &self, other: &dyn SparseArray<T>, ) -> SparseResult<Box<dyn SparseArray<T>>>
Source§fn div(
&self,
other: &dyn SparseArray<T>,
) -> SparseResult<Box<dyn SparseArray<T>>>
fn div( &self, other: &dyn SparseArray<T>, ) -> SparseResult<Box<dyn SparseArray<T>>>
Source§fn dot_vector(&self, other: &ArrayView1<'_, T>) -> SparseResult<Array1<T>>
fn dot_vector(&self, other: &ArrayView1<'_, T>) -> SparseResult<Array1<T>>
Source§fn transpose(&self) -> SparseResult<Box<dyn SparseArray<T>>>
fn transpose(&self) -> SparseResult<Box<dyn SparseArray<T>>>
Source§fn copy(&self) -> Box<dyn SparseArray<T>>
fn copy(&self) -> Box<dyn SparseArray<T>>
Source§fn set(&mut self, i: usize, j: usize, value: T) -> SparseResult<()>
fn set(&mut self, i: usize, j: usize, value: T) -> SparseResult<()>
Source§fn eliminate_zeros(&mut self)
fn eliminate_zeros(&mut self)
Source§fn sort_indices(&mut self)
fn sort_indices(&mut self)
Source§fn sorted_indices(&self) -> Box<dyn SparseArray<T>>
fn sorted_indices(&self) -> Box<dyn SparseArray<T>>
Source§fn has_sorted_indices(&self) -> bool
fn has_sorted_indices(&self) -> bool
Source§fn sum(&self, axis: Option<usize>) -> SparseResult<SparseSum<T>>
fn sum(&self, axis: Option<usize>) -> SparseResult<SparseSum<T>>
Source§fn slice(
&self,
row_range: (usize, usize),
col_range: (usize, usize),
) -> SparseResult<Box<dyn SparseArray<T>>>
fn slice( &self, row_range: (usize, usize), col_range: (usize, usize), ) -> SparseResult<Box<dyn SparseArray<T>>>
Auto Trait Implementations§
impl<T> Freeze for BandedArray<T>
impl<T> RefUnwindSafe for BandedArray<T>where
T: RefUnwindSafe,
impl<T> Send for BandedArray<T>where
T: Send,
impl<T> Sync for BandedArray<T>where
T: Sync,
impl<T> Unpin for BandedArray<T>
impl<T> UnwindSafe for BandedArray<T>where
T: 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
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>
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>
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