From 711ac67da9e9adb28feeb544de9dfd063a14431a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Crozet?= Date: Sat, 14 Jan 2023 16:22:27 +0100 Subject: [PATCH] Deplecate Dynamic and Dynamic::new --- examples/reshaping.rs | 6 +- nalgebra-macros/src/lib.rs | 6 +- nalgebra-sparse/src/ops/impl_std_ops.rs | 22 ++--- src/base/alias.rs | 32 +++---- src/base/alias_slice.rs | 90 +++++++++---------- src/base/alias_view.rs | 90 +++++++++---------- src/base/allocator.rs | 2 +- src/base/blas.rs | 4 +- src/base/blas_uninit.rs | 16 ++-- src/base/constraint.rs | 14 +-- src/base/construction.rs | 42 ++++----- src/base/construction_view.rs | 54 ++++++------ src/base/conversion.rs | 26 +++--- src/base/default_allocator.rs | 90 +++++++++---------- src/base/dimension.rs | 55 ++++++------ src/base/edition.rs | 110 ++++++++++++------------ src/base/indexing.rs | 106 +++++++++++------------ src/base/matrix.rs | 16 ++-- src/base/matrix_view.rs | 84 +++++++++--------- src/base/ops.rs | 14 +-- src/base/vec_storage.rs | 82 +++++++++--------- src/debug/random_orthogonal.rs | 4 +- src/debug/random_sdp.rs | 4 +- src/linalg/bidiagonal.rs | 2 +- src/linalg/eigen.rs | 6 +- src/linalg/permutation_sequence.rs | 8 +- src/linalg/schur.rs | 30 +++---- src/proptest/mod.rs | 36 ++++---- src/sparse/cs_matrix.rs | 16 ++-- src/sparse/cs_matrix_conversion.rs | 4 +- tests/core/edition.rs | 10 +-- tests/core/reshape.rs | 28 +++--- tests/linalg/cholesky.rs | 14 +-- tests/linalg/convolution.rs | 6 +- tests/linalg/full_piv_lu.rs | 8 +- tests/proptest/mod.rs | 16 ++-- 36 files changed, 570 insertions(+), 583 deletions(-) diff --git a/examples/reshaping.rs b/examples/reshaping.rs index b2178e79..78f7bcd5 100644 --- a/examples/reshaping.rs +++ b/examples/reshaping.rs @@ -2,7 +2,7 @@ extern crate nalgebra as na; -use na::{DMatrix, Dynamic, Matrix2x3, Matrix3x2, Const}; +use na::{DMatrix, Dyn, Matrix2x3, Matrix3x2, Const}; fn main() { // Matrices can be reshaped in-place without moving or copying values. @@ -46,9 +46,9 @@ fn main() { ], ); - let dm3 = dm1.reshape_generic(Dynamic::new(6), Dynamic::new(2)); + let dm3 = dm1.reshape_generic(Dyn(6), Dyn(2)); assert_eq!(dm3, dm2); // Invalid reshapings of dynamic matrices will panic at run-time. - //let dm4 = dm3.reshape_generic(Dynamic::new(6), Dynamic::new(6)); + //let dm4 = dm3.reshape_generic(Dyn(6), Dyn(6)); } diff --git a/nalgebra-macros/src/lib.rs b/nalgebra-macros/src/lib.rs index 0d7889ae..e12139d2 100644 --- a/nalgebra-macros/src/lib.rs +++ b/nalgebra-macros/src/lib.rs @@ -191,8 +191,8 @@ pub fn dmatrix(stream: TokenStream) -> TokenStream { let output = quote! { nalgebra::DMatrix::<_> ::from_vec_storage(nalgebra::VecStorage::new( - nalgebra::Dynamic::new(#row_dim), - nalgebra::Dynamic::new(#col_dim), + nalgebra::Dyn(#row_dim), + nalgebra::Dyn(#col_dim), vec!#array_tokens)) }; @@ -285,7 +285,7 @@ pub fn dvector(stream: TokenStream) -> TokenStream { let output = quote! { nalgebra::DVector::<_> ::from_vec_storage(nalgebra::VecStorage::new( - nalgebra::Dynamic::new(#len), + nalgebra::Dyn(#len), nalgebra::Const::<1>, vec!#array_tokens)) }; diff --git a/nalgebra-sparse/src/ops/impl_std_ops.rs b/nalgebra-sparse/src/ops/impl_std_ops.rs index 91b6574f..7363c9d9 100644 --- a/nalgebra-sparse/src/ops/impl_std_ops.rs +++ b/nalgebra-sparse/src/ops/impl_std_ops.rs @@ -10,7 +10,7 @@ use nalgebra::allocator::Allocator; use nalgebra::base::storage::RawStorage; use nalgebra::constraint::{DimEq, ShapeConstraint}; use nalgebra::{ - ClosedAdd, ClosedDiv, ClosedMul, ClosedSub, DefaultAllocator, Dim, Dynamic, Matrix, OMatrix, + ClosedAdd, ClosedDiv, ClosedMul, ClosedSub, DefaultAllocator, Dim, Dyn, Matrix, OMatrix, Scalar, U1, }; use num_traits::{One, Zero}; @@ -273,8 +273,8 @@ macro_rules! impl_spmm_cs_dense { // Implement ref-ref impl_spmm_cs_dense!(&'a $matrix_type_name, &'a Matrix, $spmm_fn, |lhs, rhs| { let (_, ncols) = rhs.shape_generic(); - let nrows = Dynamic::new(lhs.nrows()); - let mut result = OMatrix::::zeros_generic(nrows, ncols); + let nrows = Dyn(lhs.nrows()); + let mut result = OMatrix::::zeros_generic(nrows, ncols); $spmm_fn(T::zero(), &mut result, T::one(), Op::NoOp(lhs), Op::NoOp(rhs)); result }); @@ -302,21 +302,21 @@ macro_rules! impl_spmm_cs_dense { R: Dim, C: Dim, S: RawStorage, - DefaultAllocator: Allocator, + DefaultAllocator: Allocator, // TODO: Is it possible to simplify these bounds? ShapeConstraint: - // Bounds so that we can turn OMatrix into a DMatrixSliceMut - DimEq>::Buffer as RawStorage>::RStride> - + DimEq - + DimEq>::Buffer as RawStorage>::CStride> + // Bounds so that we can turn OMatrix into a DMatrixSliceMut + DimEq>::Buffer as RawStorage>::RStride> + + DimEq + + DimEq>::Buffer as RawStorage>::CStride> // Bounds so that we can turn &Matrix into a DMatrixSlice + DimEq - + DimEq - + DimEq + + DimEq + + DimEq { // We need the column dimension to be generic, so that if RHS is a vector, then // we also get a vector (and not a matrix) - type Output = OMatrix; + type Output = OMatrix; fn mul(self, rhs: $dense_matrix_type) -> Self::Output { let $lhs = self; diff --git a/src/base/alias.rs b/src/base/alias.rs index 68829d9a..e3ac40b0 100644 --- a/src/base/alias.rs +++ b/src/base/alias.rs @@ -1,5 +1,5 @@ #[cfg(any(feature = "alloc", feature = "std"))] -use crate::base::dimension::Dynamic; +use crate::base::dimension::Dyn; use crate::base::dimension::{U1, U2, U3, U4, U5, U6}; use crate::base::storage::Owned; #[cfg(any(feature = "std", feature = "alloc"))] @@ -48,69 +48,69 @@ pub type SMatrix = /// /// **Because this is an alias, not all its methods are listed here. See the [`Matrix`](crate::base::Matrix) type too.** #[cfg(any(feature = "std", feature = "alloc"))] -pub type DMatrix = Matrix>; +pub type DMatrix = Matrix>; /// A heap-allocated, column-major, matrix with a dynamic number of rows and 1 columns. /// /// **Because this is an alias, not all its methods are listed here. See the [`Matrix`](crate::base::Matrix) type too.** #[cfg(any(feature = "std", feature = "alloc"))] -pub type MatrixXx1 = Matrix>; +pub type MatrixXx1 = Matrix>; /// A heap-allocated, column-major, matrix with a dynamic number of rows and 2 columns. /// /// **Because this is an alias, not all its methods are listed here. See the [`Matrix`](crate::base::Matrix) type too.** #[cfg(any(feature = "std", feature = "alloc"))] -pub type MatrixXx2 = Matrix>; +pub type MatrixXx2 = Matrix>; /// A heap-allocated, column-major, matrix with a dynamic number of rows and 3 columns. /// /// **Because this is an alias, not all its methods are listed here. See the [`Matrix`](crate::base::Matrix) type too.** #[cfg(any(feature = "std", feature = "alloc"))] -pub type MatrixXx3 = Matrix>; +pub type MatrixXx3 = Matrix>; /// A heap-allocated, column-major, matrix with a dynamic number of rows and 4 columns. /// /// **Because this is an alias, not all its methods are listed here. See the [`Matrix`](crate::base::Matrix) type too.** #[cfg(any(feature = "std", feature = "alloc"))] -pub type MatrixXx4 = Matrix>; +pub type MatrixXx4 = Matrix>; /// A heap-allocated, column-major, matrix with a dynamic number of rows and 5 columns. /// /// **Because this is an alias, not all its methods are listed here. See the [`Matrix`](crate::base::Matrix) type too.** #[cfg(any(feature = "std", feature = "alloc"))] -pub type MatrixXx5 = Matrix>; +pub type MatrixXx5 = Matrix>; /// A heap-allocated, column-major, matrix with a dynamic number of rows and 6 columns. /// /// **Because this is an alias, not all its methods are listed here. See the [`Matrix`](crate::base::Matrix) type too.** #[cfg(any(feature = "std", feature = "alloc"))] -pub type MatrixXx6 = Matrix>; +pub type MatrixXx6 = Matrix>; /// A heap-allocated, row-major, matrix with 1 rows and a dynamic number of columns. /// /// **Because this is an alias, not all its methods are listed here. See the [`Matrix`](crate::base::Matrix) type too.** #[cfg(any(feature = "std", feature = "alloc"))] -pub type Matrix1xX = Matrix>; +pub type Matrix1xX = Matrix>; /// A heap-allocated, row-major, matrix with 2 rows and a dynamic number of columns. /// /// **Because this is an alias, not all its methods are listed here. See the [`Matrix`](crate::base::Matrix) type too.** #[cfg(any(feature = "std", feature = "alloc"))] -pub type Matrix2xX = Matrix>; +pub type Matrix2xX = Matrix>; /// A heap-allocated, row-major, matrix with 3 rows and a dynamic number of columns. /// /// **Because this is an alias, not all its methods are listed here. See the [`Matrix`](crate::base::Matrix) type too.** #[cfg(any(feature = "std", feature = "alloc"))] -pub type Matrix3xX = Matrix>; +pub type Matrix3xX = Matrix>; /// A heap-allocated, row-major, matrix with 4 rows and a dynamic number of columns. /// /// **Because this is an alias, not all its methods are listed here. See the [`Matrix`](crate::base::Matrix) type too.** #[cfg(any(feature = "std", feature = "alloc"))] -pub type Matrix4xX = Matrix>; +pub type Matrix4xX = Matrix>; /// A heap-allocated, row-major, matrix with 5 rows and a dynamic number of columns. /// /// **Because this is an alias, not all its methods are listed here. See the [`Matrix`](crate::base::Matrix) type too.** #[cfg(any(feature = "std", feature = "alloc"))] -pub type Matrix5xX = Matrix>; +pub type Matrix5xX = Matrix>; /// A heap-allocated, row-major, matrix with 6 rows and a dynamic number of columns. /// /// **Because this is an alias, not all its methods are listed here. See the [`Matrix`](crate::base::Matrix) type too.** #[cfg(any(feature = "std", feature = "alloc"))] -pub type Matrix6xX = Matrix>; +pub type Matrix6xX = Matrix>; /// A stack-allocated, column-major, 1x1 square matrix. /// @@ -276,7 +276,7 @@ pub type Matrix6x5 = Matrix>; */ /// A dynamically sized column vector. #[cfg(any(feature = "std", feature = "alloc"))] -pub type DVector = Matrix>; +pub type DVector = Matrix>; /// An owned D-dimensional column vector. pub type OVector = Matrix>; @@ -316,7 +316,7 @@ pub type Vector6 = Matrix>; */ /// A dynamically sized row vector. #[cfg(any(feature = "std", feature = "alloc"))] -pub type RowDVector = Matrix>; +pub type RowDVector = Matrix>; /// An owned D-dimensional row vector. pub type RowOVector = Matrix>; diff --git a/src/base/alias_slice.rs b/src/base/alias_slice.rs index d3f8879a..9c1a9a87 100644 --- a/src/base/alias_slice.rs +++ b/src/base/alias_slice.rs @@ -1,4 +1,4 @@ -use crate::base::dimension::{Dynamic, U1, U2, U3, U4, U5, U6}; +use crate::base::dimension::{Dyn, U1, U2, U3, U4, U5, U6}; use crate::base::matrix_view::{ViewStorage, ViewStorageMut}; use crate::base::{Const, Matrix}; use crate::slice_deprecation_note; @@ -22,8 +22,8 @@ pub type SMatrixSlice<'a, T, const R: usize, const C: usize> = /// /// **Because this is an alias, not all its methods are listed here. See the [`Matrix`](crate::base::Matrix) type too.** #[deprecated = slice_deprecation_note!(DMatrixView)] -pub type DMatrixSlice<'a, T, RStride = U1, CStride = Dynamic> = - Matrix>; +pub type DMatrixSlice<'a, T, RStride = U1, CStride = Dyn> = + Matrix>; /// A column-major 1x1 matrix slice. /// @@ -251,52 +251,52 @@ pub type MatrixSlice6x5<'a, T, RStride = U1, CStride = U6> = /// A column-major matrix slice with 1 row and a number of columns chosen at runtime. #[deprecated = slice_deprecation_note!(MatrixView1xX)] pub type MatrixSlice1xX<'a, T, RStride = U1, CStride = U1> = - Matrix>; + Matrix>; /// A column-major matrix slice with 2 rows and a number of columns chosen at runtime. #[deprecated = slice_deprecation_note!(MatrixView2xX)] pub type MatrixSlice2xX<'a, T, RStride = U1, CStride = U2> = - Matrix>; + Matrix>; /// A column-major matrix slice with 3 rows and a number of columns chosen at runtime. #[deprecated = slice_deprecation_note!(MatrixView3xX)] pub type MatrixSlice3xX<'a, T, RStride = U1, CStride = U3> = - Matrix>; + Matrix>; /// A column-major matrix slice with 4 rows and a number of columns chosen at runtime. #[deprecated = slice_deprecation_note!(MatrixView4xX)] pub type MatrixSlice4xX<'a, T, RStride = U1, CStride = U4> = - Matrix>; + Matrix>; /// A column-major matrix slice with 5 rows and a number of columns chosen at runtime. #[deprecated = slice_deprecation_note!(MatrixView5xX)] pub type MatrixSlice5xX<'a, T, RStride = U1, CStride = U5> = - Matrix>; + Matrix>; /// A column-major matrix slice with 6 rows and a number of columns chosen at runtime. #[deprecated = slice_deprecation_note!(MatrixView6xX)] pub type MatrixSlice6xX<'a, T, RStride = U1, CStride = U6> = - Matrix>; + Matrix>; /// A column-major matrix slice with a number of rows chosen at runtime and 1 column. #[deprecated = slice_deprecation_note!(MatrixViewXx1)] -pub type MatrixSliceXx1<'a, T, RStride = U1, CStride = Dynamic> = - Matrix>; +pub type MatrixSliceXx1<'a, T, RStride = U1, CStride = Dyn> = + Matrix>; /// A column-major matrix slice with a number of rows chosen at runtime and 2 columns. #[deprecated = slice_deprecation_note!(MatrixViewXx2)] -pub type MatrixSliceXx2<'a, T, RStride = U1, CStride = Dynamic> = - Matrix>; +pub type MatrixSliceXx2<'a, T, RStride = U1, CStride = Dyn> = + Matrix>; /// A column-major matrix slice with a number of rows chosen at runtime and 3 columns. #[deprecated = slice_deprecation_note!(MatrixViewXx3)] -pub type MatrixSliceXx3<'a, T, RStride = U1, CStride = Dynamic> = - Matrix>; +pub type MatrixSliceXx3<'a, T, RStride = U1, CStride = Dyn> = + Matrix>; /// A column-major matrix slice with a number of rows chosen at runtime and 4 columns. #[deprecated = slice_deprecation_note!(MatrixViewXx4)] -pub type MatrixSliceXx4<'a, T, RStride = U1, CStride = Dynamic> = - Matrix>; +pub type MatrixSliceXx4<'a, T, RStride = U1, CStride = Dyn> = + Matrix>; /// A column-major matrix slice with a number of rows chosen at runtime and 5 columns. #[deprecated = slice_deprecation_note!(MatrixViewXx5)] -pub type MatrixSliceXx5<'a, T, RStride = U1, CStride = Dynamic> = - Matrix>; +pub type MatrixSliceXx5<'a, T, RStride = U1, CStride = Dyn> = + Matrix>; /// A column-major matrix slice with a number of rows chosen at runtime and 6 columns. #[deprecated = slice_deprecation_note!(MatrixViewXx6)] -pub type MatrixSliceXx6<'a, T, RStride = U1, CStride = Dynamic> = - Matrix>; +pub type MatrixSliceXx6<'a, T, RStride = U1, CStride = Dyn> = + Matrix>; /// A column vector slice with dimensions known at compile-time. /// @@ -314,8 +314,8 @@ pub type SVectorSlice<'a, T, const D: usize> = /// A column vector slice dynamic numbers of rows and columns. #[deprecated = slice_deprecation_note!(DVectorView)] -pub type DVectorSlice<'a, T, RStride = U1, CStride = Dynamic> = - Matrix>; +pub type DVectorSlice<'a, T, RStride = U1, CStride = Dyn> = + Matrix>; /// A 1D column vector slice. /// @@ -386,8 +386,8 @@ pub type SMatrixSliceMut<'a, T, const R: usize, const C: usize> = /// /// **Because this is an alias, not all its methods are listed here. See the [`Matrix`](crate::base::Matrix) type too.** #[deprecated = slice_deprecation_note!(DMatrixViewMut)] -pub type DMatrixSliceMut<'a, T, RStride = U1, CStride = Dynamic> = - Matrix>; +pub type DMatrixSliceMut<'a, T, RStride = U1, CStride = Dyn> = + Matrix>; /// A column-major 1x1 matrix slice. /// @@ -615,52 +615,52 @@ pub type MatrixSliceMut6x5<'a, T, RStride = U1, CStride = U6> = /// A column-major matrix slice with 1 row and a number of columns chosen at runtime. #[deprecated = slice_deprecation_note!(MatrixViewMut1xX)] pub type MatrixSliceMut1xX<'a, T, RStride = U1, CStride = U1> = - Matrix>; + Matrix>; /// A column-major matrix slice with 2 rows and a number of columns chosen at runtime. #[deprecated = slice_deprecation_note!(MatrixViewMut2xX)] pub type MatrixSliceMut2xX<'a, T, RStride = U1, CStride = U2> = - Matrix>; + Matrix>; /// A column-major matrix slice with 3 rows and a number of columns chosen at runtime. #[deprecated = slice_deprecation_note!(MatrixViewMut3xX)] pub type MatrixSliceMut3xX<'a, T, RStride = U1, CStride = U3> = - Matrix>; + Matrix>; /// A column-major matrix slice with 4 rows and a number of columns chosen at runtime. #[deprecated = slice_deprecation_note!(MatrixViewMut4xX)] pub type MatrixSliceMut4xX<'a, T, RStride = U1, CStride = U4> = - Matrix>; + Matrix>; /// A column-major matrix slice with 5 rows and a number of columns chosen at runtime. #[deprecated = slice_deprecation_note!(MatrixViewMut5xX)] pub type MatrixSliceMut5xX<'a, T, RStride = U1, CStride = U5> = - Matrix>; + Matrix>; /// A column-major matrix slice with 6 rows and a number of columns chosen at runtime. #[deprecated = slice_deprecation_note!(MatrixViewMut6xX)] pub type MatrixSliceMut6xX<'a, T, RStride = U1, CStride = U6> = - Matrix>; + Matrix>; /// A column-major matrix slice with a number of rows chosen at runtime and 1 column. #[deprecated = slice_deprecation_note!(MatrixViewMutXx1)] -pub type MatrixSliceMutXx1<'a, T, RStride = U1, CStride = Dynamic> = - Matrix>; +pub type MatrixSliceMutXx1<'a, T, RStride = U1, CStride = Dyn> = + Matrix>; /// A column-major matrix slice with a number of rows chosen at runtime and 2 columns. #[deprecated = slice_deprecation_note!(MatrixViewMutXx2)] -pub type MatrixSliceMutXx2<'a, T, RStride = U1, CStride = Dynamic> = - Matrix>; +pub type MatrixSliceMutXx2<'a, T, RStride = U1, CStride = Dyn> = + Matrix>; /// A column-major matrix slice with a number of rows chosen at runtime and 3 columns. #[deprecated = slice_deprecation_note!(MatrixViewMutXx3)] -pub type MatrixSliceMutXx3<'a, T, RStride = U1, CStride = Dynamic> = - Matrix>; +pub type MatrixSliceMutXx3<'a, T, RStride = U1, CStride = Dyn> = + Matrix>; /// A column-major matrix slice with a number of rows chosen at runtime and 4 columns. #[deprecated = slice_deprecation_note!(MatrixViewMutXx4)] -pub type MatrixSliceMutXx4<'a, T, RStride = U1, CStride = Dynamic> = - Matrix>; +pub type MatrixSliceMutXx4<'a, T, RStride = U1, CStride = Dyn> = + Matrix>; /// A column-major matrix slice with a number of rows chosen at runtime and 5 columns. #[deprecated = slice_deprecation_note!(MatrixViewMutXx5)] -pub type MatrixSliceMutXx5<'a, T, RStride = U1, CStride = Dynamic> = - Matrix>; +pub type MatrixSliceMutXx5<'a, T, RStride = U1, CStride = Dyn> = + Matrix>; /// A column-major matrix slice with a number of rows chosen at runtime and 6 columns. #[deprecated = slice_deprecation_note!(MatrixViewMutXx6)] -pub type MatrixSliceMutXx6<'a, T, RStride = U1, CStride = Dynamic> = - Matrix>; +pub type MatrixSliceMutXx6<'a, T, RStride = U1, CStride = Dyn> = + Matrix>; /// A column vector slice with dimensions known at compile-time. /// @@ -680,8 +680,8 @@ pub type SVectorSliceMut<'a, T, const D: usize> = /// /// **Because this is an alias, not all its methods are listed here. See the [`Matrix`](crate::base::Matrix) type too.** #[deprecated = slice_deprecation_note!(DVectorViewMut)] -pub type DVectorSliceMut<'a, T, RStride = U1, CStride = Dynamic> = - Matrix>; +pub type DVectorSliceMut<'a, T, RStride = U1, CStride = Dyn> = + Matrix>; /// A 1D column vector slice. /// diff --git a/src/base/alias_view.rs b/src/base/alias_view.rs index 1bbee3f8..26da6f47 100644 --- a/src/base/alias_view.rs +++ b/src/base/alias_view.rs @@ -1,4 +1,4 @@ -use crate::base::dimension::{Dynamic, U1, U2, U3, U4, U5, U6}; +use crate::base::dimension::{Dyn, U1, U2, U3, U4, U5, U6}; use crate::base::matrix_view::{ViewStorage, ViewStorageMut}; use crate::base::{Const, Matrix}; @@ -19,8 +19,8 @@ pub type SMatrixView<'a, T, const R: usize, const C: usize> = /// A column-major matrix view dynamic numbers of rows and columns. /// /// **Because this is an alias, not all its methods are listed here. See the [`Matrix`](crate::base::Matrix) type too.** -pub type DMatrixView<'a, T, RStride = U1, CStride = Dynamic> = - Matrix>; +pub type DMatrixView<'a, T, RStride = U1, CStride = Dyn> = + Matrix>; /// A column-major 1x1 matrix view. /// @@ -211,41 +211,41 @@ pub type MatrixView6x5<'a, T, RStride = U1, CStride = U6> = /// A column-major matrix view with 1 row and a number of columns chosen at runtime. pub type MatrixView1xX<'a, T, RStride = U1, CStride = U1> = - Matrix>; + Matrix>; /// A column-major matrix view with 2 rows and a number of columns chosen at runtime. pub type MatrixView2xX<'a, T, RStride = U1, CStride = U2> = - Matrix>; + Matrix>; /// A column-major matrix view with 3 rows and a number of columns chosen at runtime. pub type MatrixView3xX<'a, T, RStride = U1, CStride = U3> = - Matrix>; + Matrix>; /// A column-major matrix view with 4 rows and a number of columns chosen at runtime. pub type MatrixView4xX<'a, T, RStride = U1, CStride = U4> = - Matrix>; + Matrix>; /// A column-major matrix view with 5 rows and a number of columns chosen at runtime. pub type MatrixView5xX<'a, T, RStride = U1, CStride = U5> = - Matrix>; + Matrix>; /// A column-major matrix view with 6 rows and a number of columns chosen at runtime. pub type MatrixView6xX<'a, T, RStride = U1, CStride = U6> = - Matrix>; + Matrix>; /// A column-major matrix view with a number of rows chosen at runtime and 1 column. -pub type MatrixViewXx1<'a, T, RStride = U1, CStride = Dynamic> = - Matrix>; +pub type MatrixViewXx1<'a, T, RStride = U1, CStride = Dyn> = + Matrix>; /// A column-major matrix view with a number of rows chosen at runtime and 2 columns. -pub type MatrixViewXx2<'a, T, RStride = U1, CStride = Dynamic> = - Matrix>; +pub type MatrixViewXx2<'a, T, RStride = U1, CStride = Dyn> = + Matrix>; /// A column-major matrix view with a number of rows chosen at runtime and 3 columns. -pub type MatrixViewXx3<'a, T, RStride = U1, CStride = Dynamic> = - Matrix>; +pub type MatrixViewXx3<'a, T, RStride = U1, CStride = Dyn> = + Matrix>; /// A column-major matrix view with a number of rows chosen at runtime and 4 columns. -pub type MatrixViewXx4<'a, T, RStride = U1, CStride = Dynamic> = - Matrix>; +pub type MatrixViewXx4<'a, T, RStride = U1, CStride = Dyn> = + Matrix>; /// A column-major matrix view with a number of rows chosen at runtime and 5 columns. -pub type MatrixViewXx5<'a, T, RStride = U1, CStride = Dynamic> = - Matrix>; +pub type MatrixViewXx5<'a, T, RStride = U1, CStride = Dyn> = + Matrix>; /// A column-major matrix view with a number of rows chosen at runtime and 6 columns. -pub type MatrixViewXx6<'a, T, RStride = U1, CStride = Dynamic> = - Matrix>; +pub type MatrixViewXx6<'a, T, RStride = U1, CStride = Dyn> = + Matrix>; /// A column vector view with dimensions known at compile-time. /// @@ -260,8 +260,8 @@ pub type SVectorView<'a, T, const D: usize> = Matrix, Const<1>, ViewStorage<'a, T, Const, Const<1>, Const<1>, Const>>; /// A column vector view dynamic numbers of rows and columns. -pub type DVectorView<'a, T, RStride = U1, CStride = Dynamic> = - Matrix>; +pub type DVectorView<'a, T, RStride = U1, CStride = Dyn> = + Matrix>; /// A 1D column vector view. /// @@ -311,8 +311,8 @@ pub type SMatrixViewMut<'a, T, const R: usize, const C: usize> = /// A column-major matrix view dynamic numbers of rows and columns. /// /// **Because this is an alias, not all its methods are listed here. See the [`Matrix`](crate::base::Matrix) type too.** -pub type DMatrixViewMut<'a, T, RStride = U1, CStride = Dynamic> = - Matrix>; +pub type DMatrixViewMut<'a, T, RStride = U1, CStride = Dyn> = + Matrix>; /// A column-major 1x1 matrix view. /// @@ -503,41 +503,41 @@ pub type MatrixViewMut6x5<'a, T, RStride = U1, CStride = U6> = /// A column-major matrix view with 1 row and a number of columns chosen at runtime. pub type MatrixViewMut1xX<'a, T, RStride = U1, CStride = U1> = - Matrix>; + Matrix>; /// A column-major matrix view with 2 rows and a number of columns chosen at runtime. pub type MatrixViewMut2xX<'a, T, RStride = U1, CStride = U2> = - Matrix>; + Matrix>; /// A column-major matrix view with 3 rows and a number of columns chosen at runtime. pub type MatrixViewMut3xX<'a, T, RStride = U1, CStride = U3> = - Matrix>; + Matrix>; /// A column-major matrix view with 4 rows and a number of columns chosen at runtime. pub type MatrixViewMut4xX<'a, T, RStride = U1, CStride = U4> = - Matrix>; + Matrix>; /// A column-major matrix view with 5 rows and a number of columns chosen at runtime. pub type MatrixViewMut5xX<'a, T, RStride = U1, CStride = U5> = - Matrix>; + Matrix>; /// A column-major matrix view with 6 rows and a number of columns chosen at runtime. pub type MatrixViewMut6xX<'a, T, RStride = U1, CStride = U6> = - Matrix>; + Matrix>; /// A column-major matrix view with a number of rows chosen at runtime and 1 column. -pub type MatrixViewMutXx1<'a, T, RStride = U1, CStride = Dynamic> = - Matrix>; +pub type MatrixViewMutXx1<'a, T, RStride = U1, CStride = Dyn> = + Matrix>; /// A column-major matrix view with a number of rows chosen at runtime and 2 columns. -pub type MatrixViewMutXx2<'a, T, RStride = U1, CStride = Dynamic> = - Matrix>; +pub type MatrixViewMutXx2<'a, T, RStride = U1, CStride = Dyn> = + Matrix>; /// A column-major matrix view with a number of rows chosen at runtime and 3 columns. -pub type MatrixViewMutXx3<'a, T, RStride = U1, CStride = Dynamic> = - Matrix>; +pub type MatrixViewMutXx3<'a, T, RStride = U1, CStride = Dyn> = + Matrix>; /// A column-major matrix view with a number of rows chosen at runtime and 4 columns. -pub type MatrixViewMutXx4<'a, T, RStride = U1, CStride = Dynamic> = - Matrix>; +pub type MatrixViewMutXx4<'a, T, RStride = U1, CStride = Dyn> = + Matrix>; /// A column-major matrix view with a number of rows chosen at runtime and 5 columns. -pub type MatrixViewMutXx5<'a, T, RStride = U1, CStride = Dynamic> = - Matrix>; +pub type MatrixViewMutXx5<'a, T, RStride = U1, CStride = Dyn> = + Matrix>; /// A column-major matrix view with a number of rows chosen at runtime and 6 columns. -pub type MatrixViewMutXx6<'a, T, RStride = U1, CStride = Dynamic> = - Matrix>; +pub type MatrixViewMutXx6<'a, T, RStride = U1, CStride = Dyn> = + Matrix>; /// A column vector view with dimensions known at compile-time. /// @@ -554,8 +554,8 @@ pub type SVectorViewMut<'a, T, const D: usize> = /// A column vector view dynamic numbers of rows and columns. /// /// **Because this is an alias, not all its methods are listed here. See the [`Matrix`](crate::base::Matrix) type too.** -pub type DVectorViewMut<'a, T, RStride = U1, CStride = Dynamic> = - Matrix>; +pub type DVectorViewMut<'a, T, RStride = U1, CStride = Dyn> = + Matrix>; /// A 1D column vector view. /// diff --git a/src/base/allocator.rs b/src/base/allocator.rs index bb227d3b..6458b8cb 100644 --- a/src/base/allocator.rs +++ b/src/base/allocator.rs @@ -15,7 +15,7 @@ use std::mem::MaybeUninit; /// /// An allocator is said to be: /// − static: if `R` and `C` both implement `DimName`. -/// − dynamic: if either one (or both) of `R` or `C` is equal to `Dynamic`. +/// − dynamic: if either one (or both) of `R` or `C` is equal to `Dyn`. /// /// Every allocator must be both static and dynamic. Though not all implementations may share the /// same `Buffer` type. diff --git a/src/base/blas.rs b/src/base/blas.rs index 9d9dd2bd..e5741568 100644 --- a/src/base/blas.rs +++ b/src/base/blas.rs @@ -7,7 +7,7 @@ use crate::base::blas_uninit::{axcpy_uninit, gemm_uninit, gemv_uninit}; use crate::base::constraint::{ AreMultipliable, DimEq, SameNumberOfColumns, SameNumberOfRows, ShapeConstraint, }; -use crate::base::dimension::{Const, Dim, Dynamic, U1, U2, U3, U4}; +use crate::base::dimension::{Const, Dim, Dyn, U1, U2, U3, U4}; use crate::base::storage::{Storage, StorageMut}; use crate::base::uninit::Init; use crate::base::{ @@ -890,7 +890,7 @@ where for j in 0..dim1 { let val = unsafe { conjugate(y.vget_unchecked(j).clone()) }; - let subdim = Dynamic::new(dim1 - j); + let subdim = Dyn(dim1 - j); // TODO: avoid bound checks. self.generic_view_mut((j, j), (subdim, Const::<1>)).axpy( alpha.clone() * val, diff --git a/src/base/blas_uninit.rs b/src/base/blas_uninit.rs index 7e449d7d..3fcfa6e1 100644 --- a/src/base/blas_uninit.rs +++ b/src/base/blas_uninit.rs @@ -18,7 +18,7 @@ use std::mem; use crate::base::constraint::{ AreMultipliable, DimEq, SameNumberOfColumns, SameNumberOfRows, ShapeConstraint, }; -use crate::base::dimension::{Dim, Dynamic, U1}; +use crate::base::dimension::{Dim, Dyn, U1}; use crate::base::storage::{RawStorage, RawStorageMut}; use crate::base::uninit::InitStatus; use crate::base::{Matrix, Scalar, Vector}; @@ -209,16 +209,16 @@ pub unsafe fn gemm_uninit< #[cfg(feature = "std")] { - // We assume large matrices will be Dynamic but small matrices static. + // We assume large matrices will be Dyn but small matrices static. // We could use matrixmultiply for large statically-sized matrices but the performance // threshold to activate it would be different from SMALL_DIM because our code optimizes // better for statically-sized matrices. - if R1::is::() - || C1::is::() - || R2::is::() - || C2::is::() - || R3::is::() - || C3::is::() + if R1::is::() + || C1::is::() + || R2::is::() + || C2::is::() + || R3::is::() + || C3::is::() { // matrixmultiply can be used only if the std feature is available. let nrows1 = y.nrows(); diff --git a/src/base/constraint.rs b/src/base/constraint.rs index b8febd03..5aecc279 100644 --- a/src/base/constraint.rs +++ b/src/base/constraint.rs @@ -1,6 +1,6 @@ //! Compatibility constraints between matrix shapes, e.g., for addition or multiplication. -use crate::base::dimension::{Dim, DimName, Dynamic}; +use crate::base::dimension::{Dim, DimName, Dyn}; /// A type used in `where` clauses for enforcing constraints. #[derive(Copy, Clone, Debug)] @@ -25,11 +25,11 @@ impl DimEq for ShapeConstraint { type Representative = D; } -impl DimEq for ShapeConstraint { +impl DimEq for ShapeConstraint { type Representative = D; } -impl DimEq for ShapeConstraint { +impl DimEq for ShapeConstraint { type Representative = D; } @@ -47,11 +47,11 @@ macro_rules! equality_trait_decl( type Representative = D; } - impl $Trait for ShapeConstraint { + impl $Trait for ShapeConstraint { type Representative = D; } - impl $Trait for ShapeConstraint { + impl $Trait for ShapeConstraint { type Representative = D; } )*} @@ -82,10 +82,10 @@ impl SameDimension for ShapeConstraint { type Representative = D; } -impl SameDimension for ShapeConstraint { +impl SameDimension for ShapeConstraint { type Representative = D; } -impl SameDimension for ShapeConstraint { +impl SameDimension for ShapeConstraint { type Representative = D; } diff --git a/src/base/construction.rs b/src/base/construction.rs index 009d8c76..aabe75d8 100644 --- a/src/base/construction.rs +++ b/src/base/construction.rs @@ -19,7 +19,7 @@ use typenum::{self, Cmp, Greater}; use simba::scalar::{ClosedAdd, ClosedMul}; use crate::base::allocator::Allocator; -use crate::base::dimension::{Dim, DimName, Dynamic, ToTypenum}; +use crate::base::dimension::{Dim, DimName, Dyn, ToTypenum}; use crate::base::storage::RawStorage; use crate::base::{ ArrayStorage, Const, DefaultAllocator, Matrix, OMatrix, OVector, Scalar, Unit, Vector, @@ -317,12 +317,12 @@ where /// /// # Example /// ``` - /// # use nalgebra::{Dynamic, DMatrix, Matrix, Const}; + /// # use nalgebra::{Dyn, DMatrix, Matrix, Const}; /// /// let vec = vec![0, 1, 2, 3, 4, 5]; /// let vec_ptr = vec.as_ptr(); /// - /// let matrix = Matrix::from_vec_generic(Dynamic::new(vec.len()), Const::<1>, vec); + /// let matrix = Matrix::from_vec_generic(Dyn(vec.len()), Const::<1>, vec); /// let matrix_storage_ptr = matrix.data.as_vec().as_ptr(); /// /// // `matrix` is backed by exactly the same `Vec` as it was constructed from. @@ -656,35 +656,35 @@ where } /// # Constructors of matrices with a dynamic number of columns -impl OMatrix +impl OMatrix where - DefaultAllocator: Allocator, + DefaultAllocator: Allocator, { - impl_constructors!(R, Dynamic; + impl_constructors!(R, Dyn; => R: DimName; - R::name(), Dynamic::new(ncols); + R::name(), Dyn(ncols); ncols); } /// # Constructors of dynamic vectors and matrices with a dynamic number of rows -impl OMatrix +impl OMatrix where - DefaultAllocator: Allocator, + DefaultAllocator: Allocator, { - impl_constructors!(Dynamic, C; + impl_constructors!(Dyn, C; => C: DimName; - Dynamic::new(nrows), C::name(); + Dyn(nrows), C::name(); nrows); } /// # Constructors of fully dynamic matrices -impl OMatrix +impl OMatrix where - DefaultAllocator: Allocator, + DefaultAllocator: Allocator, { - impl_constructors!(Dynamic, Dynamic; + impl_constructors!(Dyn, Dyn; ; - Dynamic::new(nrows), Dynamic::new(ncols); + Dyn(nrows), Dyn(ncols); nrows, ncols); } @@ -790,19 +790,19 @@ impl_constructors_from_data!(data; R, C; // Arguments for Matri R::name(), C::name(); // Arguments for `_generic` constructors. ); // Arguments for non-generic constructors. -impl_constructors_from_data!(data; R, Dynamic; +impl_constructors_from_data!(data; R, Dyn; => R: DimName; -R::name(), Dynamic::new(data.len() / R::dim()); +R::name(), Dyn(data.len() / R::dim()); ); -impl_constructors_from_data!(data; Dynamic, C; +impl_constructors_from_data!(data; Dyn, C; => C: DimName; -Dynamic::new(data.len() / C::dim()), C::name(); +Dyn(data.len() / C::dim()), C::name(); ); -impl_constructors_from_data!(data; Dynamic, Dynamic; +impl_constructors_from_data!(data; Dyn, Dyn; ; - Dynamic::new(nrows), Dynamic::new(ncols); + Dyn(nrows), Dyn(ncols); nrows, ncols); /* diff --git a/src/base/construction_view.rs b/src/base/construction_view.rs index 910b2873..8584f5b2 100644 --- a/src/base/construction_view.rs +++ b/src/base/construction_view.rs @@ -1,4 +1,4 @@ -use crate::base::dimension::{Const, Dim, DimName, Dynamic}; +use crate::base::dimension::{Const, Dim, DimName, Dyn}; use crate::base::matrix_view::{ViewStorage, ViewStorageMut}; use crate::base::{MatrixView, MatrixViewMut, Scalar}; @@ -12,7 +12,7 @@ impl<'a, T: Scalar, R: Dim, C: Dim, RStride: Dim, CStride: Dim> /// /// # Safety /// This method is unsafe because the input data array is not checked to contain enough elements. - /// The generic types `R`, `C`, `RStride`, `CStride` can either be type-level integers or integers wrapped with `Dynamic::new()`. + /// The generic types `R`, `C`, `RStride`, `CStride` can either be type-level integers or integers wrapped with `Dyn()`. #[inline] pub unsafe fn from_slice_with_strides_generic_unchecked( data: &'a [T], @@ -33,7 +33,7 @@ impl<'a, T: Scalar, R: Dim, C: Dim, RStride: Dim, CStride: Dim> /// Creates a matrix view from an array and with dimensions and strides specified by generic types instances. /// /// Panics if the input data array dose not contain enough elements. - /// The generic types `R`, `C`, `RStride`, `CStride` can either be type-level integers or integers wrapped with `Dynamic::new()`. + /// The generic types `R`, `C`, `RStride`, `CStride` can either be type-level integers or integers wrapped with `Dyn()`. #[inline] pub fn from_slice_with_strides_generic( data: &'a [T], @@ -62,7 +62,7 @@ impl<'a, T: Scalar, R: Dim, C: Dim> MatrixView<'a, T, R, C> { /// /// # Safety /// This method is unsafe because the input data array is not checked to contain enough elements. - /// The generic types `R` and `C` can either be type-level integers or integers wrapped with `Dynamic::new()`. + /// The generic types `R` and `C` can either be type-level integers or integers wrapped with `Dyn()`. #[inline] pub unsafe fn from_slice_generic_unchecked( data: &'a [T], @@ -78,7 +78,7 @@ impl<'a, T: Scalar, R: Dim, C: Dim> MatrixView<'a, T, R, C> { /// Creates a matrix view from an array and with dimensions and strides specified by generic types instances. /// /// Panics if the input data array dose not contain enough elements. - /// The generic types `R` and `C` can either be type-level integers or integers wrapped with `Dynamic::new()`. + /// The generic types `R` and `C` can either be type-level integers or integers wrapped with `Dyn()`. #[inline] pub fn from_slice_generic(data: &'a [T], nrows: R, ncols: C) -> Self { Self::from_slice_with_strides_generic(data, nrows, ncols, Const::<1>, nrows) @@ -103,19 +103,19 @@ macro_rules! impl_constructors( } } - impl<'a, T: Scalar, $($DimIdent: $DimBound, )*> MatrixView<'a, T, $($Dims,)* Dynamic, Dynamic> { + impl<'a, T: Scalar, $($DimIdent: $DimBound, )*> MatrixView<'a, T, $($Dims,)* Dyn, Dyn> { /// Creates a new matrix view with the specified strides from the given data array. /// /// Panics if `data` does not contain enough elements. #[inline] pub fn from_slice_with_strides(data: &'a [T], $($args: usize,)* rstride: usize, cstride: usize) -> Self { - Self::from_slice_with_strides_generic(data, $($gargs,)* Dynamic::new(rstride), Dynamic::new(cstride)) + Self::from_slice_with_strides_generic(data, $($gargs,)* Dyn(rstride), Dyn(cstride)) } /// Creates, without bound checking, a new matrix view with the specified strides from the given data array. #[inline] pub unsafe fn from_slice_with_strides_unchecked(data: &'a [T], start: usize, $($args: usize,)* rstride: usize, cstride: usize) -> Self { - Self::from_slice_with_strides_generic_unchecked(data, start, $($gargs,)* Dynamic::new(rstride), Dynamic::new(cstride)) + Self::from_slice_with_strides_generic_unchecked(data, start, $($gargs,)* Dyn(rstride), Dyn(cstride)) } } } @@ -127,19 +127,19 @@ impl_constructors!(R, C; // Arguments for Matrix R: DimName; - R::name(), Dynamic::new(ncols); + R::name(), Dyn(ncols); ncols); -impl_constructors!(Dynamic, C; +impl_constructors!(Dyn, C; => C: DimName; - Dynamic::new(nrows), C::name(); + Dyn(nrows), C::name(); nrows); -impl_constructors!(Dynamic, Dynamic; +impl_constructors!(Dyn, Dyn; ; - Dynamic::new(nrows), Dynamic::new(ncols); + Dyn(nrows), Dyn(ncols); nrows, ncols); /// # Creating mutable matrix views from `&mut [T]` @@ -150,7 +150,7 @@ impl<'a, T: Scalar, R: Dim, C: Dim, RStride: Dim, CStride: Dim> /// /// # Safety /// This method is unsafe because the input data array is not checked to contain enough elements. - /// The generic types `R`, `C`, `RStride`, `CStride` can either be type-level integers or integers wrapped with `Dynamic::new()`. + /// The generic types `R`, `C`, `RStride`, `CStride` can either be type-level integers or integers wrapped with `Dyn()`. #[inline] pub unsafe fn from_slice_with_strides_generic_unchecked( data: &'a mut [T], @@ -171,7 +171,7 @@ impl<'a, T: Scalar, R: Dim, C: Dim, RStride: Dim, CStride: Dim> /// Creates a mutable matrix view from an array and with dimensions and strides specified by generic types instances. /// /// Panics if the input data array dose not contain enough elements. - /// The generic types `R`, `C`, `RStride`, `CStride` can either be type-level integers or integers wrapped with `Dynamic::new()`. + /// The generic types `R`, `C`, `RStride`, `CStride` can either be type-level integers or integers wrapped with `Dyn()`. #[inline] pub fn from_slice_with_strides_generic( data: &'a mut [T], @@ -222,7 +222,7 @@ impl<'a, T: Scalar, R: Dim, C: Dim> MatrixViewMut<'a, T, R, C> { /// /// # Safety /// This method is unsafe because the input data array is not checked to contain enough elements. - /// The generic types `R` and `C` can either be type-level integers or integers wrapped with `Dynamic::new()`. + /// The generic types `R` and `C` can either be type-level integers or integers wrapped with `Dyn()`. #[inline] pub unsafe fn from_slice_generic_unchecked( data: &'a mut [T], @@ -238,7 +238,7 @@ impl<'a, T: Scalar, R: Dim, C: Dim> MatrixViewMut<'a, T, R, C> { /// Creates a mutable matrix view from an array and with dimensions and strides specified by generic types instances. /// /// Panics if the input data array dose not contain enough elements. - /// The generic types `R` and `C` can either be type-level integers or integers wrapped with `Dynamic::new()`. + /// The generic types `R` and `C` can either be type-level integers or integers wrapped with `Dyn()`. #[inline] pub fn from_slice_generic(data: &'a mut [T], nrows: R, ncols: C) -> Self { Self::from_slice_with_strides_generic(data, nrows, ncols, Const::<1>, nrows) @@ -263,21 +263,21 @@ macro_rules! impl_constructors_mut( } } - impl<'a, T: Scalar, $($DimIdent: $DimBound, )*> MatrixViewMut<'a, T, $($Dims,)* Dynamic, Dynamic> { + impl<'a, T: Scalar, $($DimIdent: $DimBound, )*> MatrixViewMut<'a, T, $($Dims,)* Dyn, Dyn> { /// Creates a new mutable matrix view with the specified strides from the given data array. /// /// Panics if `data` does not contain enough elements. #[inline] pub fn from_slice_with_strides_mut(data: &'a mut [T], $($args: usize,)* rstride: usize, cstride: usize) -> Self { Self::from_slice_with_strides_generic( - data, $($gargs,)* Dynamic::new(rstride), Dynamic::new(cstride)) + data, $($gargs,)* Dyn(rstride), Dyn(cstride)) } /// Creates, without bound checking, a new mutable matrix view with the specified strides from the given data array. #[inline] pub unsafe fn from_slice_with_strides_unchecked(data: &'a mut [T], start: usize, $($args: usize,)* rstride: usize, cstride: usize) -> Self { Self::from_slice_with_strides_generic_unchecked( - data, start, $($gargs,)* Dynamic::new(rstride), Dynamic::new(cstride)) + data, start, $($gargs,)* Dyn(rstride), Dyn(cstride)) } } } @@ -289,17 +289,17 @@ impl_constructors_mut!(R, C; // Arguments for Matrix R: DimName; - R::name(), Dynamic::new(ncols); + R::name(), Dyn(ncols); ncols); -impl_constructors_mut!(Dynamic, C; +impl_constructors_mut!(Dyn, C; => C: DimName; - Dynamic::new(nrows), C::name(); + Dyn(nrows), C::name(); nrows); -impl_constructors_mut!(Dynamic, Dynamic; +impl_constructors_mut!(Dyn, Dyn; ; - Dynamic::new(nrows), Dynamic::new(ncols); + Dyn(nrows), Dyn(ncols); nrows, ncols); diff --git a/src/base/conversion.rs b/src/base/conversion.rs index 02f72a43..22774287 100644 --- a/src/base/conversion.rs +++ b/src/base/conversion.rs @@ -9,7 +9,7 @@ use simba::simd::{PrimitiveSimdValue, SimdValue}; use crate::base::allocator::{Allocator, SameShapeAllocator}; use crate::base::constraint::{SameNumberOfColumns, SameNumberOfRows, ShapeConstraint}; #[cfg(any(feature = "std", feature = "alloc"))] -use crate::base::dimension::Dynamic; +use crate::base::dimension::Dyn; use crate::base::dimension::{ Const, Dim, DimName, U1, U10, U11, U12, U13, U14, U15, U16, U2, U3, U4, U5, U6, U7, U8, U9, }; @@ -302,29 +302,29 @@ where } #[cfg(any(feature = "std", feature = "alloc"))] -impl<'a, T, C, RStride, CStride> From> - for Matrix> +impl<'a, T, C, RStride, CStride> From> + for Matrix> where T: Scalar, C: Dim, RStride: Dim, CStride: Dim, { - fn from(matrix_view: MatrixView<'a, T, Dynamic, C, RStride, CStride>) -> Self { + fn from(matrix_view: MatrixView<'a, T, Dyn, C, RStride, CStride>) -> Self { matrix_view.into_owned() } } #[cfg(any(feature = "std", feature = "alloc"))] -impl<'a, T, R, RStride, CStride> From> - for Matrix> +impl<'a, T, R, RStride, CStride> From> + for Matrix> where T: Scalar, R: DimName, RStride: Dim, CStride: Dim, { - fn from(matrix_view: MatrixView<'a, T, R, Dynamic, RStride, CStride>) -> Self { + fn from(matrix_view: MatrixView<'a, T, R, Dyn, RStride, CStride>) -> Self { matrix_view.into_owned() } } @@ -343,29 +343,29 @@ where } #[cfg(any(feature = "std", feature = "alloc"))] -impl<'a, T, C, RStride, CStride> From> - for Matrix> +impl<'a, T, C, RStride, CStride> From> + for Matrix> where T: Scalar, C: Dim, RStride: Dim, CStride: Dim, { - fn from(matrix_view: MatrixViewMut<'a, T, Dynamic, C, RStride, CStride>) -> Self { + fn from(matrix_view: MatrixViewMut<'a, T, Dyn, C, RStride, CStride>) -> Self { matrix_view.into_owned() } } #[cfg(any(feature = "std", feature = "alloc"))] -impl<'a, T, R, RStride, CStride> From> - for Matrix> +impl<'a, T, R, RStride, CStride> From> + for Matrix> where T: Scalar, R: DimName, RStride: Dim, CStride: Dim, { - fn from(matrix_view: MatrixViewMut<'a, T, R, Dynamic, RStride, CStride>) -> Self { + fn from(matrix_view: MatrixViewMut<'a, T, R, Dyn, RStride, CStride>) -> Self { matrix_view.into_owned() } } diff --git a/src/base/default_allocator.rs b/src/base/default_allocator.rs index 6aaadfc7..ff645d62 100644 --- a/src/base/default_allocator.rs +++ b/src/base/default_allocator.rs @@ -13,7 +13,7 @@ use super::Const; use crate::base::allocator::{Allocator, Reallocator}; use crate::base::array_storage::ArrayStorage; #[cfg(any(feature = "alloc", feature = "std"))] -use crate::base::dimension::Dynamic; +use crate::base::dimension::Dyn; use crate::base::dimension::{Dim, DimName}; use crate::base::storage::{RawStorage, RawStorageMut}; #[cfg(any(feature = "std", feature = "alloc"))] @@ -82,15 +82,15 @@ impl Allocator, Const> } } -// Dynamic - Static -// Dynamic - Dynamic +// Dyn - Static +// Dyn - Dyn #[cfg(any(feature = "std", feature = "alloc"))] -impl Allocator for DefaultAllocator { - type Buffer = VecStorage; - type BufferUninit = VecStorage, Dynamic, C>; +impl Allocator for DefaultAllocator { + type Buffer = VecStorage; + type BufferUninit = VecStorage, Dyn, C>; #[inline] - fn allocate_uninit(nrows: Dynamic, ncols: C) -> VecStorage, Dynamic, C> { + fn allocate_uninit(nrows: Dyn, ncols: C) -> VecStorage, Dyn, C> { let mut data = Vec::new(); let length = nrows.value() * ncols.value(); data.reserve_exact(length); @@ -99,9 +99,7 @@ impl Allocator for DefaultAllocator { } #[inline] - unsafe fn assume_init( - uninit: VecStorage, Dynamic, C>, - ) -> VecStorage { + unsafe fn assume_init(uninit: VecStorage, Dyn, C>) -> VecStorage { // Avoids a double-drop. let (nrows, ncols) = uninit.shape(); let vec: Vec<_> = uninit.into(); @@ -117,7 +115,7 @@ impl Allocator for DefaultAllocator { #[inline] fn allocate_from_iterator>( - nrows: Dynamic, + nrows: Dyn, ncols: C, iter: I, ) -> Self::Buffer { @@ -130,14 +128,14 @@ impl Allocator for DefaultAllocator { } } -// Static - Dynamic +// Static - Dyn #[cfg(any(feature = "std", feature = "alloc"))] -impl Allocator for DefaultAllocator { - type Buffer = VecStorage; - type BufferUninit = VecStorage, R, Dynamic>; +impl Allocator for DefaultAllocator { + type Buffer = VecStorage; + type BufferUninit = VecStorage, R, Dyn>; #[inline] - fn allocate_uninit(nrows: R, ncols: Dynamic) -> VecStorage, R, Dynamic> { + fn allocate_uninit(nrows: R, ncols: Dyn) -> VecStorage, R, Dyn> { let mut data = Vec::new(); let length = nrows.value() * ncols.value(); data.reserve_exact(length); @@ -147,9 +145,7 @@ impl Allocator for DefaultAllocator { } #[inline] - unsafe fn assume_init( - uninit: VecStorage, R, Dynamic>, - ) -> VecStorage { + unsafe fn assume_init(uninit: VecStorage, R, Dyn>) -> VecStorage { // Avoids a double-drop. let (nrows, ncols) = uninit.shape(); let vec: Vec<_> = uninit.into(); @@ -166,7 +162,7 @@ impl Allocator for DefaultAllocator { #[inline] fn allocate_from_iterator>( nrows: R, - ncols: Dynamic, + ncols: Dyn, iter: I, ) -> Self::Buffer { let it = iter.into_iter(); @@ -215,20 +211,20 @@ where } } -// Static × Static -> Dynamic × Any +// Static × Static -> Dyn × Any #[cfg(any(feature = "std", feature = "alloc"))] impl - Reallocator, Const, Dynamic, CTo> for DefaultAllocator + Reallocator, Const, Dyn, CTo> for DefaultAllocator where CTo: Dim, { #[inline] unsafe fn reallocate_copy( - rto: Dynamic, + rto: Dyn, cto: CTo, buf: ArrayStorage, - ) -> VecStorage, Dynamic, CTo> { - let mut res = >::allocate_uninit(rto, cto); + ) -> VecStorage, Dyn, CTo> { + let mut res = >::allocate_uninit(rto, cto); let (rfrom, cfrom) = buf.shape(); @@ -246,20 +242,20 @@ where } } -// Static × Static -> Static × Dynamic +// Static × Static -> Static × Dyn #[cfg(any(feature = "std", feature = "alloc"))] impl - Reallocator, Const, RTo, Dynamic> for DefaultAllocator + Reallocator, Const, RTo, Dyn> for DefaultAllocator where RTo: DimName, { #[inline] unsafe fn reallocate_copy( rto: RTo, - cto: Dynamic, + cto: Dyn, buf: ArrayStorage, - ) -> VecStorage, RTo, Dynamic> { - let mut res = >::allocate_uninit(rto, cto); + ) -> VecStorage, RTo, Dyn> { + let mut res = >::allocate_uninit(rto, cto); let (rfrom, cfrom) = buf.shape(); @@ -279,60 +275,58 @@ where // All conversion from a dynamic buffer to a dynamic buffer. #[cfg(any(feature = "std", feature = "alloc"))] -impl Reallocator - for DefaultAllocator -{ +impl Reallocator for DefaultAllocator { #[inline] unsafe fn reallocate_copy( - rto: Dynamic, + rto: Dyn, cto: CTo, - buf: VecStorage, - ) -> VecStorage, Dynamic, CTo> { + buf: VecStorage, + ) -> VecStorage, Dyn, CTo> { let new_buf = buf.resize(rto.value() * cto.value()); VecStorage::new(rto, cto, new_buf) } } #[cfg(any(feature = "std", feature = "alloc"))] -impl Reallocator +impl Reallocator for DefaultAllocator { #[inline] unsafe fn reallocate_copy( rto: RTo, - cto: Dynamic, - buf: VecStorage, - ) -> VecStorage, RTo, Dynamic> { + cto: Dyn, + buf: VecStorage, + ) -> VecStorage, RTo, Dyn> { let new_buf = buf.resize(rto.value() * cto.value()); VecStorage::new(rto, cto, new_buf) } } #[cfg(any(feature = "std", feature = "alloc"))] -impl Reallocator +impl Reallocator for DefaultAllocator { #[inline] unsafe fn reallocate_copy( - rto: Dynamic, + rto: Dyn, cto: CTo, - buf: VecStorage, - ) -> VecStorage, Dynamic, CTo> { + buf: VecStorage, + ) -> VecStorage, Dyn, CTo> { let new_buf = buf.resize(rto.value() * cto.value()); VecStorage::new(rto, cto, new_buf) } } #[cfg(any(feature = "std", feature = "alloc"))] -impl Reallocator +impl Reallocator for DefaultAllocator { #[inline] unsafe fn reallocate_copy( rto: RTo, - cto: Dynamic, - buf: VecStorage, - ) -> VecStorage, RTo, Dynamic> { + cto: Dyn, + buf: VecStorage, + ) -> VecStorage, RTo, Dyn> { let new_buf = buf.resize(rto.value() * cto.value()); VecStorage::new(rto, cto, new_buf) } diff --git a/src/base/dimension.rs b/src/base/dimension.rs index 71472783..97616129 100644 --- a/src/base/dimension.rs +++ b/src/base/dimension.rs @@ -24,19 +24,20 @@ use serde::{Deserialize, Deserializer, Serialize, Serializer}; #[cfg_attr(feature = "cuda", derive(cust_core::DeviceCopy))] pub struct Dyn(pub usize); -// TODO: Deprecate? +#[deprecated(note = "use Dyn instead.")] pub type Dynamic = Dyn; -impl Dynamic { +impl Dyn { /// A dynamic size equal to `value`. #[inline] + #[deprecated(note = "use Dyn(value) instead.")] pub const fn new(value: usize) -> Self { Self(value) } } #[cfg(feature = "serde-serialize-no-std")] -impl Serialize for Dynamic { +impl Serialize for Dyn { fn serialize(&self, serializer: S) -> Result where S: Serializer, @@ -46,25 +47,25 @@ impl Serialize for Dynamic { } #[cfg(feature = "serde-serialize-no-std")] -impl<'de> Deserialize<'de> for Dynamic { +impl<'de> Deserialize<'de> for Dyn { fn deserialize(deserializer: D) -> Result where D: Deserializer<'de>, { - usize::deserialize(deserializer).map(|x| Dynamic::new(x)) + usize::deserialize(deserializer).map(|x| Dyn(x)) } } -/// Trait implemented by `Dynamic`. +/// Trait implemented by `Dyn`. pub trait IsDynamic {} -/// Trait implemented by `Dynamic` and type-level integers different from `U1`. +/// Trait implemented by `Dyn` and type-level integers different from `U1`. pub trait IsNotStaticOne {} -impl IsDynamic for Dynamic {} -impl IsNotStaticOne for Dynamic {} +impl IsDynamic for Dyn {} +impl IsNotStaticOne for Dyn {} /// Trait implemented by any type that can be used as a dimension. This includes type-level -/// integers and `Dynamic` (for dimensions not known at compile-time). +/// integers and `Dyn` (for dimensions not known at compile-time). pub unsafe trait Dim: Any + Debug + Copy + PartialEq + Send + Sync { #[inline(always)] fn is() -> bool { @@ -72,7 +73,7 @@ pub unsafe trait Dim: Any + Debug + Copy + PartialEq + Send + Sync { } /// Gets the compile-time value of `Self`. Returns `None` if it is not known, i.e., if `Self = - /// Dynamic`. + /// Dyn`. fn try_to_usize() -> Option; /// Gets the run-time value of `self`. For type-level integers, this is the same as @@ -84,7 +85,7 @@ pub unsafe trait Dim: Any + Debug + Copy + PartialEq + Send + Sync { fn from_usize(dim: usize) -> Self; } -unsafe impl Dim for Dynamic { +unsafe impl Dim for Dyn { #[inline] fn try_to_usize() -> Option { None @@ -92,7 +93,7 @@ unsafe impl Dim for Dynamic { #[inline] fn from_usize(dim: usize) -> Self { - Self::new(dim) + Self(dim) } #[inline] @@ -101,21 +102,21 @@ unsafe impl Dim for Dynamic { } } -impl Add for Dynamic { - type Output = Dynamic; +impl Add for Dyn { + type Output = Dyn; #[inline] fn add(self, rhs: usize) -> Self { - Self::new(self.0 + rhs) + Self(self.0 + rhs) } } -impl Sub for Dynamic { - type Output = Dynamic; +impl Sub for Dyn { + type Output = Dyn; #[inline] fn sub(self, rhs: usize) -> Self { - Self::new(self.0 - rhs) + Self(self.0 - rhs) } } @@ -153,22 +154,22 @@ macro_rules! dim_ops( } } - impl $DimOp for Dynamic { - type Output = Dynamic; + impl $DimOp for Dyn { + type Output = Dyn; #[inline] - fn $op(self, other: D) -> Dynamic { - Dynamic::new($op_path(self.value(), other.value())) + fn $op(self, other: D) -> Dyn { + Dyn($op_path(self.value(), other.value())) } } // TODO: use Const instead of D: DimName? - impl $DimOp for D { - type Output = Dynamic; + impl $DimOp for D { + type Output = Dyn; #[inline] - fn $op(self, other: Dynamic) -> Dynamic { - Dynamic::new($op_path(self.value(), other.value())) + fn $op(self, other: Dyn) -> Dyn { + Dyn($op_path(self.value(), other.value())) } } diff --git a/src/base/edition.rs b/src/base/edition.rs index 104bd7fb..e482fa24 100644 --- a/src/base/edition.rs +++ b/src/base/edition.rs @@ -7,7 +7,7 @@ use std::ptr; use crate::base::allocator::{Allocator, Reallocator}; use crate::base::constraint::{DimEq, SameNumberOfColumns, SameNumberOfRows, ShapeConstraint}; #[cfg(any(feature = "std", feature = "alloc"))] -use crate::base::dimension::Dynamic; +use crate::base::dimension::Dyn; use crate::base::dimension::{Const, Dim, DimAdd, DimDiff, DimMin, DimMinimum, DimSub, DimSum, U1}; use crate::base::storage::{RawStorage, RawStorageMut, ReshapableStorage}; use crate::base::{DefaultAllocator, Matrix, OMatrix, RowVector, Scalar, Vector}; @@ -48,15 +48,15 @@ impl> Matrix { /// Creates a new matrix by extracting the given set of rows from `self`. #[cfg(any(feature = "std", feature = "alloc"))] #[must_use] - pub fn select_rows<'a, I>(&self, irows: I) -> OMatrix + pub fn select_rows<'a, I>(&self, irows: I) -> OMatrix where I: IntoIterator, I::IntoIter: ExactSizeIterator + Clone, - DefaultAllocator: Allocator, + DefaultAllocator: Allocator, { let irows = irows.into_iter(); let ncols = self.shape_generic().1; - let mut res = Matrix::uninit(Dynamic::new(irows.len()), ncols); + let mut res = Matrix::uninit(Dyn(irows.len()), ncols); // First, check that all the indices from irows are valid. // This will allow us to use unchecked access in the inner loop. @@ -85,15 +85,15 @@ impl> Matrix { /// Creates a new matrix by extracting the given set of columns from `self`. #[cfg(any(feature = "std", feature = "alloc"))] #[must_use] - pub fn select_columns<'a, I>(&self, icols: I) -> OMatrix + pub fn select_columns<'a, I>(&self, icols: I) -> OMatrix where I: IntoIterator, I::IntoIter: ExactSizeIterator, - DefaultAllocator: Allocator, + DefaultAllocator: Allocator, { let icols = icols.into_iter(); let nrows = self.shape_generic().0; - let mut res = Matrix::uninit(nrows, Dynamic::new(icols.len())); + let mut res = Matrix::uninit(nrows, Dyn(icols.len())); for (destination, source) in icols.enumerate() { // NOTE: this is basically a copy_frow but wrapping the values insnide of MaybeUninit. @@ -359,10 +359,10 @@ impl> Matrix { /// Removes all columns in `indices` #[cfg(any(feature = "std", feature = "alloc"))] - pub fn remove_columns_at(self, indices: &[usize]) -> OMatrix + pub fn remove_columns_at(self, indices: &[usize]) -> OMatrix where - C: DimSub, - DefaultAllocator: Reallocator, + C: DimSub, + DefaultAllocator: Reallocator, { let mut m = self.into_owned(); let (nrows, ncols) = m.shape_generic(); @@ -400,7 +400,7 @@ impl> Matrix { unsafe { let new_data = DefaultAllocator::reallocate_copy( nrows, - ncols.sub(Dynamic::from_usize(offset)), + ncols.sub(Dyn::from_usize(offset)), m.data, ); @@ -410,10 +410,10 @@ impl> Matrix { /// Removes all rows in `indices` #[cfg(any(feature = "std", feature = "alloc"))] - pub fn remove_rows_at(self, indices: &[usize]) -> OMatrix + pub fn remove_rows_at(self, indices: &[usize]) -> OMatrix where - R: DimSub, - DefaultAllocator: Reallocator, + R: DimSub, + DefaultAllocator: Reallocator, { let mut m = self.into_owned(); let (nrows, ncols) = m.shape_generic(); @@ -448,7 +448,7 @@ impl> Matrix { // be assumed to be initialized. unsafe { let new_data = DefaultAllocator::reallocate_copy( - nrows.sub(Dynamic::from_usize(offset / ncols.value())), + nrows.sub(Dyn::from_usize(offset / ncols.value())), ncols, m.data, ); @@ -474,12 +474,12 @@ impl> Matrix { /// Removes `n` consecutive columns from this matrix, starting with the `i`-th (included). #[inline] #[cfg(any(feature = "std", feature = "alloc"))] - pub fn remove_columns(self, i: usize, n: usize) -> OMatrix + pub fn remove_columns(self, i: usize, n: usize) -> OMatrix where - C: DimSub, - DefaultAllocator: Reallocator, + C: DimSub, + DefaultAllocator: Reallocator, { - self.remove_columns_generic(i, Dynamic::new(n)) + self.remove_columns_generic(i, Dyn(n)) } /// Removes `nremove.value()` columns from this matrix, starting with the `i`-th (included). @@ -569,12 +569,12 @@ impl> Matrix { /// Removes `n` consecutive rows from this matrix, starting with the `i`-th (included). #[inline] #[cfg(any(feature = "std", feature = "alloc"))] - pub fn remove_rows(self, i: usize, n: usize) -> OMatrix + pub fn remove_rows(self, i: usize, n: usize) -> OMatrix where - R: DimSub, - DefaultAllocator: Reallocator, + R: DimSub, + DefaultAllocator: Reallocator, { - self.remove_rows_generic(i, Dynamic::new(n)) + self.remove_rows_generic(i, Dyn(n)) } /// Removes `nremove.value()` rows from this matrix, starting with the `i`-th (included). @@ -659,12 +659,12 @@ impl> Matrix { /// Inserts `n` columns filled with `val` starting at the `i-th` position. #[inline] #[cfg(any(feature = "std", feature = "alloc"))] - pub fn insert_columns(self, i: usize, n: usize, val: T) -> OMatrix + pub fn insert_columns(self, i: usize, n: usize, val: T) -> OMatrix where - C: DimAdd, - DefaultAllocator: Reallocator, + C: DimAdd, + DefaultAllocator: Reallocator, { - let mut res = unsafe { self.insert_columns_generic_uninitialized(i, Dynamic::new(n)) }; + let mut res = unsafe { self.insert_columns_generic_uninitialized(i, Dyn(n)) }; res.columns_mut(i, n) .fill_with(|| MaybeUninit::new(val.clone())); @@ -752,12 +752,12 @@ impl> Matrix { /// Inserts `n` rows filled with `val` starting at the `i-th` position. #[inline] #[cfg(any(feature = "std", feature = "alloc"))] - pub fn insert_rows(self, i: usize, n: usize, val: T) -> OMatrix + pub fn insert_rows(self, i: usize, n: usize, val: T) -> OMatrix where - R: DimAdd, - DefaultAllocator: Reallocator, + R: DimAdd, + DefaultAllocator: Reallocator, { - let mut res = unsafe { self.insert_rows_generic_uninitialized(i, Dynamic::new(n)) }; + let mut res = unsafe { self.insert_rows_generic_uninitialized(i, Dyn(n)) }; res.rows_mut(i, n) .fill_with(|| MaybeUninit::new(val.clone())); @@ -815,11 +815,11 @@ impl> Matrix { /// The values are copied such that `self[(i, j)] == result[(i, j)]`. If the result has more /// rows and/or columns than `self`, then the extra rows or columns are filled with `val`. #[cfg(any(feature = "std", feature = "alloc"))] - pub fn resize(self, new_nrows: usize, new_ncols: usize, val: T) -> OMatrix + pub fn resize(self, new_nrows: usize, new_ncols: usize, val: T) -> OMatrix where - DefaultAllocator: Reallocator, + DefaultAllocator: Reallocator, { - self.resize_generic(Dynamic::new(new_nrows), Dynamic::new(new_ncols), val) + self.resize_generic(Dyn(new_nrows), Dyn(new_ncols), val) } /// Resizes this matrix vertically, i.e., so that it contains `new_nrows` rows while keeping the same number of columns. @@ -827,12 +827,12 @@ impl> Matrix { /// The values are copied such that `self[(i, j)] == result[(i, j)]`. If the result has more /// rows than `self`, then the extra rows are filled with `val`. #[cfg(any(feature = "std", feature = "alloc"))] - pub fn resize_vertically(self, new_nrows: usize, val: T) -> OMatrix + pub fn resize_vertically(self, new_nrows: usize, val: T) -> OMatrix where - DefaultAllocator: Reallocator, + DefaultAllocator: Reallocator, { let ncols = self.shape_generic().1; - self.resize_generic(Dynamic::new(new_nrows), ncols, val) + self.resize_generic(Dyn(new_nrows), ncols, val) } /// Resizes this matrix horizontally, i.e., so that it contains `new_ncolumns` columns while keeping the same number of columns. @@ -840,12 +840,12 @@ impl> Matrix { /// The values are copied such that `self[(i, j)] == result[(i, j)]`. If the result has more /// columns than `self`, then the extra columns are filled with `val`. #[cfg(any(feature = "std", feature = "alloc"))] - pub fn resize_horizontally(self, new_ncols: usize, val: T) -> OMatrix + pub fn resize_horizontally(self, new_ncols: usize, val: T) -> OMatrix where - DefaultAllocator: Reallocator, + DefaultAllocator: Reallocator, { let nrows = self.shape_generic().0; - self.resize_generic(nrows, Dynamic::new(new_ncols), val) + self.resize_generic(nrows, Dyn(new_ncols), val) } /// Resizes this matrix so that it contains `R2::value()` rows and `C2::value()` columns. @@ -962,7 +962,7 @@ impl> Matrix { /// # Examples /// /// ``` - /// # use nalgebra::{Matrix3x2, Matrix2x3, DMatrix, Const, Dynamic}; + /// # use nalgebra::{Matrix3x2, Matrix2x3, DMatrix, Const, Dyn}; /// /// let m1 = Matrix2x3::new( /// 1.1, 1.2, 1.3, @@ -998,7 +998,7 @@ impl> Matrix { /// 0.0, 0.0, /// ], /// ); - /// let reshaped = dm1.reshape_generic(Dynamic::new(6), Dynamic::new(2)); + /// let reshaped = dm1.reshape_generic(Dyn(6), Dyn(2)); /// assert_eq!(reshaped, dm2); /// ``` pub fn reshape_generic( @@ -1018,7 +1018,7 @@ impl> Matrix { /// # In-place resizing #[cfg(any(feature = "std", feature = "alloc"))] -impl OMatrix { +impl OMatrix { /// Resizes this matrix in-place. /// /// The values are copied such that `self[(i, j)] == result[(i, j)]`. If the result has more @@ -1027,7 +1027,7 @@ impl OMatrix { /// Defined only for owned fully-dynamic matrices, i.e., `DMatrix`. pub fn resize_mut(&mut self, new_nrows: usize, new_ncols: usize, val: T) where - DefaultAllocator: Reallocator, + DefaultAllocator: Reallocator, { // TODO: avoid the clone. *self = self.clone().resize(new_nrows, new_ncols, val); @@ -1035,9 +1035,9 @@ impl OMatrix { } #[cfg(any(feature = "std", feature = "alloc"))] -impl OMatrix +impl OMatrix where - DefaultAllocator: Allocator, + DefaultAllocator: Allocator, { /// Changes the number of rows of this matrix in-place. /// @@ -1048,7 +1048,7 @@ where #[cfg(any(feature = "std", feature = "alloc"))] pub fn resize_vertically_mut(&mut self, new_nrows: usize, val: T) where - DefaultAllocator: Reallocator, + DefaultAllocator: Reallocator, { // TODO: avoid the clone. *self = self.clone().resize_vertically(new_nrows, val); @@ -1056,9 +1056,9 @@ where } #[cfg(any(feature = "std", feature = "alloc"))] -impl OMatrix +impl OMatrix where - DefaultAllocator: Allocator, + DefaultAllocator: Allocator, { /// Changes the number of column of this matrix in-place. /// @@ -1069,7 +1069,7 @@ where #[cfg(any(feature = "std", feature = "alloc"))] pub fn resize_horizontally_mut(&mut self, new_ncols: usize, val: T) where - DefaultAllocator: Reallocator, + DefaultAllocator: Reallocator, { // TODO: avoid the clone. *self = self.clone().resize_horizontally(new_ncols, val); @@ -1167,7 +1167,7 @@ unsafe fn extend_rows(data: &mut [T], nrows: usize, ncols: usize, i: usize, n /// Extend the number of columns of the `Matrix` with elements from /// a given iterator. #[cfg(any(feature = "std", feature = "alloc"))] -impl Extend for Matrix +impl Extend for Matrix where T: Scalar, R: Dim, @@ -1178,7 +1178,7 @@ where /// /// # Example /// ``` - /// # use nalgebra::{DMatrix, Dynamic, Matrix, OMatrix, Matrix3}; + /// # use nalgebra::{DMatrix, Dyn, Matrix, OMatrix, Matrix3}; /// /// let data = vec![0, 1, 2, // column 1 /// 3, 4, 5]; // column 2 @@ -1198,7 +1198,7 @@ where /// `Matrix`. /// /// ```should_panic - /// # use nalgebra::{DMatrix, Dynamic, OMatrix}; + /// # use nalgebra::{DMatrix, Dyn, OMatrix}; /// let data = vec![0, 1, 2, // column 1 /// 3, 4, 5]; // column 2 /// @@ -1215,7 +1215,7 @@ where /// Extend the number of rows of the `Vector` with elements from /// a given iterator. #[cfg(any(feature = "std", feature = "alloc"))] -impl Extend for Matrix +impl Extend for Matrix where T: Scalar, S: Extend, @@ -1236,7 +1236,7 @@ where } #[cfg(any(feature = "std", feature = "alloc"))] -impl Extend> for Matrix +impl Extend> for Matrix where T: Scalar, R: Dim, diff --git a/src/base/indexing.rs b/src/base/indexing.rs index ceefe91e..48dd8fad 100644 --- a/src/base/indexing.rs +++ b/src/base/indexing.rs @@ -3,7 +3,7 @@ use crate::base::storage::{RawStorage, RawStorageMut}; use crate::base::{ - Const, Dim, DimDiff, DimName, DimSub, Dynamic, Matrix, MatrixView, MatrixViewMut, Scalar, U1, + Const, Dim, DimDiff, DimName, DimSub, Dyn, Matrix, MatrixView, MatrixViewMut, Scalar, U1, }; use std::ops; @@ -49,7 +49,7 @@ fn dimrange_usize() { } impl DimRange for ops::Range { - type Length = Dynamic; + type Length = Dyn; #[inline(always)] fn lower(&self, _: D) -> usize { @@ -58,7 +58,7 @@ impl DimRange for ops::Range { #[inline(always)] fn length(&self, _: D) -> Self::Length { - Dynamic::new(self.end.saturating_sub(self.start)) + Dyn(self.end.saturating_sub(self.start)) } #[inline(always)] @@ -74,24 +74,24 @@ fn dimrange_range_usize() { assert!(DimRange::contained_by(&(0..1), Const::<1>)); assert!(DimRange::contained_by( &((usize::MAX - 1)..usize::MAX), - Dynamic::new(usize::MAX) + Dyn(usize::MAX) )); assert_eq!( - DimRange::length(&((usize::MAX - 1)..usize::MAX), Dynamic::new(usize::MAX)), - Dynamic::new(1) + DimRange::length(&((usize::MAX - 1)..usize::MAX), Dyn(usize::MAX)), + Dyn(1) ); assert_eq!( - DimRange::length(&(usize::MAX..(usize::MAX - 1)), Dynamic::new(usize::MAX)), - Dynamic::new(0) + DimRange::length(&(usize::MAX..(usize::MAX - 1)), Dyn(usize::MAX)), + Dyn(0) ); assert_eq!( - DimRange::length(&(usize::MAX..usize::MAX), Dynamic::new(usize::MAX)), - Dynamic::new(0) + DimRange::length(&(usize::MAX..usize::MAX), Dyn(usize::MAX)), + Dyn(0) ); } impl DimRange for ops::RangeFrom { - type Length = Dynamic; + type Length = Dyn; #[inline(always)] fn lower(&self, _: D) -> usize { @@ -116,16 +116,13 @@ fn dimrange_rangefrom_usize() { assert!(DimRange::contained_by(&(0..), Const::<1>)); assert!(DimRange::contained_by( &((usize::MAX - 1)..), - Dynamic::new(usize::MAX) + Dyn(usize::MAX) )); assert_eq!( - DimRange::length(&((usize::MAX - 1)..), Dynamic::new(usize::MAX)), - Dynamic::new(1) - ); - assert_eq!( - DimRange::length(&(usize::MAX..), Dynamic::new(usize::MAX)), - Dynamic::new(0) + DimRange::length(&((usize::MAX - 1)..), Dyn(usize::MAX)), + Dyn(1) ); + assert_eq!(DimRange::length(&(usize::MAX..), Dyn(usize::MAX)), Dyn(0)); } impl DimRange for ops::RangeFrom @@ -181,7 +178,7 @@ fn dimrange_rangefull() { } impl DimRange for ops::RangeInclusive { - type Length = Dynamic; + type Length = Dyn; #[inline(always)] fn lower(&self, _: D) -> usize { @@ -190,7 +187,7 @@ impl DimRange for ops::RangeInclusive { #[inline(always)] fn length(&self, _: D) -> Self::Length { - Dynamic::new(if self.end() < self.start() { + Dyn(if self.end() < self.start() { 0 } else { self.end().wrapping_sub(self.start().wrapping_sub(1)) @@ -209,33 +206,33 @@ fn dimrange_rangeinclusive_usize() { assert!(DimRange::contained_by(&(0..=0), Const::<1>)); assert!(!DimRange::contained_by( &(usize::MAX..=usize::MAX), - Dynamic::new(usize::MAX) + Dyn(usize::MAX) )); assert!(!DimRange::contained_by( &((usize::MAX - 1)..=usize::MAX), - Dynamic::new(usize::MAX) + Dyn(usize::MAX) )); assert!(DimRange::contained_by( &((usize::MAX - 1)..=(usize::MAX - 1)), - Dynamic::new(usize::MAX) + Dyn(usize::MAX) )); - assert_eq!(DimRange::length(&(0..=0), Const::<1>), Dynamic::new(1)); + assert_eq!(DimRange::length(&(0..=0), Const::<1>), Dyn(1)); assert_eq!( - DimRange::length(&((usize::MAX - 1)..=usize::MAX), Dynamic::new(usize::MAX)), - Dynamic::new(2) + DimRange::length(&((usize::MAX - 1)..=usize::MAX), Dyn(usize::MAX)), + Dyn(2) ); assert_eq!( - DimRange::length(&(usize::MAX..=(usize::MAX - 1)), Dynamic::new(usize::MAX)), - Dynamic::new(0) + DimRange::length(&(usize::MAX..=(usize::MAX - 1)), Dyn(usize::MAX)), + Dyn(0) ); assert_eq!( - DimRange::length(&(usize::MAX..=usize::MAX), Dynamic::new(usize::MAX)), - Dynamic::new(1) + DimRange::length(&(usize::MAX..=usize::MAX), Dyn(usize::MAX)), + Dyn(1) ); } impl DimRange for ops::RangeTo { - type Length = Dynamic; + type Length = Dyn; #[inline(always)] fn lower(&self, _: D) -> usize { @@ -244,7 +241,7 @@ impl DimRange for ops::RangeTo { #[inline(always)] fn length(&self, _: D) -> Self::Length { - Dynamic::new(self.end) + Dyn(self.end) } #[inline(always)] @@ -260,20 +257,20 @@ fn dimrange_rangeto_usize() { assert!(DimRange::contained_by(&(..0), Const::<1>)); assert!(DimRange::contained_by( &(..(usize::MAX - 1)), - Dynamic::new(usize::MAX) + Dyn(usize::MAX) )); assert_eq!( - DimRange::length(&(..(usize::MAX - 1)), Dynamic::new(usize::MAX)), - Dynamic::new(usize::MAX - 1) + DimRange::length(&(..(usize::MAX - 1)), Dyn(usize::MAX)), + Dyn(usize::MAX - 1) ); assert_eq!( - DimRange::length(&(..usize::MAX), Dynamic::new(usize::MAX)), - Dynamic::new(usize::MAX) + DimRange::length(&(..usize::MAX), Dyn(usize::MAX)), + Dyn(usize::MAX) ); } impl DimRange for ops::RangeToInclusive { - type Length = Dynamic; + type Length = Dyn; #[inline(always)] fn lower(&self, _: D) -> usize { @@ -282,7 +279,7 @@ impl DimRange for ops::RangeToInclusive { #[inline(always)] fn length(&self, _: D) -> Self::Length { - Dynamic::new(self.end + 1) + Dyn(self.end + 1) } #[inline(always)] @@ -296,17 +293,14 @@ fn dimrange_rangetoinclusive_usize() { assert!(!DimRange::contained_by(&(..=0), Const::<0>)); assert!(!DimRange::contained_by(&(..=1), Const::<0>)); assert!(DimRange::contained_by(&(..=0), Const::<1>)); - assert!(!DimRange::contained_by( - &(..=(usize::MAX)), - Dynamic::new(usize::MAX) - )); + assert!(!DimRange::contained_by(&(..=(usize::MAX)), Dyn(usize::MAX))); assert!(DimRange::contained_by( &(..=(usize::MAX - 1)), - Dynamic::new(usize::MAX) + Dyn(usize::MAX) )); assert_eq!( - DimRange::length(&(..=(usize::MAX - 1)), Dynamic::new(usize::MAX)), - Dynamic::new(usize::MAX) + DimRange::length(&(..=(usize::MAX - 1)), Dyn(usize::MAX)), + Dyn(usize::MAX) ); } @@ -742,12 +736,12 @@ macro_rules! impl_index_pairs { impl_index_pairs! { index R with { [<> usize => U1], - [<> ops::Range => Dynamic], - [<> ops::RangeFrom => Dynamic], + [<> ops::Range => Dyn], + [<> ops::RangeFrom => Dyn], [<> ops::RangeFull => R], - [<> ops::RangeInclusive => Dynamic], - [<> ops::RangeTo => Dynamic], - [<> ops::RangeToInclusive => Dynamic], + [<> ops::RangeInclusive => Dyn], + [<> ops::RangeTo => Dyn], + [<> ops::RangeToInclusive => Dyn], [ ops::RangeFrom => DimDiff @@ -755,12 +749,12 @@ impl_index_pairs! { } index C with { [<> usize => U1], - [<> ops::Range => Dynamic], - [<> ops::RangeFrom => Dynamic], + [<> ops::Range => Dyn], + [<> ops::RangeFrom => Dyn], [<> ops::RangeFull => C], - [<> ops::RangeInclusive => Dynamic], - [<> ops::RangeTo => Dynamic], - [<> ops::RangeToInclusive => Dynamic], + [<> ops::RangeInclusive => Dyn], + [<> ops::RangeTo => Dyn], + [<> ops::RangeToInclusive => Dyn], [ ops::RangeFrom => DimDiff diff --git a/src/base/matrix.rs b/src/base/matrix.rs index f0fa8d81..d4875944 100644 --- a/src/base/matrix.rs +++ b/src/base/matrix.rs @@ -32,7 +32,7 @@ use crate::{ArrayStorage, SMatrix, SimdComplexField, Storage, UninitMatrix}; use crate::storage::IsContiguous; use crate::uninit::{Init, InitStatus, Uninit}; #[cfg(any(feature = "std", feature = "alloc"))] -use crate::{DMatrix, DVector, Dynamic, RowDVector, VecStorage}; +use crate::{DMatrix, DVector, Dyn, RowDVector, VecStorage}; use std::mem::MaybeUninit; /// A square matrix. @@ -146,13 +146,13 @@ pub type MatrixCross = /// - type-level unsigned integer constants (e.g. `U1024`, `U10000`) from the `typenum::` crate. /// Using those, you will not get error messages as nice as for numbers smaller than 128 defined on /// the `nalgebra::` module. -/// - the special value `Dynamic` from the `nalgebra::` root module. This indicates that the +/// - the special value `Dyn` from the `nalgebra::` root module. This indicates that the /// specified dimension is not known at compile-time. Note that this will generally imply that the /// matrix data storage `S` performs a dynamic allocation and contains extra metadata for the /// matrix shape. /// -/// Note that mixing `Dynamic` with type-level unsigned integers is allowed. Actually, a -/// dynamically-sized column vector should be represented as a `Matrix` (given +/// Note that mixing `Dyn` with type-level unsigned integers is allowed. Actually, a +/// dynamically-sized column vector should be represented as a `Matrix` (given /// some concrete types for `T` and a compatible data storage type `S`). #[repr(C)] #[derive(Clone, Copy)] @@ -341,7 +341,7 @@ impl DMatrix { /// /// This method exists primarily as a workaround for the fact that `from_data` can not /// work in `const fn` contexts. - pub const fn from_vec_storage(storage: VecStorage) -> Self { + pub const fn from_vec_storage(storage: VecStorage) -> Self { // This is sound because the dimensions of the matrix and the storage are guaranteed // to be the same unsafe { Self::from_data_statically_unchecked(storage) } @@ -356,7 +356,7 @@ impl DVector { /// /// This method exists primarily as a workaround for the fact that `from_data` can not /// work in `const fn` contexts. - pub const fn from_vec_storage(storage: VecStorage) -> Self { + pub const fn from_vec_storage(storage: VecStorage) -> Self { // This is sound because the dimensions of the matrix and the storage are guaranteed // to be the same unsafe { Self::from_data_statically_unchecked(storage) } @@ -371,7 +371,7 @@ impl RowDVector { /// /// This method exists primarily as a workaround for the fact that `from_data` can not /// work in `const fn` contexts. - pub const fn from_vec_storage(storage: VecStorage) -> Self { + pub const fn from_vec_storage(storage: VecStorage) -> Self { // This is sound because the dimensions of the matrix and the storage are guaranteed // to be the same unsafe { Self::from_data_statically_unchecked(storage) } @@ -417,7 +417,7 @@ impl> Matrix { (nrows.value(), ncols.value()) } - /// The shape of this matrix wrapped into their representative types (`Const` or `Dynamic`). + /// The shape of this matrix wrapped into their representative types (`Const` or `Dyn`). #[inline] #[must_use] pub fn shape_generic(&self) -> (R, C) { diff --git a/src/base/matrix_view.rs b/src/base/matrix_view.rs index 7257629b..fa6f8f00 100644 --- a/src/base/matrix_view.rs +++ b/src/base/matrix_view.rs @@ -4,7 +4,7 @@ use std::slice; use crate::base::allocator::Allocator; use crate::base::default_allocator::DefaultAllocator; -use crate::base::dimension::{Const, Dim, DimName, Dynamic, IsNotStaticOne, U1}; +use crate::base::dimension::{Const, Dim, DimName, Dyn, IsNotStaticOne, U1}; use crate::base::iter::MatrixIter; use crate::base::storage::{IsContiguous, Owned, RawStorage, RawStorageMut, Storage}; use crate::base::{Matrix, Scalar}; @@ -60,8 +60,8 @@ macro_rules! view_storage_impl ( } } - // Dynamic is arbitrary. It's just to be able to call the constructors with `Slice::` - impl<'a, T, R: Dim, C: Dim> $T<'a, T, R, C, Dynamic, Dynamic> { + // Dyn is arbitrary. It's just to be able to call the constructors with `Slice::` + impl<'a, T, R: Dim, C: Dim> $T<'a, T, R, C, Dyn, Dyn> { /// Create a new matrix view without bounds checking. #[inline] pub unsafe fn new_unchecked(storage: $SRef, start: (usize, usize), shape: (R, C)) @@ -180,7 +180,7 @@ macro_rules! storage_impl( #[inline] fn is_contiguous(&self) -> bool { // Common cases that can be deduced at compile-time even if one of the dimensions - // is Dynamic. + // is Dyn. if (RStride::is::() && C::is::()) || // Column vector. (CStride::is::() && R::is::()) { // Row vector. true @@ -325,24 +325,24 @@ macro_rules! matrix_view_impl ( /// Returns a view containing the `n` first elements of the i-th row of this matrix. #[inline] - pub fn $row_part($me: $Me, i: usize, n: usize) -> $MatrixView<'_, T, U1, Dynamic, S::RStride, S::CStride> { - $me.$generic_view((i, 0), (Const::<1>, Dynamic::new(n))) + pub fn $row_part($me: $Me, i: usize, n: usize) -> $MatrixView<'_, T, U1, Dyn, S::RStride, S::CStride> { + $me.$generic_view((i, 0), (Const::<1>, Dyn(n))) } /// Extracts from this matrix a set of consecutive rows. #[inline] pub fn $rows($me: $Me, first_row: usize, nrows: usize) - -> $MatrixView<'_, T, Dynamic, C, S::RStride, S::CStride> { + -> $MatrixView<'_, T, Dyn, C, S::RStride, S::CStride> { - $me.$rows_generic(first_row, Dynamic::new(nrows)) + $me.$rows_generic(first_row, Dyn(nrows)) } /// Extracts from this matrix a set of consecutive rows regularly skipping `step` rows. #[inline] pub fn $rows_with_step($me: $Me, first_row: usize, nrows: usize, step: usize) - -> $MatrixView<'_, T, Dynamic, C, Dynamic, S::CStride> { + -> $MatrixView<'_, T, Dyn, C, Dyn, S::CStride> { - $me.$rows_generic_with_step(first_row, Dynamic::new(nrows), step) + $me.$rows_generic_with_step(first_row, Dyn(nrows), step) } /// Extracts a compile-time number of consecutive rows from this matrix. @@ -357,7 +357,7 @@ macro_rules! matrix_view_impl ( /// rows. #[inline] pub fn $fixed_rows_with_step($me: $Me, first_row: usize, step: usize) - -> $MatrixView<'_, T, Const, C, Dynamic, S::CStride> { + -> $MatrixView<'_, T, Const, C, Dyn, S::CStride> { $me.$rows_generic_with_step(first_row, Const::, step) } @@ -383,14 +383,14 @@ macro_rules! matrix_view_impl ( /// argument may or may not be values known at compile-time. #[inline] pub fn $rows_generic_with_step($me: $Me, row_start: usize, nrows: RView, step: usize) - -> $MatrixView<'_, T, RView, C, Dynamic, S::CStride> + -> $MatrixView<'_, T, RView, C, Dyn, S::CStride> where RView: Dim { let my_shape = $me.shape_generic(); let my_strides = $me.data.strides(); $me.assert_view_index((row_start, 0), (nrows.value(), my_shape.1.value()), (step, 0)); - let strides = (Dynamic::new((step + 1) * my_strides.0.value()), my_strides.1); + let strides = (Dyn((step + 1) * my_strides.0.value()), my_strides.1); let shape = (nrows, my_shape.1); unsafe { @@ -412,25 +412,25 @@ macro_rules! matrix_view_impl ( /// Returns a view containing the `n` first elements of the i-th column of this matrix. #[inline] - pub fn $column_part($me: $Me, i: usize, n: usize) -> $MatrixView<'_, T, Dynamic, U1, S::RStride, S::CStride> { - $me.$generic_view((0, i), (Dynamic::new(n), Const::<1>)) + pub fn $column_part($me: $Me, i: usize, n: usize) -> $MatrixView<'_, T, Dyn, U1, S::RStride, S::CStride> { + $me.$generic_view((0, i), (Dyn(n), Const::<1>)) } /// Extracts from this matrix a set of consecutive columns. #[inline] pub fn $columns($me: $Me, first_col: usize, ncols: usize) - -> $MatrixView<'_, T, R, Dynamic, S::RStride, S::CStride> { + -> $MatrixView<'_, T, R, Dyn, S::RStride, S::CStride> { - $me.$columns_generic(first_col, Dynamic::new(ncols)) + $me.$columns_generic(first_col, Dyn(ncols)) } /// Extracts from this matrix a set of consecutive columns regularly skipping `step` /// columns. #[inline] pub fn $columns_with_step($me: $Me, first_col: usize, ncols: usize, step: usize) - -> $MatrixView<'_, T, R, Dynamic, S::RStride, Dynamic> { + -> $MatrixView<'_, T, R, Dyn, S::RStride, Dyn> { - $me.$columns_generic_with_step(first_col, Dynamic::new(ncols), step) + $me.$columns_generic_with_step(first_col, Dyn(ncols), step) } /// Extracts a compile-time number of consecutive columns from this matrix. @@ -445,7 +445,7 @@ macro_rules! matrix_view_impl ( /// `step` columns. #[inline] pub fn $fixed_columns_with_step($me: $Me, first_col: usize, step: usize) - -> $MatrixView<'_, T, R, Const, S::RStride, Dynamic> { + -> $MatrixView<'_, T, R, Const, S::RStride, Dyn> { $me.$columns_generic_with_step(first_col, Const::, step) } @@ -471,14 +471,14 @@ macro_rules! matrix_view_impl ( /// or may not be values known at compile-time. #[inline] pub fn $columns_generic_with_step($me: $Me, first_col: usize, ncols: CView, step: usize) - -> $MatrixView<'_, T, R, CView, S::RStride, Dynamic> { + -> $MatrixView<'_, T, R, CView, S::RStride, Dyn> { let my_shape = $me.shape_generic(); let my_strides = $me.data.strides(); $me.assert_view_index((0, first_col), (my_shape.0.value(), ncols.value()), (0, step)); - let strides = (my_strides.0, Dynamic::new((step + 1) * my_strides.1.value())); + let strides = (my_strides.0, Dyn((step + 1) * my_strides.1.value())); let shape = (my_shape.0, ncols); unsafe { @@ -497,7 +497,7 @@ macro_rules! matrix_view_impl ( #[inline] #[deprecated = slice_deprecation_note!($view)] pub fn $slice($me: $Me, start: (usize, usize), shape: (usize, usize)) - -> $MatrixView<'_, T, Dynamic, Dynamic, S::RStride, S::CStride> { + -> $MatrixView<'_, T, Dyn, Dyn, S::RStride, S::CStride> { $me.$view(start, shape) } @@ -505,10 +505,10 @@ macro_rules! matrix_view_impl ( /// consecutive elements. #[inline] pub fn $view($me: $Me, start: (usize, usize), shape: (usize, usize)) - -> $MatrixView<'_, T, Dynamic, Dynamic, S::RStride, S::CStride> { + -> $MatrixView<'_, T, Dyn, Dyn, S::RStride, S::CStride> { $me.assert_view_index(start, shape, (0, 0)); - let shape = (Dynamic::new(shape.0), Dynamic::new(shape.1)); + let shape = (Dyn(shape.0), Dyn(shape.1)); unsafe { let data = $ViewStorage::new_unchecked($data, start, shape); @@ -523,7 +523,7 @@ macro_rules! matrix_view_impl ( #[inline] #[deprecated = slice_deprecation_note!($view_with_steps)] pub fn $slice_with_steps($me: $Me, start: (usize, usize), shape: (usize, usize), steps: (usize, usize)) - -> $MatrixView<'_, T, Dynamic, Dynamic, Dynamic, Dynamic> { + -> $MatrixView<'_, T, Dyn, Dyn, Dyn, Dyn> { $me.$view_with_steps(start, shape, steps) } @@ -533,8 +533,8 @@ macro_rules! matrix_view_impl ( /// original matrix. #[inline] pub fn $view_with_steps($me: $Me, start: (usize, usize), shape: (usize, usize), steps: (usize, usize)) - -> $MatrixView<'_, T, Dynamic, Dynamic, Dynamic, Dynamic> { - let shape = (Dynamic::new(shape.0), Dynamic::new(shape.1)); + -> $MatrixView<'_, T, Dyn, Dyn, Dyn, Dyn> { + let shape = (Dyn(shape.0), Dyn(shape.1)); $me.$generic_view_with_steps(start, shape, steps) } @@ -569,7 +569,7 @@ macro_rules! matrix_view_impl ( #[inline] #[deprecated = slice_deprecation_note!($fixed_view_with_steps)] pub fn $fixed_slice_with_steps($me: $Me, start: (usize, usize), steps: (usize, usize)) - -> $MatrixView<'_, T, Const, Const, Dynamic, Dynamic> { + -> $MatrixView<'_, T, Const, Const, Dyn, Dyn> { $me.$fixed_view_with_steps(start, steps) } @@ -579,7 +579,7 @@ macro_rules! matrix_view_impl ( /// the original matrix. #[inline] pub fn $fixed_view_with_steps($me: $Me, start: (usize, usize), steps: (usize, usize)) - -> $MatrixView<'_, T, Const, Const, Dynamic, Dynamic> { + -> $MatrixView<'_, T, Const, Const, Dyn, Dyn> { let shape = (Const::, Const::); $me.$generic_view_with_steps(start, shape, steps) } @@ -616,7 +616,7 @@ macro_rules! matrix_view_impl ( start: (usize, usize), shape: (RView, CView), steps: (usize, usize)) - -> $MatrixView<'_, T, RView, CView, Dynamic, Dynamic> + -> $MatrixView<'_, T, RView, CView, Dyn, Dyn> where RView: Dim, CView: Dim { $me.$generic_view_with_steps(start, shape, steps) @@ -628,15 +628,15 @@ macro_rules! matrix_view_impl ( start: (usize, usize), shape: (RView, CView), steps: (usize, usize)) - -> $MatrixView<'_, T, RView, CView, Dynamic, Dynamic> + -> $MatrixView<'_, T, RView, CView, Dyn, Dyn> where RView: Dim, CView: Dim { $me.assert_view_index(start, (shape.0.value(), shape.1.value()), steps); let my_strides = $me.data.strides(); - let strides = (Dynamic::new((steps.0 + 1) * my_strides.0.value()), - Dynamic::new((steps.1 + 1) * my_strides.1.value())); + let strides = (Dyn((steps.0 + 1) * my_strides.0.value()), + Dyn((steps.1 + 1) * my_strides.1.value())); unsafe { let data = $ViewStorage::new_with_strides_unchecked($data, start, shape, strides); @@ -860,7 +860,7 @@ impl DimRange for usize { } impl DimRange for Range { - type Size = Dynamic; + type Size = Dyn; #[inline(always)] fn begin(&self, _: D) -> usize { @@ -874,12 +874,12 @@ impl DimRange for Range { #[inline(always)] fn size(&self, _: D) -> Self::Size { - Dynamic::new(self.end - self.start) + Dyn(self.end - self.start) } } impl DimRange for RangeFrom { - type Size = Dynamic; + type Size = Dyn; #[inline(always)] fn begin(&self, _: D) -> usize { @@ -893,12 +893,12 @@ impl DimRange for RangeFrom { #[inline(always)] fn size(&self, dim: D) -> Self::Size { - Dynamic::new(dim.value() - self.start) + Dyn(dim.value() - self.start) } } impl DimRange for RangeTo { - type Size = Dynamic; + type Size = Dyn; #[inline(always)] fn begin(&self, _: D) -> usize { @@ -912,7 +912,7 @@ impl DimRange for RangeTo { #[inline(always)] fn size(&self, _: D) -> Self::Size { - Dynamic::new(self.end) + Dyn(self.end) } } @@ -936,7 +936,7 @@ impl DimRange for RangeFull { } impl DimRange for RangeInclusive { - type Size = Dynamic; + type Size = Dyn; #[inline(always)] fn begin(&self, _: D) -> usize { @@ -950,7 +950,7 @@ impl DimRange for RangeInclusive { #[inline(always)] fn size(&self, _: D) -> Self::Size { - Dynamic::new(*self.end() + 1 - *self.start()) + Dyn(*self.end() + 1 - *self.start()) } } diff --git a/src/base/ops.rs b/src/base/ops.rs index 60ed5e26..d5cf3a51 100644 --- a/src/base/ops.rs +++ b/src/base/ops.rs @@ -11,7 +11,7 @@ use crate::base::blas_uninit::gemm_uninit; use crate::base::constraint::{ AreMultipliable, DimEq, SameNumberOfColumns, SameNumberOfRows, ShapeConstraint, }; -use crate::base::dimension::{Dim, DimMul, DimName, DimProd, Dynamic}; +use crate::base::dimension::{Dim, DimMul, DimName, DimProd, Dyn}; use crate::base::storage::{Storage, StorageMut}; use crate::base::uninit::Uninit; use crate::base::{DefaultAllocator, Matrix, MatrixSum, OMatrix, Scalar, VectorView}; @@ -374,10 +374,10 @@ where } } -impl iter::Sum for OMatrix +impl iter::Sum for OMatrix where T: Scalar + ClosedAdd + Zero, - DefaultAllocator: Allocator, + DefaultAllocator: Allocator, { /// # Example /// ``` @@ -395,7 +395,7 @@ where /// # use nalgebra::DMatrix; /// iter::empty::>().sum::>(); // panics! /// ``` - fn sum>>(mut iter: I) -> OMatrix { + fn sum>>(mut iter: I) -> OMatrix { if let Some(first) = iter.next() { iter.fold(first, |acc, x| acc + x) } else { @@ -414,10 +414,10 @@ where } } -impl<'a, T, C: Dim> iter::Sum<&'a OMatrix> for OMatrix +impl<'a, T, C: Dim> iter::Sum<&'a OMatrix> for OMatrix where T: Scalar + ClosedAdd + Zero, - DefaultAllocator: Allocator, + DefaultAllocator: Allocator, { /// # Example /// ``` @@ -435,7 +435,7 @@ where /// # use nalgebra::DMatrix; /// iter::empty::<&DMatrix>().sum::>(); // panics! /// ``` - fn sum>>(mut iter: I) -> OMatrix { + fn sum>>(mut iter: I) -> OMatrix { if let Some(first) = iter.next() { iter.fold(first.clone(), |acc, x| acc + x) } else { diff --git a/src/base/vec_storage.rs b/src/base/vec_storage.rs index 414354cd..4614598b 100644 --- a/src/base/vec_storage.rs +++ b/src/base/vec_storage.rs @@ -4,7 +4,7 @@ use alloc::vec::Vec; use crate::base::allocator::Allocator; use crate::base::constraint::{SameNumberOfRows, ShapeConstraint}; use crate::base::default_allocator::DefaultAllocator; -use crate::base::dimension::{Dim, DimName, Dynamic, U1}; +use crate::base::dimension::{Dim, DimName, Dyn, U1}; use crate::base::storage::{IsContiguous, Owned, RawStorage, RawStorageMut, ReshapableStorage}; use crate::base::{Scalar, Vector}; @@ -188,13 +188,13 @@ impl From> for Vec { /* * - * Dynamic − Static - * Dynamic − Dynamic + * Dyn − Static + * Dyn − Dyn * */ -unsafe impl RawStorage for VecStorage { +unsafe impl RawStorage for VecStorage { type RStride = U1; - type CStride = Dynamic; + type CStride = Dyn; #[inline] fn ptr(&self) -> *const T { @@ -202,7 +202,7 @@ unsafe impl RawStorage for VecStorage { } #[inline] - fn shape(&self) -> (Dynamic, C) { + fn shape(&self) -> (Dyn, C) { (self.nrows, self.ncols) } @@ -222,28 +222,28 @@ unsafe impl RawStorage for VecStorage { } } -unsafe impl Storage for VecStorage +unsafe impl Storage for VecStorage where - DefaultAllocator: Allocator, + DefaultAllocator: Allocator, { #[inline] - fn into_owned(self) -> Owned + fn into_owned(self) -> Owned where - DefaultAllocator: Allocator, + DefaultAllocator: Allocator, { self } #[inline] - fn clone_owned(&self) -> Owned + fn clone_owned(&self) -> Owned where - DefaultAllocator: Allocator, + DefaultAllocator: Allocator, { self.clone() } } -unsafe impl RawStorage for VecStorage { +unsafe impl RawStorage for VecStorage { type RStride = U1; type CStride = R; @@ -253,7 +253,7 @@ unsafe impl RawStorage for VecStorage (R, Dynamic) { + fn shape(&self) -> (R, Dyn) { (self.nrows, self.ncols) } @@ -273,22 +273,22 @@ unsafe impl RawStorage for VecStorage Storage for VecStorage +unsafe impl Storage for VecStorage where - DefaultAllocator: Allocator, + DefaultAllocator: Allocator, { #[inline] - fn into_owned(self) -> Owned + fn into_owned(self) -> Owned where - DefaultAllocator: Allocator, + DefaultAllocator: Allocator, { self } #[inline] - fn clone_owned(&self) -> Owned + fn clone_owned(&self) -> Owned where - DefaultAllocator: Allocator, + DefaultAllocator: Allocator, { self.clone() } @@ -299,7 +299,7 @@ where * RawStorageMut, ContiguousStorage. * */ -unsafe impl RawStorageMut for VecStorage { +unsafe impl RawStorageMut for VecStorage { #[inline] fn ptr_mut(&mut self) -> *mut T { self.data.as_mut_ptr() @@ -313,15 +313,15 @@ unsafe impl RawStorageMut for VecStorage IsContiguous for VecStorage {} -impl ReshapableStorage for VecStorage +impl ReshapableStorage for VecStorage where T: Scalar, C1: Dim, C2: Dim, { - type Output = VecStorage; + type Output = VecStorage; - fn reshape_generic(self, nrows: Dynamic, ncols: C2) -> Self::Output { + fn reshape_generic(self, nrows: Dyn, ncols: C2) -> Self::Output { assert_eq!(nrows.value() * ncols.value(), self.data.len()); VecStorage { data: self.data, @@ -331,15 +331,15 @@ where } } -impl ReshapableStorage for VecStorage +impl ReshapableStorage for VecStorage where T: Scalar, C1: Dim, R2: DimName, { - type Output = VecStorage; + type Output = VecStorage; - fn reshape_generic(self, nrows: R2, ncols: Dynamic) -> Self::Output { + fn reshape_generic(self, nrows: R2, ncols: Dyn) -> Self::Output { assert_eq!(nrows.value() * ncols.value(), self.data.len()); VecStorage { data: self.data, @@ -349,7 +349,7 @@ where } } -unsafe impl RawStorageMut for VecStorage { +unsafe impl RawStorageMut for VecStorage { #[inline] fn ptr_mut(&mut self) -> *mut T { self.data.as_mut_ptr() @@ -361,15 +361,15 @@ unsafe impl RawStorageMut for VecStorage ReshapableStorage for VecStorage +impl ReshapableStorage for VecStorage where T: Scalar, R1: DimName, C2: Dim, { - type Output = VecStorage; + type Output = VecStorage; - fn reshape_generic(self, nrows: Dynamic, ncols: C2) -> Self::Output { + fn reshape_generic(self, nrows: Dyn, ncols: C2) -> Self::Output { assert_eq!(nrows.value() * ncols.value(), self.data.len()); VecStorage { data: self.data, @@ -379,15 +379,15 @@ where } } -impl ReshapableStorage for VecStorage +impl ReshapableStorage for VecStorage where T: Scalar, R1: DimName, R2: DimName, { - type Output = VecStorage; + type Output = VecStorage; - fn reshape_generic(self, nrows: R2, ncols: Dynamic) -> Self::Output { + fn reshape_generic(self, nrows: R2, ncols: Dyn) -> Self::Output { assert_eq!(nrows.value() * ncols.value(), self.data.len()); VecStorage { data: self.data, @@ -397,7 +397,7 @@ where } } -impl Extend for VecStorage { +impl Extend for VecStorage { /// Extends the number of columns of the `VecStorage` with elements /// from the given iterator. /// @@ -407,13 +407,13 @@ impl Extend for VecStorage { /// `VecStorage`. fn extend>(&mut self, iter: I) { self.data.extend(iter); - self.ncols = Dynamic::new(self.data.len() / self.nrows.value()); + self.ncols = Dyn(self.data.len() / self.nrows.value()); assert!(self.data.len() % self.nrows.value() == 0, "The number of elements produced by the given iterator was not a multiple of the number of rows."); } } -impl<'a, T: 'a + Copy, R: Dim> Extend<&'a T> for VecStorage { +impl<'a, T: 'a + Copy, R: Dim> Extend<&'a T> for VecStorage { /// Extends the number of columns of the `VecStorage` with elements /// from the given iterator. /// @@ -426,7 +426,7 @@ impl<'a, T: 'a + Copy, R: Dim> Extend<&'a T> for VecStorage { } } -impl Extend> for VecStorage +impl Extend> for VecStorage where T: Scalar, R: Dim, @@ -450,15 +450,15 @@ where assert_eq!(nrows, vector.shape().0); self.data.extend(vector.iter().cloned()); } - self.ncols = Dynamic::new(self.data.len() / nrows); + self.ncols = Dyn(self.data.len() / nrows); } } -impl Extend for VecStorage { +impl Extend for VecStorage { /// Extends the number of rows of the `VecStorage` with elements /// from the given iterator. fn extend>(&mut self, iter: I) { self.data.extend(iter); - self.nrows = Dynamic::new(self.data.len()); + self.nrows = Dyn(self.data.len()); } } diff --git a/src/debug/random_orthogonal.rs b/src/debug/random_orthogonal.rs index c9684238..18924fb2 100644 --- a/src/debug/random_orthogonal.rs +++ b/src/debug/random_orthogonal.rs @@ -4,7 +4,7 @@ use crate::base::storage::Owned; use quickcheck::{Arbitrary, Gen}; use crate::base::allocator::Allocator; -use crate::base::dimension::{Dim, Dynamic}; +use crate::base::dimension::{Dim, Dyn}; use crate::base::Scalar; use crate::base::{DefaultAllocator, OMatrix}; use crate::linalg::givens::GivensRotation; @@ -12,7 +12,7 @@ use simba::scalar::ComplexField; /// A random orthogonal matrix. #[derive(Clone, Debug)] -pub struct RandomOrthogonal +pub struct RandomOrthogonal where DefaultAllocator: Allocator, { diff --git a/src/debug/random_sdp.rs b/src/debug/random_sdp.rs index a915f2fc..278071a8 100644 --- a/src/debug/random_sdp.rs +++ b/src/debug/random_sdp.rs @@ -4,7 +4,7 @@ use crate::base::storage::Owned; use quickcheck::{Arbitrary, Gen}; use crate::base::allocator::Allocator; -use crate::base::dimension::{Dim, Dynamic}; +use crate::base::dimension::{Dim, Dyn}; use crate::base::Scalar; use crate::base::{DefaultAllocator, OMatrix}; use simba::scalar::ComplexField; @@ -13,7 +13,7 @@ use crate::debug::RandomOrthogonal; /// A random, well-conditioned, symmetric definite-positive matrix. #[derive(Clone, Debug)] -pub struct RandomSDP +pub struct RandomSDP where DefaultAllocator: Allocator, { diff --git a/src/linalg/bidiagonal.rs b/src/linalg/bidiagonal.rs index 56591ab1..3036e9f1 100644 --- a/src/linalg/bidiagonal.rs +++ b/src/linalg/bidiagonal.rs @@ -304,7 +304,7 @@ where } } -// impl + DimSub> Bidiagonal +// impl + DimSub> Bidiagonal // where DefaultAllocator: Allocator + // Allocator { // /// Solves the linear system `self * x = b`, where `x` is the unknown to be determined. diff --git a/src/linalg/eigen.rs b/src/linalg/eigen.rs index 37b5ddea..a1f6172e 100644 --- a/src/linalg/eigen.rs +++ b/src/linalg/eigen.rs @@ -8,7 +8,7 @@ use std::fmt::Display; use std::ops::MulAssign; use crate::allocator::Allocator; -use crate::base::dimension::{Dim, DimDiff, DimSub, Dynamic, U1, U2, U3}; +use crate::base::dimension::{Dim, DimDiff, DimSub, Dyn, U1, U2, U3}; use crate::base::storage::Storage; use crate::base::{ DefaultAllocator, Hessenberg, OMatrix, OVector, SquareMatrix, Unit, Vector2, Vector3, @@ -52,8 +52,8 @@ where impl Eigen where - D: DimSub, // For Hessenberg. - ShapeConstraint: DimEq>, // For Hessenberg. + D: DimSub, // For Hessenberg. + ShapeConstraint: DimEq>, // For Hessenberg. DefaultAllocator: Allocator> + Allocator> + Allocator diff --git a/src/linalg/permutation_sequence.rs b/src/linalg/permutation_sequence.rs index f4521988..9e4eb37b 100644 --- a/src/linalg/permutation_sequence.rs +++ b/src/linalg/permutation_sequence.rs @@ -7,7 +7,7 @@ use simba::scalar::ClosedNeg; use crate::allocator::Allocator; use crate::base::{DefaultAllocator, Matrix, OVector, Scalar}; #[cfg(any(feature = "std", feature = "alloc"))] -use crate::dimension::Dynamic; +use crate::dimension::Dyn; use crate::dimension::{Const, Dim, DimName}; use crate::storage::StorageMut; @@ -51,14 +51,14 @@ where } #[cfg(any(feature = "std", feature = "alloc"))] -impl PermutationSequence +impl PermutationSequence where - DefaultAllocator: Allocator<(usize, usize), Dynamic>, + DefaultAllocator: Allocator<(usize, usize), Dyn>, { /// Creates a new dynamically-allocated sequence of `n` identity permutations. #[inline] pub fn identity(n: usize) -> Self { - Self::identity_generic(Dynamic::new(n)) + Self::identity_generic(Dyn(n)) } } diff --git a/src/linalg/schur.rs b/src/linalg/schur.rs index 06d8426b..3f734723 100644 --- a/src/linalg/schur.rs +++ b/src/linalg/schur.rs @@ -8,7 +8,7 @@ use simba::scalar::{ComplexField, RealField}; use std::cmp; use crate::allocator::Allocator; -use crate::base::dimension::{Const, Dim, DimDiff, DimSub, Dynamic, U1, U2}; +use crate::base::dimension::{Const, Dim, DimDiff, DimSub, Dyn, U1, U2}; use crate::base::storage::Storage; use crate::base::{DefaultAllocator, OMatrix, OVector, SquareMatrix, Unit, Vector2, Vector3}; @@ -174,12 +174,11 @@ where { let krows = cmp::min(k + 4, end + 1); let mut work = work.rows_mut(0, krows); - refl.reflect(&mut t.generic_view_mut( - (k, k), - (Const::<3>, Dynamic::new(dim.value() - k)), - )); + refl.reflect( + &mut t.generic_view_mut((k, k), (Const::<3>, Dyn(dim.value() - k))), + ); refl.reflect_rows( - &mut t.generic_view_mut((0, k), (Dynamic::new(krows), Const::<3>)), + &mut t.generic_view_mut((0, k), (Dyn(krows), Const::<3>)), &mut work, ); } @@ -212,13 +211,10 @@ where { let mut work = work.rows_mut(0, end + 1); refl.reflect( - &mut t.generic_view_mut( - (m, m), - (Const::<2>, Dynamic::new(dim.value() - m)), - ), + &mut t.generic_view_mut((m, m), (Const::<2>, Dyn(dim.value() - m))), ); refl.reflect_rows( - &mut t.generic_view_mut((0, m), (Dynamic::new(end + 1), Const::<2>)), + &mut t.generic_view_mut((0, m), (Dyn(end + 1), Const::<2>)), &mut work, ); } @@ -231,12 +227,14 @@ where // Decouple the 2x2 block if it has real eigenvalues. if let Some(rot) = compute_2x2_basis(&t.fixed_view::<2, 2>(start, start)) { let inv_rot = rot.inverse(); - inv_rot.rotate(&mut t.generic_view_mut( - (start, start), - (Const::<2>, Dynamic::new(dim.value() - start)), - )); + inv_rot.rotate( + &mut t.generic_view_mut( + (start, start), + (Const::<2>, Dyn(dim.value() - start)), + ), + ); rot.rotate_rows( - &mut t.generic_view_mut((0, start), (Dynamic::new(end + 1), Const::<2>)), + &mut t.generic_view_mut((0, start), (Dyn(end + 1), Const::<2>)), ); t[(end, start)] = T::zero(); diff --git a/src/proptest/mod.rs b/src/proptest/mod.rs index a7cbe549..6cb31521 100644 --- a/src/proptest/mod.rs +++ b/src/proptest/mod.rs @@ -53,11 +53,11 @@ //! with [matrix](fn.matrix.html) as follows: //! //! ``` -//! use nalgebra::{Dynamic, OMatrix, Const}; +//! use nalgebra::{Dyn, OMatrix, Const}; //! use nalgebra::proptest::matrix; //! use proptest::prelude::*; //! -//! type MyMatrix = OMatrix, Dynamic>; +//! type MyMatrix = OMatrix, Dyn>; //! //! /// Returns a strategy for pairs of matrices with `U3` rows and the same number of //! /// columns. @@ -93,7 +93,7 @@ //! If you don't care about the dimensions of matrices, you can write tests like these: //! //! ``` -//! use nalgebra::{DMatrix, DVector, Dynamic, Matrix3, OMatrix, Vector3, U3}; +//! use nalgebra::{DMatrix, DVector, Dyn, Matrix3, OMatrix, Vector3, U3}; //! use proptest::prelude::*; //! //! proptest! { @@ -108,7 +108,7 @@ //! # /* //! #[test] //! # */ -//! fn test_static_and_mixed(matrix: Matrix3, matrix2: OMatrix) { +//! fn test_static_and_mixed(matrix: Matrix3, matrix2: OMatrix) { //! // Test some property involving these matrices //! } //! @@ -141,7 +141,7 @@ //! PROPTEST_MAX_SHRINK_ITERS=100000 cargo test my_failing_test //! ``` use crate::allocator::Allocator; -use crate::{Const, DefaultAllocator, Dim, DimName, Dynamic, OMatrix, Scalar, U1}; +use crate::{Const, DefaultAllocator, Dim, DimName, Dyn, OMatrix, Scalar, U1}; use proptest::arbitrary::Arbitrary; use proptest::collection::vec; use proptest::strategy::{BoxedStrategy, Just, NewTree, Strategy, ValueTree}; @@ -167,9 +167,9 @@ pub struct MatrixParameters { /// of matrices with `proptest`. In most cases, you do not need to concern yourself with /// `DimRange` directly, as it supports conversion from other types such as `U3` or inclusive /// ranges such as `5 ..= 6`. The latter example corresponds to dimensions from (inclusive) -/// `Dynamic::new(5)` to `Dynamic::new(6)` (inclusive). +/// `Dyn(5)` to `Dyn(6)` (inclusive). #[derive(Debug, Clone, PartialEq, Eq)] -pub struct DimRange(RangeInclusive); +pub struct DimRange(RangeInclusive); impl DimRange { /// The lower bound for dimensions generated. @@ -195,9 +195,9 @@ impl From> for DimRange { } } -impl From> for DimRange { +impl From> for DimRange { fn from(range: RangeInclusive) -> Self { - DimRange::from(Dynamic::new(*range.start())..=Dynamic::new(*range.end())) + DimRange::from(Dyn(*range.start())..=Dyn(*range.end())) } } @@ -208,14 +208,14 @@ impl DimRange { } } -impl From for DimRange { +impl From for DimRange { fn from(dim: usize) -> Self { - DimRange::from(Dynamic::new(dim)) + DimRange::from(Dyn(dim)) } } -/// The default range used for Dynamic dimensions when generating arbitrary matrices. -fn dynamic_dim_range() -> DimRange { +/// The default range used for Dyn dimensions when generating arbitrary matrices. +fn dynamic_dim_range() -> DimRange { DimRange::from(0..=6) } @@ -225,7 +225,7 @@ fn dynamic_dim_range() -> DimRange { /// ## Examples /// ``` /// use nalgebra::proptest::matrix; -/// use nalgebra::{OMatrix, Const, Dynamic}; +/// use nalgebra::{OMatrix, Const, Dyn}; /// use proptest::prelude::*; /// /// proptest! { @@ -234,7 +234,7 @@ fn dynamic_dim_range() -> DimRange { /// # */ /// fn my_test(a in matrix(0 .. 5i32, Const::<3>, 0 ..= 5)) { /// // Let's make sure we've got the correct type first -/// let a: OMatrix<_, Const::<3>, Dynamic> = a; +/// let a: OMatrix<_, Const::<3>, Dyn> = a; /// prop_assert!(a.nrows() == 3); /// prop_assert!(a.ncols() <= 5); /// prop_assert!(a.iter().all(|x_ij| *x_ij >= 0 && *x_ij < 5)); @@ -347,7 +347,7 @@ where } } -impl Default for MatrixParameters +impl Default for MatrixParameters where NParameters: Default, R: DimName, @@ -361,7 +361,7 @@ where } } -impl Default for MatrixParameters +impl Default for MatrixParameters where NParameters: Default, C: DimName, @@ -375,7 +375,7 @@ where } } -impl Default for MatrixParameters +impl Default for MatrixParameters where NParameters: Default, { diff --git a/src/sparse/cs_matrix.rs b/src/sparse/cs_matrix.rs index 14f8d41e..5b63e537 100644 --- a/src/sparse/cs_matrix.rs +++ b/src/sparse/cs_matrix.rs @@ -7,7 +7,7 @@ use std::slice; use crate::allocator::Allocator; use crate::sparse::cs_utils; -use crate::{Const, DefaultAllocator, Dim, Dynamic, Matrix, OVector, Scalar, Vector, U1}; +use crate::{Const, DefaultAllocator, Dim, Dyn, Matrix, OVector, Scalar, Vector, U1}; pub struct ColumnEntries<'a, T> { curr: usize, @@ -236,16 +236,16 @@ impl CsStorageMut for CsVecStorage pub struct CsSliceStorage<'a, T: Scalar, R: Dim, C: DimAdd> { shape: (R, C), p: VectorSlice>, - i: VectorSlice, - vals: VectorSlice, + i: VectorSlice, + vals: VectorSlice, }*/ /// A compressed sparse column matrix. #[derive(Clone, Debug, PartialEq)] pub struct CsMatrix< T: Scalar, - R: Dim = Dynamic, - C: Dim = Dynamic, + R: Dim = Dyn, + C: Dim = Dyn, S: CsStorage = CsVecStorage, > { pub(crate) data: S, @@ -253,7 +253,7 @@ pub struct CsMatrix< } /// A column compressed sparse vector. -pub type CsVector> = CsMatrix; +pub type CsVector> = CsMatrix; impl CsMatrix where @@ -342,8 +342,8 @@ impl CsMatrix { vals: Vec, ) -> Self { - let nrows = Dynamic::new(nrows); - let ncols = Dynamic::new(ncols); + let nrows = Dyn(nrows); + let ncols = Dyn(ncols); let p = DVector::from_data(VecStorage::new(ncols, U1, p)); Self::from_parts_generic(nrows, ncols, p, i, vals) } diff --git a/src/sparse/cs_matrix_conversion.rs b/src/sparse/cs_matrix_conversion.rs index e7ff8c36..4154f452 100644 --- a/src/sparse/cs_matrix_conversion.rs +++ b/src/sparse/cs_matrix_conversion.rs @@ -5,7 +5,7 @@ use crate::allocator::Allocator; use crate::sparse::cs_utils; use crate::sparse::{CsMatrix, CsStorage}; use crate::storage::Storage; -use crate::{DefaultAllocator, Dim, Dynamic, Matrix, OMatrix, Scalar}; +use crate::{DefaultAllocator, Dim, Dyn, Matrix, OMatrix, Scalar}; impl<'a, T: Scalar + Zero + ClosedAdd> CsMatrix { /// Creates a column-compressed sparse matrix from a sparse matrix in triplet form. @@ -16,7 +16,7 @@ impl<'a, T: Scalar + Zero + ClosedAdd> CsMatrix { icols: &[usize], vals: &[T], ) -> Self { - Self::from_triplet_generic(Dynamic::new(nrows), Dynamic::new(ncols), irows, icols, vals) + Self::from_triplet_generic(Dyn(nrows), Dyn(ncols), irows, icols, vals) } } diff --git a/tests/core/edition.rs b/tests/core/edition.rs index bd882652..f5a51874 100644 --- a/tests/core/edition.rs +++ b/tests/core/edition.rs @@ -2,7 +2,7 @@ use na::{ DMatrix, Matrix, Matrix3, Matrix3x4, Matrix3x5, Matrix4, Matrix4x3, Matrix4x5, Matrix5, Matrix5x3, Matrix5x4, }; -use na::{Dynamic, U3, U5}; +use na::{Dyn, U3, U5}; #[test] #[rustfmt::skip] @@ -257,7 +257,7 @@ fn remove_columns() { assert_eq!(m.remove_fixed_columns::<2>(2), expected_b3); // The following is just to verify that the return type dimensions is correctly inferred. - let computed: Matrix<_, U3, Dynamic, _> = m.remove_columns(3, 2); + let computed: Matrix<_, U3, Dyn, _> = m.remove_columns(3, 2); assert!(computed.eq(&expected_b2)); /* @@ -391,7 +391,7 @@ fn remove_rows() { assert_eq!(m.remove_fixed_rows::<2>(2), expected3); // The following is just to verify that the return type dimensions is correctly inferred. - let computed: Matrix<_, Dynamic, U3, _> = m.remove_rows(3, 2); + let computed: Matrix<_, Dyn, U3, _> = m.remove_rows(3, 2); assert!(computed.eq(&expected2)); } @@ -508,7 +508,7 @@ fn insert_columns() { assert_eq!(m.insert_fixed_columns::<2>(2, 0), expected3); // The following is just to verify that the return type dimensions is correctly inferred. - let computed: Matrix<_, U5, Dynamic, _> = m.insert_columns(3, 2, 0); + let computed: Matrix<_, U5, Dyn, _> = m.insert_columns(3, 2, 0); assert!(computed.eq(&expected2)); } @@ -581,7 +581,7 @@ fn insert_rows() { assert_eq!(m.insert_fixed_rows::<2>(2, 0), expected3); // The following is just to verify that the return type dimensions is correctly inferred. - let computed: Matrix<_, Dynamic, U5, _> = m.insert_rows(3, 2, 0); + let computed: Matrix<_, Dyn, U5, _> = m.insert_rows(3, 2, 0); assert!(computed.eq(&expected2)); } diff --git a/tests/core/reshape.rs b/tests/core/reshape.rs index 42afa9bf..0ad24bc6 100644 --- a/tests/core/reshape.rs +++ b/tests/core/reshape.rs @@ -1,5 +1,5 @@ use na::{ - Const, DMatrix, DMatrixView, DMatrixViewMut, Dyn, Dynamic, Matrix, MatrixView, MatrixViewMut, + Const, DMatrix, DMatrixView, DMatrixViewMut, Dyn, Dyn, Matrix, MatrixView, MatrixViewMut, SMatrix, SMatrixView, SMatrixViewMut, VecStorage, U3, U4, }; use nalgebra_macros::matrix; @@ -60,21 +60,21 @@ fn reshape_slice() { // Static "source slice" test_reshape!(SMatrixView<_, 4, 3> => SMatrixView<_, 3, 4>, U3, U4); - test_reshape!(SMatrixView<_, 4, 3> => DMatrixView<_>, Dynamic::new(3), Dynamic::new(4)); - test_reshape!(SMatrixView<_, 4, 3> => MatrixView<_, Const<3>, Dynamic>, U3, Dynamic::new(4)); - test_reshape!(SMatrixView<_, 4, 3> => MatrixView<_, Dynamic, Const<4>>, Dynamic::new(3), U4); + test_reshape!(SMatrixView<_, 4, 3> => DMatrixView<_>, Dyn(3), Dyn(4)); + test_reshape!(SMatrixView<_, 4, 3> => MatrixView<_, Const<3>, Dyn>, U3, Dyn(4)); + test_reshape!(SMatrixView<_, 4, 3> => MatrixView<_, Dyn, Const<4>>, Dyn(3), U4); test_reshape!(SMatrixViewMut<_, 4, 3> => SMatrixViewMut<_, 3, 4>, U3, U4); - test_reshape!(SMatrixViewMut<_, 4, 3> => DMatrixViewMut<_>, Dynamic::new(3), Dynamic::new(4)); - test_reshape!(SMatrixViewMut<_, 4, 3> => MatrixViewMut<_, Const<3>, Dynamic>, U3, Dynamic::new(4)); - test_reshape!(SMatrixViewMut<_, 4, 3> => MatrixViewMut<_, Dynamic, Const<4>>, Dynamic::new(3), U4); + test_reshape!(SMatrixViewMut<_, 4, 3> => DMatrixViewMut<_>, Dyn(3), Dyn(4)); + test_reshape!(SMatrixViewMut<_, 4, 3> => MatrixViewMut<_, Const<3>, Dyn>, U3, Dyn(4)); + test_reshape!(SMatrixViewMut<_, 4, 3> => MatrixViewMut<_, Dyn, Const<4>>, Dyn(3), U4); - // Dynamic "source slice" + // Dyn "source slice" test_reshape!(DMatrixView<_> => SMatrixView<_, 3, 4>, U3, U4); - test_reshape!(DMatrixView<_> => DMatrixView<_>, Dynamic::new(3), Dynamic::new(4)); - test_reshape!(DMatrixView<_> => MatrixView<_, Const<3>, Dynamic>, U3, Dynamic::new(4)); - test_reshape!(DMatrixView<_> => MatrixView<_, Dynamic, Const<4>>, Dynamic::new(3), U4); + test_reshape!(DMatrixView<_> => DMatrixView<_>, Dyn(3), Dyn(4)); + test_reshape!(DMatrixView<_> => MatrixView<_, Const<3>, Dyn>, U3, Dyn(4)); + test_reshape!(DMatrixView<_> => MatrixView<_, Dyn, Const<4>>, Dyn(3), U4); test_reshape!(DMatrixViewMut<_> => SMatrixViewMut<_, 3, 4>, U3, U4); - test_reshape!(DMatrixViewMut<_> => DMatrixViewMut<_>, Dynamic::new(3), Dynamic::new(4)); - test_reshape!(DMatrixViewMut<_> => MatrixViewMut<_, Const<3>, Dynamic>, U3, Dynamic::new(4)); - test_reshape!(DMatrixViewMut<_> => MatrixViewMut<_, Dynamic, Const<4>>, Dynamic::new(3), U4); + test_reshape!(DMatrixViewMut<_> => DMatrixViewMut<_>, Dyn(3), Dyn(4)); + test_reshape!(DMatrixViewMut<_> => MatrixViewMut<_, Const<3>, Dyn>, U3, Dyn(4)); + test_reshape!(DMatrixViewMut<_> => MatrixViewMut<_, Dyn, Const<4>>, Dyn(3), U4); } diff --git a/tests/linalg/cholesky.rs b/tests/linalg/cholesky.rs index 891e54ca..a73fa947 100644 --- a/tests/linalg/cholesky.rs +++ b/tests/linalg/cholesky.rs @@ -15,7 +15,7 @@ macro_rules! gen_tests( ($module: ident, $scalar: ty) => { mod $module { use na::debug::RandomSDP; - use na::dimension::{Const, Dynamic}; + use na::dimension::{Const, Dyn}; use na::{DMatrix, DVector, Matrix4x3, Vector4}; use rand::random; use simba::scalar::ComplexField; @@ -28,7 +28,7 @@ macro_rules! gen_tests( proptest! { #[test] fn cholesky(n in PROPTEST_MATRIX_DIM) { - let m = RandomSDP::new(Dynamic::new(n), || random::<$scalar>().0).unwrap(); + let m = RandomSDP::new(Dyn(n), || random::<$scalar>().0).unwrap(); let l = m.clone().cholesky().unwrap().unpack(); prop_assert!(relative_eq!(m, &l * l.adjoint(), epsilon = 1.0e-7)); } @@ -44,7 +44,7 @@ macro_rules! gen_tests( #[test] fn cholesky_solve(n in PROPTEST_MATRIX_DIM, nb in PROPTEST_MATRIX_DIM) { - let m = RandomSDP::new(Dynamic::new(n), || random::<$scalar>().0).unwrap(); + let m = RandomSDP::new(Dyn(n), || random::<$scalar>().0).unwrap(); let chol = m.clone().cholesky().unwrap(); let b1 = DVector::<$scalar>::new_random(n).map(|e| e.0); @@ -73,7 +73,7 @@ macro_rules! gen_tests( #[test] fn cholesky_inverse(n in PROPTEST_MATRIX_DIM) { - let m = RandomSDP::new(Dynamic::new(n), || random::<$scalar>().0).unwrap(); + let m = RandomSDP::new(Dyn(n), || random::<$scalar>().0).unwrap(); let m1 = m.clone().cholesky().unwrap().inverse(); let id1 = &m * &m1; let id2 = &m1 * &m; @@ -93,7 +93,7 @@ macro_rules! gen_tests( #[test] fn cholesky_determinant(n in PROPTEST_MATRIX_DIM) { - let m = RandomSDP::new(Dynamic::new(n), || random::<$scalar>().0).unwrap(); + let m = RandomSDP::new(Dyn(n), || random::<$scalar>().0).unwrap(); let lu_det = m.clone().lu().determinant(); assert_relative_eq!(lu_det.imaginary(), 0., epsilon = 1.0e-7); let chol_det = m.cholesky().unwrap().determinant(); @@ -137,7 +137,7 @@ macro_rules! gen_tests( fn cholesky_insert_column(n in PROPTEST_MATRIX_DIM) { let n = n.max(1).min(10); let j = random::() % n; - let m_updated = RandomSDP::new(Dynamic::new(n), || random::<$scalar>().0).unwrap(); + let m_updated = RandomSDP::new(Dyn(n), || random::<$scalar>().0).unwrap(); // build m and col from m_updated let col = m_updated.column(j); @@ -154,7 +154,7 @@ macro_rules! gen_tests( fn cholesky_remove_column(n in PROPTEST_MATRIX_DIM) { let n = n.max(1).min(10); let j = random::() % n; - let m = RandomSDP::new(Dynamic::new(n), || random::<$scalar>().0).unwrap(); + let m = RandomSDP::new(Dyn(n), || random::<$scalar>().0).unwrap(); // remove column from cholesky decomposition and rebuild m let chol = m.clone().cholesky().unwrap().remove_column(j); diff --git a/tests/linalg/convolution.rs b/tests/linalg/convolution.rs index b2e151d3..eba8b84d 100644 --- a/tests/linalg/convolution.rs +++ b/tests/linalg/convolution.rs @@ -16,7 +16,7 @@ fn convolve_same_check() { assert!(relative_eq!(actual_s, expected_s, epsilon = 1.0e-7)); - // Dynamic Tests + // Dyn Tests let actual_d = DVector::from_vec(vec![1.0, 4.0, 7.0, 10.0]); let expected_d = DVector::from_vec(vec![1.0, 2.0, 3.0, 4.0]) .convolve_same(DVector::from_vec(vec![1.0, 2.0])); @@ -54,7 +54,7 @@ fn convolve_full_check() { assert!(relative_eq!(actual_s, expected_s, epsilon = 1.0e-7)); - // Dynamic Tests + // Dyn Tests let actual_d = DVector::from_vec(vec![1.0, 4.0, 7.0, 10.0, 8.0]); let expected_d = DVector::from_vec(vec![1.0, 2.0, 3.0, 4.0]) .convolve_full(DVector::from_vec(vec![1.0, 2.0])); @@ -90,7 +90,7 @@ fn convolve_valid_check() { assert!(relative_eq!(actual_s, expected_s, epsilon = 1.0e-7)); - // Dynamic Tests + // Dyn Tests let actual_d = DVector::from_vec(vec![4.0, 7.0, 10.0]); let expected_d = DVector::from_vec(vec![1.0, 2.0, 3.0, 4.0]) .convolve_valid(DVector::from_vec(vec![1.0, 2.0])); diff --git a/tests/linalg/full_piv_lu.rs b/tests/linalg/full_piv_lu.rs index 7ac95b0f..24e3bb48 100644 --- a/tests/linalg/full_piv_lu.rs +++ b/tests/linalg/full_piv_lu.rs @@ -253,7 +253,7 @@ fn remove_columns() { assert_eq!(m.remove_fixed_columns::(2), expected3); // The following is just to verify that the return type dimensions is correctly inferred. - let computed: Matrix<_, U3, Dynamic, _> = m.remove_columns(3, 2); + let computed: Matrix<_, U3, Dyn, _> = m.remove_columns(3, 2); assert!(computed.eq(&expected2)); } @@ -309,7 +309,7 @@ fn remove_rows() { assert_eq!(m.remove_fixed_rows::(2), expected3); // The following is just to verify that the return type dimensions is correctly inferred. - let computed: Matrix<_, Dynamic, U3, _> = m.remove_rows(3, 2); + let computed: Matrix<_, Dyn, U3, _> = m.remove_rows(3, 2); assert!(computed.eq(&expected2)); } @@ -374,7 +374,7 @@ fn insert_columns() { assert_eq!(m.insert_fixed_columns::(2, 0), expected3); // The following is just to verify that the return type dimensions is correctly inferred. - let computed: Matrix<_, U5, Dynamic, _> = m.insert_columns(3, 2, 0); + let computed: Matrix<_, U5, Dyn, _> = m.insert_columns(3, 2, 0); assert!(computed.eq(&expected2)); } @@ -434,7 +434,7 @@ fn insert_rows() { assert_eq!(m.insert_fixed_rows::<2>(2, 0), expected3); // The following is just to verify that the return type dimensions is correctly inferred. - let computed: Matrix<_, Dynamic, U5, _> = m.insert_rows(3, 2, 0); + let computed: Matrix<_, Dyn, U5, _> = m.insert_rows(3, 2, 0); assert!(computed.eq(&expected2)); } diff --git a/tests/proptest/mod.rs b/tests/proptest/mod.rs index ec2e2c7b..cedfae84 100644 --- a/tests/proptest/mod.rs +++ b/tests/proptest/mod.rs @@ -101,11 +101,11 @@ pub fn dvector() -> impl Strategy> { pub fn dmatrix_( scalar_strategy: ScalarStrategy, -) -> impl Strategy> +) -> impl Strategy> where ScalarStrategy: Strategy + Clone + 'static, ScalarStrategy::Value: Scalar, - DefaultAllocator: Allocator, + DefaultAllocator: Allocator, { matrix(scalar_strategy, PROPTEST_MATRIX_DIM, PROPTEST_MATRIX_DIM) } @@ -114,7 +114,7 @@ where // where // RangeInclusive: Strategy, // T: Scalar + PartialEq + Copy, -// DefaultAllocator: Allocator, +// DefaultAllocator: Allocator, // { // vector(range, PROPTEST_MATRIX_DIM) // } @@ -213,9 +213,9 @@ fn test_matrix_output_types() { // Test that the dimension types are correct for the given inputs let _: MatrixStrategy<_, U3, U4> = matrix(-5..5, Const::<3>, Const::<4>); let _: MatrixStrategy<_, U3, U3> = matrix(-5..5, Const::<3>, Const::<3>); - let _: MatrixStrategy<_, U3, Dynamic> = matrix(-5..5, Const::<3>, 1..=5); - let _: MatrixStrategy<_, Dynamic, U3> = matrix(-5..5, 1..=5, Const::<3>); - let _: MatrixStrategy<_, Dynamic, Dynamic> = matrix(-5..5, 1..=5, 1..=5); + let _: MatrixStrategy<_, U3, Dyn> = matrix(-5..5, Const::<3>, 1..=5); + let _: MatrixStrategy<_, Dyn, U3> = matrix(-5..5, 1..=5, Const::<3>); + let _: MatrixStrategy<_, Dyn, Dyn> = matrix(-5..5, 1..=5, 1..=5); } // Below we have some tests to ensure that specific instances of OMatrix are usable @@ -225,10 +225,10 @@ proptest! { fn ensure_arbitrary_test_compiles_matrix3(_: Matrix3) {} #[test] - fn ensure_arbitrary_test_compiles_matrixmn_u3_dynamic(_: OMatrix) {} + fn ensure_arbitrary_test_compiles_matrixmn_u3_dynamic(_: OMatrix) {} #[test] - fn ensure_arbitrary_test_compiles_matrixmn_dynamic_u3(_: OMatrix) {} + fn ensure_arbitrary_test_compiles_matrixmn_dynamic_u3(_: OMatrix) {} #[test] fn ensure_arbitrary_test_compiles_dmatrix(_: DMatrix) {}