pub struct CsrMatrixView<'a, T>(/* private fields */);Expand description
An immutable view of a CSR matrix.
This provides efficient read-only access to CSR matrix data without allocation. Views are commonly used for matrix operations and can be easily created from both mutable and immutable CSR matrices.
§Examples
use algebra_sparse::{CsrMatrix, CsrMatrixViewMethods};
use nalgebra::DMatrix;
let dense = DMatrix::from_row_slice(2, 2, &[1.0, 2.0, 3.0, 4.0]);
let csr = CsrMatrix::from_dense(dense.as_view());
let view = csr.as_view();
println!("Number of rows: {}", view.nrows());
println!("Number of columns: {}", view.ncols());Implementations§
Source§impl<'a, T> CsrMatrixView<'a, T>
impl<'a, T> CsrMatrixView<'a, T>
Sourcepub fn from_parts_unchecked(
row_offsets: &'a [usize],
col_indices: &'a [usize],
values: &'a [T],
ncol: usize,
) -> Self
pub fn from_parts_unchecked( row_offsets: &'a [usize], col_indices: &'a [usize], values: &'a [T], ncol: usize, ) -> Self
Creates a CsrMatrixView from raw parts without checking validity.
§Safety
This function does not validate that the provided parts form a valid CSR matrix. Invalid parts may cause undefined behavior when accessing the matrix.
§Arguments
row_offsets- Row offset array (length = nrows + 1)col_indices- Column index array for non-zero elementsvalues- Non-zero values arrayncol- Number of columns
Source§impl<'a, T> CsrMatrixView<'a, T>where
T: Real,
impl<'a, T> CsrMatrixView<'a, T>where
T: Real,
Sourcepub fn dense_rate(&self) -> f32
pub fn dense_rate(&self) -> f32
Returns the density rate of the matrix.
This is the ratio of non-zero elements to total elements. A value of 0.1 means 10% of elements are non-zero.
Sourcepub fn transpose(&self) -> CscMatrixView<'a, T>
pub fn transpose(&self) -> CscMatrixView<'a, T>
Transposes the CSR matrix view to a CSC matrix view.
This is a zero-cost operation that only changes the interpretation of the data. No data is copied or moved.
§Returns
A CSC view of the same matrix data
Trait Implementations§
Source§impl<'a, T: Clone> Clone for CsrMatrixView<'a, T>
impl<'a, T: Clone> Clone for CsrMatrixView<'a, T>
Source§fn clone(&self) -> CsrMatrixView<'a, T>
fn clone(&self) -> CsrMatrixView<'a, T>
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl<'a, T: Debug> Debug for CsrMatrixView<'a, T>
impl<'a, T: Debug> Debug for CsrMatrixView<'a, T>
Source§impl<'b, T> IntoView for &CsrMatrixView<'b, T>where
T: Copy,
impl<'b, T> IntoView for &CsrMatrixView<'b, T>where
T: Copy,
Source§impl<'a, T> IntoView for CsrMatrixView<'a, T>
impl<'a, T> IntoView for CsrMatrixView<'a, T>
Source§impl<'a, T: Real> Mul<CscMatrixView<'a, T>> for CsrMatrixView<'a, T>
impl<'a, T: Real> Mul<CscMatrixView<'a, T>> for CsrMatrixView<'a, T>
Source§impl<'a, T: Real> Mul<DiagonalBlockMatrixView<'a, T>> for CsrMatrixView<'a, T>
impl<'a, T: Real> Mul<DiagonalBlockMatrixView<'a, T>> for CsrMatrixView<'a, T>
Source§impl<'a, T: Real> Mul<Matrix<T, Dyn, Const<1>, VecStorage<T, Dyn, Const<1>>>> for CsrMatrixView<'a, T>
impl<'a, T: Real> Mul<Matrix<T, Dyn, Const<1>, VecStorage<T, Dyn, Const<1>>>> for CsrMatrixView<'a, T>
Source§impl<'a, T: Real> Mul<Matrix<T, Dyn, Const<1>, ViewStorage<'a, T, Dyn, Const<1>, Const<1>, Dyn>>> for CsrMatrixView<'a, T>
impl<'a, T: Real> Mul<Matrix<T, Dyn, Const<1>, ViewStorage<'a, T, Dyn, Const<1>, Const<1>, Dyn>>> for CsrMatrixView<'a, T>
Source§impl<'a, T: Real> Mul<Matrix<T, Dyn, Dyn, ViewStorage<'a, T, Dyn, Dyn, Const<1>, Dyn>>> for CsrMatrixView<'a, T>
impl<'a, T: Real> Mul<Matrix<T, Dyn, Dyn, ViewStorage<'a, T, Dyn, Dyn, Const<1>, Dyn>>> for CsrMatrixView<'a, T>
impl<'a, T: Copy> Copy for CsrMatrixView<'a, T>
Auto Trait Implementations§
impl<'a, T> Freeze for CsrMatrixView<'a, T>
impl<'a, T> RefUnwindSafe for CsrMatrixView<'a, T>where
T: RefUnwindSafe,
impl<'a, T> Send for CsrMatrixView<'a, T>where
T: Sync,
impl<'a, T> Sync for CsrMatrixView<'a, T>where
T: Sync,
impl<'a, T> Unpin for CsrMatrixView<'a, T>
impl<'a, T> UnwindSafe for CsrMatrixView<'a, 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<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
Source§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
self from the equivalent element of its
superset. Read moreSource§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
self is actually part of its subset T (and can be converted to it).Source§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
self.to_subset but without any property checks. Always succeeds.Source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
self to the equivalent element of its superset.