pub struct DiaMatrix<T> { /* private fields */ }
Expand description
Diagonal (DIA) matrix
A sparse matrix format that stores diagonals, making it efficient for matrices with values concentrated on a small number of diagonals.
Implementations§
Source§impl<T> DiaMatrix<T>
impl<T> DiaMatrix<T>
Sourcepub fn new(
data: Vec<Vec<T>>,
offsets: Vec<isize>,
shape: (usize, usize),
) -> SparseResult<Self>
pub fn new( data: Vec<Vec<T>>, offsets: Vec<isize>, shape: (usize, usize), ) -> SparseResult<Self>
Create a new DIA matrix from raw data
§Arguments
data
- Diagonals data (n_diags x max(rows, cols))offsets
- Diagonal offsets from the main diagonalshape
- Tuple containing the matrix dimensions (rows, cols)
§Returns
- A new DIA matrix
§Examples
use scirs2_sparse::dia::DiaMatrix;
// Create a 3x3 sparse matrix with main diagonal and upper diagonal
let data = vec![
vec![1.0, 2.0, 3.0], // Main diagonal
vec![4.0, 5.0, 0.0], // Upper diagonal (k=1)
];
let offsets = vec![0, 1]; // Main diagonal and k=1
let shape = (3, 3);
let matrix = DiaMatrix::new(data, offsets, shape).unwrap();
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> 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> 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