From 105e894c0a350b61c8f86c77ba5e15b7cef6e98d Mon Sep 17 00:00:00 2001 From: Chammika Mannakkara Date: Sun, 2 May 2021 13:50:03 +0900 Subject: [PATCH] add missing doc tests --- src/base/componentwise.rs | 51 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 51 insertions(+) diff --git a/src/base/componentwise.rs b/src/base/componentwise.rs index b7030f61..2ba49b2a 100644 --- a/src/base/componentwise.rs +++ b/src/base/componentwise.rs @@ -240,6 +240,16 @@ impl> Matrix ); /// Computes the infimum (aka. componentwise min) of two matrices/vectors. + /// + /// # Example + /// + /// ``` + /// # use nalgebra::Matrix2; + /// let u = Matrix2::new(4.0, 2.0, 1.0, -2.0); + /// let v = Matrix2::new(2.0, 4.0, -2.0, 1.0); + /// let expected = Matrix2::new(2.0, 2.0, -2.0, -2.0); + /// assert_eq!(u.inf(&v), expected) + /// ``` #[inline] pub fn inf(&self, other: &Self) -> OMatrix where @@ -250,6 +260,16 @@ impl> Matrix } /// Computes the supremum (aka. componentwise max) of two matrices/vectors. + /// + /// # Example + /// + /// ``` + /// # use nalgebra::Matrix2; + /// let u = Matrix2::new(4.0, 2.0, 1.0, -2.0); + /// let v = Matrix2::new(2.0, 4.0, -2.0, 1.0); + /// let expected = Matrix2::new(4.0, 4.0, 1.0, 1.0); + /// assert_eq!(u.sup(&v), expected) + /// ``` #[inline] pub fn sup(&self, other: &Self) -> OMatrix where @@ -260,6 +280,16 @@ impl> Matrix } /// Computes the (infimum, supremum) of two matrices/vectors. + /// + /// # Example + /// + /// ``` + /// # use nalgebra::Matrix2; + /// let u = Matrix2::new(4.0, 2.0, 1.0, -2.0); + /// let v = Matrix2::new(2.0, 4.0, -2.0, 1.0); + /// let expected = (Matrix2::new(2.0, 2.0, -2.0, -2.0), Matrix2::new(4.0, 4.0, 1.0, 1.0)); + /// assert_eq!(u.inf_sup(&v), expected) + /// ``` #[inline] pub fn inf_sup(&self, other: &Self) -> (OMatrix, OMatrix) where @@ -271,6 +301,16 @@ impl> Matrix } /// Adds a scalar to `self`. + /// + /// # Example + /// + /// ``` + /// # use nalgebra::Matrix2; + /// let u = Matrix2::new(1.0, 2.0, 3.0, 4.0); + /// let s = 10.0; + /// let expected = Matrix2::new(11.0, 12.0, 13.0, 14.0); + /// assert_eq!(u.add_scalar(s), expected) + /// ``` #[inline] #[must_use = "Did you mean to use add_scalar_mut()?"] pub fn add_scalar(&self, rhs: T) -> OMatrix @@ -284,6 +324,17 @@ impl> Matrix } /// Adds a scalar to `self` in-place. + /// + /// # Example + /// + /// ``` + /// # use nalgebra::Matrix2; + /// let mut u = Matrix2::new(1.0, 2.0, 3.0, 4.0); + /// let s = 10.0; + /// u.add_scalar_mut(s); + /// let expected = Matrix2::new(11.0, 12.0, 13.0, 14.0); + /// assert_eq!(u, expected) + /// ``` #[inline] pub fn add_scalar_mut(&mut self, rhs: T) where