From c23807ac5da4dfcefe0543369d3fb37599363ac0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Crozet?= Date: Wed, 12 Jun 2024 11:16:06 +0200 Subject: [PATCH] feat: use GAT to remove the scalar type T from the Allocator trait (#1397) --- examples/dimensional_genericity.rs | 2 +- nalgebra-lapack/Cargo.toml | 46 ++--- nalgebra-lapack/src/cholesky.rs | 14 +- nalgebra-lapack/src/eigen.rs | 22 +-- .../src/generalized_eigenvalues.rs | 23 +-- nalgebra-lapack/src/hessenberg.rs | 16 +- nalgebra-lapack/src/lu.rs | 40 ++-- nalgebra-lapack/src/qr.rs | 28 +-- nalgebra-lapack/src/qz.rs | 20 +- nalgebra-lapack/src/schur.rs | 20 +- nalgebra-lapack/src/svd.rs | 62 +++--- nalgebra-lapack/src/symmetric_eigen.rs | 14 +- nalgebra-sparse/src/ops/impl_std_ops.rs | 6 +- src/base/allocator.rs | 42 ++-- src/base/array_storage.rs | 10 +- src/base/blas.rs | 4 +- src/base/cg.rs | 22 +-- src/base/componentwise.rs | 12 +- src/base/construction.rs | 32 +-- src/base/conversion.rs | 11 +- src/base/default_allocator.rs | 62 +++--- src/base/edition.rs | 12 +- src/base/interpolation.rs | 8 +- src/base/matrix.rs | 60 +++--- src/base/matrix_simba.rs | 2 +- src/base/matrix_view.rs | 4 +- src/base/norm.rs | 18 +- src/base/ops.rs | 50 ++--- src/base/properties.rs | 6 +- src/base/statistics.rs | 30 +-- src/base/storage.rs | 20 +- src/base/unit.rs | 8 +- src/base/vec_storage.rs | 12 +- src/debug/random_orthogonal.rs | 6 +- src/debug/random_sdp.rs | 6 +- src/geometry/isometry.rs | 8 +- src/geometry/isometry_conversion.rs | 23 +-- src/geometry/point.rs | 48 ++--- src/geometry/point_construction.rs | 16 +- src/geometry/point_conversion.rs | 21 +- src/geometry/point_ops.rs | 46 ++--- src/geometry/rotation.rs | 4 +- src/geometry/rotation_conversion.rs | 16 +- src/geometry/rotation_ops.rs | 6 +- src/geometry/scale.rs | 4 +- src/geometry/scale_conversion.rs | 16 +- src/geometry/similarity.rs | 6 +- src/geometry/similarity_conversion.rs | 22 +-- src/geometry/transform.rs | 52 ++--- src/geometry/transform_construction.rs | 6 +- src/geometry/transform_conversion.rs | 8 +- src/geometry/transform_ops.rs | 64 +++--- src/geometry/transform_simba.rs | 3 +- src/geometry/translation.rs | 2 +- src/geometry/translation_conversion.rs | 17 +- src/lib.rs | 6 +- src/linalg/balancing.rs | 4 +- src/linalg/bidiagonal.rs | 52 +++-- src/linalg/cholesky.rs | 20 +- src/linalg/col_piv_qr.rs | 34 ++-- src/linalg/convolution.rs | 6 +- src/linalg/decomposition.rs | 182 ++++++++---------- src/linalg/determinant.rs | 2 +- src/linalg/eigen.rs | 16 +- src/linalg/exp.rs | 25 ++- src/linalg/full_piv_lu.rs | 24 +-- src/linalg/hessenberg.rs | 14 +- src/linalg/householder.rs | 6 +- src/linalg/inverse.rs | 6 +- src/linalg/lu.rs | 28 +-- src/linalg/permutation_sequence.rs | 14 +- src/linalg/pow.rs | 4 +- src/linalg/qr.rs | 24 +-- src/linalg/schur.rs | 30 ++- src/linalg/solve.rs | 24 +-- src/linalg/svd.rs | 120 ++++++------ src/linalg/symmetric_eigen.rs | 28 ++- src/linalg/symmetric_tridiagonal.rs | 22 +-- src/linalg/udu.rs | 6 +- src/proptest/mod.rs | 16 +- src/sparse/cs_matrix.rs | 24 +-- src/sparse/cs_matrix_cholesky.rs | 4 +- src/sparse/cs_matrix_conversion.rs | 6 +- src/sparse/cs_matrix_ops.rs | 6 +- src/sparse/cs_matrix_solve.rs | 10 +- src/sparse/cs_utils.rs | 2 +- src/third_party/alga/alga_matrix.rs | 34 ++-- src/third_party/alga/alga_transform.rs | 20 +- src/third_party/mint/mint_matrix.rs | 6 +- tests/core/matrix.rs | 4 +- tests/linalg/eigen.rs | 4 +- tests/proptest/mod.rs | 4 +- 92 files changed, 943 insertions(+), 1032 deletions(-) diff --git a/examples/dimensional_genericity.rs b/examples/dimensional_genericity.rs index e3c4fb5c..9e4811af 100644 --- a/examples/dimensional_genericity.rs +++ b/examples/dimensional_genericity.rs @@ -12,7 +12,7 @@ fn reflect_wrt_hyperplane_with_dimensional_genericity( where T: RealField, D: Dim, - DefaultAllocator: Allocator, + DefaultAllocator: Allocator, { let n = plane_normal.as_ref(); // Get the underlying V. vector - n * (n.dot(vector) * na::convert(2.0)) diff --git a/nalgebra-lapack/Cargo.toml b/nalgebra-lapack/Cargo.toml index 95153a2c..1dae6e53 100644 --- a/nalgebra-lapack/Cargo.toml +++ b/nalgebra-lapack/Cargo.toml @@ -1,15 +1,15 @@ [package] -name = "nalgebra-lapack" +name = "nalgebra-lapack" version = "0.24.0" -authors = [ "Sébastien Crozet ", "Andrew Straw " ] +authors = ["Sébastien Crozet ", "Andrew Straw "] -description = "Matrix decompositions using nalgebra matrices and Lapack bindings." +description = "Matrix decompositions using nalgebra matrices and Lapack bindings." documentation = "https://www.nalgebra.org/docs" homepage = "https://nalgebra.org" repository = "https://github.com/dimforge/nalgebra" readme = "../README.md" -categories = [ "science", "mathematics" ] -keywords = [ "linear", "algebra", "matrix", "vector", "lapack" ] +categories = ["science", "mathematics"] +keywords = ["linear", "algebra", "matrix", "vector", "lapack"] license = "MIT" edition = "2018" @@ -17,31 +17,31 @@ edition = "2018" maintenance = { status = "actively-developed" } [features] -serde-serialize = [ "serde", "nalgebra/serde-serialize" ] -proptest-support = [ "nalgebra/proptest-support" ] -arbitrary = [ "nalgebra/arbitrary" ] +serde-serialize = ["serde", "nalgebra/serde-serialize"] +proptest-support = ["nalgebra/proptest-support"] +arbitrary = ["nalgebra/arbitrary"] # For BLAS/LAPACK -default = ["netlib"] -openblas = ["lapack-src/openblas"] -netlib = ["lapack-src/netlib"] +default = ["netlib"] +openblas = ["lapack-src/openblas"] +netlib = ["lapack-src/netlib"] accelerate = ["lapack-src/accelerate"] -intel-mkl = ["lapack-src/intel-mkl"] +intel-mkl = ["lapack-src/intel-mkl"] [dependencies] -nalgebra = { version = "0.32", path = ".." } -num-traits = "0.2" -num-complex = { version = "0.4", default-features = false } -simba = "0.8" -serde = { version = "1.0", features = [ "derive" ], optional = true } -lapack = { version = "0.19", default-features = false } -lapack-src = { version = "0.8", default-features = false } +nalgebra = { version = "0.32", path = ".." } +num-traits = "0.2" +num-complex = { version = "0.4", default-features = false } +simba = "0.8" +serde = { version = "1.0", features = ["derive"], optional = true } +lapack = { version = "0.19", default-features = false } +lapack-src = { version = "0.8", default-features = false } # clippy = "*" [dev-dependencies] -nalgebra = { version = "0.32", features = [ "arbitrary", "rand" ], path = ".." } -proptest = { version = "1", default-features = false, features = ["std"] } +nalgebra = { version = "0.32", features = ["arbitrary", "rand"], path = ".." } +proptest = { version = "1", default-features = false, features = ["std"] } quickcheck = "1" -approx = "0.5" -rand = "0.8" +approx = "0.5" +rand = "0.8" diff --git a/nalgebra-lapack/src/cholesky.rs b/nalgebra-lapack/src/cholesky.rs index bc3515a5..462cdddb 100644 --- a/nalgebra-lapack/src/cholesky.rs +++ b/nalgebra-lapack/src/cholesky.rs @@ -15,32 +15,32 @@ use lapack; #[cfg_attr(feature = "serde-serialize", derive(Serialize, Deserialize))] #[cfg_attr( feature = "serde-serialize", - serde(bound(serialize = "DefaultAllocator: Allocator, + serde(bound(serialize = "DefaultAllocator: Allocator, OMatrix: Serialize")) )] #[cfg_attr( feature = "serde-serialize", - serde(bound(deserialize = "DefaultAllocator: Allocator, + serde(bound(deserialize = "DefaultAllocator: Allocator, OMatrix: Deserialize<'de>")) )] #[derive(Clone, Debug)] pub struct Cholesky where - DefaultAllocator: Allocator, + DefaultAllocator: Allocator, { l: OMatrix, } impl Copy for Cholesky where - DefaultAllocator: Allocator, + DefaultAllocator: Allocator, OMatrix: Copy, { } impl Cholesky where - DefaultAllocator: Allocator, + DefaultAllocator: Allocator, { /// Computes the cholesky decomposition of the given symmetric-definite-positive square /// matrix. @@ -105,7 +105,7 @@ where ) -> Option> where S2: Storage, - DefaultAllocator: Allocator, + DefaultAllocator: Allocator, { let mut res = b.clone_owned(); if self.solve_mut(&mut res) { @@ -119,7 +119,7 @@ where /// the unknown to be determined. pub fn solve_mut(&self, b: &mut OMatrix) -> bool where - DefaultAllocator: Allocator, + DefaultAllocator: Allocator, { let dim = self.l.nrows(); diff --git a/nalgebra-lapack/src/eigen.rs b/nalgebra-lapack/src/eigen.rs index 586c372f..6ccf8804 100644 --- a/nalgebra-lapack/src/eigen.rs +++ b/nalgebra-lapack/src/eigen.rs @@ -16,24 +16,20 @@ use lapack; #[cfg_attr(feature = "serde-serialize", derive(Serialize, Deserialize))] #[cfg_attr( feature = "serde-serialize", - serde( - bound(serialize = "DefaultAllocator: Allocator + Allocator, + serde(bound(serialize = "DefaultAllocator: Allocator + Allocator, OVector: Serialize, - OMatrix: Serialize") - ) + OMatrix: Serialize")) )] #[cfg_attr( feature = "serde-serialize", - serde( - bound(deserialize = "DefaultAllocator: Allocator + Allocator, + serde(bound(deserialize = "DefaultAllocator: Allocator + Allocator, OVector: Serialize, - OMatrix: Deserialize<'de>") - ) + OMatrix: Deserialize<'de>")) )] #[derive(Clone, Debug)] pub struct Eigen where - DefaultAllocator: Allocator + Allocator, + DefaultAllocator: Allocator + Allocator, { /// The real parts of eigenvalues of the decomposed matrix. pub eigenvalues_re: OVector, @@ -47,7 +43,7 @@ where impl Copy for Eigen where - DefaultAllocator: Allocator + Allocator, + DefaultAllocator: Allocator + Allocator, OVector: Copy, OMatrix: Copy, { @@ -55,7 +51,7 @@ where impl Eigen where - DefaultAllocator: Allocator + Allocator, + DefaultAllocator: Allocator + Allocator, { /// Computes the eigenvalues and eigenvectors of the square matrix `m`. /// @@ -177,7 +173,7 @@ where Option>>, ) where - DefaultAllocator: Allocator, + DefaultAllocator: Allocator, { let (number_of_elements, _) = self.eigenvalues_re.shape_generic(); let number_of_elements_value = number_of_elements.value(); @@ -234,7 +230,7 @@ where Option, D>>>, ) where - DefaultAllocator: Allocator, D>, + DefaultAllocator: Allocator, { match self.eigenvalues_are_real() { true => (None, None, None), diff --git a/nalgebra-lapack/src/generalized_eigenvalues.rs b/nalgebra-lapack/src/generalized_eigenvalues.rs index 5d1e3ace..33312868 100644 --- a/nalgebra-lapack/src/generalized_eigenvalues.rs +++ b/nalgebra-lapack/src/generalized_eigenvalues.rs @@ -30,24 +30,20 @@ use lapack; #[cfg_attr(feature = "serde-serialize", derive(Serialize, Deserialize))] #[cfg_attr( feature = "serde-serialize", - serde( - bound(serialize = "DefaultAllocator: Allocator + Allocator, + serde(bound(serialize = "DefaultAllocator: Allocator + Allocator, OVector: Serialize, - OMatrix: Serialize") - ) + OMatrix: Serialize")) )] #[cfg_attr( feature = "serde-serialize", - serde( - bound(deserialize = "DefaultAllocator: Allocator + Allocator, + serde(bound(deserialize = "DefaultAllocator: Allocator + Allocator, OVector: Deserialize<'de>, - OMatrix: Deserialize<'de>") - ) + OMatrix: Deserialize<'de>")) )] #[derive(Clone, Debug)] pub struct GeneralizedEigen where - DefaultAllocator: Allocator + Allocator, + DefaultAllocator: Allocator + Allocator, { alphar: OVector, alphai: OVector, @@ -58,7 +54,7 @@ where impl Copy for GeneralizedEigen where - DefaultAllocator: Allocator + Allocator, + DefaultAllocator: Allocator + Allocator, OMatrix: Copy, OVector: Copy, { @@ -66,7 +62,7 @@ where impl GeneralizedEigen where - DefaultAllocator: Allocator + Allocator, + DefaultAllocator: Allocator + Allocator, { /// Attempts to compute the generalized eigenvalues, and left and right associated eigenvectors /// via the raw returns from LAPACK's dggev and sggev routines @@ -162,8 +158,7 @@ where /// as columns. pub fn eigenvectors(&self) -> (OMatrix, D, D>, OMatrix, D, D>) where - DefaultAllocator: - Allocator, D, D> + Allocator, D> + Allocator<(Complex, T), D>, + DefaultAllocator: Allocator + Allocator, { /* How the eigenvectors are built up: @@ -230,7 +225,7 @@ where #[must_use] pub fn raw_eigenvalues(&self) -> OVector<(Complex, T), D> where - DefaultAllocator: Allocator<(Complex, T), D>, + DefaultAllocator: Allocator, { let mut out = Matrix::from_element_generic( self.vsl.shape_generic().0, diff --git a/nalgebra-lapack/src/hessenberg.rs b/nalgebra-lapack/src/hessenberg.rs index e05349d9..80117afd 100644 --- a/nalgebra-lapack/src/hessenberg.rs +++ b/nalgebra-lapack/src/hessenberg.rs @@ -12,22 +12,22 @@ use lapack; #[cfg_attr(feature = "serde-serialize", derive(Serialize, Deserialize))] #[cfg_attr( feature = "serde-serialize", - serde(bound(serialize = "DefaultAllocator: Allocator + - Allocator>, + serde(bound(serialize = "DefaultAllocator: Allocator + + Allocator>, OMatrix: Serialize, OVector>: Serialize")) )] #[cfg_attr( feature = "serde-serialize", - serde(bound(deserialize = "DefaultAllocator: Allocator + - Allocator>, + serde(bound(deserialize = "DefaultAllocator: Allocator + + Allocator>, OMatrix: Deserialize<'de>, OVector>: Deserialize<'de>")) )] #[derive(Clone, Debug)] pub struct Hessenberg> where - DefaultAllocator: Allocator + Allocator>, + DefaultAllocator: Allocator + Allocator>, { h: OMatrix, tau: OVector>, @@ -35,7 +35,7 @@ where impl> Copy for Hessenberg where - DefaultAllocator: Allocator + Allocator>, + DefaultAllocator: Allocator + Allocator>, OMatrix: Copy, OVector>: Copy, { @@ -43,7 +43,7 @@ where impl> Hessenberg where - DefaultAllocator: Allocator + Allocator>, + DefaultAllocator: Allocator + Allocator>, { /// Computes the hessenberg decomposition of the matrix `m`. pub fn new(mut m: OMatrix) -> Self { @@ -97,7 +97,7 @@ where impl> Hessenberg where - DefaultAllocator: Allocator + Allocator>, + DefaultAllocator: Allocator + Allocator>, { /// Computes the matrices `(Q, H)` of this decomposition. #[inline] diff --git a/nalgebra-lapack/src/lu.rs b/nalgebra-lapack/src/lu.rs index 7540c75e..f38e675c 100644 --- a/nalgebra-lapack/src/lu.rs +++ b/nalgebra-lapack/src/lu.rs @@ -20,22 +20,22 @@ use lapack; #[cfg_attr(feature = "serde-serialize", derive(Serialize, Deserialize))] #[cfg_attr( feature = "serde-serialize", - serde(bound(serialize = "DefaultAllocator: Allocator + - Allocator>, + serde(bound(serialize = "DefaultAllocator: Allocator + + Allocator>, OMatrix: Serialize, PermutationSequence>: Serialize")) )] #[cfg_attr( feature = "serde-serialize", - serde(bound(deserialize = "DefaultAllocator: Allocator + - Allocator>, + serde(bound(deserialize = "DefaultAllocator: Allocator + + Allocator>, OMatrix: Deserialize<'de>, PermutationSequence>: Deserialize<'de>")) )] #[derive(Clone, Debug)] pub struct LU, C: Dim> where - DefaultAllocator: Allocator> + Allocator, + DefaultAllocator: Allocator> + Allocator, { lu: OMatrix, p: OVector>, @@ -43,7 +43,7 @@ where impl, C: Dim> Copy for LU where - DefaultAllocator: Allocator + Allocator>, + DefaultAllocator: Allocator + Allocator>, OMatrix: Copy, OVector>: Copy, { @@ -53,11 +53,11 @@ impl LU where T: Zero + One, R: DimMin, - DefaultAllocator: Allocator - + Allocator - + Allocator> - + Allocator, C> - + Allocator>, + DefaultAllocator: Allocator + + Allocator + + Allocator> + + Allocator, C> + + Allocator>, { /// Computes the LU decomposition with partial (row) pivoting of `matrix`. pub fn new(mut m: OMatrix) -> Self { @@ -136,7 +136,7 @@ where #[inline] pub fn permute(&self, rhs: &mut OMatrix) where - DefaultAllocator: Allocator, + DefaultAllocator: Allocator, { let (nrows, ncols) = rhs.shape(); @@ -153,7 +153,7 @@ where fn generic_solve_mut(&self, trans: u8, b: &mut OMatrix) -> bool where - DefaultAllocator: Allocator + Allocator, + DefaultAllocator: Allocator + Allocator, { let dim = self.lu.nrows(); @@ -192,7 +192,7 @@ where ) -> Option> where S2: Storage, - DefaultAllocator: Allocator + Allocator, + DefaultAllocator: Allocator + Allocator, { let mut res = b.clone_owned(); if self.generic_solve_mut(b'T', &mut res) { @@ -210,7 +210,7 @@ where ) -> Option> where S2: Storage, - DefaultAllocator: Allocator + Allocator, + DefaultAllocator: Allocator + Allocator, { let mut res = b.clone_owned(); if self.generic_solve_mut(b'T', &mut res) { @@ -228,7 +228,7 @@ where ) -> Option> where S2: Storage, - DefaultAllocator: Allocator + Allocator, + DefaultAllocator: Allocator + Allocator, { let mut res = b.clone_owned(); if self.generic_solve_mut(b'T', &mut res) { @@ -243,7 +243,7 @@ where /// Returns `false` if no solution was found (the decomposed matrix is singular). pub fn solve_mut(&self, b: &mut OMatrix) -> bool where - DefaultAllocator: Allocator + Allocator, + DefaultAllocator: Allocator + Allocator, { self.generic_solve_mut(b'T', b) } @@ -254,7 +254,7 @@ where /// Returns `false` if no solution was found (the decomposed matrix is singular). pub fn solve_transpose_mut(&self, b: &mut OMatrix) -> bool where - DefaultAllocator: Allocator + Allocator, + DefaultAllocator: Allocator + Allocator, { self.generic_solve_mut(b'T', b) } @@ -265,7 +265,7 @@ where /// Returns `false` if no solution was found (the decomposed matrix is singular). pub fn solve_adjoint_mut(&self, b: &mut OMatrix) -> bool where - DefaultAllocator: Allocator + Allocator, + DefaultAllocator: Allocator + Allocator, { self.generic_solve_mut(b'T', b) } @@ -275,7 +275,7 @@ impl LU where T: Zero + One, D: DimMin, - DefaultAllocator: Allocator + Allocator, + DefaultAllocator: Allocator + Allocator, { /// Computes the inverse of the decomposed matrix. pub fn inverse(mut self) -> Option> { diff --git a/nalgebra-lapack/src/qr.rs b/nalgebra-lapack/src/qr.rs index ade2e452..40464215 100644 --- a/nalgebra-lapack/src/qr.rs +++ b/nalgebra-lapack/src/qr.rs @@ -15,22 +15,22 @@ use lapack; #[cfg_attr(feature = "serde-serialize", derive(Serialize, Deserialize))] #[cfg_attr( feature = "serde-serialize", - serde(bound(serialize = "DefaultAllocator: Allocator + - Allocator>, + serde(bound(serialize = "DefaultAllocator: Allocator + + Allocator>, OMatrix: Serialize, OVector>: Serialize")) )] #[cfg_attr( feature = "serde-serialize", - serde(bound(deserialize = "DefaultAllocator: Allocator + - Allocator>, + serde(bound(deserialize = "DefaultAllocator: Allocator + + Allocator>, OMatrix: Deserialize<'de>, OVector>: Deserialize<'de>")) )] #[derive(Clone, Debug)] pub struct QR, C: Dim> where - DefaultAllocator: Allocator + Allocator>, + DefaultAllocator: Allocator + Allocator>, { qr: OMatrix, tau: OVector>, @@ -38,7 +38,7 @@ where impl, C: Dim> Copy for QR where - DefaultAllocator: Allocator + Allocator>, + DefaultAllocator: Allocator + Allocator>, OMatrix: Copy, OVector>: Copy, { @@ -46,10 +46,10 @@ where impl, C: Dim> QR where - DefaultAllocator: Allocator - + Allocator> - + Allocator, C> - + Allocator>, + DefaultAllocator: Allocator + + Allocator> + + Allocator, C> + + Allocator>, { /// Computes the QR decomposition of the matrix `m`. pub fn new(mut m: OMatrix) -> Self { @@ -98,10 +98,10 @@ where impl, C: Dim> QR where - DefaultAllocator: Allocator - + Allocator> - + Allocator, C> - + Allocator>, + DefaultAllocator: Allocator + + Allocator> + + Allocator, C> + + Allocator>, { /// Retrieves the matrices `(Q, R)` of this decompositions. pub fn unpack( diff --git a/nalgebra-lapack/src/qz.rs b/nalgebra-lapack/src/qz.rs index 99f3c374..ec113e97 100644 --- a/nalgebra-lapack/src/qz.rs +++ b/nalgebra-lapack/src/qz.rs @@ -22,24 +22,20 @@ use lapack; #[cfg_attr(feature = "serde-serialize", derive(Serialize, Deserialize))] #[cfg_attr( feature = "serde-serialize", - serde( - bound(serialize = "DefaultAllocator: Allocator + Allocator, + serde(bound(serialize = "DefaultAllocator: Allocator + Allocator, OVector: Serialize, - OMatrix: Serialize") - ) + OMatrix: Serialize")) )] #[cfg_attr( feature = "serde-serialize", - serde( - bound(deserialize = "DefaultAllocator: Allocator + Allocator, + serde(bound(deserialize = "DefaultAllocator: Allocator + Allocator, OVector: Deserialize<'de>, - OMatrix: Deserialize<'de>") - ) + OMatrix: Deserialize<'de>")) )] #[derive(Clone, Debug)] pub struct QZ where - DefaultAllocator: Allocator + Allocator, + DefaultAllocator: Allocator + Allocator, { alphar: OVector, alphai: OVector, @@ -52,7 +48,7 @@ where impl Copy for QZ where - DefaultAllocator: Allocator + Allocator, + DefaultAllocator: Allocator + Allocator, OMatrix: Copy, OVector: Copy, { @@ -60,7 +56,7 @@ where impl QZ where - DefaultAllocator: Allocator + Allocator, + DefaultAllocator: Allocator + Allocator, { /// Attempts to compute the QZ decomposition of input real square matrices `a` and `b`. /// @@ -182,7 +178,7 @@ where #[must_use] pub fn raw_eigenvalues(&self) -> OVector<(Complex, T), D> where - DefaultAllocator: Allocator<(Complex, T), D>, + DefaultAllocator: Allocator, { let mut out = Matrix::from_element_generic( self.vsl.shape_generic().0, diff --git a/nalgebra-lapack/src/schur.rs b/nalgebra-lapack/src/schur.rs index 52f5dced..1cc486f9 100644 --- a/nalgebra-lapack/src/schur.rs +++ b/nalgebra-lapack/src/schur.rs @@ -17,24 +17,20 @@ use lapack; #[cfg_attr(feature = "serde-serialize", derive(Serialize, Deserialize))] #[cfg_attr( feature = "serde-serialize", - serde( - bound(serialize = "DefaultAllocator: Allocator + Allocator, + serde(bound(serialize = "DefaultAllocator: Allocator + Allocator, OVector: Serialize, - OMatrix: Serialize") - ) + OMatrix: Serialize")) )] #[cfg_attr( feature = "serde-serialize", - serde( - bound(deserialize = "DefaultAllocator: Allocator + Allocator, + serde(bound(deserialize = "DefaultAllocator: Allocator + Allocator, OVector: Serialize, - OMatrix: Deserialize<'de>") - ) + OMatrix: Deserialize<'de>")) )] #[derive(Clone, Debug)] pub struct Schur where - DefaultAllocator: Allocator + Allocator, + DefaultAllocator: Allocator + Allocator, { re: OVector, im: OVector, @@ -44,7 +40,7 @@ where impl Copy for Schur where - DefaultAllocator: Allocator + Allocator, + DefaultAllocator: Allocator + Allocator, OMatrix: Copy, OVector: Copy, { @@ -52,7 +48,7 @@ where impl Schur where - DefaultAllocator: Allocator + Allocator, + DefaultAllocator: Allocator + Allocator, { /// Computes the eigenvalues and real Schur form of the matrix `m`. /// @@ -150,7 +146,7 @@ where #[must_use] pub fn complex_eigenvalues(&self) -> OVector, D> where - DefaultAllocator: Allocator, D>, + DefaultAllocator: Allocator, { let mut out = Matrix::zeros_generic(self.t.shape_generic().0, Const::<1>); diff --git a/nalgebra-lapack/src/svd.rs b/nalgebra-lapack/src/svd.rs index 804284d9..1d2f2e24 100644 --- a/nalgebra-lapack/src/svd.rs +++ b/nalgebra-lapack/src/svd.rs @@ -14,18 +14,18 @@ use lapack; #[cfg_attr(feature = "serde-serialize", derive(Serialize, Deserialize))] #[cfg_attr( feature = "serde-serialize", - serde(bound(serialize = "DefaultAllocator: Allocator> + - Allocator + - Allocator, + serde(bound(serialize = "DefaultAllocator: Allocator> + + Allocator + + Allocator, OMatrix: Serialize, OMatrix: Serialize, OVector>: Serialize")) )] #[cfg_attr( feature = "serde-serialize", - serde(bound(serialize = "DefaultAllocator: Allocator> + - Allocator + - Allocator, + serde(bound(serialize = "DefaultAllocator: Allocator> + + Allocator + + Allocator, OMatrix: Deserialize<'de>, OMatrix: Deserialize<'de>, OVector>: Deserialize<'de>")) @@ -33,7 +33,7 @@ use lapack; #[derive(Clone, Debug)] pub struct SVD, C: Dim> where - DefaultAllocator: Allocator + Allocator> + Allocator, + DefaultAllocator: Allocator + Allocator> + Allocator, { /// The left-singular vectors `U` of this SVD. pub u: OMatrix, // TODO: should be OMatrix> @@ -45,7 +45,7 @@ where impl, C: Dim> Copy for SVD where - DefaultAllocator: Allocator + Allocator + Allocator>, + DefaultAllocator: Allocator + Allocator + Allocator>, OMatrix: Copy, OMatrix: Copy, OVector>: Copy, @@ -56,10 +56,8 @@ where /// supported by the Singular Value Decompotition. pub trait SVDScalar, C: Dim>: Scalar where - DefaultAllocator: Allocator - + Allocator - + Allocator> - + Allocator, + DefaultAllocator: + Allocator + Allocator + Allocator> + Allocator, { /// Computes the SVD decomposition of `m`. fn compute(m: OMatrix) -> Option>; @@ -67,10 +65,8 @@ where impl, R: DimMin, C: Dim> SVD where - DefaultAllocator: Allocator - + Allocator - + Allocator> - + Allocator, + DefaultAllocator: + Allocator + Allocator + Allocator> + Allocator, { /// Computes the Singular Value Decomposition of `matrix`. pub fn new(m: OMatrix) -> Option { @@ -82,10 +78,10 @@ macro_rules! svd_impl( ($t: ty, $lapack_func: path) => ( impl SVDScalar for $t where R: DimMin, - DefaultAllocator: Allocator<$t, R, C> + - Allocator<$t, R, R> + - Allocator<$t, C, C> + - Allocator<$t, DimMinimum> { + DefaultAllocator: Allocator + + Allocator + + Allocator + + Allocator> { fn compute(mut m: OMatrix<$t, R, C>) -> Option> { let (nrows, ncols) = m.shape_generic(); @@ -134,16 +130,16 @@ macro_rules! svd_impl( impl, C: Dim> SVD<$t, R, C> // TODO: All those bounds… - where DefaultAllocator: Allocator<$t, R, C> + - Allocator<$t, C, R> + - Allocator<$t, U1, R> + - Allocator<$t, U1, C> + - Allocator<$t, R, R> + - Allocator<$t, DimMinimum> + - Allocator<$t, DimMinimum, R> + - Allocator<$t, DimMinimum, C> + - Allocator<$t, R, DimMinimum> + - Allocator<$t, C, C> { + where DefaultAllocator: Allocator + + Allocator + + Allocator + + Allocator + + Allocator + + Allocator> + + Allocator, R> + + Allocator, C> + + Allocator> + + Allocator { /// Reconstructs the matrix from its decomposition. /// /// Useful if some components (e.g. some singular values) of this decomposition have @@ -237,9 +233,9 @@ macro_rules! svd_complex_impl( where R: DimMin, S: ContiguousStorage, R, C>, S::Alloc: OwnedAllocator, R, C, S> + - Allocator, R, R> + - Allocator, C, C> + - Allocator<$t, DimMinimum> { + Allocator + + Allocator + + Allocator> { let (nrows, ncols) = m.shape_generic(); if nrows.value() == 0 || ncols.value() == 0 { diff --git a/nalgebra-lapack/src/symmetric_eigen.rs b/nalgebra-lapack/src/symmetric_eigen.rs index 0a4b09ce..6fda636c 100644 --- a/nalgebra-lapack/src/symmetric_eigen.rs +++ b/nalgebra-lapack/src/symmetric_eigen.rs @@ -17,22 +17,22 @@ use lapack; #[cfg_attr(feature = "serde-serialize", derive(Serialize, Deserialize))] #[cfg_attr( feature = "serde-serialize", - serde(bound(serialize = "DefaultAllocator: Allocator + - Allocator, + serde(bound(serialize = "DefaultAllocator: Allocator + + Allocator, OVector: Serialize, OMatrix: Serialize")) )] #[cfg_attr( feature = "serde-serialize", - serde(bound(deserialize = "DefaultAllocator: Allocator + - Allocator, + serde(bound(deserialize = "DefaultAllocator: Allocator + + Allocator, OVector: Deserialize<'de>, OMatrix: Deserialize<'de>")) )] #[derive(Clone, Debug)] pub struct SymmetricEigen where - DefaultAllocator: Allocator + Allocator, + DefaultAllocator: Allocator + Allocator, { /// The eigenvectors of the decomposed matrix. pub eigenvectors: OMatrix, @@ -43,7 +43,7 @@ where impl Copy for SymmetricEigen where - DefaultAllocator: Allocator + Allocator, + DefaultAllocator: Allocator + Allocator, OMatrix: Copy, OVector: Copy, { @@ -51,7 +51,7 @@ where impl SymmetricEigen where - DefaultAllocator: Allocator + Allocator, + DefaultAllocator: Allocator + Allocator, { /// Computes the eigenvalues and eigenvectors of the symmetric matrix `m`. /// diff --git a/nalgebra-sparse/src/ops/impl_std_ops.rs b/nalgebra-sparse/src/ops/impl_std_ops.rs index 63b6d22c..c0e8f4a4 100644 --- a/nalgebra-sparse/src/ops/impl_std_ops.rs +++ b/nalgebra-sparse/src/ops/impl_std_ops.rs @@ -302,13 +302,13 @@ 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>::Buffer as RawStorage>::RStride> + DimEq - + DimEq>::Buffer as RawStorage>::CStride> + + DimEq>::Buffer as RawStorage>::CStride> // Bounds so that we can turn &Matrix into a DMatrixSlice + DimEq + DimEq diff --git a/src/base/allocator.rs b/src/base/allocator.rs index 10c4bd31..07304b2d 100644 --- a/src/base/allocator.rs +++ b/src/base/allocator.rs @@ -19,36 +19,36 @@ use std::mem::MaybeUninit; /// /// Every allocator must be both static and dynamic. Though not all implementations may share the /// same `Buffer` type. -pub trait Allocator: Any + Sized { +pub trait Allocator: Any + Sized { /// The type of buffer this allocator can instantiate. - type Buffer: StorageMut + IsContiguous + Clone + Debug; + type Buffer: StorageMut + IsContiguous + Clone + Debug; /// The type of buffer with uninitialized components this allocator can instantiate. - type BufferUninit: RawStorageMut, R, C> + IsContiguous; + type BufferUninit: RawStorageMut, R, C> + IsContiguous; /// Allocates a buffer with the given number of rows and columns without initializing its content. - fn allocate_uninit(nrows: R, ncols: C) -> Self::BufferUninit; + fn allocate_uninit(nrows: R, ncols: C) -> Self::BufferUninit; /// Assumes a data buffer to be initialized. /// /// # Safety /// The user must make sure that every single entry of the buffer has been initialized, /// or Undefined Behavior will immediately occur. - unsafe fn assume_init(uninit: Self::BufferUninit) -> Self::Buffer; + unsafe fn assume_init(uninit: Self::BufferUninit) -> Self::Buffer; /// Allocates a buffer initialized with the content of the given iterator. - fn allocate_from_iterator>( + fn allocate_from_iterator>( nrows: R, ncols: C, iter: I, - ) -> Self::Buffer; + ) -> Self::Buffer; #[inline] /// Allocates a buffer initialized with the content of the given row-major order iterator. - fn allocate_from_row_iterator>( + fn allocate_from_row_iterator>( nrows: R, ncols: C, iter: I, - ) -> Self::Buffer { + ) -> Self::Buffer { let mut res = Self::allocate_uninit(nrows, ncols); let mut count = 0; @@ -73,7 +73,7 @@ pub trait Allocator: Any + Sized { "Matrix init. from row iterator: iterator not long enough." ); - >::assume_init(res) + >::assume_init(res) } } } @@ -81,7 +81,7 @@ pub trait Allocator: Any + Sized { /// A matrix reallocator. Changes the size of the memory buffer that initially contains (`RFrom` × /// `CFrom`) elements to a smaller or larger size (`RTo`, `CTo`). pub trait Reallocator: - Allocator + Allocator + Allocator + Allocator { /// Reallocates a buffer of shape `(RTo, CTo)`, possibly reusing a previously allocated buffer /// `buf`. Data stored by `buf` are linearly copied to the output: @@ -94,8 +94,8 @@ pub trait Reallocator: unsafe fn reallocate_copy( nrows: RTo, ncols: CTo, - buf: >::Buffer, - ) -> >::BufferUninit; + buf: >::Buffer, + ) -> >::BufferUninit; } /// The number of rows of the result of a componentwise operation on two matrices. @@ -106,8 +106,8 @@ pub type SameShapeC = >:: // TODO: Bad name. /// Restricts the given number of rows and columns to be respectively the same. -pub trait SameShapeAllocator: - Allocator + Allocator, SameShapeC> +pub trait SameShapeAllocator: + Allocator + Allocator, SameShapeC> where R1: Dim, R2: Dim, @@ -117,21 +117,21 @@ where { } -impl SameShapeAllocator for DefaultAllocator +impl SameShapeAllocator for DefaultAllocator where R1: Dim, R2: Dim, C1: Dim, C2: Dim, - DefaultAllocator: Allocator + Allocator, SameShapeC>, + DefaultAllocator: Allocator + Allocator, SameShapeC>, ShapeConstraint: SameNumberOfRows + SameNumberOfColumns, { } // XXX: Bad name. /// Restricts the given number of rows to be equal. -pub trait SameShapeVectorAllocator: - Allocator + Allocator> + SameShapeAllocator +pub trait SameShapeVectorAllocator: + Allocator + Allocator> + SameShapeAllocator where R1: Dim, R2: Dim, @@ -139,11 +139,11 @@ where { } -impl SameShapeVectorAllocator for DefaultAllocator +impl SameShapeVectorAllocator for DefaultAllocator where R1: Dim, R2: Dim, - DefaultAllocator: Allocator + Allocator>, + DefaultAllocator: Allocator + Allocator>, ShapeConstraint: SameNumberOfRows, { } diff --git a/src/base/array_storage.rs b/src/base/array_storage.rs index 4ac738a1..ccb1bb45 100644 --- a/src/base/array_storage.rs +++ b/src/base/array_storage.rs @@ -113,12 +113,12 @@ unsafe impl RawStorage, Const> unsafe impl Storage, Const> for ArrayStorage where - DefaultAllocator: Allocator, Const, Buffer = Self>, + DefaultAllocator: Allocator, Const, Buffer = Self>, { #[inline] fn into_owned(self) -> Owned, Const> where - DefaultAllocator: Allocator, Const>, + DefaultAllocator: Allocator, Const>, { self } @@ -126,7 +126,7 @@ where #[inline] fn clone_owned(&self) -> Owned, Const> where - DefaultAllocator: Allocator, Const>, + DefaultAllocator: Allocator, Const>, { self.clone() } @@ -250,7 +250,7 @@ where V: SeqAccess<'a>, { let mut out: ArrayStorage, R, C> = - DefaultAllocator::allocate_uninit(Const::, Const::); + >::allocate_uninit(Const::, Const::); let mut curr = 0; while let Some(value) = visitor.next_element()? { @@ -263,7 +263,7 @@ where if curr == R * C { // Safety: all the elements have been initialized. - unsafe { Ok(, Const>>::assume_init(out)) } + unsafe { Ok(, Const>>::assume_init(out)) } } else { for i in 0..curr { // Safety: diff --git a/src/base/blas.rs b/src/base/blas.rs index e5741568..ccf76dc6 100644 --- a/src/base/blas.rs +++ b/src/base/blas.rs @@ -1098,7 +1098,7 @@ where S3: Storage, S4: Storage, ShapeConstraint: DimEq + DimEq + DimEq, - DefaultAllocator: Allocator, + DefaultAllocator: Allocator, { // TODO: would it be useful to avoid the zero-initialization of the workspace data? let mut work = Matrix::zeros_generic(self.shape_generic().0, Const::<1>); @@ -1196,7 +1196,7 @@ where S2: Storage, S3: Storage, ShapeConstraint: DimEq + DimEq + AreMultipliable, - DefaultAllocator: Allocator, + DefaultAllocator: Allocator, { // TODO: would it be useful to avoid the zero-initialization of the workspace data? let mut work = Vector::zeros_generic(mid.shape_generic().0, Const::<1>); diff --git a/src/base/cg.rs b/src/base/cg.rs index 586c923e..872e7f36 100644 --- a/src/base/cg.rs +++ b/src/base/cg.rs @@ -25,7 +25,7 @@ use simba::scalar::{ClosedAdd, ClosedMul, RealField}; impl OMatrix where T: Scalar + Zero + One, - DefaultAllocator: Allocator, + DefaultAllocator: Allocator, { /// Creates a new homogeneous matrix that applies the same scaling factor on each dimension. #[inline] @@ -216,7 +216,7 @@ impl OMatrix where D: DimNameSub, - DefaultAllocator: Allocator, + DefaultAllocator: Allocator, { let mut res = self.clone_owned(); res.append_scaling_mut(scaling); @@ -229,7 +229,7 @@ impl OMatrix where D: DimNameSub, - DefaultAllocator: Allocator, + DefaultAllocator: Allocator, { let mut res = self.clone_owned(); res.prepend_scaling_mut(scaling); @@ -246,7 +246,7 @@ impl, SB: Storage>, - DefaultAllocator: Allocator, + DefaultAllocator: Allocator, { let mut res = self.clone_owned(); res.append_nonuniform_scaling_mut(scaling); @@ -263,7 +263,7 @@ impl, SB: Storage>, - DefaultAllocator: Allocator, + DefaultAllocator: Allocator, { let mut res = self.clone_owned(); res.prepend_nonuniform_scaling_mut(scaling); @@ -280,7 +280,7 @@ impl, SB: Storage>, - DefaultAllocator: Allocator, + DefaultAllocator: Allocator, { let mut res = self.clone_owned(); res.append_translation_mut(shift); @@ -297,7 +297,7 @@ impl, SB: Storage>, - DefaultAllocator: Allocator + Allocator>, + DefaultAllocator: Allocator + Allocator>, { let mut res = self.clone_owned(); res.prepend_translation_mut(shift); @@ -379,7 +379,7 @@ impl, S: StorageMut, SB: Storage>, - DefaultAllocator: Allocator>, + DefaultAllocator: Allocator>, { let scale = self .generic_view( @@ -405,9 +405,9 @@ impl, S: Storage> SquareMatrix where - DefaultAllocator: Allocator - + Allocator> - + Allocator, DimNameDiff>, + DefaultAllocator: Allocator + + Allocator> + + Allocator, DimNameDiff>, { /// Transforms the given vector, assuming the matrix `self` uses homogeneous coordinates. #[inline] diff --git a/src/base/componentwise.rs b/src/base/componentwise.rs index dad4d5b2..cabf6ddf 100644 --- a/src/base/componentwise.rs +++ b/src/base/componentwise.rs @@ -32,7 +32,7 @@ impl> Matrix { pub fn abs(&self) -> OMatrix where T: Signed, - DefaultAllocator: Allocator, + DefaultAllocator: Allocator, { let mut res = self.clone_owned(); @@ -55,7 +55,7 @@ macro_rules! component_binop_impl( where T: $Trait, R2: Dim, C2: Dim, SB: Storage, - DefaultAllocator: SameShapeAllocator, + DefaultAllocator: SameShapeAllocator, ShapeConstraint: SameNumberOfRows + SameNumberOfColumns { assert_eq!(self.shape(), rhs.shape(), "Componentwise mul/div: mismatched matrix dimensions."); @@ -257,7 +257,7 @@ impl> Matrix pub fn inf(&self, other: &Self) -> OMatrix where T: SimdPartialOrd, - DefaultAllocator: Allocator, + DefaultAllocator: Allocator, { self.zip_map(other, |a, b| a.simd_min(b)) } @@ -278,7 +278,7 @@ impl> Matrix pub fn sup(&self, other: &Self) -> OMatrix where T: SimdPartialOrd, - DefaultAllocator: Allocator, + DefaultAllocator: Allocator, { self.zip_map(other, |a, b| a.simd_max(b)) } @@ -299,7 +299,7 @@ impl> Matrix pub fn inf_sup(&self, other: &Self) -> (OMatrix, OMatrix) where T: SimdPartialOrd, - DefaultAllocator: Allocator, + DefaultAllocator: Allocator, { // TODO: can this be optimized? (self.inf(other), self.sup(other)) @@ -321,7 +321,7 @@ impl> Matrix pub fn add_scalar(&self, rhs: T) -> OMatrix where T: ClosedAdd, - DefaultAllocator: Allocator, + DefaultAllocator: Allocator, { let mut res = self.clone_owned(); res.add_scalar_mut(rhs); diff --git a/src/base/construction.rs b/src/base/construction.rs index 43475179..571b278e 100644 --- a/src/base/construction.rs +++ b/src/base/construction.rs @@ -29,7 +29,7 @@ use std::mem::MaybeUninit; impl UninitMatrix where - DefaultAllocator: Allocator, + DefaultAllocator: Allocator, { /// Builds a matrix with uninitialized elements of type `MaybeUninit`. #[inline(always)] @@ -50,7 +50,7 @@ where /// These functions should only be used when working on dimension-generic code. impl OMatrix where - DefaultAllocator: Allocator, + DefaultAllocator: Allocator, { /// Creates a matrix with all its elements set to `elem`. #[inline] @@ -338,7 +338,7 @@ where impl OMatrix where T: Scalar, - DefaultAllocator: Allocator, + DefaultAllocator: Allocator, { /// Creates a square matrix with its diagonal set to `diag` and all other entries set to 0. /// @@ -646,7 +646,7 @@ macro_rules! impl_constructors( /// # Constructors of statically-sized vectors or statically-sized matrices impl OMatrix where - DefaultAllocator: Allocator, + DefaultAllocator: Allocator, { // TODO: this is not very pretty. We could find a better call syntax. impl_constructors!(R, C; // Arguments for Matrix @@ -658,7 +658,7 @@ where /// # Constructors of matrices with a dynamic number of columns impl OMatrix where - DefaultAllocator: Allocator, + DefaultAllocator: Allocator, { impl_constructors!(R, Dyn; => R: DimName; @@ -669,7 +669,7 @@ where /// # Constructors of dynamic vectors and matrices with a dynamic number of rows impl OMatrix where - DefaultAllocator: Allocator, + DefaultAllocator: Allocator, { impl_constructors!(Dyn, C; => C: DimName; @@ -678,9 +678,10 @@ where } /// # Constructors of fully dynamic matrices +#[cfg(any(feature = "std", feature = "alloc"))] impl OMatrix where - DefaultAllocator: Allocator, + DefaultAllocator: Allocator, { impl_constructors!(Dyn, Dyn; ; @@ -697,7 +698,7 @@ where macro_rules! impl_constructors_from_data( ($data: ident; $($Dims: ty),*; $(=> $DimIdent: ident: $DimBound: ident),*; $($gargs: expr),*; $($args: ident),*) => { impl OMatrix - where DefaultAllocator: Allocator { + where DefaultAllocator: Allocator<$($Dims),*> { /// Creates a matrix with its elements filled with the components provided by a slice /// in row-major order. /// @@ -800,6 +801,7 @@ impl_constructors_from_data!(data; Dyn, C; Dyn(data.len() / C::dim()), C::name(); ); +#[cfg(any(feature = "std", feature = "alloc"))] impl_constructors_from_data!(data; Dyn, Dyn; ; Dyn(nrows), Dyn(ncols); @@ -813,7 +815,7 @@ impl_constructors_from_data!(data; Dyn, Dyn; impl Zero for OMatrix where T: Scalar + Zero + ClosedAdd, - DefaultAllocator: Allocator, + DefaultAllocator: Allocator, { #[inline] fn zero() -> Self { @@ -829,7 +831,7 @@ where impl One for OMatrix where T: Scalar + Zero + One + ClosedMul + ClosedAdd, - DefaultAllocator: Allocator, + DefaultAllocator: Allocator, { #[inline] fn one() -> Self { @@ -840,7 +842,7 @@ where impl Bounded for OMatrix where T: Scalar + Bounded, - DefaultAllocator: Allocator, + DefaultAllocator: Allocator, { #[inline] fn max_value() -> Self { @@ -856,7 +858,7 @@ where #[cfg(feature = "rand-no-std")] impl Distribution> for Standard where - DefaultAllocator: Allocator, + DefaultAllocator: Allocator, Standard: Distribution, { #[inline] @@ -874,7 +876,7 @@ where R: Dim, C: Dim, T: Scalar + Arbitrary + Send, - DefaultAllocator: Allocator, + DefaultAllocator: Allocator, Owned: Clone + Send, { #[inline] @@ -892,7 +894,7 @@ where #[cfg(feature = "rand")] impl Distribution>> for Standard where - DefaultAllocator: Allocator, + DefaultAllocator: Allocator, rand_distr::StandardNormal: Distribution, { /// Generate a uniformly distributed random unit vector. @@ -1111,7 +1113,7 @@ impl OVector where R: ToTypenum, T: Scalar + Zero + One, - DefaultAllocator: Allocator, + DefaultAllocator: Allocator, { /// The column vector with `val` as its i-th component. #[inline] diff --git a/src/base/conversion.rs b/src/base/conversion.rs index 783e6d9e..b7bf533a 100644 --- a/src/base/conversion.rs +++ b/src/base/conversion.rs @@ -35,8 +35,7 @@ where C2: Dim, T1: Scalar, T2: Scalar + SupersetOf, - DefaultAllocator: - Allocator + Allocator + SameShapeAllocator, + DefaultAllocator: Allocator + Allocator + SameShapeAllocator, ShapeConstraint: SameNumberOfRows + SameNumberOfColumns, { #[inline] @@ -561,7 +560,7 @@ impl From<[OMatrix::Element; 2]>, T::Element: Scalar + SimdValue, - DefaultAllocator: Allocator + Allocator, + DefaultAllocator: Allocator, { #[inline] fn from(arr: [OMatrix; 2]) -> Self { @@ -578,7 +577,7 @@ impl From<[OMatrix::Element; 4]>, T::Element: Scalar + SimdValue, - DefaultAllocator: Allocator + Allocator, + DefaultAllocator: Allocator, { #[inline] fn from(arr: [OMatrix; 4]) -> Self { @@ -601,7 +600,7 @@ impl From<[OMatrix::Element; 8]>, T::Element: Scalar + SimdValue, - DefaultAllocator: Allocator + Allocator, + DefaultAllocator: Allocator, { #[inline] fn from(arr: [OMatrix; 8]) -> Self { @@ -628,7 +627,7 @@ impl From<[OMatrix::Element; 16]>, T::Element: Scalar + SimdValue, - DefaultAllocator: Allocator + Allocator, + DefaultAllocator: Allocator, { fn from(arr: [OMatrix; 16]) -> Self { let (nrows, ncols) = arr[0].shape_generic(); diff --git a/src/base/default_allocator.rs b/src/base/default_allocator.rs index 3c132413..97278b54 100644 --- a/src/base/default_allocator.rs +++ b/src/base/default_allocator.rs @@ -34,21 +34,21 @@ use std::mem::MaybeUninit; pub struct DefaultAllocator; // Static - Static -impl Allocator, Const> - for DefaultAllocator -{ - type Buffer = ArrayStorage; - type BufferUninit = ArrayStorage, R, C>; +impl Allocator, Const> for DefaultAllocator { + type Buffer = ArrayStorage; + type BufferUninit = ArrayStorage, R, C>; #[inline(always)] - fn allocate_uninit(_: Const, _: Const) -> ArrayStorage, R, C> { + fn allocate_uninit(_: Const, _: Const) -> ArrayStorage, R, C> { // SAFETY: An uninitialized `[MaybeUninit<_>; _]` is valid. let array: [[MaybeUninit; R]; C] = unsafe { MaybeUninit::uninit().assume_init() }; ArrayStorage(array) } #[inline(always)] - unsafe fn assume_init(uninit: ArrayStorage, R, C>) -> ArrayStorage { + unsafe fn assume_init( + uninit: ArrayStorage, R, C>, + ) -> ArrayStorage { // Safety: // * The caller guarantees that all elements of the array are initialized // * `MaybeUninit` and T are guaranteed to have the same layout @@ -58,11 +58,11 @@ impl Allocator, Const> } #[inline] - fn allocate_from_iterator>( + fn allocate_from_iterator>( nrows: Const, ncols: Const, iter: I, - ) -> Self::Buffer { + ) -> Self::Buffer { let mut res = Self::allocate_uninit(nrows, ncols); let mut count = 0; @@ -80,19 +80,19 @@ impl Allocator, Const> // Safety: the assertion above made sure that the iterator // yielded enough elements to initialize our matrix. - unsafe { , Const>>::assume_init(res) } + unsafe { , Const>>::assume_init(res) } } } // Dyn - Static // Dyn - Dyn #[cfg(any(feature = "std", feature = "alloc"))] -impl Allocator for DefaultAllocator { - type Buffer = VecStorage; - type BufferUninit = VecStorage, Dyn, C>; +impl Allocator for DefaultAllocator { + type Buffer = VecStorage; + type BufferUninit = VecStorage, Dyn, C>; #[inline] - fn allocate_uninit(nrows: Dyn, ncols: C) -> VecStorage, Dyn, 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); @@ -101,7 +101,9 @@ impl Allocator for DefaultAllocator { } #[inline] - unsafe fn assume_init(uninit: VecStorage, Dyn, 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(); @@ -116,11 +118,11 @@ impl Allocator for DefaultAllocator { } #[inline] - fn allocate_from_iterator>( + fn allocate_from_iterator>( nrows: Dyn, ncols: C, iter: I, - ) -> Self::Buffer { + ) -> Self::Buffer { let it = iter.into_iter(); let res: Vec = it.collect(); assert!(res.len() == nrows.value() * ncols.value(), @@ -132,12 +134,12 @@ impl Allocator for DefaultAllocator { // Static - Dyn #[cfg(any(feature = "std", feature = "alloc"))] -impl Allocator for DefaultAllocator { - type Buffer = VecStorage; - type BufferUninit = VecStorage, R, Dyn>; +impl Allocator for DefaultAllocator { + type Buffer = VecStorage; + type BufferUninit = VecStorage, R, Dyn>; #[inline] - fn allocate_uninit(nrows: R, ncols: Dyn) -> VecStorage, R, Dyn> { + 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,7 +149,9 @@ impl Allocator for DefaultAllocator { } #[inline] - unsafe fn assume_init(uninit: VecStorage, R, Dyn>) -> VecStorage { + unsafe fn assume_init( + uninit: VecStorage, R, Dyn>, + ) -> VecStorage { // Avoids a double-drop. let (nrows, ncols) = uninit.shape(); let vec: Vec<_> = uninit.into(); @@ -162,11 +166,11 @@ impl Allocator for DefaultAllocator { } #[inline] - fn allocate_from_iterator>( + fn allocate_from_iterator>( nrows: R, ncols: Dyn, iter: I, - ) -> Self::Buffer { + ) -> Self::Buffer { let it = iter.into_iter(); let res: Vec = it.collect(); assert!(res.len() == nrows.value() * ncols.value(), @@ -187,15 +191,15 @@ impl where RFrom: Dim, CFrom: Dim, - Self: Allocator, + Self: Allocator, { #[inline] unsafe fn reallocate_copy( rto: Const, cto: Const, - buf: >::Buffer, + buf: >::Buffer, ) -> ArrayStorage, RTO, CTO> { - let mut res = , Const>>::allocate_uninit(rto, cto); + let mut res = , Const>>::allocate_uninit(rto, cto); let (rfrom, cfrom) = buf.shape(); @@ -226,7 +230,7 @@ where cto: CTo, buf: ArrayStorage, ) -> VecStorage, Dyn, CTo> { - let mut res = >::allocate_uninit(rto, cto); + let mut res = >::allocate_uninit(rto, cto); let (rfrom, cfrom) = buf.shape(); @@ -257,7 +261,7 @@ where cto: Dyn, buf: ArrayStorage, ) -> VecStorage, RTo, Dyn> { - let mut res = >::allocate_uninit(rto, cto); + let mut res = >::allocate_uninit(rto, cto); let (rfrom, cfrom) = buf.shape(); diff --git a/src/base/edition.rs b/src/base/edition.rs index b5c31819..dfda1438 100644 --- a/src/base/edition.rs +++ b/src/base/edition.rs @@ -21,7 +21,7 @@ impl> Matrix { #[must_use] pub fn upper_triangle(&self) -> OMatrix where - DefaultAllocator: Allocator, + DefaultAllocator: Allocator, { let mut res = self.clone_owned(); res.fill_lower_triangle(T::zero(), 1); @@ -34,7 +34,7 @@ impl> Matrix { #[must_use] pub fn lower_triangle(&self) -> OMatrix where - DefaultAllocator: Allocator, + DefaultAllocator: Allocator, { let mut res = self.clone_owned(); res.fill_upper_triangle(T::zero(), 1); @@ -52,7 +52,7 @@ impl> Matrix { where I: IntoIterator, I::IntoIter: ExactSizeIterator + Clone, - DefaultAllocator: Allocator, + DefaultAllocator: Allocator, { let irows = irows.into_iter(); let ncols = self.shape_generic().1; @@ -89,7 +89,7 @@ impl> Matrix { where I: IntoIterator, I::IntoIter: ExactSizeIterator, - DefaultAllocator: Allocator, + DefaultAllocator: Allocator, { let icols = icols.into_iter(); let nrows = self.shape_generic().0; @@ -1037,7 +1037,7 @@ impl OMatrix { #[cfg(any(feature = "std", feature = "alloc"))] impl OMatrix where - DefaultAllocator: Allocator, + DefaultAllocator: Allocator, { /// Changes the number of rows of this matrix in-place. /// @@ -1058,7 +1058,7 @@ where #[cfg(any(feature = "std", feature = "alloc"))] impl OMatrix where - DefaultAllocator: Allocator, + DefaultAllocator: Allocator, { /// Changes the number of column of this matrix in-place. /// diff --git a/src/base/interpolation.rs b/src/base/interpolation.rs index 81b1a374..bdfd1c26 100644 --- a/src/base/interpolation.rs +++ b/src/base/interpolation.rs @@ -23,7 +23,7 @@ impl>(&self, rhs: &Vector, t: T) -> OVector where - DefaultAllocator: Allocator, + DefaultAllocator: Allocator, { let mut res = self.clone_owned(); res.axpy(t.clone(), rhs, T::one() - t); @@ -50,7 +50,7 @@ impl>(&self, rhs: &Vector, t: T) -> OVector where T: RealField, - DefaultAllocator: Allocator, + DefaultAllocator: Allocator, { let me = Unit::new_normalize(self.clone_owned()); let rhs = Unit::new_normalize(rhs.clone_owned()); @@ -81,7 +81,7 @@ impl> Unit> { t: T, ) -> Unit> where - DefaultAllocator: Allocator, + DefaultAllocator: Allocator, { // TODO: the result is wrong when self and rhs are collinear with opposite direction. self.try_slerp(rhs, t, T::default_epsilon()) @@ -100,7 +100,7 @@ impl> Unit> { epsilon: T, ) -> Option>> where - DefaultAllocator: Allocator, + DefaultAllocator: Allocator, { let c_hang = self.dot(rhs); diff --git a/src/base/matrix.rs b/src/base/matrix.rs index 7daa4f1a..50599e34 100644 --- a/src/base/matrix.rs +++ b/src/base/matrix.rs @@ -383,9 +383,9 @@ impl RowDVector { } } -impl UninitMatrix +impl UninitMatrix where - DefaultAllocator: Allocator, + DefaultAllocator: Allocator, { /// Assumes a matrix's entries to be initialized. This operation should be near zero-cost. /// @@ -394,7 +394,7 @@ where /// or Undefined Behavior will immediately occur. #[inline(always)] pub unsafe fn assume_init(self) -> OMatrix { - OMatrix::from_data(>::assume_init( + OMatrix::from_data(>::assume_init( self.data, )) } @@ -533,7 +533,7 @@ impl> Matrix { max_relative: T::Epsilon, ) -> bool where - T: RelativeEq, + T: RelativeEq + Scalar, R2: Dim, C2: Dim, SB: Storage, @@ -568,7 +568,7 @@ impl> Matrix { where T: Scalar, S: Storage, - DefaultAllocator: Allocator, + DefaultAllocator: Allocator, { Matrix::from_data(self.data.into_owned()) } @@ -584,7 +584,7 @@ impl> Matrix { S: Storage, R2: Dim, C2: Dim, - DefaultAllocator: SameShapeAllocator, + DefaultAllocator: SameShapeAllocator, ShapeConstraint: SameNumberOfRows + SameNumberOfColumns, { if TypeId::of::>() == TypeId::of::>() { @@ -609,7 +609,7 @@ impl> Matrix { where T: Scalar, S: Storage, - DefaultAllocator: Allocator, + DefaultAllocator: Allocator, { Matrix::from_data(self.data.clone_owned()) } @@ -624,7 +624,7 @@ impl> Matrix { S: Storage, R2: Dim, C2: Dim, - DefaultAllocator: SameShapeAllocator, + DefaultAllocator: SameShapeAllocator, ShapeConstraint: SameNumberOfRows + SameNumberOfColumns, { let (nrows, ncols) = self.shape(); @@ -700,7 +700,7 @@ impl> Matrix { pub fn transpose(&self) -> OMatrix where T: Scalar, - DefaultAllocator: Allocator, + DefaultAllocator: Allocator, { let (nrows, ncols) = self.shape_generic(); @@ -719,7 +719,7 @@ impl> Matrix { pub fn map T2>(&self, mut f: F) -> OMatrix where T: Scalar, - DefaultAllocator: Allocator, + DefaultAllocator: Allocator, { let (nrows, ncols) = self.shape_generic(); let mut res = Matrix::uninit(nrows, ncols); @@ -751,7 +751,7 @@ impl> Matrix { where T: Scalar, OMatrix: SupersetOf, - DefaultAllocator: Allocator, + DefaultAllocator: Allocator, { crate::convert(self) } @@ -769,7 +769,7 @@ impl> Matrix { where T: Scalar, Self: SupersetOf>, - DefaultAllocator: Allocator, + DefaultAllocator: Allocator, { crate::try_convert(self) } @@ -806,7 +806,7 @@ impl> Matrix { ) -> OMatrix where T: Scalar, - DefaultAllocator: Allocator, + DefaultAllocator: Allocator, { let (nrows, ncols) = self.shape_generic(); let mut res = Matrix::uninit(nrows, ncols); @@ -836,7 +836,7 @@ impl> Matrix { N3: Scalar, S2: RawStorage, F: FnMut(T, T2) -> N3, - DefaultAllocator: Allocator, + DefaultAllocator: Allocator, { let (nrows, ncols) = self.shape_generic(); let mut res = Matrix::uninit(nrows, ncols); @@ -880,7 +880,7 @@ impl> Matrix { S2: RawStorage, S3: RawStorage, F: FnMut(T, T2, N3) -> N4, - DefaultAllocator: Allocator, + DefaultAllocator: Allocator, { let (nrows, ncols) = self.shape_generic(); let mut res = Matrix::uninit(nrows, ncols); @@ -1420,7 +1420,7 @@ impl> Matrix OMatrix where - DefaultAllocator: Allocator, + DefaultAllocator: Allocator, { let (nrows, ncols) = self.shape_generic(); @@ -1449,7 +1449,7 @@ impl> Matrix OMatrix where - DefaultAllocator: Allocator, + DefaultAllocator: Allocator, { self.adjoint() } @@ -1459,7 +1459,7 @@ impl> Matrix OMatrix where - DefaultAllocator: Allocator, + DefaultAllocator: Allocator, { self.map(|e| e.simd_conjugate()) } @@ -1469,7 +1469,7 @@ impl> Matrix OMatrix where - DefaultAllocator: Allocator, + DefaultAllocator: Allocator, { self.map(|e| e.simd_unscale(real.clone())) } @@ -1479,7 +1479,7 @@ impl> Matrix OMatrix where - DefaultAllocator: Allocator, + DefaultAllocator: Allocator, { self.map(|e| e.simd_scale(real.clone())) } @@ -1547,7 +1547,7 @@ impl> SquareMatrix { #[must_use] pub fn diagonal(&self) -> OVector where - DefaultAllocator: Allocator, + DefaultAllocator: Allocator, { self.map_diagonal(|e| e) } @@ -1559,7 +1559,7 @@ impl> SquareMatrix { #[must_use] pub fn map_diagonal(&self, mut f: impl FnMut(T) -> T2) -> OVector where - DefaultAllocator: Allocator, + DefaultAllocator: Allocator, { assert!( self.is_square(), @@ -1610,7 +1610,7 @@ impl> SquareMatrix { #[must_use] pub fn symmetric_part(&self) -> OMatrix where - DefaultAllocator: Allocator, + DefaultAllocator: Allocator, { assert!( self.is_square(), @@ -1627,7 +1627,7 @@ impl> SquareMatrix { #[must_use] pub fn hermitian_part(&self) -> OMatrix where - DefaultAllocator: Allocator, + DefaultAllocator: Allocator, { assert!( self.is_square(), @@ -1650,7 +1650,7 @@ impl + IsNotStaticOne, S: RawStorage OMatrix, DimSum> where - DefaultAllocator: Allocator, DimSum>, + DefaultAllocator: Allocator, DimSum>, { assert!( self.is_square(), @@ -1671,7 +1671,7 @@ impl, S: RawStorage> Vector { #[must_use] pub fn to_homogeneous(&self) -> OVector> where - DefaultAllocator: Allocator>, + DefaultAllocator: Allocator>, { self.push(T::zero()) } @@ -1682,7 +1682,7 @@ impl, S: RawStorage> Vector { pub fn from_homogeneous(v: Vector, SB>) -> Option> where SB: RawStorage>, - DefaultAllocator: Allocator, + DefaultAllocator: Allocator, { if v[v.len() - 1].is_zero() { let nrows = D::from_usize(v.len() - 1); @@ -1699,7 +1699,7 @@ impl, S: RawStorage> Vector { #[must_use] pub fn push(&self, element: T) -> OVector> where - DefaultAllocator: Allocator>, + DefaultAllocator: Allocator>, { let len = self.len(); let hnrows = DimSum::::from_usize(len + 1); @@ -2052,7 +2052,7 @@ impl, - DefaultAllocator: SameShapeAllocator, + DefaultAllocator: SameShapeAllocator, ShapeConstraint: SameNumberOfRows + SameNumberOfColumns, { let shape = self.shape(); @@ -2252,7 +2252,7 @@ where where T: Scalar, OVector: SupersetOf>, - DefaultAllocator: Allocator, + DefaultAllocator: Allocator, { Unit::new_unchecked(crate::convert_ref(self.as_ref())) } diff --git a/src/base/matrix_simba.rs b/src/base/matrix_simba.rs index 6284ab56..c31e8977 100644 --- a/src/base/matrix_simba.rs +++ b/src/base/matrix_simba.rs @@ -15,7 +15,7 @@ where R: Dim, C: Dim, T::Element: Scalar, - DefaultAllocator: Allocator + Allocator, + DefaultAllocator: Allocator, { type Element = OMatrix; type SimdBool = T::SimdBool; diff --git a/src/base/matrix_view.rs b/src/base/matrix_view.rs index a5f2681e..47b2965a 100644 --- a/src/base/matrix_view.rs +++ b/src/base/matrix_view.rs @@ -218,13 +218,13 @@ macro_rules! storage_impl( for $T<'a, T, R, C, RStride, CStride> { #[inline] fn into_owned(self) -> Owned - where DefaultAllocator: Allocator { + where DefaultAllocator: Allocator { self.clone_owned() } #[inline] fn clone_owned(&self) -> Owned - where DefaultAllocator: Allocator { + where DefaultAllocator: Allocator { let (nrows, ncols) = self.shape(); let it = MatrixIter::new(self).cloned(); DefaultAllocator::allocate_from_iterator(nrows, ncols, it) diff --git a/src/base/norm.rs b/src/base/norm.rs index e9010273..90362be6 100644 --- a/src/base/norm.rs +++ b/src/base/norm.rs @@ -301,7 +301,7 @@ impl> Matrix { pub fn normalize(&self) -> OMatrix where T: SimdComplexField, - DefaultAllocator: Allocator, + DefaultAllocator: Allocator, { self.unscale(self.norm()) } @@ -325,7 +325,7 @@ impl> Matrix { where T: SimdComplexField, T::Element: Scalar, - DefaultAllocator: Allocator + Allocator, + DefaultAllocator: Allocator, { let n = self.norm(); let le = n.clone().simd_le(min_norm); @@ -356,7 +356,7 @@ impl> Matrix { pub fn cap_magnitude(&self, max: T::RealField) -> OMatrix where T: ComplexField, - DefaultAllocator: Allocator, + DefaultAllocator: Allocator, { let n = self.norm(); @@ -374,7 +374,7 @@ impl> Matrix { where T: SimdComplexField, T::Element: Scalar, - DefaultAllocator: Allocator + Allocator, + DefaultAllocator: Allocator, { let n = self.norm(); let scaled = self.scale(max.clone() / n.clone()); @@ -390,7 +390,7 @@ impl> Matrix { pub fn try_normalize(&self, min_norm: T::RealField) -> Option> where T: ComplexField, - DefaultAllocator: Allocator, + DefaultAllocator: Allocator, { let n = self.norm(); @@ -430,7 +430,7 @@ impl> Matrix { where T: SimdComplexField, T::Element: Scalar, - DefaultAllocator: Allocator + Allocator, + DefaultAllocator: Allocator, { let n = self.norm(); let le = n.clone().simd_le(min_norm); @@ -459,7 +459,7 @@ impl> Matrix { impl Normed for OMatrix where - DefaultAllocator: Allocator, + DefaultAllocator: Allocator, { type Norm = T::SimdRealField; @@ -486,7 +486,7 @@ where impl Neg for Unit> where - DefaultAllocator: Allocator, + DefaultAllocator: Allocator, { type Output = Unit>; @@ -503,7 +503,7 @@ where /// # Basis and orthogonalization impl OVector where - DefaultAllocator: Allocator, + DefaultAllocator: Allocator, { /// The i-the canonical basis element. #[inline] diff --git a/src/base/ops.rs b/src/base/ops.rs index d5cf3a51..273876d3 100644 --- a/src/base/ops.rs +++ b/src/base/ops.rs @@ -81,7 +81,7 @@ impl Neg for Matrix where T: Scalar + ClosedNeg, S: Storage, - DefaultAllocator: Allocator, + DefaultAllocator: Allocator, { type Output = OMatrix; @@ -97,7 +97,7 @@ impl<'a, T, R: Dim, C: Dim, S> Neg for &'a Matrix where T: Scalar + ClosedNeg, S: Storage, - DefaultAllocator: Allocator, + DefaultAllocator: Allocator, { type Output = OMatrix; @@ -262,7 +262,7 @@ macro_rules! componentwise_binop_impl( T: Scalar + $bound, SA: Storage, SB: Storage, - DefaultAllocator: SameShapeAllocator, + DefaultAllocator: SameShapeAllocator, ShapeConstraint: SameNumberOfRows + SameNumberOfColumns { type Output = MatrixSum; @@ -280,7 +280,7 @@ macro_rules! componentwise_binop_impl( T: Scalar + $bound, SA: Storage, SB: Storage, - DefaultAllocator: SameShapeAllocator, + DefaultAllocator: SameShapeAllocator, ShapeConstraint: SameNumberOfRows + SameNumberOfColumns { type Output = MatrixSum; @@ -298,7 +298,7 @@ macro_rules! componentwise_binop_impl( T: Scalar + $bound, SA: Storage, SB: Storage, - DefaultAllocator: SameShapeAllocator, + DefaultAllocator: SameShapeAllocator, ShapeConstraint: SameNumberOfRows + SameNumberOfColumns { type Output = MatrixSum; @@ -313,7 +313,7 @@ macro_rules! componentwise_binop_impl( T: Scalar + $bound, SA: Storage, SB: Storage, - DefaultAllocator: SameShapeAllocator, + DefaultAllocator: SameShapeAllocator, ShapeConstraint: SameNumberOfRows + SameNumberOfColumns { type Output = MatrixSum; @@ -367,7 +367,7 @@ componentwise_binop_impl!(Sub, sub, ClosedSub; impl iter::Sum for OMatrix where T: Scalar + ClosedAdd + Zero, - DefaultAllocator: Allocator, + DefaultAllocator: Allocator, { fn sum>>(iter: I) -> OMatrix { iter.fold(Matrix::zero(), |acc, x| acc + x) @@ -377,7 +377,7 @@ where impl iter::Sum for OMatrix where T: Scalar + ClosedAdd + Zero, - DefaultAllocator: Allocator, + DefaultAllocator: Allocator, { /// # Example /// ``` @@ -407,7 +407,7 @@ where impl<'a, T, R: DimName, C: DimName> iter::Sum<&'a OMatrix> for OMatrix where T: Scalar + ClosedAdd + Zero, - DefaultAllocator: Allocator, + DefaultAllocator: Allocator, { fn sum>>(iter: I) -> OMatrix { iter.fold(Matrix::zero(), |acc, x| acc + x) @@ -417,7 +417,7 @@ where impl<'a, T, C: Dim> iter::Sum<&'a OMatrix> for OMatrix where T: Scalar + ClosedAdd + Zero, - DefaultAllocator: Allocator, + DefaultAllocator: Allocator, { /// # Example /// ``` @@ -458,7 +458,7 @@ macro_rules! componentwise_scalarop_impl( impl $Trait for Matrix where T: Scalar + $bound, S: Storage, - DefaultAllocator: Allocator { + DefaultAllocator: Allocator { type Output = OMatrix; #[inline] @@ -482,7 +482,7 @@ macro_rules! componentwise_scalarop_impl( impl<'a, T, R: Dim, C: Dim, S> $Trait for &'a Matrix where T: Scalar + $bound, S: Storage, - DefaultAllocator: Allocator { + DefaultAllocator: Allocator { type Output = OMatrix; #[inline] @@ -512,7 +512,7 @@ componentwise_scalarop_impl!(Div, div, ClosedDiv; DivAssign, div_assign); macro_rules! left_scalar_mul_impl( ($($T: ty),* $(,)*) => {$( impl> Mul> for $T - where DefaultAllocator: Allocator<$T, R, C> { + where DefaultAllocator: Allocator { type Output = OMatrix<$T, R, C>; #[inline] @@ -534,7 +534,7 @@ macro_rules! left_scalar_mul_impl( } impl<'b, R: Dim, C: Dim, S: Storage<$T, R, C>> Mul<&'b Matrix<$T, R, C, S>> for $T - where DefaultAllocator: Allocator<$T, R, C> { + where DefaultAllocator: Allocator { type Output = OMatrix<$T, R, C>; #[inline] @@ -554,7 +554,7 @@ where T: Scalar + Zero + One + ClosedAdd + ClosedMul, SA: Storage, SB: Storage, - DefaultAllocator: Allocator, + DefaultAllocator: Allocator, ShapeConstraint: AreMultipliable, { type Output = OMatrix; @@ -576,7 +576,7 @@ where T: Scalar + Zero + One + ClosedAdd + ClosedMul, SB: Storage, SA: Storage, - DefaultAllocator: Allocator, + DefaultAllocator: Allocator, ShapeConstraint: AreMultipliable, { type Output = OMatrix; @@ -593,7 +593,7 @@ where T: Scalar + Zero + One + ClosedAdd + ClosedMul, SB: Storage, SA: Storage, - DefaultAllocator: Allocator, + DefaultAllocator: Allocator, ShapeConstraint: AreMultipliable, { type Output = OMatrix; @@ -610,7 +610,7 @@ where T: Scalar + Zero + One + ClosedAdd + ClosedMul, SB: Storage, SA: Storage, - DefaultAllocator: Allocator, + DefaultAllocator: Allocator, ShapeConstraint: AreMultipliable, { type Output = OMatrix; @@ -633,7 +633,7 @@ where SB: Storage, SA: StorageMut + IsContiguous + Clone, // TODO: get rid of the IsContiguous ShapeConstraint: AreMultipliable, - DefaultAllocator: Allocator, + DefaultAllocator: Allocator = SA>, { #[inline] fn mul_assign(&mut self, rhs: Matrix) { @@ -651,7 +651,7 @@ where SA: StorageMut + IsContiguous + Clone, // TODO: get rid of the IsContiguous ShapeConstraint: AreMultipliable, // TODO: this is too restrictive. See comments for the non-ref version. - DefaultAllocator: Allocator, + DefaultAllocator: Allocator = SA>, { #[inline] fn mul_assign(&mut self, rhs: &'b Matrix) { @@ -671,7 +671,7 @@ where pub fn tr_mul(&self, rhs: &Matrix) -> OMatrix where SB: Storage, - DefaultAllocator: Allocator, + DefaultAllocator: Allocator, ShapeConstraint: SameNumberOfRows, { let mut res = Matrix::uninit(self.shape_generic().1, rhs.shape_generic().1); @@ -687,7 +687,7 @@ where where T: SimdComplexField, SB: Storage, - DefaultAllocator: Allocator, + DefaultAllocator: Allocator, ShapeConstraint: SameNumberOfRows, { let mut res = Matrix::uninit(self.shape_generic().1, rhs.shape_generic().1); @@ -803,7 +803,7 @@ where R1: DimMul, C1: DimMul, SB: Storage, - DefaultAllocator: Allocator, DimProd>, + DefaultAllocator: Allocator, DimProd>, { let (nrows1, ncols1) = self.shape_generic(); let (nrows2, ncols2) = rhs.shape_generic(); @@ -836,7 +836,7 @@ where impl iter::Product for OMatrix where T: Scalar + Zero + One + ClosedMul + ClosedAdd, - DefaultAllocator: Allocator, + DefaultAllocator: Allocator, { fn product>>(iter: I) -> OMatrix { iter.fold(Matrix::one(), |acc, x| acc * x) @@ -846,7 +846,7 @@ where impl<'a, T, D: DimName> iter::Product<&'a OMatrix> for OMatrix where T: Scalar + Zero + One + ClosedMul + ClosedAdd, - DefaultAllocator: Allocator, + DefaultAllocator: Allocator, { fn product>>(iter: I) -> OMatrix { iter.fold(Matrix::one(), |acc, x| acc * x) diff --git a/src/base/properties.rs b/src/base/properties.rs index 914c0b9e..ab0ceff2 100644 --- a/src/base/properties.rs +++ b/src/base/properties.rs @@ -91,7 +91,7 @@ impl> Matrix { T: Zero + One + ClosedAdd + ClosedMul + RelativeEq, S: Storage, T::Epsilon: Clone, - DefaultAllocator: Allocator + Allocator, + DefaultAllocator: Allocator + Allocator, { (self.ad_mul(self)).is_identity(eps) } @@ -99,7 +99,7 @@ impl> Matrix { impl> SquareMatrix where - DefaultAllocator: Allocator, + DefaultAllocator: Allocator, { /// Checks that this matrix is orthogonal and has a determinant equal to 1. #[inline] @@ -107,7 +107,7 @@ where pub fn is_special_orthogonal(&self, eps: T) -> bool where D: DimMin, - DefaultAllocator: Allocator<(usize, usize), D>, + DefaultAllocator: Allocator, { self.is_square() && self.is_orthogonal(eps) && self.determinant() > T::zero() } diff --git a/src/base/statistics.rs b/src/base/statistics.rs index 5bb05fd0..85c0f11c 100644 --- a/src/base/statistics.rs +++ b/src/base/statistics.rs @@ -16,7 +16,7 @@ impl> Matrix { f: impl Fn(VectorView<'_, T, R, S::RStride, S::CStride>) -> T, ) -> RowOVector where - DefaultAllocator: Allocator, + DefaultAllocator: Allocator, { let ncols = self.shape_generic().1; let mut res = Matrix::uninit(Const::<1>, ncols); @@ -44,7 +44,7 @@ impl> Matrix { f: impl Fn(VectorView<'_, T, R, S::RStride, S::CStride>) -> T, ) -> OVector where - DefaultAllocator: Allocator, + DefaultAllocator: Allocator, { let ncols = self.shape_generic().1; let mut res = Matrix::uninit(ncols, Const::<1>); @@ -70,7 +70,7 @@ impl> Matrix { f: impl Fn(&mut OVector, VectorView<'_, T, R, S::RStride, S::CStride>), ) -> OVector where - DefaultAllocator: Allocator, + DefaultAllocator: Allocator, { let mut res = init; @@ -133,7 +133,7 @@ impl> Matrix { pub fn row_sum(&self) -> RowOVector where T: ClosedAdd + Zero, - DefaultAllocator: Allocator, + DefaultAllocator: Allocator, { self.compress_rows(|col| col.sum()) } @@ -160,7 +160,7 @@ impl> Matrix { pub fn row_sum_tr(&self) -> OVector where T: ClosedAdd + Zero, - DefaultAllocator: Allocator, + DefaultAllocator: Allocator, { self.compress_rows_tr(|col| col.sum()) } @@ -187,7 +187,7 @@ impl> Matrix { pub fn column_sum(&self) -> OVector where T: ClosedAdd + Zero, - DefaultAllocator: Allocator, + DefaultAllocator: Allocator, { let nrows = self.shape_generic().0; self.compress_columns(OVector::zeros_generic(nrows, Const::<1>), |out, col| { @@ -244,7 +244,7 @@ impl> Matrix { pub fn row_product(&self) -> RowOVector where T: ClosedMul + One, - DefaultAllocator: Allocator, + DefaultAllocator: Allocator, { self.compress_rows(|col| col.product()) } @@ -271,7 +271,7 @@ impl> Matrix { pub fn row_product_tr(&self) -> OVector where T: ClosedMul + One, - DefaultAllocator: Allocator, + DefaultAllocator: Allocator, { self.compress_rows_tr(|col| col.product()) } @@ -298,7 +298,7 @@ impl> Matrix { pub fn column_product(&self) -> OVector where T: ClosedMul + One, - DefaultAllocator: Allocator, + DefaultAllocator: Allocator, { let nrows = self.shape_generic().0; self.compress_columns( @@ -361,7 +361,7 @@ impl> Matrix { pub fn row_variance(&self) -> RowOVector where T: Field + SupersetOf, - DefaultAllocator: Allocator, + DefaultAllocator: Allocator, { self.compress_rows(|col| col.variance()) } @@ -382,7 +382,7 @@ impl> Matrix { pub fn row_variance_tr(&self) -> OVector where T: Field + SupersetOf, - DefaultAllocator: Allocator, + DefaultAllocator: Allocator, { self.compress_rows_tr(|col| col.variance()) } @@ -404,7 +404,7 @@ impl> Matrix { pub fn column_variance(&self) -> OVector where T: Field + SupersetOf, - DefaultAllocator: Allocator, + DefaultAllocator: Allocator, { let (nrows, ncols) = self.shape_generic(); @@ -469,7 +469,7 @@ impl> Matrix { pub fn row_mean(&self) -> RowOVector where T: Field + SupersetOf, - DefaultAllocator: Allocator, + DefaultAllocator: Allocator, { self.compress_rows(|col| col.mean()) } @@ -490,7 +490,7 @@ impl> Matrix { pub fn row_mean_tr(&self) -> OVector where T: Field + SupersetOf, - DefaultAllocator: Allocator, + DefaultAllocator: Allocator, { self.compress_rows_tr(|col| col.mean()) } @@ -511,7 +511,7 @@ impl> Matrix { pub fn column_mean(&self) -> OVector where T: Field + SupersetOf, - DefaultAllocator: Allocator, + DefaultAllocator: Allocator, { let (nrows, ncols) = self.shape_generic(); let denom = T::one() / crate::convert::<_, T>(ncols.value() as f64); diff --git a/src/base/storage.rs b/src/base/storage.rs index 168253e6..93dbfcd8 100644 --- a/src/base/storage.rs +++ b/src/base/storage.rs @@ -12,22 +12,22 @@ use crate::base::Scalar; */ /// The data storage for the sum of two matrices with dimensions `(R1, C1)` and `(R2, C2)`. pub type SameShapeStorage = - , SameShapeC>>::Buffer; + , SameShapeC>>::Buffer; // TODO: better name than Owned ? /// The owned data storage that can be allocated from `S`. -pub type Owned = >::Buffer; +pub type Owned = >::Buffer; /// The owned data storage that can be allocated from `S`. -pub type OwnedUninit = >::BufferUninit; +pub type OwnedUninit = >::BufferUninit; /// The row-stride of the owned data storage for a buffer of dimension `(R, C)`. pub type RStride = - <>::Buffer as RawStorage>::RStride; + <>::Buffer as RawStorage>::RStride; /// The column-stride of the owned data storage for a buffer of dimension `(R, C)`. pub type CStride = - <>::Buffer as RawStorage>::CStride; + <>::Buffer as RawStorage>::CStride; /// The trait shared by all matrix data storage. /// @@ -139,16 +139,16 @@ pub unsafe trait RawStorage: Sized { /// should **not** allow the user to modify the size of the underlying buffer with safe methods /// (for example the `VecStorage::data_mut` method is unsafe because the user could change the /// vector's size so that it no longer contains enough elements: this will lead to UB. -pub unsafe trait Storage: RawStorage { +pub unsafe trait Storage: RawStorage { /// Builds a matrix data storage that does not contain any reference. fn into_owned(self) -> Owned where - DefaultAllocator: Allocator; + DefaultAllocator: Allocator; /// Clones this data storage to one that does not contain any reference. fn clone_owned(&self) -> Owned where - DefaultAllocator: Allocator; + DefaultAllocator: Allocator; } /// Trait implemented by matrix data storage that can provide a mutable access to its elements. @@ -260,12 +260,12 @@ pub unsafe trait RawStorageMut: RawStorage { /// # Safety /// /// See safety note for `Storage`, `RawStorageMut`. -pub unsafe trait StorageMut: +pub unsafe trait StorageMut: Storage + RawStorageMut { } -unsafe impl StorageMut for S +unsafe impl StorageMut for S where R: Dim, C: Dim, diff --git a/src/base/unit.rs b/src/base/unit.rs index b8e62b8c..84cfc315 100644 --- a/src/base/unit.rs +++ b/src/base/unit.rs @@ -303,7 +303,7 @@ impl where T: From<[::Element; 2]>, T::Element: Scalar, - DefaultAllocator: Allocator + Allocator, + DefaultAllocator: Allocator, { #[inline] fn from(arr: [Unit>; 2]) -> Self { @@ -319,7 +319,7 @@ impl where T: From<[::Element; 4]>, T::Element: Scalar, - DefaultAllocator: Allocator + Allocator, + DefaultAllocator: Allocator, { #[inline] fn from(arr: [Unit>; 4]) -> Self { @@ -337,7 +337,7 @@ impl where T: From<[::Element; 8]>, T::Element: Scalar, - DefaultAllocator: Allocator + Allocator, + DefaultAllocator: Allocator, { #[inline] fn from(arr: [Unit>; 8]) -> Self { @@ -359,7 +359,7 @@ impl where T: From<[::Element; 16]>, T::Element: Scalar, - DefaultAllocator: Allocator + Allocator, + DefaultAllocator: Allocator, { #[inline] fn from(arr: [Unit>; 16]) -> Self { diff --git a/src/base/vec_storage.rs b/src/base/vec_storage.rs index 5b29b6a3..72f84499 100644 --- a/src/base/vec_storage.rs +++ b/src/base/vec_storage.rs @@ -264,12 +264,12 @@ unsafe impl RawStorage for VecStorage { unsafe impl Storage for VecStorage where - DefaultAllocator: Allocator, + DefaultAllocator: Allocator = Self>, { #[inline] fn into_owned(self) -> Owned where - DefaultAllocator: Allocator, + DefaultAllocator: Allocator, { self } @@ -277,7 +277,7 @@ where #[inline] fn clone_owned(&self) -> Owned where - DefaultAllocator: Allocator, + DefaultAllocator: Allocator, { self.clone() } @@ -315,12 +315,12 @@ unsafe impl RawStorage for VecStorage { unsafe impl Storage for VecStorage where - DefaultAllocator: Allocator, + DefaultAllocator: Allocator = Self>, { #[inline] fn into_owned(self) -> Owned where - DefaultAllocator: Allocator, + DefaultAllocator: Allocator, { self } @@ -328,7 +328,7 @@ where #[inline] fn clone_owned(&self) -> Owned where - DefaultAllocator: Allocator, + DefaultAllocator: Allocator, { self.clone() } diff --git a/src/debug/random_orthogonal.rs b/src/debug/random_orthogonal.rs index 18924fb2..77d0302d 100644 --- a/src/debug/random_orthogonal.rs +++ b/src/debug/random_orthogonal.rs @@ -14,14 +14,14 @@ use simba::scalar::ComplexField; #[derive(Clone, Debug)] pub struct RandomOrthogonal where - DefaultAllocator: Allocator, + DefaultAllocator: Allocator, { m: OMatrix, } impl RandomOrthogonal where - DefaultAllocator: Allocator, + DefaultAllocator: Allocator, { /// Retrieve the generated matrix. pub fn unwrap(self) -> OMatrix { @@ -45,7 +45,7 @@ where #[cfg(feature = "arbitrary")] impl Arbitrary for RandomOrthogonal where - DefaultAllocator: Allocator, + DefaultAllocator: Allocator, Owned: Clone + Send, { fn arbitrary(g: &mut Gen) -> Self { diff --git a/src/debug/random_sdp.rs b/src/debug/random_sdp.rs index 278071a8..0827d5d3 100644 --- a/src/debug/random_sdp.rs +++ b/src/debug/random_sdp.rs @@ -15,14 +15,14 @@ use crate::debug::RandomOrthogonal; #[derive(Clone, Debug)] pub struct RandomSDP where - DefaultAllocator: Allocator, + DefaultAllocator: Allocator, { m: OMatrix, } impl RandomSDP where - DefaultAllocator: Allocator, + DefaultAllocator: Allocator, { /// Retrieve the generated matrix. pub fn unwrap(self) -> OMatrix { @@ -48,7 +48,7 @@ where #[cfg(feature = "arbitrary")] impl Arbitrary for RandomSDP where - DefaultAllocator: Allocator, + DefaultAllocator: Allocator, Owned: Clone + Send, { fn arbitrary(g: &mut Gen) -> Self { diff --git a/src/geometry/isometry.rs b/src/geometry/isometry.rs index e2dc93a3..86d659fd 100644 --- a/src/geometry/isometry.rs +++ b/src/geometry/isometry.rs @@ -58,14 +58,14 @@ use rkyv::bytecheck; #[cfg_attr( feature = "serde-serialize-no-std", serde(bound(serialize = "R: Serialize, - DefaultAllocator: Allocator>, + DefaultAllocator: Allocator>, Owned>: Serialize, T: Scalar")) )] #[cfg_attr( feature = "serde-serialize-no-std", serde(bound(deserialize = "R: Deserialize<'de>, - DefaultAllocator: Allocator>, + DefaultAllocator: Allocator>, Owned>: Deserialize<'de>, T: Scalar")) )] @@ -433,7 +433,7 @@ impl Isometry { where Const: DimNameAdd, R: SubsetOf, U1>, DimNameSum, U1>>>, - DefaultAllocator: Allocator, U1>, DimNameSum, U1>>, + DefaultAllocator: Allocator, U1>, DimNameSum, U1>>, { let mut res: OMatrix = crate::convert_ref(&self.rotation); res.fixed_view_mut::(0, D) @@ -465,7 +465,7 @@ impl Isometry { where Const: DimNameAdd, R: SubsetOf, U1>, DimNameSum, U1>>>, - DefaultAllocator: Allocator, U1>, DimNameSum, U1>>, + DefaultAllocator: Allocator, U1>, DimNameSum, U1>>, { self.to_homogeneous() } diff --git a/src/geometry/isometry_conversion.rs b/src/geometry/isometry_conversion.rs index 06507631..1d82669d 100644 --- a/src/geometry/isometry_conversion.rs +++ b/src/geometry/isometry_conversion.rs @@ -9,7 +9,7 @@ use crate::geometry::{ AbstractRotation, Isometry, Isometry3, Similarity, SuperTCategoryOf, TAffine, Transform, Translation, UnitDualQuaternion, UnitQuaternion, }; -use crate::{Point, SVector}; +use crate::{ArrayStorage, Point, SVector}; /* * This file provides the following conversions: @@ -105,13 +105,11 @@ where + SubsetOf, U1>, DimNameSum, U1>>> + SubsetOf, U1>, DimNameSum, U1>>>, Const: DimNameAdd + DimMin, Output = Const>, // needed by .is_special_orthogonal() - DefaultAllocator: Allocator, U1>, DimNameSum, U1>> - + Allocator, U1>, DimNameSum, U1>> - + Allocator, U1>, DimNameSum, U1>>, + DefaultAllocator: Allocator, U1>, DimNameSum, U1>>, // + Allocator - // + Allocator<(usize, usize), D> - // + Allocator - // + Allocator + // + Allocator + // + Allocator + // + Allocator { #[inline] fn to_superset(&self) -> Transform { @@ -138,13 +136,8 @@ where + SubsetOf, U1>, DimNameSum, U1>>> + SubsetOf, U1>, DimNameSum, U1>>>, Const: DimNameAdd + DimMin, Output = Const>, // needed by .is_special_orthogonal() - DefaultAllocator: Allocator, U1>, DimNameSum, U1>> - + Allocator, U1>, DimNameSum, U1>> - + Allocator, U1>, DimNameSum, U1>>, // + Allocator<(usize, usize), D> - // + Allocator - // + Allocator - // + Allocator - // + Allocator + DefaultAllocator: Allocator, Const<1>, Buffer = ArrayStorage> + + Allocator, U1>, DimNameSum, U1>>, { #[inline] fn to_superset(&self) -> OMatrix, U1>, DimNameSum, U1>> { @@ -191,7 +184,7 @@ impl From> where Const: DimNameAdd, R: SubsetOf, U1>, DimNameSum, U1>>>, - DefaultAllocator: Allocator, U1>, DimNameSum, U1>>, // + Allocator, + DefaultAllocator: Allocator, U1>, DimNameSum, U1>>, // + Allocator, { #[inline] fn from(iso: Isometry) -> Self { diff --git a/src/geometry/point.rs b/src/geometry/point.rs index 94bd95a7..5ac9d7a7 100644 --- a/src/geometry/point.rs +++ b/src/geometry/point.rs @@ -49,13 +49,13 @@ use std::mem::MaybeUninit; T: rkyv::Archive, T::Archived: Scalar, OVector: rkyv::Archive>, - DefaultAllocator: Allocator, + DefaultAllocator: Allocator, ") ) )] pub struct OPoint where - DefaultAllocator: Allocator, + DefaultAllocator: Allocator, { /// The coordinates of this point, i.e., the shift from the origin. pub coords: OVector, @@ -63,7 +63,7 @@ where impl fmt::Debug for OPoint where - DefaultAllocator: Allocator, + DefaultAllocator: Allocator, { fn fmt(&self, formatter: &mut fmt::Formatter<'_>) -> Result<(), fmt::Error> { self.coords.as_slice().fmt(formatter) @@ -72,7 +72,7 @@ where impl hash::Hash for OPoint where - DefaultAllocator: Allocator, + DefaultAllocator: Allocator, { fn hash(&self, state: &mut H) { self.coords.hash(state) @@ -81,7 +81,7 @@ where impl Copy for OPoint where - DefaultAllocator: Allocator, + DefaultAllocator: Allocator, OVector: Copy, { } @@ -90,7 +90,7 @@ where unsafe impl bytemuck::Zeroable for OPoint where OVector: bytemuck::Zeroable, - DefaultAllocator: Allocator, + DefaultAllocator: Allocator, { } @@ -99,15 +99,15 @@ unsafe impl bytemuck::Pod for OPoint where T: Copy, OVector: bytemuck::Pod, - DefaultAllocator: Allocator, + DefaultAllocator: Allocator, { } #[cfg(feature = "serde-serialize-no-std")] impl Serialize for OPoint where - DefaultAllocator: Allocator, - >::Buffer: Serialize, + DefaultAllocator: Allocator, + >::Buffer: Serialize, { fn serialize(&self, serializer: S) -> Result where @@ -120,8 +120,8 @@ where #[cfg(feature = "serde-serialize-no-std")] impl<'a, T: Scalar, D: DimName> Deserialize<'a> for OPoint where - DefaultAllocator: Allocator, - >::Buffer: Deserialize<'a>, + DefaultAllocator: Allocator, + >::Buffer: Deserialize<'a>, { fn deserialize(deserializer: Des) -> Result where @@ -135,7 +135,7 @@ where impl OPoint where - DefaultAllocator: Allocator, + DefaultAllocator: Allocator, { /// Returns a point containing the result of `f` applied to each of its entries. /// @@ -153,7 +153,7 @@ where #[must_use] pub fn map T2>(&self, f: F) -> OPoint where - DefaultAllocator: Allocator, + DefaultAllocator: Allocator, { self.coords.map(f).into() } @@ -198,7 +198,7 @@ where where T: One, D: DimNameAdd, - DefaultAllocator: Allocator>, + DefaultAllocator: Allocator>, { // TODO: this is mostly a copy-past from Vector::push. // But we can’t use Vector::push because of the DimAdd bound @@ -304,7 +304,7 @@ where #[inline] pub fn iter( &self, - ) -> MatrixIter<'_, T, D, Const<1>, >::Buffer> { + ) -> MatrixIter<'_, T, D, Const<1>, >::Buffer> { self.coords.iter() } @@ -335,7 +335,7 @@ where #[inline] pub fn iter_mut( &mut self, - ) -> MatrixIterMut<'_, T, D, Const<1>, >::Buffer> { + ) -> MatrixIterMut<'_, T, D, Const<1>, >::Buffer> { self.coords.iter_mut() } @@ -364,7 +364,7 @@ where impl AbsDiffEq for OPoint where T::Epsilon: Clone, - DefaultAllocator: Allocator, + DefaultAllocator: Allocator, { type Epsilon = T::Epsilon; @@ -382,7 +382,7 @@ where impl RelativeEq for OPoint where T::Epsilon: Clone, - DefaultAllocator: Allocator, + DefaultAllocator: Allocator, { #[inline] fn default_max_relative() -> Self::Epsilon { @@ -404,7 +404,7 @@ where impl UlpsEq for OPoint where T::Epsilon: Clone, - DefaultAllocator: Allocator, + DefaultAllocator: Allocator, { #[inline] fn default_max_ulps() -> u32 { @@ -417,11 +417,11 @@ where } } -impl Eq for OPoint where DefaultAllocator: Allocator {} +impl Eq for OPoint where DefaultAllocator: Allocator {} impl PartialEq for OPoint where - DefaultAllocator: Allocator, + DefaultAllocator: Allocator, { #[inline] fn eq(&self, right: &Self) -> bool { @@ -431,7 +431,7 @@ where impl PartialOrd for OPoint where - DefaultAllocator: Allocator, + DefaultAllocator: Allocator, { #[inline] fn partial_cmp(&self, other: &Self) -> Option { @@ -464,7 +464,7 @@ where */ impl OPoint where - DefaultAllocator: Allocator, + DefaultAllocator: Allocator, { /// Computes the infimum (aka. componentwise min) of two points. #[inline] @@ -496,7 +496,7 @@ where */ impl fmt::Display for OPoint where - DefaultAllocator: Allocator, + DefaultAllocator: Allocator, { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { write!(f, "{{")?; diff --git a/src/geometry/point_construction.rs b/src/geometry/point_construction.rs index b60e65ac..3a498e74 100644 --- a/src/geometry/point_construction.rs +++ b/src/geometry/point_construction.rs @@ -21,7 +21,7 @@ use crate::geometry::Point; impl Default for OPoint where - DefaultAllocator: Allocator, + DefaultAllocator: Allocator, { fn default() -> Self { Self::origin() @@ -31,7 +31,7 @@ where /// # Other construction methods impl OPoint where - DefaultAllocator: Allocator, + DefaultAllocator: Allocator, { /// Creates a new point with all coordinates equal to zero. /// @@ -110,7 +110,7 @@ where where T: Scalar + Zero + One + ClosedDiv, D: DimNameAdd, - DefaultAllocator: Allocator>, + DefaultAllocator: Allocator>, { if !v[D::dim()].is_zero() { let coords = v.generic_view((0, 0), (D::name(), Const::<1>)) / v[D::dim()].clone(); @@ -132,7 +132,7 @@ where pub fn cast(self) -> OPoint where OPoint: SupersetOf, - DefaultAllocator: Allocator, + DefaultAllocator: Allocator, { crate::convert(self) } @@ -145,7 +145,7 @@ where */ impl Bounded for OPoint where - DefaultAllocator: Allocator, + DefaultAllocator: Allocator, { #[inline] fn max_value() -> Self { @@ -162,7 +162,7 @@ where impl Distribution> for Standard where Standard: Distribution, - DefaultAllocator: Allocator, + DefaultAllocator: Allocator, { /// Generate a `Point` where each coordinate is an independent variate from `[0, 1)`. #[inline] @@ -174,8 +174,8 @@ where #[cfg(feature = "arbitrary")] impl Arbitrary for OPoint where - >::Buffer: Send, - DefaultAllocator: Allocator, + >::Buffer: Send, + DefaultAllocator: Allocator, { #[inline] fn arbitrary(g: &mut Gen) -> Self { diff --git a/src/geometry/point_conversion.rs b/src/geometry/point_conversion.rs index 81870379..b63f43c9 100644 --- a/src/geometry/point_conversion.rs +++ b/src/geometry/point_conversion.rs @@ -21,7 +21,7 @@ impl SubsetOf> for OPoint where T1: Scalar, T2: Scalar + SupersetOf, - DefaultAllocator: Allocator + Allocator, + DefaultAllocator: Allocator, { #[inline] fn to_superset(&self) -> OPoint { @@ -46,12 +46,9 @@ where D: DimNameAdd, T1: Scalar, T2: Scalar + Zero + One + ClosedDiv + SupersetOf, - DefaultAllocator: Allocator - + Allocator - + Allocator> - + Allocator>, + DefaultAllocator: Allocator + Allocator>, // + Allocator - // + Allocator, + // + Allocator, { #[inline] fn to_superset(&self) -> OVector> { @@ -76,7 +73,7 @@ where impl From> for OVector> where D: DimNameAdd, - DefaultAllocator: Allocator> + Allocator, + DefaultAllocator: Allocator> + Allocator, { #[inline] fn from(t: OPoint) -> Self { @@ -102,7 +99,7 @@ impl From> for [T; D] { impl From> for OPoint where - DefaultAllocator: Allocator, + DefaultAllocator: Allocator, { #[inline] fn from(coords: OVector) -> Self { @@ -115,7 +112,7 @@ impl From<[Point::Element; 2]>, T::Element: Scalar + Copy, - >>::Buffer: Copy, + >>::Buffer: Copy, { #[inline] fn from(arr: [Point; 2]) -> Self { @@ -128,7 +125,7 @@ impl From<[Point::Element; 4]>, T::Element: Scalar + Copy, - >>::Buffer: Copy, + >>::Buffer: Copy, { #[inline] fn from(arr: [Point; 4]) -> Self { @@ -146,7 +143,7 @@ impl From<[Point::Element; 8]>, T::Element: Scalar + Copy, - >>::Buffer: Copy, + >>::Buffer: Copy, { #[inline] fn from(arr: [Point; 8]) -> Self { @@ -168,7 +165,7 @@ impl From<[Point::Element; 16]>, T::Element: Scalar + Copy, - >>::Buffer: Copy, + >>::Buffer: Copy, { #[inline] fn from(arr: [Point; 16]) -> Self { diff --git a/src/geometry/point_ops.rs b/src/geometry/point_ops.rs index 5b019a9d..c0a9a40e 100644 --- a/src/geometry/point_ops.rs +++ b/src/geometry/point_ops.rs @@ -23,7 +23,7 @@ use crate::DefaultAllocator; */ impl Index for OPoint where - DefaultAllocator: Allocator, + DefaultAllocator: Allocator, { type Output = T; @@ -35,7 +35,7 @@ where impl IndexMut for OPoint where - DefaultAllocator: Allocator, + DefaultAllocator: Allocator, { #[inline] fn index_mut(&mut self, i: usize) -> &mut Self::Output { @@ -50,7 +50,7 @@ where */ impl Neg for OPoint where - DefaultAllocator: Allocator, + DefaultAllocator: Allocator, { type Output = Self; @@ -62,7 +62,7 @@ where impl<'a, T: Scalar + ClosedNeg, D: DimName> Neg for &'a OPoint where - DefaultAllocator: Allocator, + DefaultAllocator: Allocator, { type Output = OPoint; @@ -81,25 +81,25 @@ where // Point - Point add_sub_impl!(Sub, sub, ClosedSub; (D, U1), (D, U1) -> (D, U1) - const; for D; where D: DimName, DefaultAllocator: Allocator; + const; for D; where D: DimName, DefaultAllocator: Allocator; self: &'a OPoint, right: &'b OPoint, Output = OVector; &self.coords - &right.coords; 'a, 'b); add_sub_impl!(Sub, sub, ClosedSub; (D, U1), (D, U1) -> (D, U1) - const; for D; where D: DimName, DefaultAllocator: Allocator; + const; for D; where D: DimName, DefaultAllocator: Allocator; self: &'a OPoint, right: OPoint, Output = OVector; &self.coords - right.coords; 'a); add_sub_impl!(Sub, sub, ClosedSub; (D, U1), (D, U1) -> (D, U1) - const; for D; where D: DimName, DefaultAllocator: Allocator; + const; for D; where D: DimName, DefaultAllocator: Allocator; self: OPoint, right: &'b OPoint, Output = OVector; self.coords - &right.coords; 'b); add_sub_impl!(Sub, sub, ClosedSub; (D, U1), (D, U1) -> (D, U1) - const; for D; where D: DimName, DefaultAllocator: Allocator; + const; for D; where D: DimName, DefaultAllocator: Allocator; self: OPoint, right: OPoint, Output = OVector; self.coords - right.coords; ); @@ -108,7 +108,7 @@ add_sub_impl!(Sub, sub, ClosedSub; (D1, U1), (D2, U1) -> (D1, U1) const; for D1, D2, SB; - where D1: DimName, D2: Dim, SB: Storage, DefaultAllocator: Allocator; + where D1: DimName, D2: Dim, SB: Storage, DefaultAllocator: Allocator; self: &'a OPoint, right: &'b Vector, Output = OPoint; Self::Output::from(&self.coords - right); 'a, 'b); @@ -116,7 +116,7 @@ add_sub_impl!(Sub, sub, ClosedSub; (D1, U1), (D2, U1) -> (D1, U1) const; for D1, D2, SB; - where D1: DimName, D2: Dim, SB: Storage, DefaultAllocator: Allocator; + where D1: DimName, D2: Dim, SB: Storage, DefaultAllocator: Allocator; self: &'a OPoint, right: Vector, Output = OPoint; Self::Output::from(&self.coords - &right); 'a); // TODO: should not be a ref to `right`. @@ -124,7 +124,7 @@ add_sub_impl!(Sub, sub, ClosedSub; (D1, U1), (D2, U1) -> (D1, U1) const; for D1, D2, SB; - where D1: DimName, D2: Dim, SB: Storage, DefaultAllocator: Allocator; + where D1: DimName, D2: Dim, SB: Storage, DefaultAllocator: Allocator; self: OPoint, right: &'b Vector, Output = OPoint; Self::Output::from(self.coords - right); 'b); @@ -132,7 +132,7 @@ add_sub_impl!(Sub, sub, ClosedSub; (D1, U1), (D2, U1) -> (D1, U1) const; for D1, D2, SB; - where D1: DimName, D2: Dim, SB: Storage, DefaultAllocator: Allocator; + where D1: DimName, D2: Dim, SB: Storage, DefaultAllocator: Allocator; self: OPoint, right: Vector, Output = OPoint; Self::Output::from(self.coords - right); ); @@ -141,7 +141,7 @@ add_sub_impl!(Add, add, ClosedAdd; (D1, U1), (D2, U1) -> (D1, U1) const; for D1, D2, SB; - where D1: DimName, D2: Dim, SB: Storage, DefaultAllocator: Allocator; + where D1: DimName, D2: Dim, SB: Storage, DefaultAllocator: Allocator; self: &'a OPoint, right: &'b Vector, Output = OPoint; Self::Output::from(&self.coords + right); 'a, 'b); @@ -149,7 +149,7 @@ add_sub_impl!(Add, add, ClosedAdd; (D1, U1), (D2, U1) -> (D1, U1) const; for D1, D2, SB; - where D1: DimName, D2: Dim, SB: Storage, DefaultAllocator: Allocator; + where D1: DimName, D2: Dim, SB: Storage, DefaultAllocator: Allocator; self: &'a OPoint, right: Vector, Output = OPoint; Self::Output::from(&self.coords + &right); 'a); // TODO: should not be a ref to `right`. @@ -157,7 +157,7 @@ add_sub_impl!(Add, add, ClosedAdd; (D1, U1), (D2, U1) -> (D1, U1) const; for D1, D2, SB; - where D1: DimName, D2: Dim, SB: Storage, DefaultAllocator: Allocator; + where D1: DimName, D2: Dim, SB: Storage, DefaultAllocator: Allocator; self: OPoint, right: &'b Vector, Output = OPoint; Self::Output::from(self.coords + right); 'b); @@ -165,7 +165,7 @@ add_sub_impl!(Add, add, ClosedAdd; (D1, U1), (D2, U1) -> (D1, U1) const; for D1, D2, SB; - where D1: DimName, D2: Dim, SB: Storage, DefaultAllocator: Allocator; + where D1: DimName, D2: Dim, SB: Storage, DefaultAllocator: Allocator; self: OPoint, right: Vector, Output = OPoint; Self::Output::from(self.coords + right); ); @@ -176,7 +176,7 @@ macro_rules! op_assign_impl( where T: Scalar + $bound, SB: Storage, ShapeConstraint: SameNumberOfRows, - DefaultAllocator: Allocator { + DefaultAllocator: Allocator { #[inline] fn $method_assign(&mut self, right: &'b Vector) { @@ -188,7 +188,7 @@ macro_rules! op_assign_impl( where T: Scalar + $bound, SB: Storage, ShapeConstraint: SameNumberOfRows, - DefaultAllocator: Allocator { + DefaultAllocator: Allocator { #[inline] fn $method_assign(&mut self, right: Vector) { @@ -231,7 +231,7 @@ macro_rules! componentwise_scalarop_impl( ($Trait: ident, $method: ident, $bound: ident; $TraitAssign: ident, $method_assign: ident) => { impl $Trait for OPoint - where DefaultAllocator: Allocator + where DefaultAllocator: Allocator { type Output = OPoint; @@ -242,7 +242,7 @@ macro_rules! componentwise_scalarop_impl( } impl<'a, T: Scalar + $bound, D: DimName> $Trait for &'a OPoint - where DefaultAllocator: Allocator + where DefaultAllocator: Allocator { type Output = OPoint; @@ -253,7 +253,7 @@ macro_rules! componentwise_scalarop_impl( } impl $TraitAssign for OPoint - where DefaultAllocator: Allocator + where DefaultAllocator: Allocator { #[inline] fn $method_assign(&mut self, right: T) { @@ -269,7 +269,7 @@ componentwise_scalarop_impl!(Div, div, ClosedDiv; DivAssign, div_assign); macro_rules! left_scalar_mul_impl( ($($T: ty),* $(,)*) => {$( impl Mul> for $T - where DefaultAllocator: Allocator<$T, D> + where DefaultAllocator: Allocator { type Output = OPoint<$T, D>; @@ -280,7 +280,7 @@ macro_rules! left_scalar_mul_impl( } impl<'b, D: DimName> Mul<&'b OPoint<$T, D>> for $T - where DefaultAllocator: Allocator<$T, D> + where DefaultAllocator: Allocator { type Output = OPoint<$T, D>; diff --git a/src/geometry/rotation.rs b/src/geometry/rotation.rs index d09a862a..01bca1d8 100644 --- a/src/geometry/rotation.rs +++ b/src/geometry/rotation.rs @@ -77,7 +77,7 @@ impl fmt::Debug for Rotation { impl hash::Hash for Rotation where - , Const>>::Buffer: hash::Hash, + , Const>>::Buffer: hash::Hash, { fn hash(&self, state: &mut H) { self.matrix.hash(state) @@ -265,7 +265,7 @@ impl Rotation { where T: Zero + One, Const: DimNameAdd, - DefaultAllocator: Allocator, U1>, DimNameSum, U1>>, + DefaultAllocator: Allocator, U1>, DimNameSum, U1>>, { // We could use `SMatrix::to_homogeneous()` here, but that would imply // adding the additional traits `DimAdd` and `IsNotStaticOne`. Maybe diff --git a/src/geometry/rotation_conversion.rs b/src/geometry/rotation_conversion.rs index c37b5cdd..95c0d9a6 100644 --- a/src/geometry/rotation_conversion.rs +++ b/src/geometry/rotation_conversion.rs @@ -1,5 +1,6 @@ use num::Zero; +use crate::ArrayStorage; use simba::scalar::{RealField, SubsetOf, SupersetOf}; use simba::simd::{PrimitiveSimdValue, SimdValue}; @@ -169,11 +170,9 @@ where T2: RealField + SupersetOf, C: SuperTCategoryOf, Const: DimNameAdd + DimMin, Output = Const>, // needed by .is_special_orthogonal() - DefaultAllocator: Allocator, U1>, DimNameSum, U1>> - + Allocator, U1>, DimNameSum, U1>>, - // + Allocator<(usize, usize), D>, - // Allocator - // + Allocator + DefaultAllocator: Allocator, U1>, DimNameSum, U1>>, + // + Allocator, + // + Allocator { // needed by .is_special_orthogonal() #[inline] @@ -198,10 +197,9 @@ where T1: RealField, T2: RealField + SupersetOf, Const: DimNameAdd + DimMin, Output = Const>, // needed by .is_special_orthogonal() - DefaultAllocator: Allocator, U1>, DimNameSum, U1>> - + Allocator, U1>, DimNameSum, U1>>, // + Allocator<(usize, usize), D>, - // + Allocator - // + Allocator + DefaultAllocator: Allocator, Const, Buffer = ArrayStorage> + + Allocator, U1>, DimNameSum, U1>>, // + Allocator, + // + Allocator { // needed by .is_special_orthogonal() #[inline] diff --git a/src/geometry/rotation_ops.rs b/src/geometry/rotation_ops.rs index 863acd39..213faa7d 100644 --- a/src/geometry/rotation_ops.rs +++ b/src/geometry/rotation_ops.rs @@ -77,7 +77,7 @@ md_impl_all!( const D1; for R2, C2, SB; where R2: Dim, C2: Dim, SB: Storage, - DefaultAllocator: Allocator, C2>, + DefaultAllocator: Allocator, C2>, ShapeConstraint: AreMultipliable, Const, R2, C2>; self: Rotation, right: Matrix, Output = OMatrix, C2>; [val val] => self.into_inner() * right; @@ -93,7 +93,7 @@ md_impl_all!( const D2; for R1, C1, SA; where R1: Dim, C1: Dim, SA: Storage, - DefaultAllocator: Allocator>, + DefaultAllocator: Allocator>, ShapeConstraint: AreMultipliable, Const>; self: Matrix, right: Rotation, Output = OMatrix>; [val val] => self * right.into_inner(); @@ -109,7 +109,7 @@ md_impl_all!( const D2; for R1, C1, SA; where R1: Dim, C1: Dim, SA: Storage, - DefaultAllocator: Allocator>, + DefaultAllocator: Allocator>, ShapeConstraint: AreMultipliable, Const>; self: Matrix, right: Rotation, Output = OMatrix>; [val val] => #[allow(clippy::suspicious_arithmetic_impl)] { self * right.inverse() }; diff --git a/src/geometry/scale.rs b/src/geometry/scale.rs index 31985e5a..80725f13 100644 --- a/src/geometry/scale.rs +++ b/src/geometry/scale.rs @@ -221,8 +221,8 @@ impl Scale { where T: Zero + One + Clone, Const: DimNameAdd, - DefaultAllocator: Allocator, U1>, DimNameSum, U1>> - + Allocator, U1>, U1>, + DefaultAllocator: Allocator, U1>, DimNameSum, U1>> + + Allocator, U1>, U1>, { // TODO: use self.vector.push() instead. We can’t right now because // that would require the DimAdd bound (but here we use DimNameAdd). diff --git a/src/geometry/scale_conversion.rs b/src/geometry/scale_conversion.rs index 2d807e3a..bf1b0647 100644 --- a/src/geometry/scale_conversion.rs +++ b/src/geometry/scale_conversion.rs @@ -48,9 +48,8 @@ where T2: RealField + SupersetOf, C: SuperTCategoryOf, Const: DimNameAdd, - DefaultAllocator: Allocator, U1>, DimNameSum, U1>> - + Allocator, U1>, U1> - + Allocator, U1>, DimNameSum, U1>>, + DefaultAllocator: Allocator, U1>, DimNameSum, U1>> + + Allocator, U1>, U1>, { #[inline] fn to_superset(&self) -> Transform { @@ -74,9 +73,8 @@ where T1: RealField, T2: RealField + SupersetOf, Const: DimNameAdd, - DefaultAllocator: Allocator, U1>, DimNameSum, U1>> - + Allocator, U1>, U1> - + Allocator, U1>, DimNameSum, U1>>, + DefaultAllocator: Allocator, U1>, DimNameSum, U1>> + + Allocator, U1>, U1>, { #[inline] fn to_superset(&self) -> OMatrix, U1>, DimNameSum, U1>> { @@ -113,9 +111,9 @@ impl From> for OMatrix, U1>, DimNameSum, U1>> where Const: DimNameAdd, - DefaultAllocator: Allocator, U1>, DimNameSum, U1>> - + Allocator, U1>, U1> - + Allocator>, + DefaultAllocator: Allocator, U1>, DimNameSum, U1>> + + Allocator, U1>, U1> + + Allocator>, { #[inline] fn from(t: Scale) -> Self { diff --git a/src/geometry/similarity.rs b/src/geometry/similarity.rs index 630ebac6..5499444f 100644 --- a/src/geometry/similarity.rs +++ b/src/geometry/similarity.rs @@ -26,14 +26,14 @@ use rkyv::bytecheck; feature = "serde-serialize-no-std", serde(bound(serialize = "T: Scalar + Serialize, R: Serialize, - DefaultAllocator: Allocator>, + DefaultAllocator: Allocator>, Owned>: Serialize")) )] #[cfg_attr( feature = "serde-serialize-no-std", serde(bound(deserialize = "T: Scalar + Deserialize<'de>, R: Deserialize<'de>, - DefaultAllocator: Allocator>, + DefaultAllocator: Allocator>, Owned>: Deserialize<'de>")) )] #[cfg_attr(feature = "rkyv-serialize", derive(bytecheck::CheckBytes))] @@ -307,7 +307,7 @@ impl Similarity { where Const: DimNameAdd, R: SubsetOf, U1>, DimNameSum, U1>>>, - DefaultAllocator: Allocator, U1>, DimNameSum, U1>>, + DefaultAllocator: Allocator, U1>, DimNameSum, U1>>, { let mut res = self.isometry.to_homogeneous(); diff --git a/src/geometry/similarity_conversion.rs b/src/geometry/similarity_conversion.rs index e5d28906..0f6a3078 100644 --- a/src/geometry/similarity_conversion.rs +++ b/src/geometry/similarity_conversion.rs @@ -1,5 +1,6 @@ use num::Zero; +use crate::ArrayStorage; use simba::scalar::{RealField, SubsetOf, SupersetOf}; use simba::simd::{PrimitiveSimdValue, SimdRealField, SimdValue}; @@ -56,14 +57,12 @@ where + SubsetOf, U1>, DimNameSum, U1>>> + SubsetOf, U1>, DimNameSum, U1>>>, Const: DimNameAdd + DimMin, Output = Const>, // needed by .determinant() - DefaultAllocator: Allocator, U1>, DimNameSum, U1>> - + Allocator, U1>, DimNameSum, U1>> - + Allocator, U1>, DimNameSum, U1>>, - // + Allocator<(usize, usize), D> + DefaultAllocator: Allocator, U1>, DimNameSum, U1>>, + // + Allocator // + Allocator // + Allocator - // + Allocator - // + Allocator, + // + Allocator + // + Allocator, { #[inline] fn to_superset(&self) -> Transform { @@ -91,13 +90,8 @@ where + SubsetOf, U1>, DimNameSum, U1>>> + SubsetOf, U1>, DimNameSum, U1>>>, Const: DimNameAdd + DimMin, Output = Const>, // needed by .determinant() - DefaultAllocator: Allocator, U1>, DimNameSum, U1>> - + Allocator, U1>, DimNameSum, U1>> - + Allocator, U1>, DimNameSum, U1>>, // + Allocator<(usize, usize), D> - // + Allocator - // + Allocator - // + Allocator - // + Allocator + DefaultAllocator: Allocator, Const<1>, Buffer = ArrayStorage> + + Allocator, U1>, DimNameSum, U1>>, { #[inline] fn to_superset(&self) -> OMatrix, U1>, DimNameSum, U1>> { @@ -178,7 +172,7 @@ impl From> where Const: DimNameAdd, R: SubsetOf, U1>, DimNameSum, U1>>>, - DefaultAllocator: Allocator, U1>, DimNameSum, U1>>, // + Allocator + DefaultAllocator: Allocator, U1>, DimNameSum, U1>>, // + Allocator { #[inline] fn from(sim: Similarity) -> Self { diff --git a/src/geometry/transform.rs b/src/geometry/transform.rs index 5e468792..5366ea81 100755 --- a/src/geometry/transform.rs +++ b/src/geometry/transform.rs @@ -32,7 +32,7 @@ pub trait TCategory: Any + Debug + Copy + PartialEq + Send { fn check_homogeneous_invariants(mat: &OMatrix) -> bool where T::Epsilon: Clone, - DefaultAllocator: Allocator; + DefaultAllocator: Allocator; } /// Traits that gives the `Transform` category that is compatible with the result of the @@ -75,7 +75,7 @@ impl TCategory for TGeneral { fn check_homogeneous_invariants(_: &OMatrix) -> bool where T::Epsilon: Clone, - DefaultAllocator: Allocator, + DefaultAllocator: Allocator, { true } @@ -86,7 +86,7 @@ impl TCategory for TProjective { fn check_homogeneous_invariants(mat: &OMatrix) -> bool where T::Epsilon: Clone, - DefaultAllocator: Allocator, + DefaultAllocator: Allocator, { mat.is_invertible() } @@ -102,7 +102,7 @@ impl TCategory for TAffine { fn check_homogeneous_invariants(mat: &OMatrix) -> bool where T::Epsilon: Clone, - DefaultAllocator: Allocator, + DefaultAllocator: Allocator, { let last = D::dim() - 1; mat.is_invertible() @@ -160,7 +160,7 @@ super_tcategory_impl!( pub struct Transform where Const: DimNameAdd, - DefaultAllocator: Allocator, U1>, DimNameSum, U1>>, + DefaultAllocator: Allocator, U1>, DimNameSum, U1>>, { matrix: OMatrix, U1>, DimNameSum, U1>>, _phantom: PhantomData, @@ -169,7 +169,7 @@ where impl Debug for Transform where Const: DimNameAdd, - DefaultAllocator: Allocator, U1>, DimNameSum, U1>>, + DefaultAllocator: Allocator, U1>, DimNameSum, U1>>, { fn fmt(&self, formatter: &mut fmt::Formatter<'_>) -> Result<(), fmt::Error> { self.matrix.fmt(formatter) @@ -179,7 +179,7 @@ where impl hash::Hash for Transform where Const: DimNameAdd, - DefaultAllocator: Allocator, U1>, DimNameSum, U1>>, + DefaultAllocator: Allocator, U1>, DimNameSum, U1>>, Owned, U1>, DimNameSum, U1>>: hash::Hash, { fn hash(&self, state: &mut H) { @@ -190,7 +190,7 @@ where impl Copy for Transform where Const: DimNameAdd, - DefaultAllocator: Allocator, U1>, DimNameSum, U1>>, + DefaultAllocator: Allocator, U1>, DimNameSum, U1>>, Owned, U1>, DimNameSum, U1>>: Copy, { } @@ -198,7 +198,7 @@ where impl Clone for Transform where Const: DimNameAdd, - DefaultAllocator: Allocator, U1>, DimNameSum, U1>>, + DefaultAllocator: Allocator, U1>, DimNameSum, U1>>, { #[inline] fn clone(&self) -> Self { @@ -211,7 +211,7 @@ unsafe impl bytemuck::Zeroable for Transform: DimNameAdd, - DefaultAllocator: Allocator, U1>, DimNameSum, U1>>, + DefaultAllocator: Allocator, U1>, DimNameSum, U1>>, OMatrix, U1>, DimNameSum, U1>>: bytemuck::Zeroable, { } @@ -221,7 +221,7 @@ unsafe impl bytemuck::Pod for Transform: DimNameAdd, - DefaultAllocator: Allocator, U1>, DimNameSum, U1>>, + DefaultAllocator: Allocator, U1>, DimNameSum, U1>>, OMatrix, U1>, DimNameSum, U1>>: bytemuck::Pod, Owned, U1>, DimNameSum, U1>>: Copy, { @@ -231,7 +231,7 @@ where impl Serialize for Transform where Const: DimNameAdd, - DefaultAllocator: Allocator, U1>, DimNameSum, U1>>, + DefaultAllocator: Allocator, U1>, DimNameSum, U1>>, Owned, U1>, DimNameSum, U1>>: Serialize, { fn serialize(&self, serializer: S) -> Result @@ -246,7 +246,7 @@ where impl<'a, T: RealField, C: TCategory, const D: usize> Deserialize<'a> for Transform where Const: DimNameAdd, - DefaultAllocator: Allocator, U1>, DimNameSum, U1>>, + DefaultAllocator: Allocator, U1>, DimNameSum, U1>>, Owned, U1>, DimNameSum, U1>>: Deserialize<'a>, { fn deserialize(deserializer: Des) -> Result @@ -264,14 +264,14 @@ where impl Eq for Transform where Const: DimNameAdd, - DefaultAllocator: Allocator, U1>, DimNameSum, U1>>, + DefaultAllocator: Allocator, U1>, DimNameSum, U1>>, { } impl PartialEq for Transform where Const: DimNameAdd, - DefaultAllocator: Allocator, U1>, DimNameSum, U1>>, + DefaultAllocator: Allocator, U1>, DimNameSum, U1>>, { #[inline] fn eq(&self, right: &Self) -> bool { @@ -282,7 +282,7 @@ where impl Transform where Const: DimNameAdd, - DefaultAllocator: Allocator, U1>, DimNameSum, U1>>, + DefaultAllocator: Allocator, U1>, DimNameSum, U1>>, { /// Creates a new transformation from the given homogeneous matrix. The transformation category /// of `Self` is not checked to be verified by the given matrix. @@ -523,9 +523,9 @@ where T: RealField, C: TCategory, Const: DimNameAdd, - DefaultAllocator: Allocator, U1>, DimNameSum, U1>> - + Allocator, U1>>, // + Allocator - // + Allocator + DefaultAllocator: Allocator, U1>, DimNameSum, U1>> + + Allocator, U1>>, // + Allocator + // + Allocator { /// Transform the given point by this transformation. /// @@ -551,9 +551,9 @@ impl Transform where Const: DimNameAdd, C: SubTCategoryOf, - DefaultAllocator: Allocator, U1>, DimNameSum, U1>> - + Allocator, U1>>, // + Allocator - // + Allocator + DefaultAllocator: Allocator, U1>, DimNameSum, U1>> + + Allocator, U1>>, // + Allocator + // + Allocator { /// Transform the given point by the inverse of this transformation. /// This may be cheaper than inverting the transformation and transforming @@ -577,7 +577,7 @@ where impl Transform where Const: DimNameAdd, - DefaultAllocator: Allocator, U1>, DimNameSum, U1>>, + DefaultAllocator: Allocator, U1>, DimNameSum, U1>>, { /// A mutable reference to underlying matrix. Use `.matrix_mut_unchecked` instead if this /// transformation category is not `TGeneral`. @@ -593,7 +593,7 @@ impl AbsDiffEq for Transform: DimNameAdd, T::Epsilon: Clone, - DefaultAllocator: Allocator, U1>, DimNameSum, U1>>, + DefaultAllocator: Allocator, U1>, DimNameSum, U1>>, { type Epsilon = T::Epsilon; @@ -612,7 +612,7 @@ impl RelativeEq for Transform: DimNameAdd, T::Epsilon: Clone, - DefaultAllocator: Allocator, U1>, DimNameSum, U1>>, + DefaultAllocator: Allocator, U1>, DimNameSum, U1>>, { #[inline] fn default_max_relative() -> Self::Epsilon { @@ -635,7 +635,7 @@ impl UlpsEq for Transform where Const: DimNameAdd, T::Epsilon: Clone, - DefaultAllocator: Allocator, U1>, DimNameSum, U1>>, + DefaultAllocator: Allocator, U1>, DimNameSum, U1>>, { #[inline] fn default_max_ulps() -> u32 { diff --git a/src/geometry/transform_construction.rs b/src/geometry/transform_construction.rs index 45d61fcf..3d1aaa7f 100644 --- a/src/geometry/transform_construction.rs +++ b/src/geometry/transform_construction.rs @@ -11,7 +11,7 @@ use crate::geometry::{TCategory, Transform}; impl Default for Transform where Const: DimNameAdd, - DefaultAllocator: Allocator, U1>, DimNameSum, U1>>, + DefaultAllocator: Allocator, U1>, DimNameSum, U1>>, { fn default() -> Self { Self::identity() @@ -21,7 +21,7 @@ where impl Transform where Const: DimNameAdd, - DefaultAllocator: Allocator, U1>, DimNameSum, U1>>, + DefaultAllocator: Allocator, U1>, DimNameSum, U1>>, { /// Creates a new identity transform. /// @@ -64,7 +64,7 @@ where impl One for Transform where Const: DimNameAdd, - DefaultAllocator: Allocator, U1>, DimNameSum, U1>>, + DefaultAllocator: Allocator, U1>, DimNameSum, U1>>, { /// Creates a new identity transform. #[inline] diff --git a/src/geometry/transform_conversion.rs b/src/geometry/transform_conversion.rs index e8eb3908..84753c7e 100644 --- a/src/geometry/transform_conversion.rs +++ b/src/geometry/transform_conversion.rs @@ -13,8 +13,7 @@ where C1: TCategory, C2: SuperTCategoryOf, Const: DimNameAdd, - DefaultAllocator: Allocator, U1>, DimNameSum, U1>> - + Allocator, U1>, DimNameSum, U1>>, + DefaultAllocator: Allocator, U1>, DimNameSum, U1>>, T1::Epsilon: Copy, T2::Epsilon: Copy, { @@ -42,8 +41,7 @@ where T2: RealField, C: TCategory, Const: DimNameAdd, - DefaultAllocator: Allocator, U1>, DimNameSum, U1>> - + Allocator, U1>, DimNameSum, U1>>, + DefaultAllocator: Allocator, U1>, DimNameSum, U1>>, T1::Epsilon: Copy, T2::Epsilon: Copy, { @@ -70,7 +68,7 @@ impl From> where Const: DimNameAdd, C: TCategory, - DefaultAllocator: Allocator, U1>, DimNameSum, U1>>, + DefaultAllocator: Allocator, U1>, DimNameSum, U1>>, { #[inline] fn from(t: Transform) -> Self { diff --git a/src/geometry/transform_ops.rs b/src/geometry/transform_ops.rs index 4c6284d0..acc368ca 100644 --- a/src/geometry/transform_ops.rs +++ b/src/geometry/transform_ops.rs @@ -85,7 +85,7 @@ use crate::geometry::{ impl Index<(usize, usize)> for Transform where Const: DimNameAdd, - DefaultAllocator: Allocator, U1>, DimNameSum, U1>>, + DefaultAllocator: Allocator, U1>, DimNameSum, U1>>, { type Output = T; @@ -99,7 +99,7 @@ where impl IndexMut<(usize, usize)> for Transform where Const: DimNameAdd, - DefaultAllocator: Allocator, U1>, DimNameSum, U1>>, + DefaultAllocator: Allocator, U1>, DimNameSum, U1>>, { #[inline] fn index_mut(&mut self, ij: (usize, usize)) -> &mut T { @@ -114,7 +114,7 @@ md_impl_all!( const D; for C; where Const: DimNameAdd, C: TCategory, - DefaultAllocator: Allocator, U1>, DimNameSum, U1>>; + DefaultAllocator: Allocator, U1>, DimNameSum, U1>>; self: Transform, rhs: SVector, Output = SVector; [val val] => &self * &rhs; [ref val] => self * &rhs; @@ -142,7 +142,7 @@ md_impl_all!( const D; for C; where Const: DimNameAdd, C: TCategory, - DefaultAllocator: Allocator, U1>, DimNameSum, U1>>; + DefaultAllocator: Allocator, U1>, DimNameSum, U1>>; self: Transform, rhs: Point, Output = Point; [val val] => &self * &rhs; [ref val] => self * &rhs; @@ -172,7 +172,7 @@ md_impl_all!( const D; for CA, CB; where Const: DimNameAdd, CA: TCategoryMul, CB: TCategory, - DefaultAllocator: Allocator, U1>, DimNameSum, U1>>; + DefaultAllocator: Allocator, U1>, DimNameSum, U1>>; self: Transform, rhs: Transform, Output = Transform; [val val] => Self::Output::from_matrix_unchecked(self.into_inner() * rhs.into_inner()); [ref val] => Self::Output::from_matrix_unchecked(self.matrix() * rhs.into_inner()); @@ -188,7 +188,7 @@ md_impl_all!( const D; for C; where Const: DimNameAdd, C: TCategoryMul, - DefaultAllocator: Allocator, U1>, DimNameSum, U1>>; + DefaultAllocator: Allocator, U1>, DimNameSum, U1>>; self: Transform, rhs: Rotation, Output = Transform; [val val] => Self::Output::from_matrix_unchecked(self.into_inner() * rhs.to_homogeneous()); [ref val] => Self::Output::from_matrix_unchecked(self.matrix() * rhs.to_homogeneous()); @@ -203,7 +203,7 @@ md_impl_all!( const D; for C; where Const: DimNameAdd, C: TCategoryMul, - DefaultAllocator: Allocator, U1>, DimNameSum, U1>>; + DefaultAllocator: Allocator, U1>, DimNameSum, U1>>; self: Rotation, rhs: Transform, Output = Transform; [val val] => Self::Output::from_matrix_unchecked(self.to_homogeneous() * rhs.into_inner()); [ref val] => Self::Output::from_matrix_unchecked(self.to_homogeneous() * rhs.into_inner()); @@ -274,7 +274,7 @@ md_impl_all!( const D; for C, R; where Const: DimNameAdd, C: TCategoryMul, R: SubsetOf, U1>, DimNameSum, U1>> >, - DefaultAllocator: Allocator, U1>, DimNameSum, U1>>; + DefaultAllocator: Allocator, U1>, DimNameSum, U1>>; self: Transform, rhs: Isometry, Output = Transform; [val val] => Self::Output::from_matrix_unchecked(self.into_inner() * rhs.to_homogeneous()); [ref val] => Self::Output::from_matrix_unchecked(self.matrix() * rhs.to_homogeneous()); @@ -289,7 +289,7 @@ md_impl_all!( const D; for C, R; where Const: DimNameAdd, C: TCategoryMul, R: SubsetOf, U1>, DimNameSum, U1>> >, - DefaultAllocator: Allocator, U1>, DimNameSum, U1>>; + DefaultAllocator: Allocator, U1>, DimNameSum, U1>>; self: Isometry, rhs: Transform, Output = Transform; [val val] => Self::Output::from_matrix_unchecked(self.to_homogeneous() * rhs.into_inner()); [ref val] => Self::Output::from_matrix_unchecked(self.to_homogeneous() * rhs.into_inner()); @@ -304,7 +304,7 @@ md_impl_all!( const D; for C, R; where Const: DimNameAdd, C: TCategoryMul, R: SubsetOf, U1>, DimNameSum, U1>> >, - DefaultAllocator: Allocator, U1>, DimNameSum, U1>>; + DefaultAllocator: Allocator, U1>, DimNameSum, U1>>; self: Transform, rhs: Similarity, Output = Transform; [val val] => Self::Output::from_matrix_unchecked(self.into_inner() * rhs.to_homogeneous()); [ref val] => Self::Output::from_matrix_unchecked(self.matrix() * rhs.to_homogeneous()); @@ -319,7 +319,7 @@ md_impl_all!( const D; for C, R; where Const: DimNameAdd, C: TCategoryMul, R: SubsetOf, U1>, DimNameSum, U1>> >, - DefaultAllocator: Allocator, U1>, DimNameSum, U1>>; + DefaultAllocator: Allocator, U1>, DimNameSum, U1>>; self: Similarity, rhs: Transform, Output = Transform; [val val] => Self::Output::from_matrix_unchecked(self.to_homogeneous() * rhs.into_inner()); [ref val] => Self::Output::from_matrix_unchecked(self.to_homogeneous() * rhs.into_inner()); @@ -342,7 +342,7 @@ md_impl_all!( const D; for C; where Const: DimNameAdd, C: TCategoryMul, - DefaultAllocator: Allocator, U1>, DimNameSum, U1>>; + DefaultAllocator: Allocator, U1>, DimNameSum, U1>>; self: Transform, rhs: Translation, Output = Transform; [val val] => Self::Output::from_matrix_unchecked(self.into_inner() * rhs.to_homogeneous()); [ref val] => Self::Output::from_matrix_unchecked(self.matrix() * rhs.to_homogeneous()); @@ -357,7 +357,7 @@ md_impl_all!( const D; for C; where Const: DimNameAdd, C: TCategoryMul, - DefaultAllocator: Allocator, U1>, DimNameSum, U1>>; + DefaultAllocator: Allocator, U1>, DimNameSum, U1>>; self: Translation, rhs: Transform, Output = Transform; [val val] => Self::Output::from_matrix_unchecked(self.to_homogeneous() * rhs.into_inner()); [ref val] => Self::Output::from_matrix_unchecked(self.to_homogeneous() * rhs.into_inner()); @@ -372,7 +372,7 @@ md_impl_all!( const D; for CA, CB; where Const: DimNameAdd, CA: TCategoryMul, CB: SubTCategoryOf, - DefaultAllocator: Allocator, U1>, DimNameSum, U1>>; + DefaultAllocator: Allocator, U1>, DimNameSum, U1>>; self: Transform, rhs: Transform, Output = Transform; [val val] => #[allow(clippy::suspicious_arithmetic_impl)] { self * rhs.inverse() }; [ref val] => #[allow(clippy::suspicious_arithmetic_impl)] { self * rhs.inverse() }; @@ -387,7 +387,7 @@ md_impl_all!( const D; for C; where Const: DimNameAdd, C: TCategoryMul, - DefaultAllocator: Allocator, U1>, DimNameSum, U1>>; + DefaultAllocator: Allocator, U1>, DimNameSum, U1>>; self: Transform, rhs: Rotation, Output = Transform; [val val] => #[allow(clippy::suspicious_arithmetic_impl)] { self * rhs.inverse() }; [ref val] => #[allow(clippy::suspicious_arithmetic_impl)] { self * rhs.inverse() }; @@ -402,7 +402,7 @@ md_impl_all!( const D; for C; where Const: DimNameAdd, C: TCategoryMul, - DefaultAllocator: Allocator, U1>, DimNameSum, U1>>; + DefaultAllocator: Allocator, U1>, DimNameSum, U1>>; self: Rotation, rhs: Transform, Output = Transform; [val val] => #[allow(clippy::suspicious_arithmetic_impl)] { self.inverse() * rhs }; [ref val] => #[allow(clippy::suspicious_arithmetic_impl)] { self.inverse() * rhs }; @@ -443,7 +443,7 @@ md_impl_all!( // Div, div where T: RealField; // (DimNameSum, U1>, DimNameSum, U1>), (Const, U1) // for Const: DimNameAdd, C: TCategoryMul, R: SubsetOf, U1>, DimNameSum, U1>> > -// where SB::Alloc: Allocator, U1>, DimNameSum, U1> >; +// where SB::Alloc: Allocator, U1>, DimNameSum, U1> >; // self: Transform, rhs: Isometry, Output = Transform; // [val val] => Self::Output::from_matrix_unchecked(self.into_inner() * rhs.inverse().to_homogeneous()); // [ref val] => Self::Output::from_matrix_unchecked(self.matrix() * rhs.inverse().to_homogeneous()); @@ -456,7 +456,7 @@ md_impl_all!( // Div, div where T: RealField; // (Const, U1), (DimNameSum, U1>, DimNameSum, U1>) // for Const: DimNameAdd, C: TCategoryMul, R: SubsetOf, U1>, DimNameSum, U1>> > -// where SA::Alloc: Allocator, U1>, DimNameSum, U1> >; +// where SA::Alloc: Allocator, U1>, DimNameSum, U1> >; // self: Isometry, rhs: Transform, Output = Transform; // [val val] => Self::Output::from_matrix_unchecked(self.to_homogeneous() * rhs.into_inner()); // [ref val] => Self::Output::from_matrix_unchecked(self.to_homogeneous() * rhs.into_inner()); @@ -469,8 +469,8 @@ md_impl_all!( // Div, div where T: RealField; // (DimNameSum, U1>, DimNameSum, U1>), (Const, U1) // for Const: DimNameAdd, C: TCategoryMul, R: SubsetOf, U1>, DimNameSum, U1>> > -// where SB::Alloc: Allocator -// where SB::Alloc: Allocator, U1>, DimNameSum, U1> >; +// where SB::Alloc: Allocator +// where SB::Alloc: Allocator, U1>, DimNameSum, U1> >; // self: Transform, rhs: Similarity, Output = Transform; // [val val] => Self::Output::from_matrix_unchecked(self.into_inner() * rhs.to_homogeneous()); // [ref val] => Self::Output::from_matrix_unchecked(self.matrix() * rhs.to_homogeneous()); @@ -483,8 +483,8 @@ md_impl_all!( // Div, div where T: RealField; // (Const, U1), (DimNameSum, U1>, DimNameSum, U1>) // for Const: DimNameAdd, C: TCategoryMul, R: SubsetOf, U1>, DimNameSum, U1>> > -// where SA::Alloc: Allocator -// where SA::Alloc: Allocator, U1>, DimNameSum, U1> >; +// where SA::Alloc: Allocator +// where SA::Alloc: Allocator, U1>, DimNameSum, U1> >; // self: Similarity, rhs: Transform, Output = Transform; // [val val] => Self::Output::from_matrix_unchecked(self.to_homogeneous() * rhs.into_inner()); // [ref val] => Self::Output::from_matrix_unchecked(self.to_homogeneous() * rhs.into_inner()); @@ -499,7 +499,7 @@ md_impl_all!( const D; for C; where Const: DimNameAdd, C: TCategoryMul, - DefaultAllocator: Allocator, U1>, DimNameSum, U1>>; + DefaultAllocator: Allocator, U1>, DimNameSum, U1>>; self: Transform, rhs: Translation, Output = Transform; [val val] => #[allow(clippy::suspicious_arithmetic_impl)] { self * rhs.inverse() }; [ref val] => #[allow(clippy::suspicious_arithmetic_impl)] { self * rhs.inverse() }; @@ -514,7 +514,7 @@ md_impl_all!( const D; for C; where Const: DimNameAdd, C: TCategoryMul, - DefaultAllocator: Allocator, U1>, DimNameSum, U1>>; + DefaultAllocator: Allocator, U1>, DimNameSum, U1>>; self: Translation, rhs: Transform, Output = Transform; [val val] => #[allow(clippy::suspicious_arithmetic_impl)] { self.inverse() * rhs }; [ref val] => #[allow(clippy::suspicious_arithmetic_impl)] { self.inverse() * rhs }; @@ -529,7 +529,7 @@ md_assign_impl_all!( const D; for CA, CB; where Const: DimNameAdd, CA: TCategory, CB: SubTCategoryOf, - DefaultAllocator: Allocator, U1>, DimNameSum, U1>>; + DefaultAllocator: Allocator, U1>, DimNameSum, U1>>; self: Transform, rhs: Transform; [val] => *self.matrix_mut_unchecked() *= rhs.into_inner(); [ref] => *self.matrix_mut_unchecked() *= rhs.matrix(); @@ -542,7 +542,7 @@ md_assign_impl_all!( const D; for C, R; where Const: DimNameAdd, C: TCategory, R: SubsetOf, U1>, DimNameSum, U1>> >, - DefaultAllocator: Allocator, U1>, DimNameSum, U1>>; + DefaultAllocator: Allocator, U1>, DimNameSum, U1>>; self: Transform, rhs: Similarity; [val] => *self.matrix_mut_unchecked() *= rhs.to_homogeneous(); [ref] => *self.matrix_mut_unchecked() *= rhs.to_homogeneous(); @@ -555,7 +555,7 @@ md_assign_impl_all!( const D; for C, R; where Const: DimNameAdd, C: TCategory, R: SubsetOf, U1>, DimNameSum, U1>> >, - DefaultAllocator: Allocator, U1>, DimNameSum, U1>>; + DefaultAllocator: Allocator, U1>, DimNameSum, U1>>; self: Transform, rhs: Isometry; [val] => *self.matrix_mut_unchecked() *= rhs.to_homogeneous(); [ref] => *self.matrix_mut_unchecked() *= rhs.to_homogeneous(); @@ -576,7 +576,7 @@ md_assign_impl_all!( const D; for C; where Const: DimNameAdd, C: TCategory, - DefaultAllocator: Allocator, U1>, DimNameSum, U1>>; + DefaultAllocator: Allocator, U1>, DimNameSum, U1>>; self: Transform, rhs: Translation; [val] => *self.matrix_mut_unchecked() *= rhs.to_homogeneous(); [ref] => *self.matrix_mut_unchecked() *= rhs.to_homogeneous(); @@ -589,7 +589,7 @@ md_assign_impl_all!( const D; for C; where Const: DimNameAdd, C: TCategory, - DefaultAllocator: Allocator, U1>, DimNameSum, U1>>; + DefaultAllocator: Allocator, U1>, DimNameSum, U1>>; self: Transform, rhs: Rotation; [val] => *self.matrix_mut_unchecked() *= rhs.to_homogeneous(); [ref] => *self.matrix_mut_unchecked() *= rhs.to_homogeneous(); @@ -626,7 +626,7 @@ md_assign_impl_all!( const D; for CA, CB; where Const: DimNameAdd, CA: SuperTCategoryOf, CB: SubTCategoryOf, - DefaultAllocator: Allocator, U1>, DimNameSum, U1>>; + DefaultAllocator: Allocator, U1>, DimNameSum, U1>>; self: Transform, rhs: Transform; [val] => #[allow(clippy::suspicious_op_assign_impl)] { *self *= rhs.inverse() }; [ref] => #[allow(clippy::suspicious_op_assign_impl)] { *self *= rhs.clone().inverse() }; @@ -660,7 +660,7 @@ md_assign_impl_all!( const D; for C; where Const: DimNameAdd, C: TCategory, - DefaultAllocator: Allocator, U1>, DimNameSum, U1>>; + DefaultAllocator: Allocator, U1>, DimNameSum, U1>>; self: Transform, rhs: Translation; [val] => #[allow(clippy::suspicious_op_assign_impl)] { *self *= rhs.inverse() }; [ref] => #[allow(clippy::suspicious_op_assign_impl)] { *self *= rhs.inverse() }; @@ -673,7 +673,7 @@ md_assign_impl_all!( const D; for C; where Const: DimNameAdd, C: TCategory, - DefaultAllocator: Allocator, U1>, DimNameSum, U1>>; + DefaultAllocator: Allocator, U1>, DimNameSum, U1>>; self: Transform, rhs: Rotation; [val] => #[allow(clippy::suspicious_op_assign_impl)] { *self *= rhs.inverse() }; [ref] => #[allow(clippy::suspicious_op_assign_impl)] { *self *= rhs.inverse() }; diff --git a/src/geometry/transform_simba.rs b/src/geometry/transform_simba.rs index db794712..09372483 100755 --- a/src/geometry/transform_simba.rs +++ b/src/geometry/transform_simba.rs @@ -12,8 +12,7 @@ where T::Element: Scalar, C: TCategory, Const: DimNameAdd, - DefaultAllocator: Allocator, U1>, DimNameSum, U1>> - + Allocator, U1>, DimNameSum, U1>>, + DefaultAllocator: Allocator, U1>, DimNameSum, U1>>, { type Element = Transform; type SimdBool = T::SimdBool; diff --git a/src/geometry/translation.rs b/src/geometry/translation.rs index d626b1dc..5e04f376 100644 --- a/src/geometry/translation.rs +++ b/src/geometry/translation.rs @@ -153,7 +153,7 @@ impl Translation { where T: Zero + One, Const: DimNameAdd, - DefaultAllocator: Allocator, U1>, DimNameSum, U1>>, + DefaultAllocator: Allocator, U1>, DimNameSum, U1>>, { let mut res = OMatrix::, U1>, DimNameSum, U1>>::identity(); res.fixed_view_mut::(0, D).copy_from(&self.vector); diff --git a/src/geometry/translation_conversion.rs b/src/geometry/translation_conversion.rs index 73646780..1175170f 100644 --- a/src/geometry/translation_conversion.rs +++ b/src/geometry/translation_conversion.rs @@ -11,7 +11,7 @@ use crate::geometry::{ AbstractRotation, Isometry, Similarity, SuperTCategoryOf, TAffine, Transform, Translation, Translation3, UnitDualQuaternion, UnitQuaternion, }; -use crate::Point; +use crate::{ArrayStorage, Point}; /* * This file provides the following conversions: @@ -122,8 +122,7 @@ where T2: RealField + SupersetOf, C: SuperTCategoryOf, Const: DimNameAdd, - DefaultAllocator: Allocator, U1>, DimNameSum, U1>> - + Allocator, U1>, DimNameSum, U1>>, + DefaultAllocator: Allocator, U1>, DimNameSum, U1>>, { #[inline] fn to_superset(&self) -> Transform { @@ -147,10 +146,8 @@ where T1: RealField, T2: RealField + SupersetOf, Const: DimNameAdd, - DefaultAllocator: Allocator, U1>, DimNameSum, U1>> - + Allocator, U1>, DimNameSum, U1>>, - // + Allocator - // + Allocator + DefaultAllocator: Allocator, Buffer = ArrayStorage> + + Allocator, U1>, DimNameSum, U1>>, { #[inline] fn to_superset(&self) -> OMatrix, U1>, DimNameSum, U1>> { @@ -173,9 +170,9 @@ where fn from_superset_unchecked( m: &OMatrix, U1>, DimNameSum, U1>>, ) -> Self { - let t = m.fixed_view::(0, D); + let t: OVector> = m.fixed_view::(0, D).into_owned(); Self { - vector: crate::convert_unchecked(t.into_owned()), + vector: crate::convert_unchecked(t), } } } @@ -185,7 +182,7 @@ impl From> where Const: DimNameAdd, DefaultAllocator: - Allocator, U1>, DimNameSum, U1>> + Allocator>, + Allocator, U1>, DimNameSum, U1>> + Allocator>, { #[inline] fn from(t: Translation) -> Self { diff --git a/src/lib.rs b/src/lib.rs index 8532d532..48662e87 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -275,7 +275,7 @@ pub fn abs(a: &T) -> T { pub fn inf(a: &OMatrix, b: &OMatrix) -> OMatrix where T: Scalar + SimdPartialOrd, - DefaultAllocator: Allocator, + DefaultAllocator: Allocator, { a.inf(b) } @@ -286,7 +286,7 @@ where pub fn sup(a: &OMatrix, b: &OMatrix) -> OMatrix where T: Scalar + SimdPartialOrd, - DefaultAllocator: Allocator, + DefaultAllocator: Allocator, { a.sup(b) } @@ -300,7 +300,7 @@ pub fn inf_sup( ) -> (OMatrix, OMatrix) where T: Scalar + SimdPartialOrd, - DefaultAllocator: Allocator, + DefaultAllocator: Allocator, { a.inf_sup(b) } diff --git a/src/linalg/balancing.rs b/src/linalg/balancing.rs index 4be9ba9f..f10e793a 100644 --- a/src/linalg/balancing.rs +++ b/src/linalg/balancing.rs @@ -13,7 +13,7 @@ use crate::base::{Const, DefaultAllocator, OMatrix, OVector}; /// See pub fn balance_parlett_reinsch(matrix: &mut OMatrix) -> OVector where - DefaultAllocator: Allocator + Allocator, + DefaultAllocator: Allocator + Allocator, { assert!(matrix.is_square(), "Unable to balance a non-square matrix."); @@ -68,7 +68,7 @@ where /// Computes in-place `D * m * D.inverse()`, where `D` is the matrix with diagonal `d`. pub fn unbalance(m: &mut OMatrix, d: &OVector) where - DefaultAllocator: Allocator + Allocator, + DefaultAllocator: Allocator + Allocator, { assert!(m.is_square(), "Unable to unbalance a non-square matrix."); assert_eq!(m.nrows(), d.len(), "Unbalancing: mismatched dimensions."); diff --git a/src/linalg/bidiagonal.rs b/src/linalg/bidiagonal.rs index 4faa9c5a..13ffc7ea 100644 --- a/src/linalg/bidiagonal.rs +++ b/src/linalg/bidiagonal.rs @@ -16,9 +16,9 @@ use std::mem::MaybeUninit; #[cfg_attr( feature = "serde-serialize-no-std", serde(bound(serialize = "DimMinimum: DimSub, - DefaultAllocator: Allocator + - Allocator> + - Allocator, U1>>, + DefaultAllocator: Allocator + + Allocator> + + Allocator, U1>>, OMatrix: Serialize, OVector>: Serialize, OVector, U1>>: Serialize")) @@ -26,9 +26,9 @@ use std::mem::MaybeUninit; #[cfg_attr( feature = "serde-serialize-no-std", serde(bound(deserialize = "DimMinimum: DimSub, - DefaultAllocator: Allocator + - Allocator> + - Allocator, U1>>, + DefaultAllocator: Allocator + + Allocator> + + Allocator, U1>>, OMatrix: Deserialize<'de>, OVector>: Deserialize<'de>, OVector, U1>>: Deserialize<'de>")) @@ -37,9 +37,8 @@ use std::mem::MaybeUninit; pub struct Bidiagonal, C: Dim> where DimMinimum: DimSub, - DefaultAllocator: Allocator - + Allocator> - + Allocator, U1>>, + DefaultAllocator: + Allocator + Allocator> + Allocator, U1>>, { // TODO: perhaps we should pack the axes into different vectors so that axes for `v_t` are // contiguous. This prevents some useless copies. @@ -54,9 +53,8 @@ where impl, C: Dim> Copy for Bidiagonal where DimMinimum: DimSub, - DefaultAllocator: Allocator - + Allocator> - + Allocator, U1>>, + DefaultAllocator: + Allocator + Allocator> + Allocator, U1>>, OMatrix: Copy, OVector>: Copy, OVector, U1>>: Copy, @@ -66,11 +64,11 @@ where impl, C: Dim> Bidiagonal where DimMinimum: DimSub, - DefaultAllocator: Allocator - + Allocator - + Allocator - + Allocator> - + Allocator, U1>>, + DefaultAllocator: Allocator + + Allocator + + Allocator + + Allocator> + + Allocator, U1>>, { /// Computes the Bidiagonal decomposition using householder reflections. pub fn new(mut matrix: OMatrix) -> Self { @@ -177,9 +175,9 @@ where OMatrix, C>, ) where - DefaultAllocator: Allocator, DimMinimum> - + Allocator> - + Allocator, C>, + DefaultAllocator: Allocator, DimMinimum> + + Allocator> + + Allocator, C>, { // TODO: optimize by calling a reallocator. (self.u(), self.d(), self.v_t()) @@ -190,7 +188,7 @@ where #[must_use] pub fn d(&self) -> OMatrix, DimMinimum> where - DefaultAllocator: Allocator, DimMinimum>, + DefaultAllocator: Allocator, DimMinimum>, { let (nrows, ncols) = self.uv.shape_generic(); @@ -218,7 +216,7 @@ where #[must_use] pub fn u(&self) -> OMatrix> where - DefaultAllocator: Allocator>, + DefaultAllocator: Allocator>, { let (nrows, ncols) = self.uv.shape_generic(); @@ -253,7 +251,7 @@ where #[must_use] pub fn v_t(&self) -> OMatrix, C> where - DefaultAllocator: Allocator, C>, + DefaultAllocator: Allocator, C>, { let (nrows, ncols) = self.uv.shape_generic(); let min_nrows_ncols = nrows.min(ncols); @@ -293,7 +291,7 @@ where #[must_use] pub fn diagonal(&self) -> OVector> where - DefaultAllocator: Allocator>, + DefaultAllocator: Allocator>, { self.diagonal.map(|e| e.modulus()) } @@ -302,7 +300,7 @@ where #[must_use] pub fn off_diagonal(&self) -> OVector, U1>> where - DefaultAllocator: Allocator, U1>>, + DefaultAllocator: Allocator, U1>>, { self.off_diagonal.map(|e| e.modulus()) } @@ -314,8 +312,8 @@ where } // impl + DimSub> Bidiagonal -// where DefaultAllocator: Allocator + -// Allocator { +// where DefaultAllocator: Allocator + +// Allocator { // /// Solves the linear system `self * x = b`, where `x` is the unknown to be determined. // pub fn solve(&self, b: &Matrix) -> OMatrix // where S2: StorageMut, diff --git a/src/linalg/cholesky.rs b/src/linalg/cholesky.rs index 02101748..95c4a4ed 100644 --- a/src/linalg/cholesky.rs +++ b/src/linalg/cholesky.rs @@ -15,32 +15,32 @@ use crate::storage::{Storage, StorageMut}; #[cfg_attr(feature = "serde-serialize-no-std", derive(Serialize, Deserialize))] #[cfg_attr( feature = "serde-serialize-no-std", - serde(bound(serialize = "DefaultAllocator: Allocator, + serde(bound(serialize = "DefaultAllocator: Allocator, OMatrix: Serialize")) )] #[cfg_attr( feature = "serde-serialize-no-std", - serde(bound(deserialize = "DefaultAllocator: Allocator, + serde(bound(deserialize = "DefaultAllocator: Allocator, OMatrix: Deserialize<'de>")) )] #[derive(Clone, Debug)] pub struct Cholesky where - DefaultAllocator: Allocator, + DefaultAllocator: Allocator, { chol: OMatrix, } impl Copy for Cholesky where - DefaultAllocator: Allocator, + DefaultAllocator: Allocator, OMatrix: Copy, { } impl Cholesky where - DefaultAllocator: Allocator, + DefaultAllocator: Allocator, { /// Computes the Cholesky decomposition of `matrix` without checking that the matrix is definite-positive. /// @@ -133,7 +133,7 @@ where pub fn solve(&self, b: &Matrix) -> OMatrix where S2: Storage, - DefaultAllocator: Allocator, + DefaultAllocator: Allocator, ShapeConstraint: SameNumberOfRows, { let mut res = b.clone_owned(); @@ -186,7 +186,7 @@ where impl Cholesky where - DefaultAllocator: Allocator, + DefaultAllocator: Allocator, { /// Attempts to compute the Cholesky decomposition of `matrix`. /// @@ -268,7 +268,7 @@ where pub fn rank_one_update(&mut self, x: &Vector, sigma: T::RealField) where S2: Storage, - DefaultAllocator: Allocator, + DefaultAllocator: Allocator, ShapeConstraint: SameNumberOfRows, { Self::xx_rank_one_update(&mut self.chol, &mut x.clone_owned(), sigma) @@ -285,7 +285,7 @@ where D: DimAdd, R2: Dim, S2: Storage, - DefaultAllocator: Allocator, DimSum> + Allocator, + DefaultAllocator: Allocator, DimSum> + Allocator, ShapeConstraint: SameNumberOfRows>, { let mut col = col.into_owned(); @@ -357,7 +357,7 @@ where pub fn remove_column(&self, j: usize) -> Cholesky> where D: DimSub, - DefaultAllocator: Allocator, DimDiff> + Allocator, + DefaultAllocator: Allocator, DimDiff> + Allocator, { let n = self.chol.nrows(); assert!(n > 0, "The matrix needs at least one column."); diff --git a/src/linalg/col_piv_qr.rs b/src/linalg/col_piv_qr.rs index bd234b60..40d9f596 100644 --- a/src/linalg/col_piv_qr.rs +++ b/src/linalg/col_piv_qr.rs @@ -17,16 +17,16 @@ use std::mem::MaybeUninit; #[cfg_attr(feature = "serde-serialize-no-std", derive(Serialize, Deserialize))] #[cfg_attr( feature = "serde-serialize-no-std", - serde(bound(serialize = "DefaultAllocator: Allocator + - Allocator>, + serde(bound(serialize = "DefaultAllocator: Allocator + + Allocator>, OMatrix: Serialize, PermutationSequence>: Serialize, OVector>: Serialize")) )] #[cfg_attr( feature = "serde-serialize-no-std", - serde(bound(deserialize = "DefaultAllocator: Allocator + - Allocator>, + serde(bound(deserialize = "DefaultAllocator: Allocator + + Allocator>, OMatrix: Deserialize<'de>, PermutationSequence>: Deserialize<'de>, OVector>: Deserialize<'de>")) @@ -34,9 +34,7 @@ use std::mem::MaybeUninit; #[derive(Clone, Debug)] pub struct ColPivQR, C: Dim> where - DefaultAllocator: Allocator - + Allocator> - + Allocator<(usize, usize), DimMinimum>, + DefaultAllocator: Allocator + Allocator>, { col_piv_qr: OMatrix, p: PermutationSequence>, @@ -45,9 +43,7 @@ where impl, C: Dim> Copy for ColPivQR where - DefaultAllocator: Allocator - + Allocator> - + Allocator<(usize, usize), DimMinimum>, + DefaultAllocator: Allocator + Allocator>, OMatrix: Copy, PermutationSequence>: Copy, OVector>: Copy, @@ -56,10 +52,7 @@ where impl, C: Dim> ColPivQR where - DefaultAllocator: Allocator - + Allocator - + Allocator> - + Allocator<(usize, usize), DimMinimum>, + DefaultAllocator: Allocator + Allocator + Allocator>, { /// Computes the `ColPivQR` decomposition using householder reflections. pub fn new(mut matrix: OMatrix) -> Self { @@ -102,7 +95,7 @@ where #[must_use] pub fn r(&self) -> OMatrix, C> where - DefaultAllocator: Allocator, C>, + DefaultAllocator: Allocator, C>, { let (nrows, ncols) = self.col_piv_qr.shape_generic(); let mut res = self @@ -134,7 +127,7 @@ where #[must_use] pub fn q(&self) -> OMatrix> where - DefaultAllocator: Allocator>, + DefaultAllocator: Allocator>, { let (nrows, ncols) = self.col_piv_qr.shape_generic(); @@ -171,9 +164,9 @@ where ) where DimMinimum: DimMin>, - DefaultAllocator: Allocator> + DefaultAllocator: Allocator> + Reallocator, C> - + Allocator<(usize, usize), DimMinimum>, + + Allocator>, { (self.q(), self.r(), self.p) } @@ -202,8 +195,7 @@ where impl> ColPivQR where - DefaultAllocator: - Allocator + Allocator + Allocator<(usize, usize), DimMinimum>, + DefaultAllocator: Allocator + Allocator + Allocator>, { /// Solves the linear system `self * x = b`, where `x` is the unknown to be determined. /// @@ -216,7 +208,7 @@ where where S2: StorageMut, ShapeConstraint: SameNumberOfRows, - DefaultAllocator: Allocator, + DefaultAllocator: Allocator, { let mut res = b.clone_owned(); diff --git a/src/linalg/convolution.rs b/src/linalg/convolution.rs index b0abe994..3434f3a8 100644 --- a/src/linalg/convolution.rs +++ b/src/linalg/convolution.rs @@ -25,7 +25,7 @@ impl> Vector { D2: DimAdd>, DimSum: DimSub, S2: Storage, - DefaultAllocator: Allocator, U1>>, + DefaultAllocator: Allocator, U1>>, { let vec = self.len(); let ker = kernel.len(); @@ -78,7 +78,7 @@ impl> Vector { D2: Dim, DimSum: DimSub, S2: Storage, - DefaultAllocator: Allocator, D2>>, + DefaultAllocator: Allocator, D2>>, { let vec = self.len(); let ker = kernel.len(); @@ -117,7 +117,7 @@ impl> Vector { where D2: Dim, S2: Storage, - DefaultAllocator: Allocator, + DefaultAllocator: Allocator, { let vec = self.len(); let ker = kernel.len(); diff --git a/src/linalg/decomposition.rs b/src/linalg/decomposition.rs index c72babf3..bc4ccbe4 100644 --- a/src/linalg/decomposition.rs +++ b/src/linalg/decomposition.rs @@ -24,11 +24,11 @@ impl> Matrix { where R: DimMin, DimMinimum: DimSub, - DefaultAllocator: Allocator - + Allocator - + Allocator - + Allocator> - + Allocator, U1>>, + DefaultAllocator: Allocator + + Allocator + + Allocator + + Allocator> + + Allocator, U1>>, { Bidiagonal::new(self.into_owned()) } @@ -39,7 +39,7 @@ impl> Matrix { pub fn full_piv_lu(self) -> FullPivLU where R: DimMin, - DefaultAllocator: Allocator + Allocator<(usize, usize), DimMinimum>, + DefaultAllocator: Allocator + Allocator>, { FullPivLU::new(self.into_owned()) } @@ -48,7 +48,7 @@ impl> Matrix { pub fn lu(self) -> LU where R: DimMin, - DefaultAllocator: Allocator + Allocator<(usize, usize), DimMinimum>, + DefaultAllocator: Allocator + Allocator>, { LU::new(self.into_owned()) } @@ -57,7 +57,7 @@ impl> Matrix { pub fn qr(self) -> QR where R: DimMin, - DefaultAllocator: Allocator + Allocator + Allocator>, + DefaultAllocator: Allocator + Allocator + Allocator>, { QR::new(self.into_owned()) } @@ -66,10 +66,10 @@ impl> Matrix { pub fn col_piv_qr(self) -> ColPivQR where R: DimMin, - DefaultAllocator: Allocator - + Allocator - + Allocator> - + Allocator<(usize, usize), DimMinimum>, + DefaultAllocator: Allocator + + Allocator + + Allocator> + + Allocator>, { ColPivQR::new(self.into_owned()) } @@ -81,17 +81,13 @@ impl> Matrix { where R: DimMin, DimMinimum: DimSub, // for Bidiagonal. - DefaultAllocator: Allocator - + Allocator - + Allocator - + Allocator, U1>> - + Allocator, C> - + Allocator> - + Allocator> - + Allocator> - + Allocator, U1>> - + Allocator<(usize, usize), DimMinimum> - + Allocator<(T::RealField, usize), DimMinimum>, + DefaultAllocator: Allocator + + Allocator + + Allocator + + Allocator, U1>> + + Allocator, C> + + Allocator> + + Allocator>, { SVD::new(self.into_owned(), compute_u, compute_v) } @@ -103,15 +99,13 @@ impl> Matrix { where R: DimMin, DimMinimum: DimSub, // for Bidiagonal. - DefaultAllocator: Allocator - + Allocator - + Allocator - + Allocator, U1>> - + Allocator, C> - + Allocator> - + Allocator> - + Allocator> - + Allocator, U1>>, + DefaultAllocator: Allocator + + Allocator + + Allocator + + Allocator, U1>> + + Allocator, C> + + Allocator> + + Allocator>, { SVD::new_unordered(self.into_owned(), compute_u, compute_v) } @@ -138,17 +132,13 @@ impl> Matrix { where R: DimMin, DimMinimum: DimSub, // for Bidiagonal. - DefaultAllocator: Allocator - + Allocator - + Allocator - + Allocator, U1>> - + Allocator, C> - + Allocator> - + Allocator> - + Allocator> - + Allocator, U1>> - + Allocator<(usize, usize), DimMinimum> - + Allocator<(T::RealField, usize), DimMinimum>, + DefaultAllocator: Allocator + + Allocator + + Allocator + + Allocator, U1>> + + Allocator, C> + + Allocator> + + Allocator>, { SVD::try_new(self.into_owned(), compute_u, compute_v, eps, max_niter) } @@ -175,15 +165,15 @@ impl> Matrix { where R: DimMin, DimMinimum: DimSub, // for Bidiagonal. - DefaultAllocator: Allocator - + Allocator - + Allocator - + Allocator, U1>> - + Allocator, C> - + Allocator> - + Allocator> - + Allocator> - + Allocator, U1>>, + DefaultAllocator: Allocator + + Allocator + + Allocator + + Allocator, U1>> + + Allocator, C> + + Allocator> + + Allocator> + + Allocator> + + Allocator, U1>>, { SVD::try_new_unordered(self.into_owned(), compute_u, compute_v, eps, max_niter) } @@ -193,19 +183,19 @@ impl> Matrix { where R: DimMin, DimMinimum: DimSub, // for Bidiagonal. - DefaultAllocator: Allocator - + Allocator, R> - + Allocator> - + Allocator - + Allocator, DimMinimum> - + Allocator - + Allocator - + Allocator, U1>> - + Allocator, C> - + Allocator> - + Allocator> - + Allocator> - + Allocator, U1>>, + DefaultAllocator: Allocator + + Allocator, R> + + Allocator> + + Allocator + + Allocator, DimMinimum> + + Allocator + + Allocator + + Allocator, U1>> + + Allocator, C> + + Allocator> + + Allocator> + + Allocator> + + Allocator, U1>>, { SVD::new_unordered(self.into_owned(), true, true) .to_polar() @@ -226,19 +216,19 @@ impl> Matrix { where R: DimMin, DimMinimum: DimSub, // for Bidiagonal. - DefaultAllocator: Allocator - + Allocator, R> - + Allocator> - + Allocator - + Allocator, DimMinimum> - + Allocator - + Allocator - + Allocator, U1>> - + Allocator, C> - + Allocator> - + Allocator> - + Allocator> - + Allocator, U1>>, + DefaultAllocator: Allocator + + Allocator, R> + + Allocator> + + Allocator + + Allocator, DimMinimum> + + Allocator + + Allocator + + Allocator, U1>> + + Allocator, C> + + Allocator> + + Allocator> + + Allocator> + + Allocator, U1>>, { SVD::try_new_unordered(self.into_owned(), true, true, eps, max_niter) .and_then(|svd| svd.to_polar()) @@ -265,7 +255,7 @@ impl> Matrix { /// to be symmetric and only the lower-triangular part is read. pub fn cholesky(self) -> Option> where - DefaultAllocator: Allocator, + DefaultAllocator: Allocator, { Cholesky::new(self.into_owned()) } @@ -277,7 +267,7 @@ impl> Matrix { pub fn udu(self) -> Option> where T: RealField, - DefaultAllocator: Allocator + Allocator, + DefaultAllocator: Allocator + Allocator, { UDU::new(self.into_owned()) } @@ -286,7 +276,7 @@ impl> Matrix { pub fn hessenberg(self) -> Hessenberg where D: DimSub, - DefaultAllocator: Allocator + Allocator + Allocator>, + DefaultAllocator: Allocator + Allocator + Allocator>, { Hessenberg::new(self.into_owned()) } @@ -295,10 +285,10 @@ impl> Matrix { pub fn schur(self) -> Schur where D: DimSub, // For Hessenberg. - DefaultAllocator: Allocator> - + Allocator> - + Allocator - + Allocator, + DefaultAllocator: Allocator> + + Allocator> + + Allocator + + Allocator, { Schur::new(self.into_owned()) } @@ -317,10 +307,10 @@ impl> Matrix { pub fn try_schur(self, eps: T::RealField, max_niter: usize) -> Option> where D: DimSub, // For Hessenberg. - DefaultAllocator: Allocator> - + Allocator> - + Allocator - + Allocator, + DefaultAllocator: Allocator> + + Allocator> + + Allocator + + Allocator, { Schur::try_new(self.into_owned(), eps, max_niter) } @@ -331,10 +321,8 @@ impl> Matrix { pub fn symmetric_eigen(self) -> SymmetricEigen where D: DimSub, - DefaultAllocator: Allocator - + Allocator> - + Allocator - + Allocator>, + DefaultAllocator: + Allocator + Allocator> + Allocator + Allocator>, { SymmetricEigen::new(self.into_owned()) } @@ -357,10 +345,8 @@ impl> Matrix { ) -> Option> where D: DimSub, - DefaultAllocator: Allocator - + Allocator> - + Allocator - + Allocator>, + DefaultAllocator: + Allocator + Allocator> + Allocator + Allocator>, { SymmetricEigen::try_new(self.into_owned(), eps, max_niter) } @@ -371,7 +357,7 @@ impl> Matrix { pub fn symmetric_tridiagonalize(self) -> SymmetricTridiagonal where D: DimSub, - DefaultAllocator: Allocator + Allocator>, + DefaultAllocator: Allocator + Allocator>, { SymmetricTridiagonal::new(self.into_owned()) } diff --git a/src/linalg/determinant.rs b/src/linalg/determinant.rs index fe1ae82f..2ff01a20 100644 --- a/src/linalg/determinant.rs +++ b/src/linalg/determinant.rs @@ -15,7 +15,7 @@ impl, S: Storage> SquareMatri #[must_use] pub fn determinant(&self) -> T where - DefaultAllocator: Allocator + Allocator<(usize, usize), D>, + DefaultAllocator: Allocator + Allocator, { assert!( self.is_square(), diff --git a/src/linalg/eigen.rs b/src/linalg/eigen.rs index a1f6172e..a7853d99 100644 --- a/src/linalg/eigen.rs +++ b/src/linalg/eigen.rs @@ -23,20 +23,20 @@ use crate::linalg::Schur; #[cfg_attr(feature = "serde-serialize-no-std", derive(Serialize, Deserialize))] #[cfg_attr( feature = "serde-serialize-no-std", - serde(bound(serialize = "DefaultAllocator: Allocator, + serde(bound(serialize = "DefaultAllocator: Allocator, OVector: Serialize, OMatrix: Serialize")) )] #[cfg_attr( feature = "serde-serialize-no-std", - serde(bound(deserialize = "DefaultAllocator: Allocator, + serde(bound(deserialize = "DefaultAllocator: Allocator, OVector: Serialize, OMatrix: Deserialize<'de>")) )] #[derive(Clone, Debug)] pub struct Eigen where - DefaultAllocator: Allocator + Allocator, + DefaultAllocator: Allocator + Allocator, { pub eigenvectors: OMatrix, pub eigenvalues: OVector, @@ -44,7 +44,7 @@ where impl Copy for Eigen where - DefaultAllocator: Allocator + Allocator, + DefaultAllocator: Allocator + Allocator, OMatrix: Copy, OVector: Copy, { @@ -54,12 +54,10 @@ impl Eigen where D: DimSub, // For Hessenberg. ShapeConstraint: DimEq>, // For Hessenberg. - DefaultAllocator: Allocator> - + Allocator> - + Allocator - + Allocator, + DefaultAllocator: + Allocator> + Allocator> + Allocator + Allocator, // XXX: for debug - DefaultAllocator: Allocator, + DefaultAllocator: Allocator, OMatrix: Display, { /// Computes the eigendecomposition of a diagonalizable matrix with Complex eigenvalues. diff --git a/src/linalg/exp.rs b/src/linalg/exp.rs index d6f61956..1560297c 100644 --- a/src/linalg/exp.rs +++ b/src/linalg/exp.rs @@ -57,7 +57,7 @@ struct ExpmPadeHelper where T: ComplexField, D: DimMin, - DefaultAllocator: Allocator + Allocator<(usize, usize), DimMinimum>, + DefaultAllocator: Allocator + Allocator>, { use_exact_norm: bool, ident: OMatrix, @@ -84,7 +84,7 @@ impl ExpmPadeHelper where T: ComplexField, D: DimMin, - DefaultAllocator: Allocator + Allocator<(usize, usize), DimMinimum>, + DefaultAllocator: Allocator + Allocator>, { fn new(a: OMatrix, use_exact_norm: bool) -> Self { let (nrows, ncols) = a.shape_generic(); @@ -397,7 +397,7 @@ fn onenorm_matrix_power_nonm(a: &OMatrix, p: usize) -> T where T: RealField, D: Dim, - DefaultAllocator: Allocator + Allocator, + DefaultAllocator: Allocator + Allocator, { let nrows = a.shape_generic().0; let mut v = crate::OVector::::repeat_generic(nrows, Const::<1>, convert(1.0)); @@ -414,10 +414,7 @@ fn ell(a: &OMatrix, m: usize) -> u64 where T: ComplexField, D: Dim, - DefaultAllocator: Allocator - + Allocator - + Allocator - + Allocator, + DefaultAllocator: Allocator + Allocator + Allocator + Allocator, { let a_abs = a.map(|x| x.abs()); @@ -449,7 +446,7 @@ fn solve_p_q(u: OMatrix, v: OMatrix) -> OMatrix where T: ComplexField, D: DimMin, - DefaultAllocator: Allocator + Allocator<(usize, usize), DimMinimum>, + DefaultAllocator: Allocator + Allocator>, { let p = &u + &v; let q = &v - &u; @@ -461,7 +458,7 @@ fn one_norm(m: &OMatrix) -> T::RealField where T: ComplexField, D: Dim, - DefaultAllocator: Allocator, + DefaultAllocator: Allocator, { let mut max = ::RealField::zero(); @@ -481,11 +478,11 @@ where impl OMatrix where D: DimMin, - DefaultAllocator: Allocator - + Allocator<(usize, usize), DimMinimum> - + Allocator - + Allocator - + Allocator, + DefaultAllocator: Allocator + + Allocator> + + Allocator + + Allocator + + Allocator, { /// Computes exponential of this matrix #[must_use] diff --git a/src/linalg/full_piv_lu.rs b/src/linalg/full_piv_lu.rs index 2037e285..123de7c0 100644 --- a/src/linalg/full_piv_lu.rs +++ b/src/linalg/full_piv_lu.rs @@ -15,22 +15,22 @@ use crate::linalg::PermutationSequence; #[cfg_attr(feature = "serde-serialize-no-std", derive(Serialize, Deserialize))] #[cfg_attr( feature = "serde-serialize-no-std", - serde(bound(serialize = "DefaultAllocator: Allocator + - Allocator<(usize, usize), DimMinimum>, + serde(bound(serialize = "DefaultAllocator: Allocator + + Allocator>, OMatrix: Serialize, PermutationSequence>: Serialize")) )] #[cfg_attr( feature = "serde-serialize-no-std", - serde(bound(deserialize = "DefaultAllocator: Allocator + - Allocator<(usize, usize), DimMinimum>, + serde(bound(deserialize = "DefaultAllocator: Allocator + + Allocator>, OMatrix: Deserialize<'de>, PermutationSequence>: Deserialize<'de>")) )] #[derive(Clone, Debug)] pub struct FullPivLU, C: Dim> where - DefaultAllocator: Allocator + Allocator<(usize, usize), DimMinimum>, + DefaultAllocator: Allocator + Allocator>, { lu: OMatrix, p: PermutationSequence>, @@ -39,7 +39,7 @@ where impl, C: Dim> Copy for FullPivLU where - DefaultAllocator: Allocator + Allocator<(usize, usize), DimMinimum>, + DefaultAllocator: Allocator + Allocator>, OMatrix: Copy, PermutationSequence>: Copy, { @@ -47,7 +47,7 @@ where impl, C: Dim> FullPivLU where - DefaultAllocator: Allocator + Allocator<(usize, usize), DimMinimum>, + DefaultAllocator: Allocator + Allocator>, { /// Computes the LU decomposition with full pivoting of `matrix`. /// @@ -99,7 +99,7 @@ where #[must_use] pub fn l(&self) -> OMatrix> where - DefaultAllocator: Allocator>, + DefaultAllocator: Allocator>, { let (nrows, ncols) = self.lu.shape_generic(); let mut m = self.lu.columns_generic(0, nrows.min(ncols)).into_owned(); @@ -113,7 +113,7 @@ where #[must_use] pub fn u(&self) -> OMatrix, C> where - DefaultAllocator: Allocator, C>, + DefaultAllocator: Allocator, C>, { let (nrows, ncols) = self.lu.shape_generic(); self.lu.rows_generic(0, nrows.min(ncols)).upper_triangle() @@ -144,7 +144,7 @@ where PermutationSequence>, ) where - DefaultAllocator: Allocator> + Allocator, C>, + DefaultAllocator: Allocator> + Allocator, C>, { // Use reallocation for either l or u. let l = self.l(); @@ -158,7 +158,7 @@ where impl> FullPivLU where - DefaultAllocator: Allocator + Allocator<(usize, usize), D>, + DefaultAllocator: Allocator + Allocator, { /// Solves the linear system `self * x = b`, where `x` is the unknown to be determined. /// @@ -171,7 +171,7 @@ where where S2: Storage, ShapeConstraint: SameNumberOfRows, - DefaultAllocator: Allocator, + DefaultAllocator: Allocator, { let mut res = b.clone_owned(); if self.solve_mut(&mut res) { diff --git a/src/linalg/hessenberg.rs b/src/linalg/hessenberg.rs index 0313a0bb..d1e57bcc 100644 --- a/src/linalg/hessenberg.rs +++ b/src/linalg/hessenberg.rs @@ -14,22 +14,22 @@ use std::mem::MaybeUninit; #[cfg_attr(feature = "serde-serialize-no-std", derive(Serialize, Deserialize))] #[cfg_attr( feature = "serde-serialize-no-std", - serde(bound(serialize = "DefaultAllocator: Allocator + - Allocator>, + serde(bound(serialize = "DefaultAllocator: Allocator + + Allocator>, OMatrix: Serialize, OVector>: Serialize")) )] #[cfg_attr( feature = "serde-serialize-no-std", - serde(bound(deserialize = "DefaultAllocator: Allocator + - Allocator>, + serde(bound(deserialize = "DefaultAllocator: Allocator + + Allocator>, OMatrix: Deserialize<'de>, OVector>: Deserialize<'de>")) )] #[derive(Clone, Debug)] pub struct Hessenberg> where - DefaultAllocator: Allocator + Allocator>, + DefaultAllocator: Allocator + Allocator>, { hess: OMatrix, subdiag: OVector>, @@ -37,7 +37,7 @@ where impl> Copy for Hessenberg where - DefaultAllocator: Allocator + Allocator>, + DefaultAllocator: Allocator + Allocator>, OMatrix: Copy, OVector>: Copy, { @@ -45,7 +45,7 @@ where impl> Hessenberg where - DefaultAllocator: Allocator + Allocator + Allocator>, + DefaultAllocator: Allocator + Allocator + Allocator>, { /// Computes the Hessenberg decomposition using householder reflections. pub fn new(hess: OMatrix) -> Self { diff --git a/src/linalg/householder.rs b/src/linalg/householder.rs index dbae93f9..bab090d8 100644 --- a/src/linalg/householder.rs +++ b/src/linalg/householder.rs @@ -65,7 +65,7 @@ pub fn clear_column_unchecked( bilateral: Option<&mut OVector>, ) -> T where - DefaultAllocator: Allocator + Allocator, + DefaultAllocator: Allocator + Allocator, { let (mut left, mut right) = matrix.columns_range_pair_mut(icol, icol + 1..); let mut axis = left.rows_range_mut(icol + shift..); @@ -98,7 +98,7 @@ pub fn clear_row_unchecked( shift: usize, ) -> T where - DefaultAllocator: Allocator + Allocator + Allocator, + DefaultAllocator: Allocator + Allocator + Allocator, { let (mut top, mut bottom) = matrix.rows_range_pair_mut(irow, irow + 1..); let mut axis = axis_packed.rows_range_mut(irow + shift..); @@ -129,7 +129,7 @@ where #[doc(hidden)] pub fn assemble_q(m: &OMatrix, signs: &[T]) -> OMatrix where - DefaultAllocator: Allocator, + DefaultAllocator: Allocator, { assert!(m.is_square()); let dim = m.shape_generic().0; diff --git a/src/linalg/inverse.rs b/src/linalg/inverse.rs index 0f6e6614..b11eae13 100644 --- a/src/linalg/inverse.rs +++ b/src/linalg/inverse.rs @@ -17,7 +17,7 @@ impl> SquareMatrix { #[must_use = "Did you mean to use try_inverse_mut()?"] pub fn try_inverse(self) -> Option> where - DefaultAllocator: Allocator, + DefaultAllocator: Allocator, { let mut me = self.into_owned(); if me.try_inverse_mut() { @@ -38,7 +38,7 @@ impl> SquareMatrix { #[inline] pub fn try_inverse_mut(&mut self) -> bool where - DefaultAllocator: Allocator, + DefaultAllocator: Allocator, { assert!(self.is_square(), "Unable to invert a non-square matrix."); @@ -141,7 +141,7 @@ fn do_inverse4>( out: &mut SquareMatrix, ) -> bool where - DefaultAllocator: Allocator, + DefaultAllocator: Allocator, { let m = m.as_slice(); diff --git a/src/linalg/lu.rs b/src/linalg/lu.rs index a5e87072..1ebfe63a 100644 --- a/src/linalg/lu.rs +++ b/src/linalg/lu.rs @@ -15,22 +15,22 @@ use crate::linalg::PermutationSequence; #[cfg_attr(feature = "serde-serialize-no-std", derive(Serialize, Deserialize))] #[cfg_attr( feature = "serde-serialize-no-std", - serde(bound(serialize = "DefaultAllocator: Allocator + - Allocator<(usize, usize), DimMinimum>, + serde(bound(serialize = "DefaultAllocator: Allocator + + Allocator>, OMatrix: Serialize, PermutationSequence>: Serialize")) )] #[cfg_attr( feature = "serde-serialize-no-std", - serde(bound(deserialize = "DefaultAllocator: Allocator + - Allocator<(usize, usize), DimMinimum>, + serde(bound(deserialize = "DefaultAllocator: Allocator + + Allocator>, OMatrix: Deserialize<'de>, PermutationSequence>: Deserialize<'de>")) )] #[derive(Clone, Debug)] pub struct LU, C: Dim> where - DefaultAllocator: Allocator + Allocator<(usize, usize), DimMinimum>, + DefaultAllocator: Allocator + Allocator>, { lu: OMatrix, p: PermutationSequence>, @@ -38,7 +38,7 @@ where impl, C: Dim> Copy for LU where - DefaultAllocator: Allocator + Allocator<(usize, usize), DimMinimum>, + DefaultAllocator: Allocator + Allocator>, OMatrix: Copy, PermutationSequence>: Copy, { @@ -53,7 +53,7 @@ pub fn try_invert_to( ) -> bool where S: StorageMut, - DefaultAllocator: Allocator, + DefaultAllocator: Allocator, { assert!( matrix.is_square(), @@ -86,7 +86,7 @@ where impl, C: Dim> LU where - DefaultAllocator: Allocator + Allocator<(usize, usize), DimMinimum>, + DefaultAllocator: Allocator + Allocator>, { /// Computes the LU decomposition with partial (row) pivoting of `matrix`. pub fn new(mut matrix: OMatrix) -> Self { @@ -130,7 +130,7 @@ where #[must_use] pub fn l(&self) -> OMatrix> where - DefaultAllocator: Allocator>, + DefaultAllocator: Allocator>, { let (nrows, ncols) = self.lu.shape_generic(); let mut m = self.lu.columns_generic(0, nrows.min(ncols)).into_owned(); @@ -174,7 +174,7 @@ where #[must_use] pub fn u(&self) -> OMatrix, C> where - DefaultAllocator: Allocator, C>, + DefaultAllocator: Allocator, C>, { let (nrows, ncols) = self.lu.shape_generic(); self.lu.rows_generic(0, nrows.min(ncols)).upper_triangle() @@ -197,8 +197,8 @@ where OMatrix, C>, ) where - DefaultAllocator: Allocator> - + Allocator, C> + DefaultAllocator: Allocator> + + Allocator, C> + Reallocator>, { // Use reallocation for either l or u. @@ -211,7 +211,7 @@ where impl> LU where - DefaultAllocator: Allocator + Allocator<(usize, usize), D>, + DefaultAllocator: Allocator + Allocator, { /// Solves the linear system `self * x = b`, where `x` is the unknown to be determined. /// @@ -224,7 +224,7 @@ where where S2: Storage, ShapeConstraint: SameNumberOfRows, - DefaultAllocator: Allocator, + DefaultAllocator: Allocator, { let mut res = b.clone_owned(); if self.solve_mut(&mut res) { diff --git a/src/linalg/permutation_sequence.rs b/src/linalg/permutation_sequence.rs index 9e4eb37b..df7ad7dd 100644 --- a/src/linalg/permutation_sequence.rs +++ b/src/linalg/permutation_sequence.rs @@ -15,18 +15,18 @@ use crate::storage::StorageMut; #[cfg_attr(feature = "serde-serialize-no-std", derive(Serialize, Deserialize))] #[cfg_attr( feature = "serde-serialize-no-std", - serde(bound(serialize = "DefaultAllocator: Allocator<(usize, usize), D>, + serde(bound(serialize = "DefaultAllocator: Allocator, OVector<(usize, usize), D>: Serialize")) )] #[cfg_attr( feature = "serde-serialize-no-std", - serde(bound(deserialize = "DefaultAllocator: Allocator<(usize, usize), D>, + serde(bound(deserialize = "DefaultAllocator: Allocator, OVector<(usize, usize), D>: Deserialize<'de>")) )] #[derive(Clone, Debug)] pub struct PermutationSequence where - DefaultAllocator: Allocator<(usize, usize), D>, + DefaultAllocator: Allocator, { len: usize, ipiv: OVector<(usize, usize), D>, @@ -34,14 +34,14 @@ where impl Copy for PermutationSequence where - DefaultAllocator: Allocator<(usize, usize), D>, + DefaultAllocator: Allocator, OVector<(usize, usize), D>: Copy, { } impl PermutationSequence where - DefaultAllocator: Allocator<(usize, usize), D>, + DefaultAllocator: Allocator, { /// Creates a new statically-allocated sequence of `D` identity permutations. #[inline] @@ -53,7 +53,7 @@ where #[cfg(any(feature = "std", feature = "alloc"))] impl PermutationSequence where - DefaultAllocator: Allocator<(usize, usize), Dyn>, + DefaultAllocator: Allocator, { /// Creates a new dynamically-allocated sequence of `n` identity permutations. #[inline] @@ -64,7 +64,7 @@ where impl PermutationSequence where - DefaultAllocator: Allocator<(usize, usize), D>, + DefaultAllocator: Allocator, { /// Creates a new sequence of D identity permutations. #[inline] diff --git a/src/linalg/pow.rs b/src/linalg/pow.rs index e8c174d3..9d5673ee 100644 --- a/src/linalg/pow.rs +++ b/src/linalg/pow.rs @@ -13,7 +13,7 @@ where T: Scalar + Zero + One + ClosedAdd + ClosedMul, D: DimMin, S: StorageMut, - DefaultAllocator: Allocator + Allocator, + DefaultAllocator: Allocator + Allocator, { /// Raises this matrix to an integral power `exp` in-place. pub fn pow_mut(&mut self, mut exp: u32) { @@ -59,7 +59,7 @@ where T: Scalar + Zero + One + ClosedAdd + ClosedMul, D: DimMin, S: StorageMut, - DefaultAllocator: Allocator + Allocator, + DefaultAllocator: Allocator + Allocator, { /// Raise this matrix to an integral power `exp`. #[must_use] diff --git a/src/linalg/qr.rs b/src/linalg/qr.rs index 54921939..d464b3d5 100644 --- a/src/linalg/qr.rs +++ b/src/linalg/qr.rs @@ -17,22 +17,22 @@ use std::mem::MaybeUninit; #[cfg_attr(feature = "serde-serialize-no-std", derive(Serialize, Deserialize))] #[cfg_attr( feature = "serde-serialize-no-std", - serde(bound(serialize = "DefaultAllocator: Allocator + - Allocator>, + serde(bound(serialize = "DefaultAllocator: Allocator + + Allocator>, OMatrix: Serialize, OVector>: Serialize")) )] #[cfg_attr( feature = "serde-serialize-no-std", - serde(bound(deserialize = "DefaultAllocator: Allocator + - Allocator>, + serde(bound(deserialize = "DefaultAllocator: Allocator + + Allocator>, OMatrix: Deserialize<'de>, OVector>: Deserialize<'de>")) )] #[derive(Clone, Debug)] pub struct QR, C: Dim> where - DefaultAllocator: Allocator + Allocator>, + DefaultAllocator: Allocator + Allocator>, { qr: OMatrix, diag: OVector>, @@ -40,7 +40,7 @@ where impl, C: Dim> Copy for QR where - DefaultAllocator: Allocator + Allocator>, + DefaultAllocator: Allocator + Allocator>, OMatrix: Copy, OVector>: Copy, { @@ -48,7 +48,7 @@ where impl, C: Dim> QR where - DefaultAllocator: Allocator + Allocator + Allocator>, + DefaultAllocator: Allocator + Allocator + Allocator>, { /// Computes the QR decomposition using householder reflections. pub fn new(mut matrix: OMatrix) -> Self { @@ -79,7 +79,7 @@ where #[must_use] pub fn r(&self) -> OMatrix, C> where - DefaultAllocator: Allocator, C>, + DefaultAllocator: Allocator, C>, { let (nrows, ncols) = self.qr.shape_generic(); let mut res = self.qr.rows_generic(0, nrows.min(ncols)).upper_triangle(); @@ -106,7 +106,7 @@ where #[must_use] pub fn q(&self) -> OMatrix> where - DefaultAllocator: Allocator>, + DefaultAllocator: Allocator>, { let (nrows, ncols) = self.qr.shape_generic(); @@ -137,7 +137,7 @@ where where DimMinimum: DimMin>, DefaultAllocator: - Allocator> + Reallocator, C>, + Allocator> + Reallocator, C>, { (self.q(), self.unpack_r()) } @@ -172,7 +172,7 @@ where impl> QR where - DefaultAllocator: Allocator + Allocator, + DefaultAllocator: Allocator + Allocator, { /// Solves the linear system `self * x = b`, where `x` is the unknown to be determined. /// @@ -185,7 +185,7 @@ where where S2: Storage, ShapeConstraint: SameNumberOfRows, - DefaultAllocator: Allocator, + DefaultAllocator: Allocator, { let mut res = b.clone_owned(); diff --git a/src/linalg/schur.rs b/src/linalg/schur.rs index 3f734723..d93d4cbf 100644 --- a/src/linalg/schur.rs +++ b/src/linalg/schur.rs @@ -25,18 +25,18 @@ use std::mem::MaybeUninit; #[cfg_attr(feature = "serde-serialize-no-std", derive(Serialize, Deserialize))] #[cfg_attr( feature = "serde-serialize-no-std", - serde(bound(serialize = "DefaultAllocator: Allocator, + serde(bound(serialize = "DefaultAllocator: Allocator, OMatrix: Serialize")) )] #[cfg_attr( feature = "serde-serialize-no-std", - serde(bound(deserialize = "DefaultAllocator: Allocator, + serde(bound(deserialize = "DefaultAllocator: Allocator, OMatrix: Deserialize<'de>")) )] #[derive(Clone, Debug)] pub struct Schur where - DefaultAllocator: Allocator, + DefaultAllocator: Allocator, { q: OMatrix, t: OMatrix, @@ -44,7 +44,7 @@ where impl Copy for Schur where - DefaultAllocator: Allocator, + DefaultAllocator: Allocator, OMatrix: Copy, { } @@ -52,10 +52,8 @@ where impl Schur where D: DimSub, // For Hessenberg. - DefaultAllocator: Allocator> - + Allocator> - + Allocator - + Allocator, + DefaultAllocator: + Allocator> + Allocator> + Allocator + Allocator, { /// Computes the Schur decomposition of a square matrix. pub fn new(m: OMatrix) -> Self { @@ -295,7 +293,7 @@ where fn do_complex_eigenvalues(t: &OMatrix, out: &mut UninitVector, D>) where T: RealField, - DefaultAllocator: Allocator, D>, + DefaultAllocator: Allocator, { let dim = t.nrows(); let mut m = 0; @@ -340,7 +338,7 @@ where fn delimit_subproblem(t: &mut OMatrix, eps: T::RealField, end: usize) -> (usize, usize) where D: DimSub, - DefaultAllocator: Allocator>, + DefaultAllocator: Allocator>, { let mut n = end; @@ -406,7 +404,7 @@ where pub fn complex_eigenvalues(&self) -> OVector, D> where T: RealField, - DefaultAllocator: Allocator, D>, + DefaultAllocator: Allocator, { let mut out = Matrix::uninit(self.t.shape_generic().0, Const::<1>); Self::do_complex_eigenvalues(&self.t, &mut out); @@ -420,7 +418,7 @@ fn decompose_2x2( compute_q: bool, ) -> Option<(Option>, OMatrix)> where - DefaultAllocator: Allocator, + DefaultAllocator: Allocator, { let dim = m.shape_generic().0; let mut q = None; @@ -508,10 +506,8 @@ fn compute_2x2_basis>( impl> SquareMatrix where D: DimSub, // For Hessenberg. - DefaultAllocator: Allocator> - + Allocator> - + Allocator - + Allocator, + DefaultAllocator: + Allocator> + Allocator> + Allocator + Allocator, { /// Computes the eigenvalues of this matrix. #[must_use] @@ -561,7 +557,7 @@ where // TODO: add balancing? where T: RealField, - DefaultAllocator: Allocator, D>, + DefaultAllocator: Allocator, { let dim = self.shape_generic().0; let mut work = Matrix::zeros_generic(dim, Const::<1>); diff --git a/src/linalg/solve.rs b/src/linalg/solve.rs index 237986a8..65fbcd3a 100644 --- a/src/linalg/solve.rs +++ b/src/linalg/solve.rs @@ -18,7 +18,7 @@ impl> SquareMatrix { ) -> Option> where S2: Storage, - DefaultAllocator: Allocator, + DefaultAllocator: Allocator, ShapeConstraint: SameNumberOfRows, { let mut res = b.clone_owned(); @@ -39,7 +39,7 @@ impl> SquareMatrix { ) -> Option> where S2: Storage, - DefaultAllocator: Allocator, + DefaultAllocator: Allocator, ShapeConstraint: SameNumberOfRows, { let mut res = b.clone_owned(); @@ -196,7 +196,7 @@ impl> SquareMatrix { ) -> Option> where S2: Storage, - DefaultAllocator: Allocator, + DefaultAllocator: Allocator, ShapeConstraint: SameNumberOfRows, { let mut res = b.clone_owned(); @@ -217,7 +217,7 @@ impl> SquareMatrix { ) -> Option> where S2: Storage, - DefaultAllocator: Allocator, + DefaultAllocator: Allocator, ShapeConstraint: SameNumberOfRows, { let mut res = b.clone_owned(); @@ -288,7 +288,7 @@ impl> SquareMatrix { ) -> Option> where S2: Storage, - DefaultAllocator: Allocator, + DefaultAllocator: Allocator, ShapeConstraint: SameNumberOfRows, { let mut res = b.clone_owned(); @@ -309,7 +309,7 @@ impl> SquareMatrix { ) -> Option> where S2: Storage, - DefaultAllocator: Allocator, + DefaultAllocator: Allocator, ShapeConstraint: SameNumberOfRows, { let mut res = b.clone_owned(); @@ -457,7 +457,7 @@ impl> SquareMatrix { ) -> OMatrix where S2: Storage, - DefaultAllocator: Allocator, + DefaultAllocator: Allocator, ShapeConstraint: SameNumberOfRows, { let mut res = b.clone_owned(); @@ -475,7 +475,7 @@ impl> SquareMatrix { ) -> OMatrix where S2: Storage, - DefaultAllocator: Allocator, + DefaultAllocator: Allocator, ShapeConstraint: SameNumberOfRows, { let mut res = b.clone_owned(); @@ -594,7 +594,7 @@ impl> SquareMatrix { ) -> OMatrix where S2: Storage, - DefaultAllocator: Allocator, + DefaultAllocator: Allocator, ShapeConstraint: SameNumberOfRows, { let mut res = b.clone_owned(); @@ -612,7 +612,7 @@ impl> SquareMatrix { ) -> OMatrix where S2: Storage, - DefaultAllocator: Allocator, + DefaultAllocator: Allocator, ShapeConstraint: SameNumberOfRows, { let mut res = b.clone_owned(); @@ -666,7 +666,7 @@ impl> SquareMatrix { ) -> OMatrix where S2: Storage, - DefaultAllocator: Allocator, + DefaultAllocator: Allocator, ShapeConstraint: SameNumberOfRows, { let mut res = b.clone_owned(); @@ -684,7 +684,7 @@ impl> SquareMatrix { ) -> OMatrix where S2: Storage, - DefaultAllocator: Allocator, + DefaultAllocator: Allocator, ShapeConstraint: SameNumberOfRows, { let mut res = b.clone_owned(); diff --git a/src/linalg/svd.rs b/src/linalg/svd.rs index 39283e24..c788e2c0 100644 --- a/src/linalg/svd.rs +++ b/src/linalg/svd.rs @@ -21,32 +21,28 @@ use crate::linalg::Bidiagonal; #[cfg_attr(feature = "serde-serialize-no-std", derive(Serialize, Deserialize))] #[cfg_attr( feature = "serde-serialize-no-std", - serde(bound( - serialize = "DefaultAllocator: Allocator> + - Allocator, C> + - Allocator>, + serde(bound(serialize = "DefaultAllocator: Allocator> + + Allocator, C> + + Allocator>, OMatrix>: Serialize, OMatrix, C>: Serialize, - OVector>: Serialize" - )) + OVector>: Serialize")) )] #[cfg_attr( feature = "serde-serialize-no-std", - serde(bound( - deserialize = "DefaultAllocator: Allocator> + - Allocator, C> + - Allocator>, + serde(bound(deserialize = "DefaultAllocator: Allocator> + + Allocator, C> + + Allocator>, OMatrix>: Deserialize<'de>, OMatrix, C>: Deserialize<'de>, - OVector>: Deserialize<'de>" - )) + OVector>: Deserialize<'de>")) )] #[derive(Clone, Debug)] pub struct SVD, C: Dim> where - DefaultAllocator: Allocator, C> - + Allocator> - + Allocator>, + DefaultAllocator: Allocator, C> + + Allocator> + + Allocator>, { /// The left-singular vectors `U` of this SVD. pub u: Option>>, @@ -58,9 +54,9 @@ where impl, C: Dim> Copy for SVD where - DefaultAllocator: Allocator, C> - + Allocator> - + Allocator>, + DefaultAllocator: Allocator, C> + + Allocator> + + Allocator>, OMatrix>: Copy, OMatrix, C>: Copy, OVector>: Copy, @@ -70,15 +66,15 @@ where impl, C: Dim> SVD where DimMinimum: DimSub, // for Bidiagonal. - DefaultAllocator: Allocator - + Allocator - + Allocator - + Allocator, U1>> - + Allocator, C> - + Allocator> - + Allocator> - + Allocator> - + Allocator, U1>>, + DefaultAllocator: Allocator + + Allocator + + Allocator + + Allocator, U1>> + + Allocator, C> + + Allocator> + + Allocator> + + Allocator> + + Allocator, U1>>, { fn use_special_always_ordered_svd2() -> bool { TypeId::of::>() == TypeId::of::>() @@ -579,7 +575,7 @@ where /// been computed at construction-time. pub fn pseudo_inverse(mut self, eps: T::RealField) -> Result, &'static str> where - DefaultAllocator: Allocator, + DefaultAllocator: Allocator, { if eps < T::RealField::zero() { Err("SVD pseudo inverse: the epsilon must be non-negative.") @@ -610,7 +606,7 @@ where ) -> Result, &'static str> where S2: Storage, - DefaultAllocator: Allocator + Allocator, C2>, + DefaultAllocator: Allocator + Allocator, C2>, ShapeConstraint: SameNumberOfRows, { if eps < T::RealField::zero() { @@ -648,11 +644,11 @@ where /// Returns None if the singular vectors of the SVD haven't been calculated pub fn to_polar(&self) -> Option<(OMatrix, OMatrix)> where - DefaultAllocator: Allocator //result - + Allocator, R> // adjoint - + Allocator> // mapped vals - + Allocator // result - + Allocator, DimMinimum>, // square matrix + DefaultAllocator: Allocator //result + + Allocator, R> // adjoint + + Allocator> // mapped vals + + Allocator // result + + Allocator, DimMinimum>, // square matrix { match (&self.u, &self.v_t) { (Some(u), Some(v_t)) => Some(( @@ -668,17 +664,13 @@ where impl, C: Dim> SVD where DimMinimum: DimSub, // for Bidiagonal. - DefaultAllocator: Allocator - + Allocator - + Allocator - + Allocator, U1>> - + Allocator, C> - + Allocator> - + Allocator> - + Allocator> - + Allocator, U1>> - + Allocator<(usize, usize), DimMinimum> // for sorted singular values - + Allocator<(T::RealField, usize), DimMinimum>, // for sorted singular values + DefaultAllocator: Allocator + + Allocator + + Allocator + + Allocator, U1>> + + Allocator, C> + + Allocator> + + Allocator>, // for sorted singular values { /// Computes the Singular Value Decomposition of `matrix` using implicit shift. /// The singular values are guaranteed to be sorted in descending order. @@ -784,15 +776,15 @@ where impl, C: Dim, S: Storage> Matrix where DimMinimum: DimSub, // for Bidiagonal. - DefaultAllocator: Allocator - + Allocator - + Allocator - + Allocator, U1>> - + Allocator, C> - + Allocator> - + Allocator> - + Allocator> - + Allocator, U1>>, + DefaultAllocator: Allocator + + Allocator + + Allocator + + Allocator, U1>> + + Allocator, C> + + Allocator> + + Allocator> + + Allocator> + + Allocator, U1>>, { /// Computes the singular values of this matrix. /// The singular values are not guaranteed to be sorted in any particular order. @@ -816,7 +808,7 @@ where /// All singular values below `eps` are considered equal to 0. pub fn pseudo_inverse(self, eps: T::RealField) -> Result, &'static str> where - DefaultAllocator: Allocator, + DefaultAllocator: Allocator, { SVD::new_unordered(self.clone_owned(), true, true).pseudo_inverse(eps) } @@ -825,17 +817,13 @@ where impl, C: Dim, S: Storage> Matrix where DimMinimum: DimSub, - DefaultAllocator: Allocator - + Allocator - + Allocator - + Allocator, U1>> - + Allocator, C> - + Allocator> - + Allocator> - + Allocator> - + Allocator, U1>> - + Allocator<(usize, usize), DimMinimum> - + Allocator<(T::RealField, usize), DimMinimum>, + DefaultAllocator: Allocator + + Allocator + + Allocator + + Allocator, U1>> + + Allocator, C> + + Allocator> + + Allocator>, { /// Computes the singular values of this matrix. /// The singular values are guaranteed to be sorted in descending order. diff --git a/src/linalg/symmetric_eigen.rs b/src/linalg/symmetric_eigen.rs index 70cad8a1..edea165a 100644 --- a/src/linalg/symmetric_eigen.rs +++ b/src/linalg/symmetric_eigen.rs @@ -17,22 +17,22 @@ use crate::linalg::SymmetricTridiagonal; #[cfg_attr(feature = "serde-serialize-no-std", derive(Serialize, Deserialize))] #[cfg_attr( feature = "serde-serialize-no-std", - serde(bound(serialize = "DefaultAllocator: Allocator + - Allocator, + serde(bound(serialize = "DefaultAllocator: Allocator + + Allocator, OVector: Serialize, OMatrix: Serialize")) )] #[cfg_attr( feature = "serde-serialize-no-std", - serde(bound(deserialize = "DefaultAllocator: Allocator + - Allocator, + serde(bound(deserialize = "DefaultAllocator: Allocator + + Allocator, OVector: Deserialize<'de>, OMatrix: Deserialize<'de>")) )] #[derive(Clone, Debug)] pub struct SymmetricEigen where - DefaultAllocator: Allocator + Allocator, + DefaultAllocator: Allocator + Allocator, { /// The eigenvectors of the decomposed matrix. pub eigenvectors: OMatrix, @@ -43,7 +43,7 @@ where impl Copy for SymmetricEigen where - DefaultAllocator: Allocator + Allocator, + DefaultAllocator: Allocator + Allocator, OMatrix: Copy, OVector: Copy, { @@ -51,7 +51,7 @@ where impl SymmetricEigen where - DefaultAllocator: Allocator + Allocator, + DefaultAllocator: Allocator + Allocator, { /// Computes the eigendecomposition of the given symmetric matrix. /// @@ -59,7 +59,7 @@ where pub fn new(m: OMatrix) -> Self where D: DimSub, - DefaultAllocator: Allocator> + Allocator>, + DefaultAllocator: Allocator> + Allocator>, { Self::try_new(m, T::RealField::default_epsilon(), 0).unwrap() } @@ -78,7 +78,7 @@ where pub fn try_new(m: OMatrix, eps: T::RealField, max_niter: usize) -> Option where D: DimSub, - DefaultAllocator: Allocator> + Allocator>, + DefaultAllocator: Allocator> + Allocator>, { Self::do_decompose(m, true, eps, max_niter).map(|(vals, vecs)| SymmetricEigen { eigenvectors: vecs.unwrap(), @@ -94,7 +94,7 @@ where ) -> Option<(OVector, Option>)> where D: DimSub, - DefaultAllocator: Allocator> + Allocator>, + DefaultAllocator: Allocator> + Allocator>, { assert!( matrix.is_square(), @@ -244,7 +244,7 @@ where ) -> (usize, usize) where D: DimSub, - DefaultAllocator: Allocator>, + DefaultAllocator: Allocator>, { let mut n = end; @@ -321,10 +321,8 @@ pub fn wilkinson_shift(tmm: T, tnn: T, tmn: T) -> T { */ impl, S: Storage> SquareMatrix where - DefaultAllocator: Allocator - + Allocator> - + Allocator - + Allocator>, + DefaultAllocator: + Allocator + Allocator> + Allocator + Allocator>, { /// Computes the eigenvalues of this symmetric matrix. /// diff --git a/src/linalg/symmetric_tridiagonal.rs b/src/linalg/symmetric_tridiagonal.rs index 742eb240..0d1a16c5 100644 --- a/src/linalg/symmetric_tridiagonal.rs +++ b/src/linalg/symmetric_tridiagonal.rs @@ -14,22 +14,22 @@ use std::mem::MaybeUninit; #[cfg_attr(feature = "serde-serialize-no-std", derive(Serialize, Deserialize))] #[cfg_attr( feature = "serde-serialize-no-std", - serde(bound(serialize = "DefaultAllocator: Allocator + - Allocator>, + serde(bound(serialize = "DefaultAllocator: Allocator + + Allocator>, OMatrix: Serialize, OVector>: Serialize")) )] #[cfg_attr( feature = "serde-serialize-no-std", - serde(bound(deserialize = "DefaultAllocator: Allocator + - Allocator>, + serde(bound(deserialize = "DefaultAllocator: Allocator + + Allocator>, OMatrix: Deserialize<'de>, OVector>: Deserialize<'de>")) )] #[derive(Clone, Debug)] pub struct SymmetricTridiagonal> where - DefaultAllocator: Allocator + Allocator>, + DefaultAllocator: Allocator + Allocator>, { tri: OMatrix, off_diagonal: OVector>, @@ -37,7 +37,7 @@ where impl> Copy for SymmetricTridiagonal where - DefaultAllocator: Allocator + Allocator>, + DefaultAllocator: Allocator + Allocator>, OMatrix: Copy, OVector>: Copy, { @@ -45,7 +45,7 @@ where impl> SymmetricTridiagonal where - DefaultAllocator: Allocator + Allocator>, + DefaultAllocator: Allocator + Allocator>, { /// Computes the tridiagonalization of the symmetric matrix `m`. /// @@ -108,7 +108,7 @@ where OVector>, ) where - DefaultAllocator: Allocator + Allocator>, + DefaultAllocator: Allocator + Allocator>, { let diag = self.diagonal(); let q = self.q(); @@ -124,7 +124,7 @@ where OVector>, ) where - DefaultAllocator: Allocator + Allocator>, + DefaultAllocator: Allocator + Allocator>, { (self.diagonal(), self.off_diagonal.map(T::modulus)) } @@ -133,7 +133,7 @@ where #[must_use] pub fn diagonal(&self) -> OVector where - DefaultAllocator: Allocator, + DefaultAllocator: Allocator, { self.tri.map_diagonal(|e| e.real()) } @@ -142,7 +142,7 @@ where #[must_use] pub fn off_diagonal(&self) -> OVector> where - DefaultAllocator: Allocator>, + DefaultAllocator: Allocator>, { self.off_diagonal.map(T::modulus) } diff --git a/src/linalg/udu.rs b/src/linalg/udu.rs index be4c007c..cae12517 100644 --- a/src/linalg/udu.rs +++ b/src/linalg/udu.rs @@ -21,7 +21,7 @@ use simba::scalar::RealField; #[derive(Clone, Debug)] pub struct UDU where - DefaultAllocator: Allocator + Allocator, + DefaultAllocator: Allocator + Allocator, { /// The upper triangular matrix resulting from the factorization pub u: OMatrix, @@ -31,7 +31,7 @@ where impl Copy for UDU where - DefaultAllocator: Allocator + Allocator, + DefaultAllocator: Allocator + Allocator, OVector: Copy, OMatrix: Copy, { @@ -39,7 +39,7 @@ where impl UDU where - DefaultAllocator: Allocator + Allocator, + DefaultAllocator: Allocator + Allocator, { /// Computes the UDU^T factorization. /// diff --git a/src/proptest/mod.rs b/src/proptest/mod.rs index 6701be7c..132b141c 100644 --- a/src/proptest/mod.rs +++ b/src/proptest/mod.rs @@ -257,7 +257,7 @@ where ScalarStrategy::Value: Scalar, R: Dim, C: Dim, - DefaultAllocator: Allocator, + DefaultAllocator: Allocator, { matrix_(value_strategy, rows.into(), cols.into()) } @@ -273,7 +273,7 @@ where ScalarStrategy::Value: Scalar, R: Dim, C: Dim, - DefaultAllocator: Allocator, + DefaultAllocator: Allocator, { let nrows = rows.lower_bound().value()..=rows.upper_bound().value(); let ncols = cols.lower_bound().value()..=cols.upper_bound().value(); @@ -327,7 +327,7 @@ where ScalarStrategy: Strategy + Clone + 'static, ScalarStrategy::Value: Scalar, D: Dim, - DefaultAllocator: Allocator, + DefaultAllocator: Allocator, { matrix_(value_strategy, length.into(), Const::<1>.into()) } @@ -395,7 +395,7 @@ where R: Dim, C: Dim, MatrixParameters: Default, - DefaultAllocator: Allocator, + DefaultAllocator: Allocator, { type Parameters = MatrixParameters; @@ -413,7 +413,7 @@ pub struct MatrixStrategy where NStrategy: Strategy, NStrategy::Value: Scalar, - DefaultAllocator: Allocator, + DefaultAllocator: Allocator, { // For now we only internally hold a boxed strategy. The reason for introducing this // separate wrapper struct is so that we can replace the strategy logic with custom logic @@ -427,7 +427,7 @@ where NStrategy::Value: Scalar, R: Dim, C: Dim, - DefaultAllocator: Allocator, + DefaultAllocator: Allocator, { type Tree = MatrixValueTree; type Value = OMatrix; @@ -446,7 +446,7 @@ where T: Scalar, R: Dim, C: Dim, - DefaultAllocator: Allocator, + DefaultAllocator: Allocator, { // For now we only wrap a boxed value tree. The reason for wrapping is that this allows us // to swap out the value tree logic down the road without significant breaking changes. @@ -458,7 +458,7 @@ where T: Scalar, R: Dim, C: Dim, - DefaultAllocator: Allocator, + DefaultAllocator: Allocator, { type Value = OMatrix; diff --git a/src/sparse/cs_matrix.rs b/src/sparse/cs_matrix.rs index 9a240ff6..1240d5c1 100644 --- a/src/sparse/cs_matrix.rs +++ b/src/sparse/cs_matrix.rs @@ -106,7 +106,7 @@ pub trait CsStorageMut: #[derive(Clone, Debug, PartialEq)] pub struct CsVecStorage where - DefaultAllocator: Allocator, + DefaultAllocator: Allocator, { pub(crate) shape: (R, C), pub(crate) p: OVector, @@ -116,7 +116,7 @@ where impl CsVecStorage where - DefaultAllocator: Allocator, + DefaultAllocator: Allocator, { /// The value buffer of this storage. #[must_use] @@ -137,11 +137,11 @@ where } } -impl CsVecStorage where DefaultAllocator: Allocator {} +impl CsVecStorage where DefaultAllocator: Allocator {} impl<'a, T: Scalar, R: Dim, C: Dim> CsStorageIter<'a, T, R, C> for CsVecStorage where - DefaultAllocator: Allocator, + DefaultAllocator: Allocator, { type ColumnEntries = ColumnEntries<'a, T>; type ColumnRowIndices = iter::Cloned>; @@ -161,7 +161,7 @@ where impl CsStorage for CsVecStorage where - DefaultAllocator: Allocator, + DefaultAllocator: Allocator, { #[inline] fn shape(&self) -> (R, C) { @@ -207,7 +207,7 @@ where impl<'a, T: Scalar, R: Dim, C: Dim> CsStorageIterMut<'a, T, R, C> for CsVecStorage where - DefaultAllocator: Allocator, + DefaultAllocator: Allocator, { type ValuesMut = slice::IterMut<'a, T>; type ColumnEntriesMut = iter::Zip>, slice::IterMut<'a, T>>; @@ -228,7 +228,7 @@ where } impl CsStorageMut for CsVecStorage where - DefaultAllocator: Allocator + DefaultAllocator: Allocator { } @@ -257,7 +257,7 @@ pub type CsVector> = CsMatrix CsMatrix where - DefaultAllocator: Allocator, + DefaultAllocator: Allocator, { /// Creates a new compressed sparse column matrix with the specified dimension and /// `nvals` possible non-zero values. @@ -295,7 +295,7 @@ where ) -> Self where T: Zero + ClosedAdd, - DefaultAllocator: Allocator, + DefaultAllocator: Allocator, { assert_eq!(ncols.value(), p.len(), "Invalid inptr size."); assert_eq!(i.len(), vals.len(), "Invalid value size."); @@ -421,7 +421,7 @@ impl> CsMatrix { #[must_use = "This function does not mutate the matrix. Consider using the return value or removing the function call. There's also transpose_mut() for square matrices."] pub fn transpose(&self) -> CsMatrix where - DefaultAllocator: Allocator, + DefaultAllocator: Allocator, { let (nrows, ncols) = self.data.shape(); @@ -462,12 +462,12 @@ impl> CsMatrix { impl CsMatrix where - DefaultAllocator: Allocator, + DefaultAllocator: Allocator, { pub(crate) fn sort(&mut self) where T: Zero, - DefaultAllocator: Allocator, + DefaultAllocator: Allocator, { // Size = R let nrows = self.data.shape().0; diff --git a/src/sparse/cs_matrix_cholesky.rs b/src/sparse/cs_matrix_cholesky.rs index dcc930bb..fbd4051d 100644 --- a/src/sparse/cs_matrix_cholesky.rs +++ b/src/sparse/cs_matrix_cholesky.rs @@ -8,7 +8,7 @@ use crate::{Const, DefaultAllocator, Dim, Matrix, OVector, RealField}; /// The cholesky decomposition of a column compressed sparse matrix. pub struct CsCholesky where - DefaultAllocator: Allocator + Allocator, + DefaultAllocator: Allocator, { // Non-zero pattern of the original matrix upper-triangular part. // Unlike the original matrix, the `original_p` array does contain the last sentinel value @@ -28,7 +28,7 @@ where impl CsCholesky where - DefaultAllocator: Allocator + Allocator, + DefaultAllocator: Allocator + Allocator, { /// Computes the cholesky decomposition of the sparse matrix `m`. pub fn new(m: &CsMatrix) -> Self { diff --git a/src/sparse/cs_matrix_conversion.rs b/src/sparse/cs_matrix_conversion.rs index 4154f452..e17925f9 100644 --- a/src/sparse/cs_matrix_conversion.rs +++ b/src/sparse/cs_matrix_conversion.rs @@ -22,7 +22,7 @@ impl<'a, T: Scalar + Zero + ClosedAdd> CsMatrix { impl<'a, T: Scalar + Zero + ClosedAdd, R: Dim, C: Dim> CsMatrix where - DefaultAllocator: Allocator + Allocator, + DefaultAllocator: Allocator + Allocator, { /// Creates a column-compressed sparse matrix from a sparse matrix in triplet form. pub fn from_triplet_generic( @@ -68,7 +68,7 @@ where impl<'a, T: Scalar + Zero, R: Dim, C: Dim, S> From> for OMatrix where S: CsStorage, - DefaultAllocator: Allocator, + DefaultAllocator: Allocator, { fn from(m: CsMatrix) -> Self { let (nrows, ncols) = m.data.shape(); @@ -87,7 +87,7 @@ where impl<'a, T: Scalar + Zero, R: Dim, C: Dim, S> From> for CsMatrix where S: Storage, - DefaultAllocator: Allocator + Allocator, + DefaultAllocator: Allocator + Allocator, { fn from(m: Matrix) -> Self { let (nrows, ncols) = m.data.shape(); diff --git a/src/sparse/cs_matrix_ops.rs b/src/sparse/cs_matrix_ops.rs index 1e695e94..b1192f86 100644 --- a/src/sparse/cs_matrix_ops.rs +++ b/src/sparse/cs_matrix_ops.rs @@ -21,7 +21,7 @@ impl> CsMatrix { ) -> usize where T: ClosedAdd + ClosedMul, - DefaultAllocator: Allocator, + DefaultAllocator: Allocator, { for (i, val) in self.data.column_entries(j) { if timestamps[i] < timestamp { @@ -134,7 +134,7 @@ where S1: CsStorage, S2: CsStorage, ShapeConstraint: AreMultipliable, - DefaultAllocator: Allocator + Allocator + Allocator, + DefaultAllocator: Allocator + Allocator + Allocator, { type Output = CsMatrix; @@ -227,7 +227,7 @@ where S1: CsStorage, S2: CsStorage, ShapeConstraint: DimEq + DimEq, - DefaultAllocator: Allocator + Allocator + Allocator, + DefaultAllocator: Allocator + Allocator + Allocator, { type Output = CsMatrix; diff --git a/src/sparse/cs_matrix_solve.rs b/src/sparse/cs_matrix_solve.rs index 2730310c..0dbe65a3 100644 --- a/src/sparse/cs_matrix_solve.rs +++ b/src/sparse/cs_matrix_solve.rs @@ -13,7 +13,7 @@ impl> CsMatrix { ) -> Option> where S2: Storage, - DefaultAllocator: Allocator, + DefaultAllocator: Allocator, ShapeConstraint: SameNumberOfRows, { let mut b = b.clone_owned(); @@ -32,7 +32,7 @@ impl> CsMatrix { ) -> Option> where S2: Storage, - DefaultAllocator: Allocator, + DefaultAllocator: Allocator, ShapeConstraint: SameNumberOfRows, { let mut b = b.clone_owned(); @@ -144,7 +144,7 @@ impl> CsMatrix { ) -> Option> where S2: CsStorage, - DefaultAllocator: Allocator + Allocator + Allocator, + DefaultAllocator: Allocator + Allocator, ShapeConstraint: SameNumberOfRows, { let mut reach = Vec::new(); @@ -208,7 +208,7 @@ impl> CsMatrix { xi: &mut Vec, ) where S2: CsStorage, - DefaultAllocator: Allocator, + DefaultAllocator: Allocator, { let mut visited = OVector::repeat_generic(self.data.shape().1, U1, false); let mut stack = Vec::new(); @@ -252,7 +252,7 @@ impl> CsMatrix { fn lower_triangular_reach(&self, b: &CsVector, xi: &mut Vec) where S2: CsStorage, - DefaultAllocator: Allocator, + DefaultAllocator: Allocator, { let mut visited = OVector::repeat_generic(self.data.shape().1, Const::<1>, false); let mut stack = Vec::new(); diff --git a/src/sparse/cs_utils.rs b/src/sparse/cs_utils.rs index 5b9d86b0..c4700674 100644 --- a/src/sparse/cs_utils.rs +++ b/src/sparse/cs_utils.rs @@ -3,7 +3,7 @@ use crate::{DefaultAllocator, Dim, OVector}; pub fn cumsum(a: &mut OVector, b: &mut OVector) -> usize where - DefaultAllocator: Allocator, + DefaultAllocator: Allocator, { assert!(a.len() == b.len()); let mut sum = 0; diff --git a/src/third_party/alga/alga_matrix.rs b/src/third_party/alga/alga_matrix.rs index 6a4cb982..83c08806 100644 --- a/src/third_party/alga/alga_matrix.rs +++ b/src/third_party/alga/alga_matrix.rs @@ -27,7 +27,7 @@ use std::mem::MaybeUninit; impl Identity for OMatrix where T: Scalar + Zero, - DefaultAllocator: Allocator, + DefaultAllocator: Allocator, { #[inline] fn identity() -> Self { @@ -38,7 +38,7 @@ where impl AbstractMagma for OMatrix where T: Scalar + ClosedAdd, - DefaultAllocator: Allocator, + DefaultAllocator: Allocator, { #[inline] fn operate(&self, other: &Self) -> Self { @@ -49,7 +49,7 @@ where impl TwoSidedInverse for OMatrix where T: Scalar + ClosedNeg, - DefaultAllocator: Allocator, + DefaultAllocator: Allocator, { #[inline] #[must_use = "Did you mean to use two_sided_inverse_mut()?"] @@ -67,7 +67,7 @@ macro_rules! inherit_additive_structure( ($($marker: ident<$operator: ident> $(+ $bounds: ident)*),* $(,)*) => {$( impl $marker<$operator> for OMatrix where T: Scalar + $marker<$operator> $(+ $bounds)*, - DefaultAllocator: Allocator { } + DefaultAllocator: Allocator { } )*} ); @@ -83,7 +83,7 @@ inherit_additive_structure!( impl AbstractModule for OMatrix where T: Scalar + RingCommutative, - DefaultAllocator: Allocator, + DefaultAllocator: Allocator, { type AbstractRing = T; @@ -96,7 +96,7 @@ where impl Module for OMatrix where T: Scalar + RingCommutative, - DefaultAllocator: Allocator, + DefaultAllocator: Allocator, { type Ring = T; } @@ -104,7 +104,7 @@ where impl VectorSpace for OMatrix where T: Scalar + Field, - DefaultAllocator: Allocator, + DefaultAllocator: Allocator, { type Field = T; } @@ -112,7 +112,7 @@ where impl FiniteDimVectorSpace for OMatrix where T: Scalar + Field, - DefaultAllocator: Allocator, + DefaultAllocator: Allocator, { #[inline] fn dimension() -> usize { @@ -154,7 +154,7 @@ impl< > NormedSpace for OMatrix where ::RealField: simba::scalar::RealField, - DefaultAllocator: Allocator, + DefaultAllocator: Allocator, { type RealField = ::RealField; type ComplexField = T; @@ -202,7 +202,7 @@ impl< > InnerSpace for OMatrix where ::RealField: simba::scalar::RealField, - DefaultAllocator: Allocator, + DefaultAllocator: Allocator, { #[inline] fn angle(&self, other: &Self) -> ::RealField { @@ -226,7 +226,7 @@ impl< > FiniteDimInnerSpace for OMatrix where ::RealField: simba::scalar::RealField, - DefaultAllocator: Allocator, + DefaultAllocator: Allocator, { #[inline] fn orthonormalize(vs: &mut [Self]) -> usize { @@ -362,7 +362,7 @@ where impl Identity for OMatrix where T: Scalar + Zero + One, - DefaultAllocator: Allocator, + DefaultAllocator: Allocator, { #[inline] fn identity() -> Self { @@ -373,7 +373,7 @@ where impl AbstractMagma for OMatrix where T: Scalar + Zero + One + ClosedAdd + ClosedMul, - DefaultAllocator: Allocator, + DefaultAllocator: Allocator, { #[inline] fn operate(&self, other: &Self) -> Self { @@ -385,7 +385,7 @@ macro_rules! impl_multiplicative_structure( ($($marker: ident<$operator: ident> $(+ $bounds: ident)*),* $(,)*) => {$( impl $marker<$operator> for OMatrix where T: Scalar + Zero + One + ClosedAdd + ClosedMul + $marker<$operator> $(+ $bounds)*, - DefaultAllocator: Allocator { } + DefaultAllocator: Allocator { } )*} ); @@ -402,7 +402,7 @@ impl_multiplicative_structure!( impl MeetSemilattice for OMatrix where T: Scalar + MeetSemilattice, - DefaultAllocator: Allocator, + DefaultAllocator: Allocator, { #[inline] fn meet(&self, other: &Self) -> Self { @@ -413,7 +413,7 @@ where impl JoinSemilattice for OMatrix where T: Scalar + JoinSemilattice, - DefaultAllocator: Allocator, + DefaultAllocator: Allocator, { #[inline] fn join(&self, other: &Self) -> Self { @@ -424,7 +424,7 @@ where impl Lattice for OMatrix where T: Scalar + Lattice, - DefaultAllocator: Allocator, + DefaultAllocator: Allocator, { #[inline] fn meet_join(&self, other: &Self) -> (Self, Self) { diff --git a/src/third_party/alga/alga_transform.rs b/src/third_party/alga/alga_transform.rs index ed75018f..adab183c 100755 --- a/src/third_party/alga/alga_transform.rs +++ b/src/third_party/alga/alga_transform.rs @@ -20,7 +20,7 @@ impl Identity: DimNameAdd, C: TCategory, - DefaultAllocator: Allocator, U1>, DimNameSum, U1>>, + DefaultAllocator: Allocator, U1>, DimNameSum, U1>>, { #[inline] fn identity() -> Self { @@ -33,7 +33,7 @@ impl TwoSidedInverse where Const: DimNameAdd, C: SubTCategoryOf, - DefaultAllocator: Allocator, U1>, DimNameSum, U1>>, + DefaultAllocator: Allocator, U1>, DimNameSum, U1>>, { #[inline] #[must_use = "Did you mean to use two_sided_inverse_mut()?"] @@ -52,7 +52,7 @@ impl AbstractMagma: DimNameAdd, C: TCategory, - DefaultAllocator: Allocator, U1>, DimNameSum, U1>>, + DefaultAllocator: Allocator, U1>, DimNameSum, U1>>, { #[inline] fn operate(&self, rhs: &Self) -> Self { @@ -66,7 +66,7 @@ macro_rules! impl_multiplicative_structures( where Const: DimNameAdd, C: TCategory, - DefaultAllocator: Allocator, U1>, DimNameSum, U1>> { } + DefaultAllocator: Allocator, U1>, DimNameSum, U1>> { } )*} ); @@ -76,7 +76,7 @@ macro_rules! impl_inversible_multiplicative_structures( where Const: DimNameAdd, C: SubTCategoryOf, - DefaultAllocator: Allocator, U1>, DimNameSum, U1>> { } + DefaultAllocator: Allocator, U1>, DimNameSum, U1>> { } )*} ); @@ -101,8 +101,8 @@ where Const: DimNameAdd, T: RealField + simba::scalar::RealField, C: TCategory, - DefaultAllocator: Allocator, U1>, DimNameSum, U1>> - + Allocator, U1>>, + DefaultAllocator: Allocator, U1>, DimNameSum, U1>> + + Allocator, U1>>, { #[inline] fn transform_point(&self, pt: &Point) -> Point { @@ -120,8 +120,8 @@ where Const: DimNameAdd, T: RealField + simba::scalar::RealField, C: SubTCategoryOf, - DefaultAllocator: Allocator, U1>, DimNameSum, U1>> - + Allocator, U1>>, + DefaultAllocator: Allocator, U1>, DimNameSum, U1>> + + Allocator, U1>>, { #[inline] fn inverse_transform_point(&self, pt: &Point) -> Point { @@ -139,7 +139,7 @@ where // impl AffineTransformation> for Transform // where T: RealField, // C: SubTCategoryOf, -// DefaultAllocator: Allocator, U1>, DimNameSum, U1>> { +// DefaultAllocator: Allocator, U1>, DimNameSum, U1>> { // type PreRotation = Rotation; // type NonUniformScaling = OVector; // type PostRotation = Rotation; diff --git a/src/third_party/mint/mint_matrix.rs b/src/third_party/mint/mint_matrix.rs index ce45fcda..9c1ff005 100644 --- a/src/third_party/mint/mint_matrix.rs +++ b/src/third_party/mint/mint_matrix.rs @@ -11,7 +11,7 @@ macro_rules! impl_from_into_mint_1D( ($($NRows: ident => $VT:ident [$SZ: expr]);* $(;)*) => {$( impl From> for OMatrix where T: Scalar, - DefaultAllocator: Allocator { + DefaultAllocator: Allocator<$NRows, U1> { #[inline] fn from(v: mint::$VT) -> Self { unsafe { @@ -81,7 +81,7 @@ macro_rules! impl_from_into_mint_2D( ($(($NRows: ty, $NCols: ty) => $MV:ident{ $($component:ident),* }[$SZRows: expr]);* $(;)*) => {$( impl From> for OMatrix where T: Scalar, - DefaultAllocator: Allocator { + DefaultAllocator: Allocator<$NRows, $NCols> { #[inline] fn from(m: mint::$MV) -> Self { unsafe { @@ -101,7 +101,7 @@ macro_rules! impl_from_into_mint_2D( impl Into> for OMatrix where T: Scalar, - DefaultAllocator: Allocator { + DefaultAllocator: Allocator<$NRows, $NCols> { #[inline] fn into(self) -> mint::$MV { unsafe { diff --git a/tests/core/matrix.rs b/tests/core/matrix.rs index 7aa551cd..50c0e426 100644 --- a/tests/core/matrix.rs +++ b/tests/core/matrix.rs @@ -1161,8 +1161,8 @@ fn generic_omatrix_to_string( ) -> (String, String) where D: nalgebra::Dim, - nalgebra::DefaultAllocator: nalgebra::base::allocator::Allocator, - nalgebra::DefaultAllocator: nalgebra::base::allocator::Allocator, + nalgebra::DefaultAllocator: nalgebra::base::allocator::Allocator, + nalgebra::DefaultAllocator: nalgebra::base::allocator::Allocator, { (vector.to_string(), matrix.to_string()) } diff --git a/tests/linalg/eigen.rs b/tests/linalg/eigen.rs index 7a944c44..2c43e11e 100644 --- a/tests/linalg/eigen.rs +++ b/tests/linalg/eigen.rs @@ -208,8 +208,8 @@ fn very_small_deviation_from_identity_issue_1368() { // fn verify_eigenvectors(m: OMatrix, mut eig: RealEigen) -> bool // where DefaultAllocator: Allocator + // Allocator + -// Allocator + -// Allocator, +// Allocator + +// Allocator, // OMatrix: Display, // OVector: Display { // let mv = &m * &eig.eigenvectors; diff --git a/tests/proptest/mod.rs b/tests/proptest/mod.rs index cedfae84..f2e53725 100644 --- a/tests/proptest/mod.rs +++ b/tests/proptest/mod.rs @@ -105,7 +105,7 @@ pub fn dmatrix_( 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) // }