From c43a2b167985d54231eaca88515a0e3a91447dc5 Mon Sep 17 00:00:00 2001 From: Andreas Longva Date: Tue, 19 Jan 2021 16:56:30 +0100 Subject: [PATCH] Impl Csr/CscMatrix::into_pattern_and_values --- nalgebra-sparse/src/cs.rs | 5 +++++ nalgebra-sparse/src/csc.rs | 5 +++++ nalgebra-sparse/src/csr.rs | 5 +++++ 3 files changed, 15 insertions(+) diff --git a/nalgebra-sparse/src/cs.rs b/nalgebra-sparse/src/cs.rs index 645df265..cf8fd382 100644 --- a/nalgebra-sparse/src/cs.rs +++ b/nalgebra-sparse/src/cs.rs @@ -93,6 +93,11 @@ impl CsMatrix { (offsets, indices, self.values) } + #[inline] + pub fn into_pattern_and_values(self) -> (SparsityPattern, Vec) { + (self.sparsity_pattern, self.values) + } + /// Returns an entry for the given major/minor indices, or `None` if the indices are out /// of bounds. pub fn get_entry(&self, major_index: usize, minor_index: usize) -> Option> { diff --git a/nalgebra-sparse/src/csc.rs b/nalgebra-sparse/src/csc.rs index d7883fa3..bbb8cd08 100644 --- a/nalgebra-sparse/src/csc.rs +++ b/nalgebra-sparse/src/csc.rs @@ -252,6 +252,11 @@ impl CscMatrix { self.cs.disassemble() } + /// Returns the sparsity pattern and values associated with this matrix. + pub fn into_pattern_and_values(self) -> (SparsityPattern, Vec) { + self.cs.into_pattern_and_values() + } + /// Returns the underlying sparsity pattern. /// /// The sparsity pattern is stored internally inside an `Arc`. This allows users to re-use diff --git a/nalgebra-sparse/src/csr.rs b/nalgebra-sparse/src/csr.rs index dceca614..f42b56f9 100644 --- a/nalgebra-sparse/src/csr.rs +++ b/nalgebra-sparse/src/csr.rs @@ -254,6 +254,11 @@ impl CsrMatrix { self.cs.disassemble() } + /// Returns the sparsity pattern and values associated with this matrix. + pub fn into_pattern_and_values(self) -> (SparsityPattern, Vec) { + self.cs.into_pattern_and_values() + } + /// Returns the underlying sparsity pattern. /// /// The sparsity pattern is stored internally inside an `Arc`. This allows users to re-use