Type Definition sprs::CsMatI [−][src]
type CsMatI<N, I, Iptr = I> = CsMatBase<N, I, Vec<Iptr>, Vec<I>, Vec<N>, Iptr>;
Implementations
impl<N, I: SpIndex, Iptr: SpIndex> CsMatI<N, I, Iptr>
[src]
pub fn eye(dim: usize) -> Self where
N: Num + Clone,
[src]
N: Num + Clone,
Identity matrix, stored as a CSR matrix.
use sprs::{CsMat, CsVec}; let eye = CsMat::eye(5); assert!(eye.is_csr()); let x = CsVec::new(5, vec![0, 2, 4], vec![1., 2., 3.]); let y = &eye * &x; assert_eq!(x, y);
pub fn eye_csc(dim: usize) -> Self where
N: Num + Clone,
[src]
N: Num + Clone,
Identity matrix, stored as a CSC matrix.
use sprs::{CsMat, CsVec}; let eye = CsMat::eye_csc(5); assert!(eye.is_csc()); let x = CsVec::new(5, vec![0, 2, 4], vec![1., 2., 3.]); let y = &eye * &x; assert_eq!(x, y);
pub fn empty(storage: CompressedStorage, inner_size: usize) -> Self
[src]
Create an empty CsMat
for building purposes
pub fn zero(shape: Shape) -> Self
[src]
Create a new CsMat
representing the zero matrix.
Hence it has no non-zero elements.
pub fn reserve_outer_dim(&mut self, outer_dim_additional: usize)
[src]
Reserve the storage for the given additional number of nonzero data
pub fn reserve_nnz(&mut self, nnz_additional: usize)
[src]
Reserve the storage for the given additional number of nonzero data
pub fn reserve_outer_dim_exact(&mut self, outer_dim_lim: usize)
[src]
Reserve the storage for the given number of nonzero data
pub fn reserve_nnz_exact(&mut self, nnz_lim: usize)
[src]
Reserve the storage for the given number of nonzero data
pub fn csr_from_dense(m: ArrayView<'_, N, Ix2>, epsilon: N) -> Self where
N: Num + Clone + PartialOrd + Signed,
[src]
N: Num + Clone + PartialOrd + Signed,
Create a CSR matrix from a dense matrix, ignoring elements lower than epsilon
.
If epsilon is negative, it will be clamped to zero.
pub fn csc_from_dense(m: ArrayView<'_, N, Ix2>, epsilon: N) -> Self where
N: Num + Clone + PartialOrd + Signed,
[src]
N: Num + Clone + PartialOrd + Signed,
Create a CSC matrix from a dense matrix, ignoring elements lower than epsilon
.
If epsilon is negative, it will be clamped to zero.
pub fn append_outer(self, data: &[N]) -> Self where
N: Clone + Num,
[src]
N: Clone + Num,
Append an outer dim to an existing matrix, compressing it in the process
pub fn append_outer_csvec(self, vec: CsVecViewI<'_, N, I>) -> Self where
N: Clone,
[src]
N: Clone,
Append an outer dim to an existing matrix, provided by a sparse vector
pub fn insert(&mut self, row: usize, col: usize, val: N)
[src]
Insert an element in the matrix. If the element is already present, its value is overwritten.
Warning: this is not an efficient operation, as it requires
a non-constant lookup followed by two Vec
insertions.
The insertion will be efficient, however, if the elements are inserted according to the matrix’s order, eg following the row order for a CSR matrix.
impl<N, I, Iptr> CsMatI<N, I, Iptr> where
N: Default,
I: SpIndex,
Iptr: SpIndex,
[src]
N: Default,
I: SpIndex,
Iptr: SpIndex,
pub fn into_csc(self) -> Self where
N: Clone,
[src]
N: Clone,
Create a new CSC matrix equivalent to this one. If this matrix is CSR, it is converted to CSC If this matrix is CSC, it is returned by value
pub fn into_csr(self) -> Self where
N: Clone,
[src]
N: Clone,
Create a new CSR matrix equivalent to this one. If this matrix is CSC, it is converted to CSR If this matrix is CSR, it is returned by value