pub struct SparseMatrix {
pub rows: usize,
pub cols: usize,
pub row_ptr: Vec<usize>,
pub col_idx: Vec<usize>,
pub values: Vec<f64>,
}Fields§
§rows: usize§cols: usize§row_ptr: Vec<usize>§col_idx: Vec<usize>§values: Vec<f64>Implementations§
Source§impl SparseMatrix
impl SparseMatrix
pub fn new(rows: usize, cols: usize) -> SparseMatrix
pub fn from_triplets( rows: usize, cols: usize, triplets: &mut [(usize, usize, f64)], ) -> SparseMatrix
pub fn identity(n: usize) -> SparseMatrix
pub fn nnz(&self) -> usize
pub fn get(&self, row: usize, col: usize) -> f64
pub fn mul_vec(&self, x: &[f64]) -> Vec<f64>
pub fn transpose(&self) -> SparseMatrix
pub fn add(&self, other: &SparseMatrix) -> SparseMatrix
pub fn scale(&self, s: f64) -> SparseMatrix
pub fn matmul(&self, other: &SparseMatrix) -> SparseMatrix
pub fn diagonal(&self) -> Vec<f64>
pub fn frobenius_norm(&self) -> f64
pub fn to_dense(&self) -> Vec<Vec<f64>>
Trait Implementations§
Source§impl Add for &SparseMatrix
impl Add for &SparseMatrix
Source§type Output = SparseMatrix
type Output = SparseMatrix
The resulting type after applying the
+ operator.Source§fn add(self, rhs: &SparseMatrix) -> SparseMatrix
fn add(self, rhs: &SparseMatrix) -> SparseMatrix
Performs the
+ operation. Read moreSource§impl Clone for SparseMatrix
impl Clone for SparseMatrix
Source§fn clone(&self) -> SparseMatrix
fn clone(&self) -> SparseMatrix
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for SparseMatrix
impl Debug for SparseMatrix
Source§impl Display for SparseMatrix
impl Display for SparseMatrix
Source§impl Mul<f64> for &SparseMatrix
impl Mul<f64> for &SparseMatrix
Source§type Output = SparseMatrix
type Output = SparseMatrix
The resulting type after applying the
* operator.Source§impl Mul for &SparseMatrix
impl Mul for &SparseMatrix
Source§type Output = SparseMatrix
type Output = SparseMatrix
The resulting type after applying the
* operator.Source§fn mul(self, rhs: &SparseMatrix) -> SparseMatrix
fn mul(self, rhs: &SparseMatrix) -> SparseMatrix
Performs the
* operation. Read moreSource§impl Neg for &SparseMatrix
impl Neg for &SparseMatrix
Source§type Output = SparseMatrix
type Output = SparseMatrix
The resulting type after applying the
- operator.Source§fn neg(self) -> SparseMatrix
fn neg(self) -> SparseMatrix
Performs the unary
- operation. Read moreSource§impl Sub for &SparseMatrix
impl Sub for &SparseMatrix
Source§type Output = SparseMatrix
type Output = SparseMatrix
The resulting type after applying the
- operator.Source§fn sub(self, rhs: &SparseMatrix) -> SparseMatrix
fn sub(self, rhs: &SparseMatrix) -> SparseMatrix
Performs the
- operation. Read moreAuto Trait Implementations§
impl Freeze for SparseMatrix
impl RefUnwindSafe for SparseMatrix
impl Send for SparseMatrix
impl Sync for SparseMatrix
impl Unpin for SparseMatrix
impl UnsafeUnpin for SparseMatrix
impl UnwindSafe for SparseMatrix
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