pub struct SparseMatrix<'a, T>where
T: MatrixElement,
<T as FromStr>::Err: Error + 'static,
Vec<T>: IntoParallelIterator,
Vec<&'a T>: IntoParallelRefIterator<'a>,{
pub data: SparseMatrixData<'a, T>,
pub nrows: usize,
pub ncols: usize,
/* private fields */
}Expand description
Represents a sparse matrix and its data
Fields§
§data: SparseMatrixData<'a, T>Vector containing all data
nrows: usizeNumber of rows
ncols: usizeNumber of columns
Implementations§
Source§impl<'a, T> SparseMatrix<'a, T>where
T: MatrixElement,
<T as FromStr>::Err: Error + 'static,
Vec<T>: IntoParallelIterator,
Vec<&'a T>: IntoParallelRefIterator<'a>,
impl<'a, T> SparseMatrix<'a, T>where
T: MatrixElement,
<T as FromStr>::Err: Error + 'static,
Vec<T>: IntoParallelIterator,
Vec<&'a T>: IntoParallelRefIterator<'a>,
Sourcepub fn new(data: SparseMatrixData<'a, T>, shape: Shape) -> Self
pub fn new(data: SparseMatrixData<'a, T>, shape: Shape) -> Self
Constructs a new sparse matrix based on a hashmap containing the indices where value is not 0
This function does not check whether or not the
indices are valid and according to shape. Use reshape
to fix this issue.
Examples
use std::collections::HashMap;
use sukker::{smd, SparseMatrix, SparseMatrixData};
// Here we can use the smd! macro
// to easily be able to set up a new hashmap
let indexes: SparseMatrixData<f64> = smd![
( (0, 0), 2.0),
( (0, 3), 4.0),
( (4, 5), 6.0),
( (2, 7), 8.0)
];
let sparse = SparseMatrix::<f64>::new(indexes, (3,3));
assert_eq!(sparse.shape(), (3,3));
assert_eq!(sparse.get(4,5), None);
assert_eq!(sparse.get(0,1), Some(0.0));Sourcepub fn eye(size: usize) -> Self
pub fn eye(size: usize) -> Self
Returns a sparse eye matrix
Examples
use sukker::SparseMatrix;
let sparse = SparseMatrix::<i32>::eye(3);
assert_eq!(sparse.ncols, 3);
assert_eq!(sparse.nrows, 3);Sourcepub fn eye_like(matrix: &Self) -> Self
pub fn eye_like(matrix: &Self) -> Self
Produces an eye with the same shape as another sparse matrix
Sourcepub fn identity(size: usize) -> Self
pub fn identity(size: usize) -> Self
Same as eye
Examples
use sukker::SparseMatrix;
let sparse = SparseMatrix::<f64>::identity(3);
assert_eq!(sparse.ncols, 3);
assert_eq!(sparse.nrows, 3);Sourcepub fn ones(sparsity: f64, shape: Shape) -> Self
pub fn ones(sparsity: f64, shape: Shape) -> Self
Creates a matrix with only one values at random locations
Same as random_like but with range from 1.0..=1.0
Sourcepub fn reshape(&mut self, nrows: usize, ncols: usize)
pub fn reshape(&mut self, nrows: usize, ncols: usize)
Reshapes a sparse matrix
Examples
use sukker::SparseMatrix;
let mut sparse = SparseMatrix::<f64>::identity(3);
sparse.reshape(5,5);
assert_eq!(sparse.ncols, 5);
assert_eq!(sparse.nrows, 5);Sourcepub fn from_dense(matrix: Matrix<'a, T>) -> Self
pub fn from_dense(matrix: Matrix<'a, T>) -> Self
Creates a sparse matrix from a already existent dense one.
Examples:
use sukker::{SparseMatrix, Matrix};
let dense = Matrix::<i32>::eye(4);
let sparse = SparseMatrix::from_dense(dense);
assert_eq!(sparse.get(0,0), Some(1));
assert_eq!(sparse.get(1,0), Some(0));
assert_eq!(sparse.shape(), (4,4));Sourcepub fn from_slices(
rows: &[usize],
cols: &[usize],
vals: &[T],
shape: Shape,
) -> Result<Self, MatrixError>
pub fn from_slices( rows: &[usize], cols: &[usize], vals: &[T], shape: Shape, ) -> Result<Self, MatrixError>
Constructs a sparse matrix from 3 slices. One for the rows, one for the cols, and one for the value. A combination of values fromt the same index corresponds to an entry in the hasmap.
Csc in numpy uses 3 lists of same size
Examples:
use sukker::SparseMatrix;
let rows = vec![0,1,2,3];
let cols = vec![1,2,3,4];
let vals= vec![0.0,1.3,0.05,4.53];
let shape = (6,7);
let sparse = SparseMatrix::from_slices(&rows, &cols, &vals, shape).unwrap();
assert_eq!(sparse.shape(), (6,7));
assert_eq!(sparse.at(1,2), 1.3);
assert_eq!(sparse.at(0,1), 0.0);Sourcepub fn from_file(path: &'static str) -> Result<Self, MatrixError>
pub fn from_file(path: &'static str) -> Result<Self, MatrixError>
Parses from file, but will return a default sparse matrix if nothing is given
§Examples
use sukker::SparseMatrix;
// let m: SparseMatrix<f32> = Matrix::from_file("../../test.txt").unwrap();
// m.print(4);Sourcepub fn get(&self, i: usize, j: usize) -> Option<T>
pub fn get(&self, i: usize, j: usize) -> Option<T>
Gets an element from the sparse matrix.
Returns None if index is out of bounds.
Examples
use sukker::SparseMatrix;
let sparse = SparseMatrix::<i32>::eye(3);
assert_eq!(sparse.get(0,0), Some(1));
assert_eq!(sparse.get(1,0), Some(0));
assert_eq!(sparse.get(4,0), None);Sourcepub fn randomize_range(start: T, end: T, sparsity: f64, shape: Shape) -> Self
pub fn randomize_range(start: T, end: T, sparsity: f64, shape: Shape) -> Self
Gets the size of the sparse matrix
Examples
use sukker::SparseMatrix;
let sparse = SparseMatrix::<f32>::randomize_range(1.0,2.0, 0.75, (4,4));
assert_eq!(sparse.shape(), (4,4));
assert_eq!(sparse.sparsity(), 0.75);
assert_eq!(sparse.all(|(_, val)| val >= 1.0 && val <= 2.0), true);
assert_eq!(sparse.size(), 16);Sourcepub fn randomize(sparcity: f64, shape: Shape) -> Self
pub fn randomize(sparcity: f64, shape: Shape) -> Self
Randomizes a sparse matrix with values between 0 and 1.
Examples
use sukker::SparseMatrix;
let sparse = SparseMatrix::<f32>::randomize(0.75, (4,4));
assert_eq!(sparse.shape(), (4,4));
assert_eq!(sparse.sparsity(), 0.75);
assert_eq!(sparse.all(|(_, val)| val >= 0.0 && val <= 1.0), true);
assert_eq!(sparse.size(), 16);Sourcepub fn randomize_range_like(start: T, end: T, matrix: &Self) -> Self
pub fn randomize_range_like(start: T, end: T, matrix: &Self) -> Self
Randomizes a sparse matrix to have same shape and sparcity as another one You can however set the range
Examples
use sukker::SparseMatrix;
let sparse = SparseMatrix::<f32>::randomize_range(1.0,2.0, 0.75, (4,4));
let copy = SparseMatrix::randomize_range_like(2.0, 4.0, &sparse);
assert_eq!(copy.shape(), (4,4));
assert_eq!(copy.sparsity(), 0.75);
assert_eq!(copy.all(|(_, val)| val >= 2.0 && val <= 4.0), true);
assert_eq!(copy.size(), 16);Sourcepub fn random_like(matrix: &Self) -> Self
pub fn random_like(matrix: &Self) -> Self
Randomizes a sparse matrix to have same shape and sparcity as another one The values here are set to be between 0 and 1, no matter the value range of the matrix whos shape is being copied.
Examples
use sukker::SparseMatrix;
let sparse = SparseMatrix::<f32>::randomize_range(2.0, 4.0, 0.75, (4,4));
let copy = SparseMatrix::random_like(&sparse);
assert_eq!(copy.shape(), (4,4));
assert_eq!(copy.sparsity(), 0.75);
assert_eq!(copy.all(|(_, val)| val >= 0.0 && val <= 1.0), true);
assert_eq!(copy.size(), 16);Sourcepub fn at(&self, i: usize, j: usize) -> T
pub fn at(&self, i: usize, j: usize) -> T
Same as get, but will panic if indexes are out of bounds
Examples:
use sukker::SparseMatrix;
let sparse = SparseMatrix::<i32>::eye(3);
assert_eq!(sparse.at(0,0), 1);
assert_eq!(sparse.at(1,0), 0);Sourcepub fn set(&mut self, value: T, idx: Shape)
pub fn set(&mut self, value: T, idx: Shape)
Sets an element
If you’re trying to insert a zero-value, this function does nothing
Mutates or inserts a value based on indeces given
Sourcepub fn insert(&mut self, i: usize, j: usize, value: T)
pub fn insert(&mut self, i: usize, j: usize, value: T)
A way of inserting with individual row and col
Sourcepub fn print(&self, decimals: usize)
pub fn print(&self, decimals: usize)
Prints out the sparse matrix data
Only prints out the hashmap with a set amount of decimals
Sourcepub fn size(&self) -> usize
pub fn size(&self) -> usize
Gets the size of the sparse matrix
Examples:
use sukker::SparseMatrix;
let sparse = SparseMatrix::<i32>::eye(4);
assert_eq!(sparse.size(), 16);Sourcepub fn get_zero_count(&self) -> usize
pub fn get_zero_count(&self) -> usize
Get’s amount of 0s in the matrix
Examples:
use sukker::SparseMatrix;
let sparse = SparseMatrix::<i32>::eye(4);
assert_eq!(sparse.get_zero_count(), 12);Sourcepub fn sparsity(&self) -> f64
pub fn sparsity(&self) -> f64
Calcualtes sparcity for the given matrix Sparity is defined as the percantage of the matrix filled with 0 values
Examples:
use sukker::SparseMatrix;
let sparse = SparseMatrix::<i32>::eye(4);
assert_eq!(sparse.sparsity(), 0.75);Sourcepub fn shape(&self) -> Shape
pub fn shape(&self) -> Shape
Shape of the matrix outputted as a tuple
Examples:
use sukker::SparseMatrix;
let sparse = SparseMatrix::<i32>::eye(3);
assert_eq!(sparse.shape(), (3,3));Sourcepub fn transpose(&mut self)
pub fn transpose(&mut self)
Transpose the matrix
Examples:
use sukker::SparseMatrix;
let mut sparse = SparseMatrix::<i32>::init(4,4);
sparse.set(1, (2,0));
sparse.set(2, (3,0));
sparse.set(3, (0,1));
sparse.set(4, (0,2));
sparse.transpose();
assert_eq!(sparse.at(0,2), 1);
assert_eq!(sparse.at(0,3), 2);
assert_eq!(sparse.at(1,0), 3);
assert_eq!(sparse.at(2,0), 4);
// Old value is now gone
assert_eq!(sparse.get(3,0), Some(0));Sourcepub fn transpose_new(&self) -> Self
pub fn transpose_new(&self) -> Self
Tranpose the matrix into a new copy
Examples:
use sukker::SparseMatrix;
let mut mat = SparseMatrix::<i32>::init(4,4);
mat.set(1, (2,0));
mat.set(2, (3,0));
mat.set(3, (0,1));
mat.set(4, (0,2));
let sparse = mat.transpose_new();
assert_eq!(sparse.at(0,2), 1);
assert_eq!(sparse.at(0,3), 2);
assert_eq!(sparse.at(1,0), 3);
assert_eq!(sparse.at(2,0), 4);
assert_eq!(sparse.get(3,0), Some(0));Source§impl<'a, T> SparseMatrix<'a, T>where
T: MatrixElement,
<T as FromStr>::Err: Error + 'static,
Vec<T>: IntoParallelIterator,
Vec<&'a T>: IntoParallelRefIterator<'a>,
Operations on sparse matrices
impl<'a, T> SparseMatrix<'a, T>where
T: MatrixElement,
<T as FromStr>::Err: Error + 'static,
Vec<T>: IntoParallelIterator,
Vec<&'a T>: IntoParallelRefIterator<'a>,
Operations on sparse matrices
Sourcepub fn add(&self, other: &Self) -> Result<Self, MatrixError>
pub fn add(&self, other: &Self) -> Result<Self, MatrixError>
Adds two sparse matrices together and return a new one
Examples:
use sukker::SparseMatrix;
let sparse1 = SparseMatrix::<i32>::eye(3);
let sparse2 = SparseMatrix::<i32>::eye(3);
let res = sparse1.add(&sparse2).unwrap();
assert_eq!(res.shape(), (3,3));
assert_eq!(res.get(0,0).unwrap(), 2);Sourcepub fn sub(&self, other: &Self) -> Result<Self, MatrixError>
pub fn sub(&self, other: &Self) -> Result<Self, MatrixError>
Subtracts two sparse matrices and return a new one
Examples:
use sukker::SparseMatrix;
let sparse1 = SparseMatrix::<i32>::eye(3);
let sparse2 = SparseMatrix::<i32>::eye(3);
let res = sparse1.sub(&sparse2).unwrap();
assert_eq!(res.shape(), (3,3));
assert_eq!(res.get(0,0).unwrap(), 2);Sourcepub fn mul(&self, other: &Self) -> Result<Self, MatrixError>
pub fn mul(&self, other: &Self) -> Result<Self, MatrixError>
Multiplies two sparse matrices together and return a new one
Examples:
use sukker::SparseMatrix;
let sparse1 = SparseMatrix::<i32>::eye(3);
let sparse2 = SparseMatrix::<i32>::eye(3);
let res = sparse1.mul(&sparse2).unwrap();
assert_eq!(res.shape(), (3,3));
assert_eq!(res.get(0,0).unwrap(), 2);Sourcepub fn dot(&self, other: &Self) -> Result<Self, MatrixError>
pub fn dot(&self, other: &Self) -> Result<Self, MatrixError>
Same as mul. This kind of matrix multiplication is called
a dot product
Sourcepub fn div(&self, other: &Self) -> Result<Self, MatrixError>
pub fn div(&self, other: &Self) -> Result<Self, MatrixError>
Divides two sparse matrices and return a new one
Examples:
use sukker::SparseMatrix;
let sparse1 = SparseMatrix::<i32>::eye(3);
let sparse2 = SparseMatrix::<i32>::eye(3);
let res = sparse1.div(&sparse2).unwrap();
assert_eq!(res.shape(), (3,3));
assert_eq!(res.get(0,0).unwrap(), 2);Sourcepub fn add_self(&mut self, other: &Self)
pub fn add_self(&mut self, other: &Self)
Adds rhs matrix on to lhs matrix. All elements from rhs gets inserted into lhs
Examples:
use sukker::SparseMatrix;
let mut sparse1 = SparseMatrix::<i32>::eye(3);
let sparse2 = SparseMatrix::<i32>::eye(3);
sparse1.add_self(&sparse2);
assert_eq!(sparse1.shape(), (3,3));
assert_eq!(sparse1.get(0,0).unwrap(), 2);Sourcepub fn sub_self(&mut self, other: &Self)
pub fn sub_self(&mut self, other: &Self)
Subs rhs matrix on to lhs matrix. All elements from rhs gets inserted into lhs
Examples:
use sukker::SparseMatrix;
let mut sparse1 = SparseMatrix::<i32>::eye(3);
let sparse2 = SparseMatrix::<i32>::eye(3);
sparse1.sub_self(&sparse2);
assert_eq!(sparse1.shape(), (3,3));
assert_eq!(sparse1.get(0,0).unwrap(), 0);Sourcepub fn mul_self(&mut self, other: &Self)
pub fn mul_self(&mut self, other: &Self)
Multiplies rhs matrix on to lhs matrix. All elements from rhs gets inserted into lhs
Examples:
use sukker::SparseMatrix;
let mut sparse1 = SparseMatrix::<i32>::eye(3);
let sparse2 = SparseMatrix::<i32>::eye(3);
sparse1.mul_self(&sparse2);
assert_eq!(sparse1.shape(), (3,3));
assert_eq!(sparse1.get(0,0).unwrap(), 1);Sourcepub fn div_self(&mut self, other: &Self)
pub fn div_self(&mut self, other: &Self)
Divides rhs matrix on to lhs matrix. All elements from rhs gets inserted into lhs
Examples:
use sukker::SparseMatrix;
let mut sparse1 = SparseMatrix::<i32>::eye(3);
let sparse2 = SparseMatrix::<i32>::eye(3);
sparse1.div_self(&sparse2);
assert_eq!(sparse1.shape(), (3,3));
assert_eq!(sparse1.get(0,0).unwrap(), 1);Sourcepub fn add_val(&self, value: T) -> Self
pub fn add_val(&self, value: T) -> Self
Adds value to all non zero values in the matrix and return a new matrix
Examples:
use sukker::SparseMatrix;
let sparse = SparseMatrix::<f32>::eye(3);
let val: f32 = 4.5;
let res = sparse.add_val(val);
assert_eq!(res.get(0,0).unwrap(), 5.5);Sourcepub fn sub_val(&self, value: T) -> Self
pub fn sub_val(&self, value: T) -> Self
Subs value to all non zero values in the matrix and return a new matrix
Examples:
use sukker::SparseMatrix;
let sparse = SparseMatrix::<f32>::eye(3);
let val: f32 = 4.5;
let res = sparse.sub_val(val);
assert_eq!(res.get(0,0).unwrap(), -3.5);Sourcepub fn mul_val(&self, value: T) -> Self
pub fn mul_val(&self, value: T) -> Self
Multiplies value to all non zero values in the matrix and return a new matrix
Examples:
use sukker::SparseMatrix;
let sparse = SparseMatrix::<f32>::eye(3);
let val: f32 = 4.5;
let res = sparse.mul_val(val);
assert_eq!(res.get(0,0).unwrap(), 4.5);Sourcepub fn div_val(&self, value: T) -> Self
pub fn div_val(&self, value: T) -> Self
Divides value to all non zero values in the matrix and return a new matrix.
Will panic if you choose to divide by zero
Examples:
use sukker::SparseMatrix;
let sparse = SparseMatrix::<f32>::eye(3);
let val: f32 = 4.0;
let res = sparse.div_val(val);
assert_eq!(res.get(0,0).unwrap(), 0.25);Sourcepub fn add_val_self(&mut self, value: T)
pub fn add_val_self(&mut self, value: T)
Adds value to all non zero elements in matrix
Examples:
use sukker::SparseMatrix;
let mut sparse = SparseMatrix::<f64>::eye(3);
let val = 10.0;
sparse.add_val_self(val);
assert_eq!(sparse.get(0,0).unwrap(), 11.0);Sourcepub fn sub_val_self(&mut self, value: T)
pub fn sub_val_self(&mut self, value: T)
Subtracts value to all non zero elements in matrix
Examples:
use sukker::SparseMatrix;
let mut sparse = SparseMatrix::<f64>::eye(3);
let val = 10.0;
sparse.sub_val_self(val);
assert_eq!(sparse.get(0,0).unwrap(), -9.0);Sourcepub fn mul_val_self(&mut self, value: T)
pub fn mul_val_self(&mut self, value: T)
Multiplies value to all non zero elements in matrix
Examples:
use sukker::SparseMatrix;
let mut sparse = SparseMatrix::<f64>::eye(3);
let val = 10.0;
sparse.mul_val_self(val);
assert_eq!(sparse.get(0,0).unwrap(), 10.0);Sourcepub fn div_val_self(&mut self, value: T)
pub fn div_val_self(&mut self, value: T)
Divides all non zero elemnts in matrix by value in-place
Will panic if you choose to divide by zero
Examples:
use sukker::SparseMatrix;
let mut sparse = SparseMatrix::<f64>::eye(3);
let val = 10.0;
sparse.div_val_self(val);
assert_eq!(sparse.get(0,0).unwrap(), 0.1);Sourcepub fn matmul_sparse(&self, other: &Self) -> Result<Self, MatrixError>
pub fn matmul_sparse(&self, other: &Self) -> Result<Self, MatrixError>
Sparse matrix multiplication
For two n x n matrices, we use this algorithm: https://theory.stanford.edu/~virgi/cs367/papers/sparsemult.pdf
Else, we use this: link..
In this example we have these two matrices:
A:
0.0 2.0 0.0 4.0 6.0 0.0 0.0 0.0 8.0
B:
2.0 0.0 0.0 4.0 8.0 0.0 8.0 6.0 0.0
0.0 24.0 0 8.0 72.0 0 0.0 0.0 48.0
Examples
use std::collections::HashMap;
use sukker::{SparseMatrix, SparseMatrixData};
let mut indexes: SparseMatrixData<f64> = HashMap::new();
indexes.insert((0, 0), 2.0);
indexes.insert((0, 1), 2.0);
indexes.insert((1, 0), 2.0);
indexes.insert((1, 1), 2.0);
let sparse = SparseMatrix::<f64>::new(indexes, (2, 2));
let mut indexes2: SparseMatrixData<f64> = HashMap::new();
indexes2.insert((0, 0), 2.0);
indexes2.insert((0, 1), 2.0);
indexes2.insert((1, 0), 2.0);
indexes2.insert((1, 1), 2.0);
let sparse2 = SparseMatrix::<f64>::new(indexes2, (2, 2));
let res = sparse.matmul_sparse(&sparse2).unwrap();
assert_eq!(res.at(0, 0), 8.0);
assert_eq!(res.at(0, 1), 8.0);
assert_eq!(res.at(1, 0), 8.0);
assert_eq!(res.at(1, 1), 8.0);Source§impl<'a, T> SparseMatrix<'a, T>where
T: MatrixElement,
<T as FromStr>::Err: Error + 'static,
Vec<T>: IntoParallelIterator,
Vec<&'a T>: IntoParallelRefIterator<'a>,
Predicates for sparse matrices
impl<'a, T> SparseMatrix<'a, T>where
T: MatrixElement,
<T as FromStr>::Err: Error + 'static,
Vec<T>: IntoParallelIterator,
Vec<&'a T>: IntoParallelRefIterator<'a>,
Predicates for sparse matrices
Sourcepub fn all<F>(&self, pred: F) -> bool
pub fn all<F>(&self, pred: F) -> bool
Returns whether or not predicate holds for all values
§Examples
use sukker::SparseMatrix;
let sparse = SparseMatrix::<i32>::eye(3);
assert_eq!(sparse.shape(), (3,3));
assert_eq!(sparse.all(|(idx, val)| val >= 0), true);Sourcepub fn any<F>(&self, pred: F) -> bool
pub fn any<F>(&self, pred: F) -> bool
Returns whether or not predicate holds for any
§Examples
use sukker::SparseMatrix;
let sparse = SparseMatrix::<i32>::eye(3);
assert_eq!(sparse.shape(), (3,3));
assert_eq!(sparse.any(|(_, val)| val == 1), true);Sourcepub fn count_where<F>(&'a self, pred: F) -> usize
pub fn count_where<F>(&'a self, pred: F) -> usize
Counts all occurances where predicate holds
§Examples
use sukker::SparseMatrix;
let sparse = SparseMatrix::<i32>::eye(3);
assert_eq!(sparse.count_where(|(_, &val)| val == 1), 3);Sourcepub fn sum_where<F>(&self, pred: F) -> T
pub fn sum_where<F>(&self, pred: F) -> T
Sums all occurances where predicate holds
§Examples
use sukker::SparseMatrix;
let sparse = SparseMatrix::<f32>::eye(3);
assert_eq!(sparse.sum_where(|(&(i, j), &val)| val == 1.0 && i > 0), 2.0);Sourcepub fn set_where<F>(&mut self, pred: F)
pub fn set_where<F>(&mut self, pred: F)
Sets all elements where predicate holds true. The new value is to be set inside the predicate as well
§Examples
Trait Implementations§
Source§impl<'a, T> Clone for SparseMatrix<'a, T>where
T: MatrixElement + Clone,
<T as FromStr>::Err: Error + 'static,
Vec<T>: IntoParallelIterator,
Vec<&'a T>: IntoParallelRefIterator<'a>,
impl<'a, T> Clone for SparseMatrix<'a, T>where
T: MatrixElement + Clone,
<T as FromStr>::Err: Error + 'static,
Vec<T>: IntoParallelIterator,
Vec<&'a T>: IntoParallelRefIterator<'a>,
Source§fn clone(&self) -> SparseMatrix<'a, T>
fn clone(&self) -> SparseMatrix<'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 for SparseMatrix<'a, T>where
T: MatrixElement + Debug,
<T as FromStr>::Err: Error + 'static,
Vec<T>: IntoParallelIterator,
Vec<&'a T>: IntoParallelRefIterator<'a>,
impl<'a, T> Debug for SparseMatrix<'a, T>where
T: MatrixElement + Debug,
<T as FromStr>::Err: Error + 'static,
Vec<T>: IntoParallelIterator,
Vec<&'a T>: IntoParallelRefIterator<'a>,
Source§impl<'a, T> Default for SparseMatrix<'a, T>where
T: MatrixElement,
<T as FromStr>::Err: Error + 'static,
Vec<T>: IntoParallelIterator,
Vec<&'a T>: IntoParallelRefIterator<'a>,
impl<'a, T> Default for SparseMatrix<'a, T>where
T: MatrixElement,
<T as FromStr>::Err: Error + 'static,
Vec<T>: IntoParallelIterator,
Vec<&'a T>: IntoParallelRefIterator<'a>,
Source§impl<'de, 'a, T> Deserialize<'de> for SparseMatrix<'a, T>where
T: MatrixElement + Deserialize<'de>,
<T as FromStr>::Err: Error + 'static,
Vec<T>: IntoParallelIterator,
Vec<&'a T>: IntoParallelRefIterator<'a>,
impl<'de, 'a, T> Deserialize<'de> for SparseMatrix<'a, T>where
T: MatrixElement + Deserialize<'de>,
<T as FromStr>::Err: Error + 'static,
Vec<T>: IntoParallelIterator,
Vec<&'a T>: IntoParallelRefIterator<'a>,
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Source§impl<'a, T> Display for SparseMatrix<'a, T>where
T: MatrixElement,
<T as FromStr>::Err: Error + 'static,
Vec<T>: IntoParallelIterator,
Vec<&'a T>: IntoParallelRefIterator<'a>,
impl<'a, T> Display for SparseMatrix<'a, T>where
T: MatrixElement,
<T as FromStr>::Err: Error + 'static,
Vec<T>: IntoParallelIterator,
Vec<&'a T>: IntoParallelRefIterator<'a>,
Source§impl<'a, T> Error for SparseMatrix<'a, T>where
T: MatrixElement,
<T as FromStr>::Err: Error + 'static,
Vec<T>: IntoParallelIterator,
Vec<&'a T>: IntoParallelRefIterator<'a>,
impl<'a, T> Error for SparseMatrix<'a, T>where
T: MatrixElement,
<T as FromStr>::Err: Error + 'static,
Vec<T>: IntoParallelIterator,
Vec<&'a T>: IntoParallelRefIterator<'a>,
1.30.0 · Source§fn source(&self) -> Option<&(dyn Error + 'static)>
fn source(&self) -> Option<&(dyn Error + 'static)>
1.0.0 · Source§fn description(&self) -> &str
fn description(&self) -> &str
Source§impl<'a, T> FromStr for SparseMatrix<'a, T>
impl<'a, T> FromStr for SparseMatrix<'a, T>
Source§impl<'a, T> LinAlgFloats<'a, T> for SparseMatrix<'a, T>where
T: MatrixElement + Float,
<T as FromStr>::Err: Error + 'static,
Vec<T>: IntoParallelIterator,
Vec<&'a T>: IntoParallelRefIterator<'a>,
Linear algebra on sparse matrices
impl<'a, T> LinAlgFloats<'a, T> for SparseMatrix<'a, T>where
T: MatrixElement + Float,
<T as FromStr>::Err: Error + 'static,
Vec<T>: IntoParallelIterator,
Vec<&'a T>: IntoParallelRefIterator<'a>,
Linear algebra on sparse matrices
fn ln(&self) -> Self
fn log(&self, base: T) -> Self
fn sin(&self) -> Self
fn cos(&self) -> Self
fn tan(&self) -> Self
fn sqrt(&self) -> Self
fn sinh(&self) -> Self
fn cosh(&self) -> Self
fn tanh(&self) -> Self
fn get_eigenvalues(&self) -> Option<Vec<T>>
fn get_eigenvectors(&self) -> Option<Vec<T>>
Source§impl<'a, T> PartialEq for SparseMatrix<'a, T>where
T: MatrixElement + PartialEq,
<T as FromStr>::Err: Error + 'static,
Vec<T>: IntoParallelIterator,
Vec<&'a T>: IntoParallelRefIterator<'a>,
impl<'a, T> PartialEq for SparseMatrix<'a, T>where
T: MatrixElement + PartialEq,
<T as FromStr>::Err: Error + 'static,
Vec<T>: IntoParallelIterator,
Vec<&'a T>: IntoParallelRefIterator<'a>,
Source§impl<'a, T> Serialize for SparseMatrix<'a, T>where
T: MatrixElement + Serialize,
<T as FromStr>::Err: Error + 'static,
Vec<T>: IntoParallelIterator,
Vec<&'a T>: IntoParallelRefIterator<'a>,
impl<'a, T> Serialize for SparseMatrix<'a, T>where
T: MatrixElement + Serialize,
<T as FromStr>::Err: Error + 'static,
Vec<T>: IntoParallelIterator,
Vec<&'a T>: IntoParallelRefIterator<'a>,
impl<'a, T> Send for SparseMatrix<'a, T>where
T: MatrixElement,
<T as FromStr>::Err: Error + 'static,
Vec<T>: IntoParallelIterator,
Vec<&'a T>: IntoParallelRefIterator<'a>,
impl<'a, T> StructuralPartialEq for SparseMatrix<'a, T>where
T: MatrixElement,
<T as FromStr>::Err: Error + 'static,
Vec<T>: IntoParallelIterator,
Vec<&'a T>: IntoParallelRefIterator<'a>,
impl<'a, T> Sync for SparseMatrix<'a, T>where
T: MatrixElement,
<T as FromStr>::Err: Error + 'static,
Vec<T>: IntoParallelIterator,
Vec<&'a T>: IntoParallelRefIterator<'a>,
Auto Trait Implementations§
impl<'a, T> Freeze for SparseMatrix<'a, T>
impl<'a, T> RefUnwindSafe for SparseMatrix<'a, T>where
T: RefUnwindSafe,
impl<'a, T> Unpin for SparseMatrix<'a, T>where
T: Unpin,
impl<'a, T> UnwindSafe for SparseMatrix<'a, T>where
T: UnwindSafe + 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