From 4d968da1adc960e4ac51d0f3c39ea0d9ef77e1c1 Mon Sep 17 00:00:00 2001 From: Solra Bizna Date: Wed, 25 May 2022 16:42:18 -0600 Subject: [PATCH 01/15] Make "Point::new" a const fn --- src/geometry/point_construction.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/geometry/point_construction.rs b/src/geometry/point_construction.rs index 2136080a..ac54b349 100644 --- a/src/geometry/point_construction.rs +++ b/src/geometry/point_construction.rs @@ -202,7 +202,7 @@ impl Point1 { /// assert_eq!(p.x, 1.0); /// ``` #[inline] - pub fn new(x: T) -> Self { + pub const fn new(x: T) -> Self { Point { coords: Vector1::new(x), } @@ -216,7 +216,7 @@ macro_rules! componentwise_constructors_impl( #[doc = $doc] #[doc = "```"] #[inline] - pub fn new($($args: T),*) -> Self { + pub const fn new($($args: T),*) -> Self { Point { coords: $Vector::new($($args),*) } } } From 8aa10b819c465eb17b3fd4558512469cfab6cd98 Mon Sep 17 00:00:00 2001 From: Benjamin Saunders Date: Sat, 11 Jun 2022 11:07:24 -0700 Subject: [PATCH 02/15] Implement `cast` for `Unit>` Currently, `cast` is resolved via `Unit`'s `Deref` impl, which leads to it confusingly stripping the `Unit` from `UnitVector`s. Add an inherent impl which takes precedence, similar to the existing specialization for `UnitQuaternion`. --- src/base/matrix.rs | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/src/base/matrix.rs b/src/base/matrix.rs index 8f8786c1..d9294c9e 100644 --- a/src/base/matrix.rs +++ b/src/base/matrix.rs @@ -2186,3 +2186,28 @@ where } } } + +impl Unit> +where + T: Scalar, + D: Dim, + S: RawStorage, +{ + /// Cast the components of `self` to another type. + /// + /// # Example + /// ``` + /// # use nalgebra::Vector3; + /// let v = Vector3::::y_axis(); + /// let v2 = v.cast::(); + /// assert_eq!(v2, Vector3::::y_axis()); + /// ``` + pub fn cast(self) -> Unit> + where + T: Scalar, + OVector: SupersetOf>, + DefaultAllocator: Allocator, + { + Unit::new_unchecked(crate::convert_ref(self.as_ref())) + } +} From d3b7acce4d97823d37b7d652293765dcc6e1562f Mon Sep 17 00:00:00 2001 From: Ritoban Roy-Chowdhury Date: Mon, 8 Aug 2022 17:48:10 -0700 Subject: [PATCH 03/15] update DefaultAllocator docs to say ArrayStorage instead of GenericArray --- src/base/default_allocator.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/base/default_allocator.rs b/src/base/default_allocator.rs index 09197bbd..6aaadfc7 100644 --- a/src/base/default_allocator.rs +++ b/src/base/default_allocator.rs @@ -26,7 +26,7 @@ use std::mem::{ManuallyDrop, MaybeUninit}; * Allocator. * */ -/// An allocator based on `GenericArray` and `VecStorage` for statically-sized and dynamically-sized +/// An allocator based on [`ArrayStorage`] and [`VecStorage`] for statically-sized and dynamically-sized /// matrices respectively. #[derive(Copy, Clone, Debug)] pub struct DefaultAllocator; From 84c44984b1fd8975bdd195e3b5c9077c4c9c5e55 Mon Sep 17 00:00:00 2001 From: Patrick Owen Date: Fri, 12 Aug 2022 01:33:11 -0400 Subject: [PATCH 04/15] Use #[inline] to improve opt-level 1 performance --- src/base/dimension.rs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/base/dimension.rs b/src/base/dimension.rs index 4be97586..b1b700d7 100644 --- a/src/base/dimension.rs +++ b/src/base/dimension.rs @@ -252,14 +252,17 @@ pub trait ToTypenum { } unsafe impl Dim for Const { + #[inline] fn try_to_usize() -> Option { Some(T) } + #[inline] fn value(&self) -> usize { T } + #[inline] fn from_usize(dim: usize) -> Self { assert_eq!(dim, T); Self From b90dc7c042e9278786ba54c5b0fc8d85db8412d7 Mon Sep 17 00:00:00 2001 From: lukas Date: Mon, 15 Aug 2022 19:14:38 -0700 Subject: [PATCH 05/15] Add `clear_triplet()` --- nalgebra-sparse/src/coo.rs | 20 +++++++++++++++++ nalgebra-sparse/tests/unit_tests/coo.rs | 29 +++++++++++++++++++++++++ 2 files changed, 49 insertions(+) diff --git a/nalgebra-sparse/src/coo.rs b/nalgebra-sparse/src/coo.rs index 2b302e37..e047745a 100644 --- a/nalgebra-sparse/src/coo.rs +++ b/nalgebra-sparse/src/coo.rs @@ -211,6 +211,26 @@ impl CooMatrix { self.values.push(v); } + /// Remove a single triplet from the matrix. + /// + /// This removes the value `v` from the `i`th row and `j`th column in the matrix. + pub fn clear_triplet(&mut self, i: usize, j: usize, v: T) -> Option<(usize, usize, T)> + where + T: PartialEq, + { + let triple_idx = self + .triplet_iter() + .position(|triplet| triplet == (i, j, &v)); + if let Some(triple_idx) = triple_idx { + self.row_indices.remove(triple_idx); + self.col_indices.remove(triple_idx); + let retv = self.values.remove(triple_idx); + Some((i, j, retv)) + } else { + None + } + } + /// The number of rows in the matrix. #[inline] #[must_use] diff --git a/nalgebra-sparse/tests/unit_tests/coo.rs b/nalgebra-sparse/tests/unit_tests/coo.rs index c70c5f97..6ec88fb1 100644 --- a/nalgebra-sparse/tests/unit_tests/coo.rs +++ b/nalgebra-sparse/tests/unit_tests/coo.rs @@ -226,6 +226,35 @@ fn coo_push_valid_entries() { ); } +#[test] +fn coo_clear_triplet_valid_entries() { + let mut coo = CooMatrix::new(3, 3); + + coo.push(0, 0, 1); + coo.push(0, 0, 2); + coo.push(2, 2, 3); + + // clear a triplet that is not included + let triplet = coo.clear_triplet(0, 0, 0); + assert_eq!(triplet, None); + assert_eq!( + coo.triplet_iter().collect::>(), + vec![(0, 0, &1), (0, 0, &2), (2, 2, &3)] + ); + let triplet = coo.clear_triplet(0, 0, 1); + assert_eq!(triplet, Some((0, 0, 1))); + assert_eq!( + coo.triplet_iter().collect::>(), + vec![(0, 0, &2), (2, 2, &3)] + ); + let triplet = coo.clear_triplet(0, 0, 2); + assert_eq!(triplet, Some((0, 0, 2))); + assert_eq!(coo.triplet_iter().collect::>(), vec![(2, 2, &3)]); + let triplet = coo.clear_triplet(2, 2, 3); + assert_eq!(triplet, Some((2, 2, 3))); + assert_eq!(coo.triplet_iter().collect::>(), vec![]); +} + #[test] fn coo_push_out_of_bounds_entries() { { From bcc5527baac743df259b85c9a61a5793a63ce8fc Mon Sep 17 00:00:00 2001 From: lukas Date: Mon, 15 Aug 2022 19:28:58 -0700 Subject: [PATCH 06/15] Switch return type to just T --- nalgebra-sparse/src/coo.rs | 6 +++--- nalgebra-sparse/tests/unit_tests/coo.rs | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/nalgebra-sparse/src/coo.rs b/nalgebra-sparse/src/coo.rs index e047745a..197ef6f4 100644 --- a/nalgebra-sparse/src/coo.rs +++ b/nalgebra-sparse/src/coo.rs @@ -214,7 +214,7 @@ impl CooMatrix { /// Remove a single triplet from the matrix. /// /// This removes the value `v` from the `i`th row and `j`th column in the matrix. - pub fn clear_triplet(&mut self, i: usize, j: usize, v: T) -> Option<(usize, usize, T)> + pub fn clear_triplet(&mut self, i: usize, j: usize, v: T) -> Option where T: PartialEq, { @@ -224,8 +224,8 @@ impl CooMatrix { if let Some(triple_idx) = triple_idx { self.row_indices.remove(triple_idx); self.col_indices.remove(triple_idx); - let retv = self.values.remove(triple_idx); - Some((i, j, retv)) + let removed_value = self.values.remove(triple_idx); + Some(removed_value) } else { None } diff --git a/nalgebra-sparse/tests/unit_tests/coo.rs b/nalgebra-sparse/tests/unit_tests/coo.rs index 6ec88fb1..4b640596 100644 --- a/nalgebra-sparse/tests/unit_tests/coo.rs +++ b/nalgebra-sparse/tests/unit_tests/coo.rs @@ -242,16 +242,16 @@ fn coo_clear_triplet_valid_entries() { vec![(0, 0, &1), (0, 0, &2), (2, 2, &3)] ); let triplet = coo.clear_triplet(0, 0, 1); - assert_eq!(triplet, Some((0, 0, 1))); + assert_eq!(triplet, Some(1)); assert_eq!( coo.triplet_iter().collect::>(), vec![(0, 0, &2), (2, 2, &3)] ); let triplet = coo.clear_triplet(0, 0, 2); - assert_eq!(triplet, Some((0, 0, 2))); + assert_eq!(triplet, Some(2)); assert_eq!(coo.triplet_iter().collect::>(), vec![(2, 2, &3)]); let triplet = coo.clear_triplet(2, 2, 3); - assert_eq!(triplet, Some((2, 2, 3))); + assert_eq!(triplet, Some(3)); assert_eq!(coo.triplet_iter().collect::>(), vec![]); } From bdfa643e3cc749b44058ab467068e4aa96287513 Mon Sep 17 00:00:00 2001 From: lukas Date: Tue, 16 Aug 2022 00:15:03 -0700 Subject: [PATCH 07/15] clear_triplets --- nalgebra-sparse/src/coo.rs | 20 +++++--------------- nalgebra-sparse/tests/unit_tests/coo.rs | 20 +++----------------- 2 files changed, 8 insertions(+), 32 deletions(-) diff --git a/nalgebra-sparse/src/coo.rs b/nalgebra-sparse/src/coo.rs index 197ef6f4..9793fa1e 100644 --- a/nalgebra-sparse/src/coo.rs +++ b/nalgebra-sparse/src/coo.rs @@ -211,24 +211,14 @@ impl CooMatrix { self.values.push(v); } - /// Remove a single triplet from the matrix. - /// - /// This removes the value `v` from the `i`th row and `j`th column in the matrix. - pub fn clear_triplet(&mut self, i: usize, j: usize, v: T) -> Option + /// Clear all triplets from the matrix. + pub fn clear_triplets(&mut self, i: usize, j: usize, v: T) -> Option where T: PartialEq, { - let triple_idx = self - .triplet_iter() - .position(|triplet| triplet == (i, j, &v)); - if let Some(triple_idx) = triple_idx { - self.row_indices.remove(triple_idx); - self.col_indices.remove(triple_idx); - let removed_value = self.values.remove(triple_idx); - Some(removed_value) - } else { - None - } + self.col_indices.clear(); + self.row_indices.clear(); + self.values.clear(); } /// The number of rows in the matrix. diff --git a/nalgebra-sparse/tests/unit_tests/coo.rs b/nalgebra-sparse/tests/unit_tests/coo.rs index 4b640596..b9c22885 100644 --- a/nalgebra-sparse/tests/unit_tests/coo.rs +++ b/nalgebra-sparse/tests/unit_tests/coo.rs @@ -227,32 +227,18 @@ fn coo_push_valid_entries() { } #[test] -fn coo_clear_triplet_valid_entries() { +fn coo_clear_triplets_valid_entries() { let mut coo = CooMatrix::new(3, 3); coo.push(0, 0, 1); coo.push(0, 0, 2); coo.push(2, 2, 3); - - // clear a triplet that is not included - let triplet = coo.clear_triplet(0, 0, 0); - assert_eq!(triplet, None); assert_eq!( coo.triplet_iter().collect::>(), vec![(0, 0, &1), (0, 0, &2), (2, 2, &3)] ); - let triplet = coo.clear_triplet(0, 0, 1); - assert_eq!(triplet, Some(1)); - assert_eq!( - coo.triplet_iter().collect::>(), - vec![(0, 0, &2), (2, 2, &3)] - ); - let triplet = coo.clear_triplet(0, 0, 2); - assert_eq!(triplet, Some(2)); - assert_eq!(coo.triplet_iter().collect::>(), vec![(2, 2, &3)]); - let triplet = coo.clear_triplet(2, 2, 3); - assert_eq!(triplet, Some(3)); - assert_eq!(coo.triplet_iter().collect::>(), vec![]); + coo.clear_triplets(); + assert_eq(coo.triplet_iter.collect::>(), vec![]); } #[test] From 41e1cc0db223bdbd4fc5547212760d68fd262f30 Mon Sep 17 00:00:00 2001 From: lukas Date: Tue, 16 Aug 2022 00:20:13 -0700 Subject: [PATCH 08/15] extend test case --- nalgebra-sparse/tests/unit_tests/coo.rs | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/nalgebra-sparse/tests/unit_tests/coo.rs b/nalgebra-sparse/tests/unit_tests/coo.rs index b9c22885..16ee5647 100644 --- a/nalgebra-sparse/tests/unit_tests/coo.rs +++ b/nalgebra-sparse/tests/unit_tests/coo.rs @@ -239,6 +239,14 @@ fn coo_clear_triplets_valid_entries() { ); coo.clear_triplets(); assert_eq(coo.triplet_iter.collect::>(), vec![]); + // making sure everyhting works after clearing + coo.push(0, 0, 1); + coo.push(0, 0, 2); + coo.push(2, 2, 3); + assert_eq!( + coo.triplet_iter().collect::>(), + vec![(0, 0, &1), (0, 0, &2), (2, 2, &3)] + ); } #[test] From b9483ab545621517974390a7d4ff1d846318683c Mon Sep 17 00:00:00 2001 From: Lukas Hermann Date: Tue, 16 Aug 2022 22:06:43 +0000 Subject: [PATCH 09/15] remove bad return type --- nalgebra-sparse/src/coo.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/nalgebra-sparse/src/coo.rs b/nalgebra-sparse/src/coo.rs index 9793fa1e..240e2c57 100644 --- a/nalgebra-sparse/src/coo.rs +++ b/nalgebra-sparse/src/coo.rs @@ -212,7 +212,7 @@ impl CooMatrix { } /// Clear all triplets from the matrix. - pub fn clear_triplets(&mut self, i: usize, j: usize, v: T) -> Option + pub fn clear_triplets(&mut self, i: usize, j: usize, v: T) where T: PartialEq, { From 0eb1f5c125b65847fea06f5d0f01f030096c3450 Mon Sep 17 00:00:00 2001 From: lukas Date: Tue, 16 Aug 2022 20:10:17 -0700 Subject: [PATCH 10/15] 'fix error's --- nalgebra-sparse/src/coo.rs | 2 +- nalgebra-sparse/tests/unit_tests/coo.rs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/nalgebra-sparse/src/coo.rs b/nalgebra-sparse/src/coo.rs index 240e2c57..1a1720ed 100644 --- a/nalgebra-sparse/src/coo.rs +++ b/nalgebra-sparse/src/coo.rs @@ -212,7 +212,7 @@ impl CooMatrix { } /// Clear all triplets from the matrix. - pub fn clear_triplets(&mut self, i: usize, j: usize, v: T) + pub fn clear_triplets(&mut self) where T: PartialEq, { diff --git a/nalgebra-sparse/tests/unit_tests/coo.rs b/nalgebra-sparse/tests/unit_tests/coo.rs index 16ee5647..d232b041 100644 --- a/nalgebra-sparse/tests/unit_tests/coo.rs +++ b/nalgebra-sparse/tests/unit_tests/coo.rs @@ -238,7 +238,7 @@ fn coo_clear_triplets_valid_entries() { vec![(0, 0, &1), (0, 0, &2), (2, 2, &3)] ); coo.clear_triplets(); - assert_eq(coo.triplet_iter.collect::>(), vec![]); + assert_eq!(coo.triplet_iter().collect::>(), vec![]); // making sure everyhting works after clearing coo.push(0, 0, 1); coo.push(0, 0, 2); From 498fbf51b13d3af325c2f4c546fa4b394d53818f Mon Sep 17 00:00:00 2001 From: lukas Date: Sat, 20 Aug 2022 00:09:12 -0700 Subject: [PATCH 11/15] remove unnecessary trait bounds --- nalgebra-sparse/src/coo.rs | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/nalgebra-sparse/src/coo.rs b/nalgebra-sparse/src/coo.rs index 1a1720ed..25dc07fb 100644 --- a/nalgebra-sparse/src/coo.rs +++ b/nalgebra-sparse/src/coo.rs @@ -212,10 +212,7 @@ impl CooMatrix { } /// Clear all triplets from the matrix. - pub fn clear_triplets(&mut self) - where - T: PartialEq, - { + pub fn clear_triplets(&mut self) { self.col_indices.clear(); self.row_indices.clear(); self.values.clear(); From 3aca9af616620aa54f63ae1f5c876ca99c1a2890 Mon Sep 17 00:00:00 2001 From: Patiga Date: Fri, 19 Aug 2022 13:34:21 +0200 Subject: [PATCH 12/15] Link listed types in lib.rs to their docs Helpful because lib.rs is the 'main page' for docs.rs This allows for easy/direct access to the mentioned types Currently you need to look up mentioned types via the search bar --- src/lib.rs | 44 +++++++++++++++++++++++++------------------- 1 file changed, 25 insertions(+), 19 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index 8da86531..86a5dc6b 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -46,28 +46,34 @@ fn main() { **nalgebra** is meant to be a general-purpose, low-dimensional, linear algebra library, with an optimized set of tools for computer graphics and physics. Those features include: -* A single parametrizable type `Matrix` for vectors, (square or rectangular) matrices, and slices - with dimensions known either at compile-time (using type-level integers) or at runtime. +* A single parametrizable type [`Matrix`](Matrix) for vectors, (square or rectangular) matrices, and + slices with dimensions known either at compile-time (using type-level integers) or at runtime. * Matrices and vectors with compile-time sizes are statically allocated while dynamic ones are allocated on the heap. -* Convenient aliases for low-dimensional matrices and vectors: `Vector1` to `Vector6` and - `Matrix1x1` to `Matrix6x6`, including rectangular matrices like `Matrix2x5`. -* Points sizes known at compile time, and convenience aliases: `Point1` to `Point6`. -* Translation (seen as a transformation that composes by multiplication): `Translation2`, - `Translation3`. -* Rotation matrices: `Rotation2`, `Rotation3`. -* Quaternions: `Quaternion`, `UnitQuaternion` (for 3D rotation). -* Unit complex numbers can be used for 2D rotation: `UnitComplex`. -* Algebraic entities with a norm equal to one: `Unit`, e.g., `Unit>`. -* Isometries (translation ⨯ rotation): `Isometry2`, `Isometry3` -* Similarity transformations (translation ⨯ rotation ⨯ uniform scale): `Similarity2`, `Similarity3`. -* Affine transformations stored as a homogeneous matrix: `Affine2`, `Affine3`. -* Projective (i.e. invertible) transformations stored as a homogeneous matrix: `Projective2`, - `Projective3`. +* Convenient aliases for low-dimensional matrices and vectors: [`Vector1`](Vector1) to + [`Vector6`](Vector6) and [`Matrix1x1`](Matrix1) to [`Matrix6x6`](Matrix6), including rectangular + matrices like [`Matrix2x5`](Matrix2x5). +* Points sizes known at compile time, and convenience aliases: [`Point1`](Point1) to + [`Point6`](Point6). +* Translation (seen as a transformation that composes by multiplication): + [`Translation2`](Translation2), [`Translation3`](Translation3). +* Rotation matrices: [`Rotation2`](Rotation2), [`Rotation3`](Rotation3). +* Quaternions: [`Quaternion`](Quaternion), [`UnitQuaternion`](UnitQuaternion) (for 3D rotation). +* Unit complex numbers can be used for 2D rotation: [`UnitComplex`](UnitComplex). +* Algebraic entities with a norm equal to one: [`Unit`](Unit), e.g., `Unit>`. +* Isometries (translation ⨯ rotation): [`Isometry2`](Isometry2), [`Isometry3`](Isometry3) +* Similarity transformations (translation ⨯ rotation ⨯ uniform scale): + [`Similarity2`](Similarity2), [`Similarity3`](Similarity3). +* Affine transformations stored as a homogeneous matrix: + [`Affine2`](Affine2), [`Affine3`](Affine3). +* Projective (i.e. invertible) transformations stored as a homogeneous matrix: + [`Projective2`](Projective2), [`Projective3`](Projective3). * General transformations that does not have to be invertible, stored as a homogeneous matrix: - `Transform2`, `Transform3`. -* 3D projections for computer graphics: `Perspective3`, `Orthographic3`. -* Matrix factorizations: `Cholesky`, `QR`, `LU`, `FullPivLU`, `SVD`, `Schur`, `Hessenberg`, `SymmetricEigen`. + [`Transform2`](Transform2), [`Transform3`](Transform3). +* 3D projections for computer graphics: [`Perspective3`](Perspective3), + [`Orthographic3`](Orthographic3). +* Matrix factorizations: [`Cholesky`](Cholesky), [`QR`](QR), [`LU`](LU), [`FullPivLU`](FullPivLU), + [`SVD`](SVD), [`Schur`](Schur), [`Hessenberg`](Hessenberg), [`SymmetricEigen`](SymmetricEigen). * Insertion and removal of rows of columns of a matrix. */ From 1079f0c1c395f9c1d8f7a66eaff979f64ac4bed3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Crozet?= Date: Sat, 24 Sep 2022 09:50:58 +0200 Subject: [PATCH 13/15] Add a non-const version of Point::new when the cuda feature is enabled --- src/geometry/point_construction.rs | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/geometry/point_construction.rs b/src/geometry/point_construction.rs index ac54b349..c061b872 100644 --- a/src/geometry/point_construction.rs +++ b/src/geometry/point_construction.rs @@ -216,9 +216,22 @@ macro_rules! componentwise_constructors_impl( #[doc = $doc] #[doc = "```"] #[inline] + #[cfg(not(feature = "cuda"))] pub const fn new($($args: T),*) -> Self { Point { coords: $Vector::new($($args),*) } } + + // TODO: always let new be const once CUDA updates its supported + // nightly version to something more recent. + #[doc = "Initializes this point from its components."] + #[doc = "# Example\n```"] + #[doc = $doc] + #[doc = "```"] + #[inline] + #[cfg(feature = "cuda")] + pub fn new($($args: T),*) -> Self { + Point { coords: $Vector::new($($args),*) } + } } )*} ); From 1870080f94e0d5b0374e88a565871b55e562619b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Crozet?= Date: Sat, 24 Sep 2022 10:13:15 +0200 Subject: [PATCH 14/15] Remove const for Point1::new when targetting cuda --- src/geometry/point_construction.rs | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/src/geometry/point_construction.rs b/src/geometry/point_construction.rs index c061b872..598cf4ed 100644 --- a/src/geometry/point_construction.rs +++ b/src/geometry/point_construction.rs @@ -202,11 +202,29 @@ impl Point1 { /// assert_eq!(p.x, 1.0); /// ``` #[inline] + #[cfg(not(feature = "cuda"))] pub const fn new(x: T) -> Self { Point { coords: Vector1::new(x), } } + + /// Initializes this point from its components. + /// + /// # Example + /// + /// ``` + /// # use nalgebra::Point1; + /// let p = Point1::new(1.0); + /// assert_eq!(p.x, 1.0); + /// ``` + #[inline] + #[cfg(feature = "cuda")] + pub fn new(x: T) -> Self { + Point { + coords: Vector1::new(x), + } + } } macro_rules! componentwise_constructors_impl( ($($doc: expr; $Point: ident, $Vector: ident, $($args: ident:$irow: expr),*);* $(;)*) => {$( From a752a4bbf5fb55c82d8776fcb9327c9b70da128c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Crozet?= Date: Sun, 9 Oct 2022 22:03:03 +0200 Subject: [PATCH 15/15] Release v0.31.2 --- CHANGELOG.md | 10 ++++++++++ Cargo.toml | 2 +- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 2950a1df..e035e084 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,16 @@ documented here. This project adheres to [Semantic Versioning](https://semver.org/). +## [0.31.2] (09 Oct. 2022) + +### Modified +- Use `#[inline]` on the `Dim` implementation for `Const` to improve opt-level 1 performance. +- Make the `Point::new` constructions const-fn. + +### Added +- Add `UnitVector::cast` to change the underlying scalar type. + + ## [0.31.1] (31 July 2022) ### Modified diff --git a/Cargo.toml b/Cargo.toml index 5b9940df..89de73e5 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "nalgebra" -version = "0.31.1" +version = "0.31.2" authors = [ "Sébastien Crozet " ] description = "General-purpose linear algebra library with transformations and statically-sized or dynamically-sized matrices."