From 5a1dbfe37d3fda5c0206b605d50c7b7f9afe258d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Crozet=20S=C3=A9bastien?= Date: Mon, 12 Apr 2021 10:34:15 +0200 Subject: [PATCH] Use explicit storage names in matrix aliases. --- src/base/alias.rs | 144 ++++++++++++++++++++++---------------------- src/base/edition.rs | 13 ++-- 2 files changed, 79 insertions(+), 78 deletions(-) diff --git a/src/base/alias.rs b/src/base/alias.rs index 5d4ecdde..0c69098f 100644 --- a/src/base/alias.rs +++ b/src/base/alias.rs @@ -4,7 +4,7 @@ use crate::base::dimension::{U1, U2, U3, U4, U5, U6}; use crate::base::storage::Owned; #[cfg(any(feature = "std", feature = "alloc"))] use crate::base::vec_storage::VecStorage; -use crate::base::{Const, Matrix, Unit}; +use crate::base::{ArrayStorage, Const, Matrix, Unit}; /* * @@ -31,230 +31,230 @@ pub type MatrixMN = Matrix>; /// /// **Because this is an alias, not all its methods are listed here. See the [`Matrix`](crate::base::Matrix) type too.** pub type SMatrix = - Matrix, Const, Owned, Const>>; + Matrix, Const, ArrayStorage>; /// A dynamically sized column-major matrix. /// /// **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. /// /// **Because this is an alias, not all its methods are listed here. See the [`Matrix`](crate::base::Matrix) type too.** -pub type Matrix1 = Matrix>; +pub type Matrix1 = Matrix>; /// A stack-allocated, column-major, 2x2 square matrix. /// /// **Because this is an alias, not all its methods are listed here. See the [`Matrix`](crate::base::Matrix) type too.** -pub type Matrix2 = Matrix>; +pub type Matrix2 = Matrix>; /// A stack-allocated, column-major, 3x3 square matrix. /// /// **Because this is an alias, not all its methods are listed here. See the [`Matrix`](crate::base::Matrix) type too.** -pub type Matrix3 = Matrix>; +pub type Matrix3 = Matrix>; /// A stack-allocated, column-major, 4x4 square matrix. /// /// **Because this is an alias, not all its methods are listed here. See the [`Matrix`](crate::base::Matrix) type too.** -pub type Matrix4 = Matrix>; +pub type Matrix4 = Matrix>; /// A stack-allocated, column-major, 5x5 square matrix. /// /// **Because this is an alias, not all its methods are listed here. See the [`Matrix`](crate::base::Matrix) type too.** -pub type Matrix5 = Matrix>; +pub type Matrix5 = Matrix>; /// A stack-allocated, column-major, 6x6 square matrix. /// /// **Because this is an alias, not all its methods are listed here. See the [`Matrix`](crate::base::Matrix) type too.** -pub type Matrix6 = Matrix>; +pub type Matrix6 = Matrix>; /// A stack-allocated, column-major, 1x2 matrix. /// /// **Because this is an alias, not all its methods are listed here. See the [`Matrix`](crate::base::Matrix) type too.** -pub type Matrix1x2 = Matrix>; +pub type Matrix1x2 = Matrix>; /// A stack-allocated, column-major, 1x3 matrix. /// /// **Because this is an alias, not all its methods are listed here. See the [`Matrix`](crate::base::Matrix) type too.** -pub type Matrix1x3 = Matrix>; +pub type Matrix1x3 = Matrix>; /// A stack-allocated, column-major, 1x4 matrix. /// /// **Because this is an alias, not all its methods are listed here. See the [`Matrix`](crate::base::Matrix) type too.** -pub type Matrix1x4 = Matrix>; +pub type Matrix1x4 = Matrix>; /// A stack-allocated, column-major, 1x5 matrix. /// /// **Because this is an alias, not all its methods are listed here. See the [`Matrix`](crate::base::Matrix) type too.** -pub type Matrix1x5 = Matrix>; +pub type Matrix1x5 = Matrix>; /// A stack-allocated, column-major, 1x6 matrix. /// /// **Because this is an alias, not all its methods are listed here. See the [`Matrix`](crate::base::Matrix) type too.** -pub type Matrix1x6 = Matrix>; +pub type Matrix1x6 = Matrix>; /// A stack-allocated, column-major, 2x3 matrix. /// /// **Because this is an alias, not all its methods are listed here. See the [`Matrix`](crate::base::Matrix) type too.** -pub type Matrix2x3 = Matrix>; +pub type Matrix2x3 = Matrix>; /// A stack-allocated, column-major, 2x4 matrix. /// /// **Because this is an alias, not all its methods are listed here. See the [`Matrix`](crate::base::Matrix) type too.** -pub type Matrix2x4 = Matrix>; +pub type Matrix2x4 = Matrix>; /// A stack-allocated, column-major, 2x5 matrix. /// /// **Because this is an alias, not all its methods are listed here. See the [`Matrix`](crate::base::Matrix) type too.** -pub type Matrix2x5 = Matrix>; +pub type Matrix2x5 = Matrix>; /// A stack-allocated, column-major, 2x6 matrix. /// /// **Because this is an alias, not all its methods are listed here. See the [`Matrix`](crate::base::Matrix) type too.** -pub type Matrix2x6 = Matrix>; +pub type Matrix2x6 = Matrix>; /// A stack-allocated, column-major, 3x4 matrix. /// /// **Because this is an alias, not all its methods are listed here. See the [`Matrix`](crate::base::Matrix) type too.** -pub type Matrix3x4 = Matrix>; +pub type Matrix3x4 = Matrix>; /// A stack-allocated, column-major, 3x5 matrix. /// /// **Because this is an alias, not all its methods are listed here. See the [`Matrix`](crate::base::Matrix) type too.** -pub type Matrix3x5 = Matrix>; +pub type Matrix3x5 = Matrix>; /// A stack-allocated, column-major, 3x6 matrix. /// /// **Because this is an alias, not all its methods are listed here. See the [`Matrix`](crate::base::Matrix) type too.** -pub type Matrix3x6 = Matrix>; +pub type Matrix3x6 = Matrix>; /// A stack-allocated, column-major, 4x5 matrix. /// /// **Because this is an alias, not all its methods are listed here. See the [`Matrix`](crate::base::Matrix) type too.** -pub type Matrix4x5 = Matrix>; +pub type Matrix4x5 = Matrix>; /// A stack-allocated, column-major, 4x6 matrix. /// /// **Because this is an alias, not all its methods are listed here. See the [`Matrix`](crate::base::Matrix) type too.** -pub type Matrix4x6 = Matrix>; +pub type Matrix4x6 = Matrix>; /// A stack-allocated, column-major, 5x6 matrix. /// /// **Because this is an alias, not all its methods are listed here. See the [`Matrix`](crate::base::Matrix) type too.** -pub type Matrix5x6 = Matrix>; +pub type Matrix5x6 = Matrix>; /// A stack-allocated, column-major, 2x1 matrix. /// /// **Because this is an alias, not all its methods are listed here. See the [`Matrix`](crate::base::Matrix) type too.** -pub type Matrix2x1 = Matrix>; +pub type Matrix2x1 = Matrix>; /// A stack-allocated, column-major, 3x1 matrix. /// /// **Because this is an alias, not all its methods are listed here. See the [`Matrix`](crate::base::Matrix) type too.** -pub type Matrix3x1 = Matrix>; +pub type Matrix3x1 = Matrix>; /// A stack-allocated, column-major, 4x1 matrix. /// /// **Because this is an alias, not all its methods are listed here. See the [`Matrix`](crate::base::Matrix) type too.** -pub type Matrix4x1 = Matrix>; +pub type Matrix4x1 = Matrix>; /// A stack-allocated, column-major, 5x1 matrix. /// /// **Because this is an alias, not all its methods are listed here. See the [`Matrix`](crate::base::Matrix) type too.** -pub type Matrix5x1 = Matrix>; +pub type Matrix5x1 = Matrix>; /// A stack-allocated, column-major, 6x1 matrix. /// /// **Because this is an alias, not all its methods are listed here. See the [`Matrix`](crate::base::Matrix) type too.** -pub type Matrix6x1 = Matrix>; +pub type Matrix6x1 = Matrix>; /// A stack-allocated, column-major, 3x2 matrix. /// /// **Because this is an alias, not all its methods are listed here. See the [`Matrix`](crate::base::Matrix) type too.** -pub type Matrix3x2 = Matrix>; +pub type Matrix3x2 = Matrix>; /// A stack-allocated, column-major, 4x2 matrix. /// /// **Because this is an alias, not all its methods are listed here. See the [`Matrix`](crate::base::Matrix) type too.** -pub type Matrix4x2 = Matrix>; +pub type Matrix4x2 = Matrix>; /// A stack-allocated, column-major, 5x2 matrix. /// /// **Because this is an alias, not all its methods are listed here. See the [`Matrix`](crate::base::Matrix) type too.** -pub type Matrix5x2 = Matrix>; +pub type Matrix5x2 = Matrix>; /// A stack-allocated, column-major, 6x2 matrix. /// /// **Because this is an alias, not all its methods are listed here. See the [`Matrix`](crate::base::Matrix) type too.** -pub type Matrix6x2 = Matrix>; +pub type Matrix6x2 = Matrix>; /// A stack-allocated, column-major, 4x3 matrix. /// /// **Because this is an alias, not all its methods are listed here. See the [`Matrix`](crate::base::Matrix) type too.** -pub type Matrix4x3 = Matrix>; +pub type Matrix4x3 = Matrix>; /// A stack-allocated, column-major, 5x3 matrix. /// /// **Because this is an alias, not all its methods are listed here. See the [`Matrix`](crate::base::Matrix) type too.** -pub type Matrix5x3 = Matrix>; +pub type Matrix5x3 = Matrix>; /// A stack-allocated, column-major, 6x3 matrix. /// /// **Because this is an alias, not all its methods are listed here. See the [`Matrix`](crate::base::Matrix) type too.** -pub type Matrix6x3 = Matrix>; +pub type Matrix6x3 = Matrix>; /// A stack-allocated, column-major, 5x4 matrix. /// /// **Because this is an alias, not all its methods are listed here. See the [`Matrix`](crate::base::Matrix) type too.** -pub type Matrix5x4 = Matrix>; +pub type Matrix5x4 = Matrix>; /// A stack-allocated, column-major, 6x4 matrix. /// /// **Because this is an alias, not all its methods are listed here. See the [`Matrix`](crate::base::Matrix) type too.** -pub type Matrix6x4 = Matrix>; +pub type Matrix6x4 = Matrix>; /// A stack-allocated, column-major, 6x5 matrix. /// /// **Because this is an alias, not all its methods are listed here. See the [`Matrix`](crate::base::Matrix) type too.** -pub type Matrix6x5 = Matrix>; +pub type Matrix6x5 = Matrix>; /* * @@ -270,7 +270,7 @@ pub type DVector = Matrix>; /// An owned D-dimensional column vector. pub type OVector = Matrix>; /// A statically sized D-dimensional column vector. -pub type SVector = Matrix, U1, Owned, U1>>; +pub type SVector = Matrix, U1, ArrayStorage>; // Owned, U1>>; /// An owned matrix column-major matrix with `R` rows and `C` columns. /// @@ -278,20 +278,20 @@ pub type SVector = Matrix, U1, Owned, #[deprecated( note = "use SVector for a statically-sized matrix using integer dimensions, or OVector for an owned matrix using types as dimensions." )] -pub type VectorN = Matrix>; +pub type VectorN = Matrix>; /// A stack-allocated, 1-dimensional column vector. -pub type Vector1 = Matrix>; +pub type Vector1 = Matrix>; /// A stack-allocated, 2-dimensional column vector. -pub type Vector2 = Matrix>; +pub type Vector2 = Matrix>; /// A stack-allocated, 3-dimensional column vector. -pub type Vector3 = Matrix>; +pub type Vector3 = Matrix>; /// A stack-allocated, 4-dimensional column vector. -pub type Vector4 = Matrix>; +pub type Vector4 = Matrix>; /// A stack-allocated, 5-dimensional column vector. -pub type Vector5 = Matrix>; +pub type Vector5 = Matrix>; /// A stack-allocated, 6-dimensional column vector. -pub type Vector6 = Matrix>; +pub type Vector6 = Matrix>; /* * @@ -308,20 +308,20 @@ pub type RowDVector = Matrix>; pub type RowOVector = Matrix>; /// A statically sized D-dimensional row vector. -pub type RowSVector = Matrix, Owned>>; +pub type RowSVector = Matrix, ArrayStorage>; /// A stack-allocated, 1-dimensional row vector. -pub type RowVector1 = Matrix>; +pub type RowVector1 = Matrix>; /// A stack-allocated, 2-dimensional row vector. -pub type RowVector2 = Matrix>; +pub type RowVector2 = Matrix>; /// A stack-allocated, 3-dimensional row vector. -pub type RowVector3 = Matrix>; +pub type RowVector3 = Matrix>; /// A stack-allocated, 4-dimensional row vector. -pub type RowVector4 = Matrix>; +pub type RowVector4 = Matrix>; /// A stack-allocated, 5-dimensional row vector. -pub type RowVector5 = Matrix>; +pub type RowVector5 = Matrix>; /// A stack-allocated, 6-dimensional row vector. -pub type RowVector6 = Matrix>; +pub type RowVector6 = Matrix>; /* * @@ -331,14 +331,14 @@ pub type RowVector6 = Matrix>; * */ /// A stack-allocated, 1-dimensional unit vector. -pub type UnitVector1 = Unit>>; +pub type UnitVector1 = Unit>>; /// A stack-allocated, 2-dimensional unit vector. -pub type UnitVector2 = Unit>>; +pub type UnitVector2 = Unit>>; /// A stack-allocated, 3-dimensional unit vector. -pub type UnitVector3 = Unit>>; +pub type UnitVector3 = Unit>>; /// A stack-allocated, 4-dimensional unit vector. -pub type UnitVector4 = Unit>>; +pub type UnitVector4 = Unit>>; /// A stack-allocated, 5-dimensional unit vector. -pub type UnitVector5 = Unit>>; +pub type UnitVector5 = Unit>>; /// A stack-allocated, 6-dimensional unit vector. -pub type UnitVector6 = Unit>>; +pub type UnitVector6 = Unit>>; diff --git a/src/base/edition.rs b/src/base/edition.rs index 189b234c..17c08c98 100644 --- a/src/base/edition.rs +++ b/src/base/edition.rs @@ -12,9 +12,7 @@ use crate::base::constraint::{DimEq, SameNumberOfColumns, SameNumberOfRows, Shap use crate::base::dimension::Dynamic; use crate::base::dimension::{Const, Dim, DimAdd, DimDiff, DimMin, DimMinimum, DimSub, DimSum, U1}; use crate::base::storage::{ReshapableStorage, Storage, StorageMut}; -#[cfg(any(feature = "std", feature = "alloc"))] -use crate::base::DMatrix; -use crate::base::{DefaultAllocator, Matrix, OMatrix, RowVector, SMatrix, Scalar, Vector}; +use crate::base::{DefaultAllocator, Matrix, OMatrix, RowVector, Scalar, Vector}; /// # Rows and columns extraction impl> Matrix { @@ -711,7 +709,7 @@ 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) -> DMatrix + pub fn resize(self, new_nrows: usize, new_ncols: usize, val: T) -> OMatrix where DefaultAllocator: Reallocator, { @@ -748,7 +746,10 @@ 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`. - pub fn fixed_resize(self, val: T) -> SMatrix + pub fn fixed_resize( + self, + val: T, + ) -> OMatrix, Const> where DefaultAllocator: Reallocator, Const>, { @@ -892,7 +893,7 @@ impl> Matrix { /// # In-place resizing #[cfg(any(feature = "std", feature = "alloc"))] -impl DMatrix { +impl OMatrix { /// Resizes this matrix in-place. /// /// The values are copied such that `self[(i, j)] == result[(i, j)]`. If the result has more