Impl Csr/CscMatrix::into_pattern_and_values

This commit is contained in:
Andreas Longva 2021-01-19 16:56:30 +01:00
parent e655fed4fa
commit c43a2b1679
3 changed files with 15 additions and 0 deletions

View File

@ -93,6 +93,11 @@ impl<T> CsMatrix<T> {
(offsets, indices, self.values) (offsets, indices, self.values)
} }
#[inline]
pub fn into_pattern_and_values(self) -> (SparsityPattern, Vec<T>) {
(self.sparsity_pattern, self.values)
}
/// Returns an entry for the given major/minor indices, or `None` if the indices are out /// Returns an entry for the given major/minor indices, or `None` if the indices are out
/// of bounds. /// of bounds.
pub fn get_entry(&self, major_index: usize, minor_index: usize) -> Option<SparseEntry<T>> { pub fn get_entry(&self, major_index: usize, minor_index: usize) -> Option<SparseEntry<T>> {

View File

@ -252,6 +252,11 @@ impl<T> CscMatrix<T> {
self.cs.disassemble() self.cs.disassemble()
} }
/// Returns the sparsity pattern and values associated with this matrix.
pub fn into_pattern_and_values(self) -> (SparsityPattern, Vec<T>) {
self.cs.into_pattern_and_values()
}
/// Returns the underlying sparsity pattern. /// Returns the underlying sparsity pattern.
/// ///
/// The sparsity pattern is stored internally inside an `Arc`. This allows users to re-use /// The sparsity pattern is stored internally inside an `Arc`. This allows users to re-use

View File

@ -254,6 +254,11 @@ impl<T> CsrMatrix<T> {
self.cs.disassemble() self.cs.disassemble()
} }
/// Returns the sparsity pattern and values associated with this matrix.
pub fn into_pattern_and_values(self) -> (SparsityPattern, Vec<T>) {
self.cs.into_pattern_and_values()
}
/// Returns the underlying sparsity pattern. /// Returns the underlying sparsity pattern.
/// ///
/// The sparsity pattern is stored internally inside an `Arc`. This allows users to re-use /// The sparsity pattern is stored internally inside an `Arc`. This allows users to re-use