pub struct DiaMatrix<T> {
pub nrows: usize,
pub ncols: usize,
pub offsets: Vec<i64>,
pub diags: Vec<Vec<T>>,
}Expand description
Diagonal storage format for banded / multi-diagonal sparse matrices.
Stores explicitly named diagonals. Diagonal offset = 0 is the main
diagonal, offset > 0 is superdiagonal, offset < 0 is subdiagonal.
§Layout
Each diagonal d with offset k has length min(nrows, ncols, nrows - max(0,-k), ncols - max(0,k)).
They are stored as flat Vec<T> with the first valid element at position 0.
Fields§
§nrows: usizeNumber of rows.
ncols: usizeNumber of columns.
offsets: Vec<i64>Diagonal offsets (may be negative).
diags: Vec<Vec<T>>Diagonal data; diags[i] has length equal to the diagonal with offsets[i].
Implementations§
Source§impl<T> DiaMatrix<T>
impl<T> DiaMatrix<T>
Sourcepub fn new(
nrows: usize,
ncols: usize,
offsets: Vec<i64>,
diags: Vec<Vec<T>>,
) -> SparseResult<Self>
pub fn new( nrows: usize, ncols: usize, offsets: Vec<i64>, diags: Vec<Vec<T>>, ) -> SparseResult<Self>
Create a DiaMatrix from explicit diagonals.
§Arguments
nrows- Number of rows.ncols- Number of columns.offsets- Diagonal offsets.diags- OneVec<T>per offset.
Sourcepub fn from_csr(csr: &CsrMatrix<T>) -> SparseResult<Self>
pub fn from_csr(csr: &CsrMatrix<T>) -> SparseResult<Self>
Construct from a CSR matrix by extracting its diagonals.
Sourcepub fn spmv(&self, x: &[T]) -> SparseResult<Vec<T>>
pub fn spmv(&self, x: &[T]) -> SparseResult<Vec<T>>
SpMV: y = self * x.
Sourcepub fn to_csr(&self) -> SparseResult<CsrMatrix<T>>
pub fn to_csr(&self) -> SparseResult<CsrMatrix<T>>
Convert to CSR format.
Trait Implementations§
Auto Trait Implementations§
impl<T> Freeze for DiaMatrix<T>
impl<T> RefUnwindSafe for DiaMatrix<T>where
T: RefUnwindSafe,
impl<T> Send for DiaMatrix<T>where
T: Send,
impl<T> Sync for DiaMatrix<T>where
T: Sync,
impl<T> Unpin for DiaMatrix<T>where
T: Unpin,
impl<T> UnsafeUnpin for DiaMatrix<T>
impl<T> UnwindSafe for DiaMatrix<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> 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