diff --git a/src/base/matrix.rs b/src/base/matrix.rs index 2e3446692..cb687983a 100644 --- a/src/base/matrix.rs +++ b/src/base/matrix.rs @@ -295,6 +295,15 @@ impl> Matrix { } } + /// Returns a pointer to the start of the matrix. + /// + /// If the matrix is not empty, this pointer is guaranteed to be aligned + /// and non-null. + #[inline] + pub fn as_ptr(&self) -> *const N { + self.data.ptr() + } + /// Tests whether `self` and `rhs` are equal up to a given epsilon. /// /// See `relative_eq` from the `RelativeEq` trait for more details. @@ -622,6 +631,15 @@ impl> Matrix { MatrixIterMut::new(&mut self.data) } + /// Returns a mutable pointer to the start of the matrix. + /// + /// If the matrix is not empty, this pointer is guaranteed to be aligned + /// and non-null. + #[inline] + pub fn as_mut_ptr(&mut self) -> *mut N { + self.data.ptr_mut() + } + /// Mutably iterates through this matrix rows. /// /// # Example