From cb0f9a5190e361038d170e4a5ef5d109cf90ef6a Mon Sep 17 00:00:00 2001 From: Andreas Longva Date: Tue, 19 Jan 2021 16:58:45 +0100 Subject: [PATCH] Add Csr/CscMatrix::pattern_and_values_mut() --- nalgebra-sparse/src/csc.rs | 6 ++++++ nalgebra-sparse/src/csr.rs | 6 ++++++ 2 files changed, 12 insertions(+) diff --git a/nalgebra-sparse/src/csc.rs b/nalgebra-sparse/src/csc.rs index bbb8cd08..c48697a8 100644 --- a/nalgebra-sparse/src/csc.rs +++ b/nalgebra-sparse/src/csc.rs @@ -257,6 +257,12 @@ impl CscMatrix { self.cs.into_pattern_and_values() } + /// Returns a reference to the sparsity pattern and a mutable reference to the values. + #[inline] + pub fn pattern_and_values_mut(&mut self) -> (&SparsityPattern, &mut [T]) { + self.cs.pattern_and_values_mut() + } + /// 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 f42b56f9..acf12e33 100644 --- a/nalgebra-sparse/src/csr.rs +++ b/nalgebra-sparse/src/csr.rs @@ -259,6 +259,12 @@ impl CsrMatrix { self.cs.into_pattern_and_values() } + /// Returns a reference to the sparsity pattern and a mutable reference to the values. + #[inline] + pub fn pattern_and_values_mut(&mut self) -> (&SparsityPattern, &mut [T]) { + self.cs.pattern_and_values_mut() + } + /// Returns the underlying sparsity pattern. /// /// The sparsity pattern is stored internally inside an `Arc`. This allows users to re-use