[−][src]Type Definition sprs::CsMatI
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) -> CsMatI<N, I, Iptr> 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
) -> CsMatI<N, I, Iptr>
[src]
storage: CompressedStorage,
inner_size: usize
) -> CsMatI<N, I, Iptr>
Create an empty CsMat for building purposes
pub fn zero(shape: Shape) -> CsMatI<N, I, Iptr>
[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 try_new(
shape: Shape,
indptr: Vec<Iptr>,
indices: Vec<I>,
data: Vec<N>
) -> Result<CsMatI<N, I, Iptr>, SprsError> where
N: Copy,
[src]
shape: Shape,
indptr: Vec<Iptr>,
indices: Vec<I>,
data: Vec<N>
) -> Result<CsMatI<N, I, Iptr>, SprsError> where
N: Copy,
Try create an owned CSR matrix from moved data.
An owned CSC matrix can be created with try_new_csc()
.
If necessary, the indices will be sorted in place.
pub fn new(
shape: Shape,
indptr: Vec<Iptr>,
indices: Vec<I>,
data: Vec<N>
) -> CsMatI<N, I, Iptr> where
N: Copy,
[src]
shape: Shape,
indptr: Vec<Iptr>,
indices: Vec<I>,
data: Vec<N>
) -> CsMatI<N, I, Iptr> where
N: Copy,
Create an owned CSR matrix from moved data.
An owned CSC matrix can be created with new_csc()
.
If necessary, the indices will be sorted in place.
Panics
- if
indptr
does not correspond to the number of rows. - if
indices
anddata
don't have exactlyindptr[rows]
elements. - if
indices
contains values greater or equal to the number of columns.
pub fn try_new_csc(
shape: Shape,
indptr: Vec<Iptr>,
indices: Vec<I>,
data: Vec<N>
) -> Result<Self, SprsError> where
N: Copy,
[src]
shape: Shape,
indptr: Vec<Iptr>,
indices: Vec<I>,
data: Vec<N>
) -> Result<Self, SprsError> where
N: Copy,
Try create an owned CSC matrix from moved data.
An owned CSC matrix can be created with new_csc()
.
If necessary, the indices will be sorted in place.
pub fn new_csc(
shape: Shape,
indptr: Vec<Iptr>,
indices: Vec<I>,
data: Vec<N>
) -> Self where
N: Copy,
[src]
shape: Shape,
indptr: Vec<Iptr>,
indices: Vec<I>,
data: Vec<N>
) -> Self where
N: Copy,
Create an owned CSC matrix from moved data.
An owned CSC matrix can be created with new_csc()
.
If necessary, the indices will be sorted in place.
Panics
- if
indptr
does not correspond to the number of rows. - if
indices
anddata
don't have exactlyindptr[rows]
elements. - if
indices
contains values greater or equal to the number of columns.
pub fn csr_from_dense(
m: ArrayView<'_, N, Ix2>,
epsilon: N
) -> CsMatI<N, I, Iptr> where
N: Num + Clone + PartialOrd + Signed,
[src]
m: ArrayView<'_, N, Ix2>,
epsilon: N
) -> CsMatI<N, I, Iptr> where
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
) -> CsMatI<N, I, Iptr> where
N: Num + Clone + PartialOrd + Signed,
[src]
m: ArrayView<'_, N, Ix2>,
epsilon: N
) -> CsMatI<N, I, Iptr> where
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: CsVecBase<&[I], &[N]>) -> 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) -> CsMatI<N, I, Iptr> 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) -> CsMatI<N, I, Iptr> 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