From b996a6f0ce3de25ab41b1621fc1ebf67d2668fa4 Mon Sep 17 00:00:00 2001 From: Chia-Sheng Chen Date: Fri, 3 Apr 2020 17:39:49 +0800 Subject: [PATCH 1/2] Supplement the document of fn vector_to_matrix_index --- src/base/matrix.rs | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/base/matrix.rs b/src/base/matrix.rs index b1e0653c..1fb93fea 100644 --- a/src/base/matrix.rs +++ b/src/base/matrix.rs @@ -279,6 +279,16 @@ impl> Matrix { /// Computes the row and column coordinates of the i-th element of this matrix seen as a /// vector. + /// + /// # Example + /// ``` + /// # use nalgebra::Matrix2; + /// let m = Matrix2::new(1, 2, + /// 3, 4); + /// let i = m.vector_to_matrix_index(3); + /// assert_eq!(i, (1, 1)); + /// assert_eq!(m[i], m[3]); + /// ``` #[inline] pub fn vector_to_matrix_index(&self, i: usize) -> (usize, usize) { let (nrows, ncols) = self.shape(); From 65bc037b5d7c5ad9811a90fd60ac27094fb6a0eb Mon Sep 17 00:00:00 2001 From: Chia-Sheng Chen Date: Fri, 3 Apr 2020 17:56:08 +0800 Subject: [PATCH 2/2] Supplement the document of fn as_ptr --- src/base/matrix.rs | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/base/matrix.rs b/src/base/matrix.rs index 1fb93fea..9004b331 100644 --- a/src/base/matrix.rs +++ b/src/base/matrix.rs @@ -308,6 +308,15 @@ impl> Matrix { /// /// If the matrix is not empty, this pointer is guaranteed to be aligned /// and non-null. + /// + /// # Example + /// ``` + /// # use nalgebra::Matrix2; + /// let m = Matrix2::new(1, 2, + /// 3, 4); + /// let ptr = m.as_ptr(); + /// assert_eq!(unsafe { *ptr }, m[0]); + /// ``` #[inline] pub fn as_ptr(&self) -> *const N { self.data.ptr()