From 292abfbaa0ec736c305d5adc0d2e54b70deece53 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Crozet?= Date: Sat, 22 Jun 2024 19:06:20 +0200 Subject: [PATCH] chore: update to simba 0.9 (#1415) --- Cargo.toml | 148 ++++++++++---------- nalgebra-glm/Cargo.toml | 30 ++-- nalgebra-glm/src/traits.rs | 14 +- nalgebra-lapack/Cargo.toml | 2 +- nalgebra-sparse/src/convert/impl_std_ops.rs | 14 +- nalgebra-sparse/src/convert/serial.rs | 8 +- nalgebra-sparse/src/ops/impl_std_ops.rs | 24 ++-- nalgebra-sparse/src/ops/serial/cs.rs | 10 +- nalgebra-sparse/src/ops/serial/csc.rs | 14 +- nalgebra-sparse/src/ops/serial/csr.rs | 14 +- src/base/blas.rs | 12 +- src/base/blas_uninit.rs | 12 +- src/base/cg.rs | 9 +- src/base/componentwise.rs | 12 +- src/base/construction.rs | 6 +- src/base/interpolation.rs | 9 +- src/base/matrix.rs | 12 +- src/base/matrix_simba.rs | 6 +- src/base/ops.rs | 40 +++--- src/base/properties.rs | 4 +- src/base/statistics.rs | 18 +-- src/geometry/abstract_rotation.rs | 4 +- src/geometry/isometry_ops.rs | 2 +- src/geometry/isometry_simba.rs | 6 +- src/geometry/op_macros.rs | 4 +- src/geometry/point.rs | 4 +- src/geometry/point_construction.rs | 4 +- src/geometry/point_conversion.rs | 4 +- src/geometry/point_ops.rs | 36 ++--- src/geometry/point_simba.rs | 6 +- src/geometry/quaternion_simba.rs | 12 +- src/geometry/rotation_construction.rs | 4 +- src/geometry/rotation_ops.rs | 2 +- src/geometry/rotation_simba.rs | 6 +- src/geometry/scale.rs | 16 +-- src/geometry/scale_construction.rs | 4 +- src/geometry/scale_ops.rs | 36 ++--- src/geometry/scale_simba.rs | 6 +- src/geometry/similarity_ops.rs | 2 +- src/geometry/similarity_simba.rs | 6 +- src/geometry/transform_ops.rs | 2 +- src/geometry/transform_simba.rs | 6 +- src/geometry/translation.rs | 6 +- src/geometry/translation_construction.rs | 4 +- src/geometry/translation_ops.rs | 34 ++--- src/geometry/translation_simba.rs | 6 +- src/geometry/unit_complex_simba.rs | 6 +- src/lib.rs | 5 +- src/linalg/exp.rs | 4 +- src/linalg/mod.rs | 4 - src/linalg/pow.rs | 6 +- src/sparse/cs_matrix.rs | 8 +- src/sparse/cs_matrix_conversion.rs | 6 +- src/sparse/cs_matrix_ops.rs | 14 +- 54 files changed, 331 insertions(+), 362 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index cfa337ccf..a4548c262 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,15 +1,15 @@ [package] -name = "nalgebra" +name = "nalgebra" version = "0.32.3" -authors = [ "Sébastien Crozet " ] +authors = ["Sébastien Crozet "] description = "General-purpose linear algebra library with transformations and statically-sized or dynamically-sized matrices." documentation = "https://www.nalgebra.org/docs" homepage = "https://nalgebra.org" repository = "https://github.com/dimforge/nalgebra" readme = "README.md" -categories = [ "science", "mathematics", "wasm", "no-std" ] -keywords = [ "linear", "algebra", "matrix", "vector", "math" ] +categories = ["science", "mathematics", "wasm", "no-std"] +keywords = ["linear", "algebra", "matrix", "vector", "math"] license = "Apache-2.0" edition = "2018" exclude = ["/ci/*", "/.travis.yml", "/Makefile"] @@ -22,108 +22,108 @@ name = "nalgebra" path = "src/lib.rs" [features] -default = [ "std", "macros" ] -std = [ "matrixmultiply", "num-traits/std", "num-complex/std", "num-rational/std", "approx/std", "simba/std" ] -sparse = [ ] -debug = [ "approx/num-complex", "rand" ] -alloc = [ ] -io = [ "pest", "pest_derive" ] -compare = [ "matrixcompare-core" ] -libm = [ "simba/libm" ] -libm-force = [ "simba/libm_force" ] -macros = [ "nalgebra-macros" ] +default = ["std", "macros"] +std = ["matrixmultiply", "num-traits/std", "num-complex/std", "num-rational/std", "approx/std", "simba/std"] +sparse = [] +debug = ["approx/num-complex", "rand"] +alloc = [] +io = ["pest", "pest_derive"] +compare = ["matrixcompare-core"] +libm = ["simba/libm"] +libm-force = ["simba/libm_force"] +macros = ["nalgebra-macros"] # Conversion -convert-mint = [ "mint" ] -convert-bytemuck = [ "bytemuck" ] -convert-glam014 = [ "glam014" ] -convert-glam015 = [ "glam015" ] -convert-glam016 = [ "glam016" ] -convert-glam017 = [ "glam017" ] -convert-glam018 = [ "glam018" ] -convert-glam019 = [ "glam019" ] -convert-glam020 = [ "glam020" ] -convert-glam021 = [ "glam021" ] -convert-glam022 = [ "glam022" ] -convert-glam023 = [ "glam023" ] -convert-glam024 = [ "glam024" ] -convert-glam025 = [ "glam025" ] -convert-glam027 = [ "glam027" ] -convert-glam028 = [ "glam028" ] +convert-mint = ["mint"] +convert-bytemuck = ["bytemuck"] +convert-glam014 = ["glam014"] +convert-glam015 = ["glam015"] +convert-glam016 = ["glam016"] +convert-glam017 = ["glam017"] +convert-glam018 = ["glam018"] +convert-glam019 = ["glam019"] +convert-glam020 = ["glam020"] +convert-glam021 = ["glam021"] +convert-glam022 = ["glam022"] +convert-glam023 = ["glam023"] +convert-glam024 = ["glam024"] +convert-glam025 = ["glam025"] +convert-glam027 = ["glam027"] +convert-glam028 = ["glam028"] # Serialization ## To use serde in a #[no-std] environment, enable the ## `serde-serialize-no-std` feature instead of `serde-serialize`. ## Serialization of dynamically-sized matrices/vectors require ## `serde-serialize`. -serde-serialize-no-std = [ "serde", "num-complex/serde" ] -serde-serialize = [ "serde-serialize-no-std", "serde/std" ] -rkyv-serialize-no-std = [ "rkyv/size_32" ] -rkyv-serialize = [ "rkyv-serialize-no-std", "rkyv/std", "rkyv/validation" ] +serde-serialize-no-std = ["serde", "num-complex/serde"] +serde-serialize = ["serde-serialize-no-std", "serde/std"] +rkyv-serialize-no-std = ["rkyv/size_32"] +rkyv-serialize = ["rkyv-serialize-no-std", "rkyv/std", "rkyv/validation"] # Randomness ## To use rand in a #[no-std] environment, enable the ## `rand-no-std` feature instead of `rand`. -rand-no-std = [ "rand-package" ] -rand = [ "rand-no-std", "rand-package/std", "rand-package/std_rng", "rand_distr" ] +rand-no-std = ["rand-package"] +rand = ["rand-no-std", "rand-package/std", "rand-package/std_rng", "rand_distr"] # Tests -arbitrary = [ "quickcheck" ] -proptest-support = [ "proptest" ] -slow-tests = [] -rkyv-safe-deser = [ "rkyv-serialize", "rkyv/validation" ] +arbitrary = ["quickcheck"] +proptest-support = ["proptest"] +slow-tests = [] +rkyv-safe-deser = ["rkyv-serialize", "rkyv/validation"] [dependencies] nalgebra-macros = { version = "0.2.1", path = "nalgebra-macros", optional = true } -typenum = "1.12" -rand-package = { package = "rand", version = "0.8", optional = true, default-features = false } -num-traits = { version = "0.2", default-features = false } -num-complex = { version = "0.4", default-features = false } -num-rational = { version = "0.4", default-features = false } -approx = { version = "0.5", default-features = false } -simba = { version = "0.8", default-features = false } -alga = { version = "0.9", default-features = false, optional = true } -rand_distr = { version = "0.4", default-features = false, optional = true } +typenum = "1.12" +rand-package = { package = "rand", version = "0.8", optional = true, default-features = false } +num-traits = { version = "0.2", default-features = false } +num-complex = { version = "0.4", default-features = false } +num-rational = { version = "0.4", default-features = false } +approx = { version = "0.5", default-features = false } +simba = { version = "0.9", default-features = false } +alga = { version = "0.9", default-features = false, optional = true } +rand_distr = { version = "0.4", default-features = false, optional = true } matrixmultiply = { version = "0.3", optional = true } -serde = { version = "1.0", default-features = false, features = [ "derive" ], optional = true } -rkyv = { version = "0.7.41", default-features = false, optional = true } -mint = { version = "0.5", optional = true } -quickcheck = { version = "1", optional = true } -pest = { version = "2", optional = true } -pest_derive = { version = "2", optional = true } -bytemuck = { version = "1.5", optional = true } +serde = { version = "1.0", default-features = false, features = ["derive"], optional = true } +rkyv = { version = "0.7.41", default-features = false, optional = true } +mint = { version = "0.5", optional = true } +quickcheck = { version = "1", optional = true } +pest = { version = "2", optional = true } +pest_derive = { version = "2", optional = true } +bytemuck = { version = "1.5", optional = true } matrixcompare-core = { version = "0.1", optional = true } -proptest = { version = "1", optional = true, default-features = false, features = ["std"] } -glam014 = { package = "glam", version = "0.14", optional = true } -glam015 = { package = "glam", version = "0.15", optional = true } -glam016 = { package = "glam", version = "0.16", optional = true } -glam017 = { package = "glam", version = "0.17", optional = true } -glam018 = { package = "glam", version = "0.18", optional = true } -glam019 = { package = "glam", version = "0.19", optional = true } -glam020 = { package = "glam", version = "0.20", optional = true } -glam021 = { package = "glam", version = "0.21", optional = true } -glam022 = { package = "glam", version = "0.22", optional = true } -glam023 = { package = "glam", version = "0.23", optional = true } -glam024 = { package = "glam", version = "0.24", optional = true } -glam025 = { package = "glam", version = "0.25", optional = true } -glam027 = { package = "glam", version = "0.27", optional = true } -glam028 = { package = "glam", version = "0.28", optional = true } -rayon = { version = "1.6", optional = true } +proptest = { version = "1", optional = true, default-features = false, features = ["std"] } +glam014 = { package = "glam", version = "0.14", optional = true } +glam015 = { package = "glam", version = "0.15", optional = true } +glam016 = { package = "glam", version = "0.16", optional = true } +glam017 = { package = "glam", version = "0.17", optional = true } +glam018 = { package = "glam", version = "0.18", optional = true } +glam019 = { package = "glam", version = "0.19", optional = true } +glam020 = { package = "glam", version = "0.20", optional = true } +glam021 = { package = "glam", version = "0.21", optional = true } +glam022 = { package = "glam", version = "0.22", optional = true } +glam023 = { package = "glam", version = "0.23", optional = true } +glam024 = { package = "glam", version = "0.24", optional = true } +glam025 = { package = "glam", version = "0.25", optional = true } +glam027 = { package = "glam", version = "0.27", optional = true } +glam028 = { package = "glam", version = "0.28", optional = true } +rayon = { version = "1.6", optional = true } [dev-dependencies] serde_json = "1.0" rand_xorshift = "0.3" rand_isaac = "0.3" criterion = { version = "0.4", features = ["html_reports"] } -nalgebra = { path = ".", features = ["debug", "compare", "rand", "macros"]} +nalgebra = { path = ".", features = ["debug", "compare", "rand", "macros"] } # For matrix comparison macro matrixcompare = "0.3.0" itertools = "0.13" [workspace] -members = [ "nalgebra-lapack", "nalgebra-glm", "nalgebra-sparse", "nalgebra-macros" ] +members = ["nalgebra-lapack", "nalgebra-glm", "nalgebra-sparse", "nalgebra-macros"] resolver = "2" [[example]] diff --git a/nalgebra-glm/Cargo.toml b/nalgebra-glm/Cargo.toml index 6b06d9cc3..334e87d54 100644 --- a/nalgebra-glm/Cargo.toml +++ b/nalgebra-glm/Cargo.toml @@ -8,8 +8,8 @@ documentation = "https://www.nalgebra.org/docs" homepage = "https://nalgebra.org" repository = "https://github.com/dimforge/nalgebra" readme = "../README.md" -categories = [ "science", "mathematics", "wasm", "no standard library" ] -keywords = [ "linear", "algebra", "matrix", "vector", "math" ] +categories = ["science", "mathematics", "wasm", "no standard library"] +keywords = ["linear", "algebra", "matrix", "vector", "math"] license = "Apache-2.0" edition = "2018" @@ -17,22 +17,22 @@ edition = "2018" maintenance = { status = "actively-developed" } [features] -default = [ "std" ] -std = [ "nalgebra/std", "simba/std" ] -arbitrary = [ "nalgebra/arbitrary" ] -serde-serialize = [ "nalgebra/serde-serialize-no-std" ] +default = ["std"] +std = ["nalgebra/std", "simba/std"] +arbitrary = ["nalgebra/arbitrary"] +serde-serialize = ["nalgebra/serde-serialize-no-std"] # Conversion -convert-mint = [ "nalgebra/mint" ] -convert-bytemuck = [ "nalgebra/bytemuck" ] -convert-glam014 = [ "nalgebra/glam014" ] -convert-glam015 = [ "nalgebra/glam015" ] -convert-glam016 = [ "nalgebra/glam016" ] -convert-glam017 = [ "nalgebra/glam017" ] -convert-glam018 = [ "nalgebra/glam018" ] +convert-mint = ["nalgebra/mint"] +convert-bytemuck = ["nalgebra/bytemuck"] +convert-glam014 = ["nalgebra/glam014"] +convert-glam015 = ["nalgebra/glam015"] +convert-glam016 = ["nalgebra/glam016"] +convert-glam017 = ["nalgebra/glam017"] +convert-glam018 = ["nalgebra/glam018"] [dependencies] num-traits = { version = "0.2", default-features = false } approx = { version = "0.5", default-features = false } -simba = { version = "0.8", default-features = false } -nalgebra = { path = "..", version = "0.32", default-features = false } +simba = { version = "0.9", default-features = false } +nalgebra = { path = "..", version = "0.32", default-features = false } diff --git a/nalgebra-glm/src/traits.rs b/nalgebra-glm/src/traits.rs index 3d919eb10..5e342c09f 100644 --- a/nalgebra-glm/src/traits.rs +++ b/nalgebra-glm/src/traits.rs @@ -2,16 +2,16 @@ use approx::AbsDiffEq; use num::{Bounded, Signed}; use na::Scalar; -use simba::scalar::{ClosedAdd, ClosedMul, ClosedSub, RealField}; +use simba::scalar::{ClosedAddAssign, ClosedMulAssign, ClosedSubAssign, RealField}; /// A number that can either be an integer or a float. pub trait Number: Scalar + Copy + PartialOrd - + ClosedAdd - + ClosedSub - + ClosedMul + + ClosedAddAssign + + ClosedSubAssign + + ClosedMulAssign + AbsDiffEq + Signed + Bounded @@ -22,9 +22,9 @@ impl< T: Scalar + Copy + PartialOrd - + ClosedAdd - + ClosedSub - + ClosedMul + + ClosedAddAssign + + ClosedSubAssign + + ClosedMulAssign + AbsDiffEq + Signed + Bounded, diff --git a/nalgebra-lapack/Cargo.toml b/nalgebra-lapack/Cargo.toml index 1dae6e539..5c4d6516f 100644 --- a/nalgebra-lapack/Cargo.toml +++ b/nalgebra-lapack/Cargo.toml @@ -32,7 +32,7 @@ intel-mkl = ["lapack-src/intel-mkl"] nalgebra = { version = "0.32", path = ".." } num-traits = "0.2" num-complex = { version = "0.4", default-features = false } -simba = "0.8" +simba = "0.9" serde = { version = "1.0", features = ["derive"], optional = true } lapack = { version = "0.19", default-features = false } lapack-src = { version = "0.8", default-features = false } diff --git a/nalgebra-sparse/src/convert/impl_std_ops.rs b/nalgebra-sparse/src/convert/impl_std_ops.rs index 683227e2c..438ce2168 100644 --- a/nalgebra-sparse/src/convert/impl_std_ops.rs +++ b/nalgebra-sparse/src/convert/impl_std_ops.rs @@ -3,7 +3,7 @@ use crate::coo::CooMatrix; use crate::csc::CscMatrix; use crate::csr::CsrMatrix; use nalgebra::storage::RawStorage; -use nalgebra::{ClosedAdd, DMatrix, Dim, Matrix, Scalar}; +use nalgebra::{ClosedAddAssign, DMatrix, Dim, Matrix, Scalar}; use num_traits::Zero; impl<'a, T, R, C, S> From<&'a Matrix> for CooMatrix @@ -20,7 +20,7 @@ where impl<'a, T> From<&'a CooMatrix> for DMatrix where - T: Scalar + Zero + ClosedAdd, + T: Scalar + Zero + ClosedAddAssign, { fn from(coo: &'a CooMatrix) -> Self { convert_coo_dense(coo) @@ -29,7 +29,7 @@ where impl<'a, T> From<&'a CooMatrix> for CsrMatrix where - T: Scalar + Zero + ClosedAdd, + T: Scalar + Zero + ClosedAddAssign, { fn from(matrix: &'a CooMatrix) -> Self { convert_coo_csr(matrix) @@ -38,7 +38,7 @@ where impl<'a, T> From<&'a CsrMatrix> for CooMatrix where - T: Scalar + Zero + ClosedAdd, + T: Scalar + Zero + ClosedAddAssign, { fn from(matrix: &'a CsrMatrix) -> Self { convert_csr_coo(matrix) @@ -59,7 +59,7 @@ where impl<'a, T> From<&'a CsrMatrix> for DMatrix where - T: Scalar + Zero + ClosedAdd, + T: Scalar + Zero + ClosedAddAssign, { fn from(matrix: &'a CsrMatrix) -> Self { convert_csr_dense(matrix) @@ -68,7 +68,7 @@ where impl<'a, T> From<&'a CooMatrix> for CscMatrix where - T: Scalar + Zero + ClosedAdd, + T: Scalar + Zero + ClosedAddAssign, { fn from(matrix: &'a CooMatrix) -> Self { convert_coo_csc(matrix) @@ -98,7 +98,7 @@ where impl<'a, T> From<&'a CscMatrix> for DMatrix where - T: Scalar + Zero + ClosedAdd, + T: Scalar + Zero + ClosedAddAssign, { fn from(matrix: &'a CscMatrix) -> Self { convert_csc_dense(matrix) diff --git a/nalgebra-sparse/src/convert/serial.rs b/nalgebra-sparse/src/convert/serial.rs index 571e33769..8cb8b16f3 100644 --- a/nalgebra-sparse/src/convert/serial.rs +++ b/nalgebra-sparse/src/convert/serial.rs @@ -8,7 +8,7 @@ use std::ops::Add; use num_traits::Zero; use nalgebra::storage::RawStorage; -use nalgebra::{ClosedAdd, DMatrix, Dim, Matrix, Scalar}; +use nalgebra::{ClosedAddAssign, DMatrix, Dim, Matrix, Scalar}; use crate::coo::CooMatrix; use crate::cs; @@ -41,7 +41,7 @@ where /// Converts a [`CooMatrix`] to a dense matrix. pub fn convert_coo_dense(coo: &CooMatrix) -> DMatrix where - T: Scalar + Zero + ClosedAdd, + T: Scalar + Zero + ClosedAddAssign, { let mut output = DMatrix::repeat(coo.nrows(), coo.ncols(), T::zero()); for (i, j, v) in coo.triplet_iter() { @@ -80,7 +80,7 @@ pub fn convert_csr_coo(csr: &CsrMatrix) -> CooMatrix { /// Converts a [`CsrMatrix`] to a dense matrix. pub fn convert_csr_dense(csr: &CsrMatrix) -> DMatrix where - T: Scalar + ClosedAdd + Zero, + T: Scalar + ClosedAddAssign + Zero, { let mut output = DMatrix::zeros(csr.nrows(), csr.ncols()); @@ -157,7 +157,7 @@ where /// Converts a [`CscMatrix`] to a dense matrix. pub fn convert_csc_dense(csc: &CscMatrix) -> DMatrix where - T: Scalar + ClosedAdd + Zero, + T: Scalar + ClosedAddAssign + Zero, { let mut output = DMatrix::zeros(csc.nrows(), csc.ncols()); diff --git a/nalgebra-sparse/src/ops/impl_std_ops.rs b/nalgebra-sparse/src/ops/impl_std_ops.rs index c0e8f4a49..9f01e15d3 100644 --- a/nalgebra-sparse/src/ops/impl_std_ops.rs +++ b/nalgebra-sparse/src/ops/impl_std_ops.rs @@ -10,8 +10,8 @@ use nalgebra::allocator::Allocator; use nalgebra::base::storage::RawStorage; use nalgebra::constraint::{DimEq, ShapeConstraint}; use nalgebra::{ - ClosedAdd, ClosedDiv, ClosedMul, ClosedSub, DefaultAllocator, Dim, Dyn, Matrix, OMatrix, - Scalar, U1, + ClosedAddAssign, ClosedDivAssign, ClosedMulAssign, ClosedSubAssign, DefaultAllocator, Dim, Dyn, + Matrix, OMatrix, Scalar, U1, }; use num_traits::{One, Zero}; use std::ops::{Add, Div, DivAssign, Mul, MulAssign, Neg, Sub}; @@ -28,7 +28,7 @@ macro_rules! impl_bin_op { // Note: The Neg bound is currently required because we delegate e.g. // Sub to SpAdd with negative coefficients. This is not well-defined for // unsigned data types. - $($scalar_type: $($bounds + )? Scalar + ClosedAdd + ClosedSub + ClosedMul + Zero + One + Neg)? + $($scalar_type: $($bounds + )? Scalar + ClosedAddAssign + ClosedSubAssign + ClosedMulAssign + Zero + One + Neg)? { type Output = $ret; fn $method(self, $b: $b_type) -> Self::Output { @@ -164,7 +164,7 @@ macro_rules! impl_scalar_mul { impl MulAssign for $matrix_type where - T: Scalar + ClosedAdd + ClosedMul + Zero + One + T: Scalar + ClosedAddAssign + ClosedMulAssign + Zero + One { fn mul_assign(&mut self, scalar: T) { for val in self.values_mut() { @@ -175,7 +175,7 @@ macro_rules! impl_scalar_mul { impl<'a, T> MulAssign<&'a T> for $matrix_type where - T: Scalar + ClosedAdd + ClosedMul + Zero + One + T: Scalar + ClosedAddAssign + ClosedMulAssign + Zero + One { fn mul_assign(&mut self, scalar: &'a T) { for val in self.values_mut() { @@ -227,15 +227,15 @@ impl_neg!(CscMatrix); macro_rules! impl_div { ($matrix_type:ident) => { - impl_bin_op!(Div, div, (matrix: $matrix_type, scalar: T) -> $matrix_type { + impl_bin_op!(Div, div, (matrix: $matrix_type, scalar: T) -> $matrix_type { let mut matrix = matrix; matrix /= scalar; matrix }); - impl_bin_op!(Div, div, <'a, T: ClosedDiv>(matrix: $matrix_type, scalar: &T) -> $matrix_type { + impl_bin_op!(Div, div, <'a, T: ClosedDivAssign>(matrix: $matrix_type, scalar: &T) -> $matrix_type { matrix / scalar.clone() }); - impl_bin_op!(Div, div, <'a, T: ClosedDiv>(matrix: &'a $matrix_type, scalar: T) -> $matrix_type { + impl_bin_op!(Div, div, <'a, T: ClosedDivAssign>(matrix: &'a $matrix_type, scalar: T) -> $matrix_type { let new_values = matrix.values() .iter() .map(|v_i| v_i.clone() / scalar.clone()) @@ -243,12 +243,12 @@ macro_rules! impl_div { $matrix_type::try_from_pattern_and_values(matrix.pattern().clone(), new_values) .unwrap() }); - impl_bin_op!(Div, div, <'a, T: ClosedDiv>(matrix: &'a $matrix_type, scalar: &'a T) -> $matrix_type { + impl_bin_op!(Div, div, <'a, T: ClosedDivAssign>(matrix: &'a $matrix_type, scalar: &'a T) -> $matrix_type { matrix / scalar.clone() }); impl DivAssign for $matrix_type - where T : Scalar + ClosedAdd + ClosedMul + ClosedDiv + Zero + One + where T : Scalar + ClosedAddAssign + ClosedMulAssign + ClosedDivAssign + Zero + One { fn div_assign(&mut self, scalar: T) { self.values_mut().iter_mut().for_each(|v_i| *v_i /= scalar.clone()); @@ -256,7 +256,7 @@ macro_rules! impl_div { } impl<'a, T> DivAssign<&'a T> for $matrix_type - where T : Scalar + ClosedAdd + ClosedMul + ClosedDiv + Zero + One + where T : Scalar + ClosedAddAssign + ClosedMulAssign + ClosedDivAssign + Zero + One { fn div_assign(&mut self, scalar: &'a T) { *self /= scalar.clone(); @@ -298,7 +298,7 @@ macro_rules! impl_spmm_cs_dense { { impl<'a, T, R, C, S> Mul<$dense_matrix_type> for $sparse_matrix_type where - T: Scalar + ClosedMul + ClosedAdd + ClosedSub + ClosedDiv + Neg + Zero + One, + T: Scalar + ClosedMulAssign + ClosedAddAssign + ClosedSubAssign + ClosedDivAssign + Neg + Zero + One, R: Dim, C: Dim, S: RawStorage, diff --git a/nalgebra-sparse/src/ops/serial/cs.rs b/nalgebra-sparse/src/ops/serial/cs.rs index a2a132fc6..ec2690358 100644 --- a/nalgebra-sparse/src/ops/serial/cs.rs +++ b/nalgebra-sparse/src/ops/serial/cs.rs @@ -2,7 +2,7 @@ use crate::cs::CsMatrix; use crate::ops::serial::{OperationError, OperationErrorKind}; use crate::ops::Op; use crate::SparseEntryMut; -use nalgebra::{ClosedAdd, ClosedMul, DMatrixView, DMatrixViewMut, Scalar}; +use nalgebra::{ClosedAddAssign, ClosedMulAssign, DMatrixView, DMatrixViewMut, Scalar}; use num_traits::{One, Zero}; fn spmm_cs_unexpected_entry() -> OperationError { @@ -28,7 +28,7 @@ pub fn spmm_cs_prealloc_unchecked( b: &CsMatrix, ) -> Result<(), OperationError> where - T: Scalar + ClosedAdd + ClosedMul + Zero + One, + T: Scalar + ClosedAddAssign + ClosedMulAssign + Zero + One, { assert_eq!(c.pattern().major_dim(), a.pattern().major_dim()); assert_eq!(c.pattern().minor_dim(), b.pattern().minor_dim()); @@ -73,7 +73,7 @@ pub fn spmm_cs_prealloc( b: &CsMatrix, ) -> Result<(), OperationError> where - T: Scalar + ClosedAdd + ClosedMul + Zero + One, + T: Scalar + ClosedAddAssign + ClosedMulAssign + Zero + One, { for i in 0..c.pattern().major_dim() { let a_lane_i = a.get_lane(i).unwrap(); @@ -119,7 +119,7 @@ pub fn spadd_cs_prealloc( a: Op<&CsMatrix>, ) -> Result<(), OperationError> where - T: Scalar + ClosedAdd + ClosedMul + Zero + One, + T: Scalar + ClosedAddAssign + ClosedMulAssign + Zero + One, { match a { Op::NoOp(a) => { @@ -181,7 +181,7 @@ pub fn spmm_cs_dense( a: Op<&CsMatrix>, b: Op>, ) where - T: Scalar + ClosedAdd + ClosedMul + Zero + One, + T: Scalar + ClosedAddAssign + ClosedMulAssign + Zero + One, { match a { Op::NoOp(a) => { diff --git a/nalgebra-sparse/src/ops/serial/csc.rs b/nalgebra-sparse/src/ops/serial/csc.rs index 85e02eb47..a7a9104c5 100644 --- a/nalgebra-sparse/src/ops/serial/csc.rs +++ b/nalgebra-sparse/src/ops/serial/csc.rs @@ -4,7 +4,7 @@ use crate::ops::serial::cs::{ }; use crate::ops::serial::{OperationError, OperationErrorKind}; use crate::ops::Op; -use nalgebra::{ClosedAdd, ClosedMul, DMatrixView, DMatrixViewMut, RealField, Scalar}; +use nalgebra::{ClosedAddAssign, ClosedMulAssign, DMatrixView, DMatrixViewMut, RealField, Scalar}; use num_traits::{One, Zero}; use std::borrow::Cow; @@ -21,7 +21,7 @@ pub fn spmm_csc_dense<'a, T>( a: Op<&CscMatrix>, b: Op>>, ) where - T: Scalar + ClosedAdd + ClosedMul + Zero + One, + T: Scalar + ClosedAddAssign + ClosedMulAssign + Zero + One, { let b = b.convert(); spmm_csc_dense_(beta, c.into(), alpha, a, b) @@ -34,7 +34,7 @@ fn spmm_csc_dense_( a: Op<&CscMatrix>, b: Op>, ) where - T: Scalar + ClosedAdd + ClosedMul + Zero + One, + T: Scalar + ClosedAddAssign + ClosedMulAssign + Zero + One, { assert_compatible_spmm_dims!(c, a, b); // Need to interpret matrix as transposed since the spmm_cs_dense function assumes CSR layout @@ -57,7 +57,7 @@ pub fn spadd_csc_prealloc( a: Op<&CscMatrix>, ) -> Result<(), OperationError> where - T: Scalar + ClosedAdd + ClosedMul + Zero + One, + T: Scalar + ClosedAddAssign + ClosedMulAssign + Zero + One, { assert_compatible_spadd_dims!(c, a); spadd_cs_prealloc(beta, &mut c.cs, alpha, a.map_same_op(|a| &a.cs)) @@ -81,7 +81,7 @@ pub fn spmm_csc_prealloc( b: Op<&CscMatrix>, ) -> Result<(), OperationError> where - T: Scalar + ClosedAdd + ClosedMul + Zero + One, + T: Scalar + ClosedAddAssign + ClosedMulAssign + Zero + One, { assert_compatible_spmm_dims!(c, a, b); @@ -109,7 +109,7 @@ pub fn spmm_csc_prealloc_unchecked( b: Op<&CscMatrix>, ) -> Result<(), OperationError> where - T: Scalar + ClosedAdd + ClosedMul + Zero + One, + T: Scalar + ClosedAddAssign + ClosedMulAssign + Zero + One, { assert_compatible_spmm_dims!(c, a, b); @@ -133,7 +133,7 @@ fn spmm_csc_transposed( spmm_kernel: F, ) -> Result<(), OperationError> where - T: Scalar + ClosedAdd + ClosedMul + Zero + One, + T: Scalar + ClosedAddAssign + ClosedMulAssign + Zero + One, F: Fn( T, &mut CscMatrix, diff --git a/nalgebra-sparse/src/ops/serial/csr.rs b/nalgebra-sparse/src/ops/serial/csr.rs index 366f30aa6..48b006571 100644 --- a/nalgebra-sparse/src/ops/serial/csr.rs +++ b/nalgebra-sparse/src/ops/serial/csr.rs @@ -4,7 +4,7 @@ use crate::ops::serial::cs::{ }; use crate::ops::serial::OperationError; use crate::ops::Op; -use nalgebra::{ClosedAdd, ClosedMul, DMatrixView, DMatrixViewMut, Scalar}; +use nalgebra::{ClosedAddAssign, ClosedMulAssign, DMatrixView, DMatrixViewMut, Scalar}; use num_traits::{One, Zero}; use std::borrow::Cow; @@ -16,7 +16,7 @@ pub fn spmm_csr_dense<'a, T>( a: Op<&CsrMatrix>, b: Op>>, ) where - T: Scalar + ClosedAdd + ClosedMul + Zero + One, + T: Scalar + ClosedAddAssign + ClosedMulAssign + Zero + One, { let b = b.convert(); spmm_csr_dense_(beta, c.into(), alpha, a, b) @@ -29,7 +29,7 @@ fn spmm_csr_dense_( a: Op<&CsrMatrix>, b: Op>, ) where - T: Scalar + ClosedAdd + ClosedMul + Zero + One, + T: Scalar + ClosedAddAssign + ClosedMulAssign + Zero + One, { assert_compatible_spmm_dims!(c, a, b); spmm_cs_dense(beta, c, alpha, a.map_same_op(|a| &a.cs), b) @@ -52,7 +52,7 @@ pub fn spadd_csr_prealloc( a: Op<&CsrMatrix>, ) -> Result<(), OperationError> where - T: Scalar + ClosedAdd + ClosedMul + Zero + One, + T: Scalar + ClosedAddAssign + ClosedMulAssign + Zero + One, { assert_compatible_spadd_dims!(c, a); spadd_cs_prealloc(beta, &mut c.cs, alpha, a.map_same_op(|a| &a.cs)) @@ -75,7 +75,7 @@ pub fn spmm_csr_prealloc( b: Op<&CsrMatrix>, ) -> Result<(), OperationError> where - T: Scalar + ClosedAdd + ClosedMul + Zero + One, + T: Scalar + ClosedAddAssign + ClosedMulAssign + Zero + One, { assert_compatible_spmm_dims!(c, a, b); @@ -100,7 +100,7 @@ pub fn spmm_csr_prealloc_unchecked( b: Op<&CsrMatrix>, ) -> Result<(), OperationError> where - T: Scalar + ClosedAdd + ClosedMul + Zero + One, + T: Scalar + ClosedAddAssign + ClosedMulAssign + Zero + One, { assert_compatible_spmm_dims!(c, a, b); @@ -121,7 +121,7 @@ fn spmm_csr_transposed( spmm_kernel: F, ) -> Result<(), OperationError> where - T: Scalar + ClosedAdd + ClosedMul + Zero + One, + T: Scalar + ClosedAddAssign + ClosedMulAssign + Zero + One, F: Fn( T, &mut CsrMatrix, diff --git a/src/base/blas.rs b/src/base/blas.rs index ccf76dc68..c142a380d 100644 --- a/src/base/blas.rs +++ b/src/base/blas.rs @@ -1,6 +1,6 @@ use crate::{RawStorage, SimdComplexField}; use num::{One, Zero}; -use simba::scalar::{ClosedAdd, ClosedMul}; +use simba::scalar::{ClosedAddAssign, ClosedMulAssign}; use crate::base::allocator::Allocator; use crate::base::blas_uninit::{axcpy_uninit, gemm_uninit, gemv_uninit}; @@ -17,7 +17,7 @@ use crate::base::{ /// # Dot/scalar product impl> Matrix where - T: Scalar + Zero + ClosedAdd + ClosedMul, + T: Scalar + Zero + ClosedAddAssign + ClosedMulAssign, { #[inline(always)] fn dotx( @@ -275,7 +275,7 @@ where /// # BLAS functions impl Vector where - T: Scalar + Zero + ClosedAdd + ClosedMul, + T: Scalar + Zero + ClosedAddAssign + ClosedMulAssign, S: StorageMut, { /// Computes `self = a * x * c + b * self`. @@ -609,7 +609,7 @@ where impl> Matrix where - T: Scalar + Zero + ClosedAdd + ClosedMul, + T: Scalar + Zero + ClosedAddAssign + ClosedMulAssign, { #[inline(always)] fn gerx( @@ -862,7 +862,7 @@ where impl> Matrix where - T: Scalar + Zero + ClosedAdd + ClosedMul, + T: Scalar + Zero + ClosedAddAssign + ClosedMulAssign, { #[inline(always)] fn xxgerx( @@ -1010,7 +1010,7 @@ where impl> SquareMatrix where - T: Scalar + Zero + One + ClosedAdd + ClosedMul, + T: Scalar + Zero + One + ClosedAddAssign + ClosedMulAssign, { /// Computes the quadratic form `self = alpha * lhs * mid * lhs.transpose() + beta * self`. /// diff --git a/src/base/blas_uninit.rs b/src/base/blas_uninit.rs index 33a7aa70a..173dff87b 100644 --- a/src/base/blas_uninit.rs +++ b/src/base/blas_uninit.rs @@ -11,7 +11,7 @@ #[cfg(feature = "std")] use matrixmultiply; use num::{One, Zero}; -use simba::scalar::{ClosedAdd, ClosedMul}; +use simba::scalar::{ClosedAddAssign, ClosedMulAssign}; #[cfg(feature = "std")] use std::{any::TypeId, mem}; @@ -41,7 +41,7 @@ unsafe fn array_axcpy( len: usize, ) where Status: InitStatus, - T: Scalar + Zero + ClosedAdd + ClosedMul, + T: Scalar + Zero + ClosedAddAssign + ClosedMulAssign, { for i in 0..len { let y = Status::assume_init_mut(y.get_unchecked_mut(i * stride1)); @@ -61,7 +61,7 @@ fn array_axc( len: usize, ) where Status: InitStatus, - T: Scalar + Zero + ClosedAdd + ClosedMul, + T: Scalar + Zero + ClosedAddAssign + ClosedMulAssign, { for i in 0..len { unsafe { @@ -89,7 +89,7 @@ pub unsafe fn axcpy_uninit( c: T, b: T, ) where - T: Scalar + Zero + ClosedAdd + ClosedMul, + T: Scalar + Zero + ClosedAddAssign + ClosedMulAssign, SA: RawStorageMut, SB: RawStorage, ShapeConstraint: DimEq, @@ -129,7 +129,7 @@ pub unsafe fn gemv_uninit, - T: Scalar + Zero + One + ClosedAdd + ClosedMul, + T: Scalar + Zero + One + ClosedAddAssign + ClosedMulAssign, SA: RawStorageMut, SB: RawStorage, SC: RawStorage, @@ -199,7 +199,7 @@ pub unsafe fn gemm_uninit< beta: T, ) where Status: InitStatus, - T: Scalar + Zero + One + ClosedAdd + ClosedMul, + T: Scalar + Zero + One + ClosedAddAssign + ClosedMulAssign, SA: RawStorageMut, SB: RawStorage, SC: RawStorage, diff --git a/src/base/cg.rs b/src/base/cg.rs index 872e7f364..650e4c1b3 100644 --- a/src/base/cg.rs +++ b/src/base/cg.rs @@ -19,7 +19,7 @@ use crate::geometry::{ Rotation3, }; -use simba::scalar::{ClosedAdd, ClosedMul, RealField}; +use simba::scalar::{ClosedAddAssign, ClosedMulAssign, RealField}; /// # Translation and scaling in any dimension impl OMatrix @@ -207,8 +207,11 @@ impl Matrix4 { } /// # Append/prepend translation and scaling -impl> - SquareMatrix +impl< + T: Scalar + Zero + One + ClosedMulAssign + ClosedAddAssign, + D: DimName, + S: Storage, + > SquareMatrix { /// Computes the transformation equal to `self` followed by an uniform scaling factor. #[inline] diff --git a/src/base/componentwise.rs b/src/base/componentwise.rs index cabf6ddf3..051bdb0a1 100644 --- a/src/base/componentwise.rs +++ b/src/base/componentwise.rs @@ -3,7 +3,7 @@ use num::{Signed, Zero}; use std::ops::{Add, Mul}; -use simba::scalar::{ClosedDiv, ClosedMul}; +use simba::scalar::{ClosedDivAssign, ClosedMulAssign}; use simba::simd::SimdPartialOrd; use crate::base::allocator::{Allocator, SameShapeAllocator}; @@ -11,7 +11,7 @@ use crate::base::constraint::{SameNumberOfColumns, SameNumberOfRows, ShapeConstr use crate::base::dimension::Dim; use crate::base::storage::{Storage, StorageMut}; use crate::base::{DefaultAllocator, Matrix, MatrixSum, OMatrix, Scalar}; -use crate::ClosedAdd; +use crate::ClosedAddAssign; /// The type of the result of a matrix component-wise operation. pub type MatrixComponentOp = MatrixSum; @@ -148,7 +148,7 @@ macro_rules! component_binop_impl( /// # Componentwise operations impl> Matrix { component_binop_impl!( - component_mul, component_mul_mut, component_mul_assign, cmpy, ClosedMul.mul.mul_assign, + component_mul, component_mul_mut, component_mul_assign, cmpy, ClosedMulAssign.mul.mul_assign, r" Componentwise matrix or vector multiplication. @@ -193,7 +193,7 @@ impl> Matrix assert_eq!(a, expected); ``` "; - component_div, component_div_mut, component_div_assign, cdpy, ClosedDiv.div.div_assign, + component_div, component_div_mut, component_div_assign, cdpy, ClosedDivAssign.div.div_assign, r" Componentwise matrix or vector division. @@ -320,7 +320,7 @@ impl> Matrix #[must_use = "Did you mean to use add_scalar_mut()?"] pub fn add_scalar(&self, rhs: T) -> OMatrix where - T: ClosedAdd, + T: ClosedAddAssign, DefaultAllocator: Allocator, { let mut res = self.clone_owned(); @@ -343,7 +343,7 @@ impl> Matrix #[inline] pub fn add_scalar_mut(&mut self, rhs: T) where - T: ClosedAdd, + T: ClosedAddAssign, SA: StorageMut, { for e in self.iter_mut() { diff --git a/src/base/construction.rs b/src/base/construction.rs index 571b278e9..ca7dbf75f 100644 --- a/src/base/construction.rs +++ b/src/base/construction.rs @@ -16,7 +16,7 @@ use rand::{ use std::iter; use typenum::{self, Cmp, Greater}; -use simba::scalar::{ClosedAdd, ClosedMul}; +use simba::scalar::{ClosedAddAssign, ClosedMulAssign}; use crate::base::allocator::Allocator; use crate::base::dimension::{Dim, DimName, Dyn, ToTypenum}; @@ -814,7 +814,7 @@ impl_constructors_from_data!(data; Dyn, Dyn; */ impl Zero for OMatrix where - T: Scalar + Zero + ClosedAdd, + T: Scalar + Zero + ClosedAddAssign, DefaultAllocator: Allocator, { #[inline] @@ -830,7 +830,7 @@ where impl One for OMatrix where - T: Scalar + Zero + One + ClosedMul + ClosedAdd, + T: Scalar + Zero + One + ClosedMulAssign + ClosedAddAssign, DefaultAllocator: Allocator, { #[inline] diff --git a/src/base/interpolation.rs b/src/base/interpolation.rs index bdfd1c264..e7ef55293 100644 --- a/src/base/interpolation.rs +++ b/src/base/interpolation.rs @@ -2,11 +2,14 @@ use crate::storage::Storage; use crate::{ Allocator, DefaultAllocator, Dim, OVector, One, RealField, Scalar, Unit, Vector, Zero, }; -use simba::scalar::{ClosedAdd, ClosedMul, ClosedSub}; +use simba::scalar::{ClosedAddAssign, ClosedMulAssign, ClosedSubAssign}; /// # Interpolation -impl> - Vector +impl< + T: Scalar + Zero + One + ClosedAddAssign + ClosedSubAssign + ClosedMulAssign, + D: Dim, + S: Storage, + > Vector { /// Returns `self * (1.0 - t) + rhs * t`, i.e., the linear blend of the vectors x and y using the scalar value a. /// diff --git a/src/base/matrix.rs b/src/base/matrix.rs index 50599e34d..945038cdd 100644 --- a/src/base/matrix.rs +++ b/src/base/matrix.rs @@ -18,7 +18,7 @@ use rkyv::bytecheck; #[cfg(feature = "rkyv-serialize-no-std")] use rkyv::{with::With, Archive, Archived}; -use simba::scalar::{ClosedAdd, ClosedMul, ClosedSub, Field, SupersetOf}; +use simba::scalar::{ClosedAddAssign, ClosedMulAssign, ClosedSubAssign, Field, SupersetOf}; use simba::simd::SimdPartialOrd; use crate::base::allocator::{Allocator, SameShapeAllocator, SameShapeC, SameShapeR}; @@ -1586,7 +1586,7 @@ impl> SquareMatrix { #[must_use] pub fn trace(&self) -> T where - T: Scalar + Zero + ClosedAdd, + T: Scalar + Zero + ClosedAddAssign, { assert!( self.is_square(), @@ -2002,8 +2002,12 @@ mod tests { } /// # Cross product -impl> - Matrix +impl< + T: Scalar + ClosedAddAssign + ClosedSubAssign + ClosedMulAssign, + R: Dim, + C: Dim, + S: RawStorage, + > Matrix { /// The perpendicular product between two 2D column vectors, i.e. `a.x * b.y - a.y * b.x`. #[inline] diff --git a/src/base/matrix_simba.rs b/src/base/matrix_simba.rs index c31e8977d..83324f5b4 100644 --- a/src/base/matrix_simba.rs +++ b/src/base/matrix_simba.rs @@ -17,14 +17,10 @@ where T::Element: Scalar, DefaultAllocator: Allocator, { + const LANES: usize = T::LANES; type Element = OMatrix; type SimdBool = T::SimdBool; - #[inline] - fn lanes() -> usize { - T::lanes() - } - #[inline] fn splat(val: Self::Element) -> Self { val.map(T::splat) diff --git a/src/base/ops.rs b/src/base/ops.rs index 273876d33..882599570 100644 --- a/src/base/ops.rs +++ b/src/base/ops.rs @@ -4,7 +4,9 @@ use std::ops::{ Add, AddAssign, Div, DivAssign, Index, IndexMut, Mul, MulAssign, Neg, Sub, SubAssign, }; -use simba::scalar::{ClosedAdd, ClosedDiv, ClosedMul, ClosedNeg, ClosedSub}; +use simba::scalar::{ + ClosedAddAssign, ClosedDivAssign, ClosedMulAssign, ClosedNeg, ClosedSubAssign, +}; use crate::base::allocator::{Allocator, SameShapeAllocator, SameShapeC, SameShapeR}; use crate::base::blas_uninit::gemm_uninit; @@ -357,16 +359,16 @@ macro_rules! componentwise_binop_impl( } ); -componentwise_binop_impl!(Add, add, ClosedAdd; +componentwise_binop_impl!(Add, add, ClosedAddAssign; AddAssign, add_assign, add_assign_statically_unchecked, add_assign_statically_unchecked_mut; add_to, add_to_statically_unchecked_uninit); -componentwise_binop_impl!(Sub, sub, ClosedSub; +componentwise_binop_impl!(Sub, sub, ClosedSubAssign; SubAssign, sub_assign, sub_assign_statically_unchecked, sub_assign_statically_unchecked_mut; sub_to, sub_to_statically_unchecked_uninit); impl iter::Sum for OMatrix where - T: Scalar + ClosedAdd + Zero, + T: Scalar + ClosedAddAssign + Zero, DefaultAllocator: Allocator, { fn sum>>(iter: I) -> OMatrix { @@ -376,7 +378,7 @@ where impl iter::Sum for OMatrix where - T: Scalar + ClosedAdd + Zero, + T: Scalar + ClosedAddAssign + Zero, DefaultAllocator: Allocator, { /// # Example @@ -406,7 +408,7 @@ where impl<'a, T, R: DimName, C: DimName> iter::Sum<&'a OMatrix> for OMatrix where - T: Scalar + ClosedAdd + Zero, + T: Scalar + ClosedAddAssign + Zero, DefaultAllocator: Allocator, { fn sum>>(iter: I) -> OMatrix { @@ -416,7 +418,7 @@ where impl<'a, T, C: Dim> iter::Sum<&'a OMatrix> for OMatrix where - T: Scalar + ClosedAdd + Zero, + T: Scalar + ClosedAddAssign + Zero, DefaultAllocator: Allocator, { /// # Example @@ -506,8 +508,8 @@ macro_rules! componentwise_scalarop_impl( } ); -componentwise_scalarop_impl!(Mul, mul, ClosedMul; MulAssign, mul_assign); -componentwise_scalarop_impl!(Div, div, ClosedDiv; DivAssign, div_assign); +componentwise_scalarop_impl!(Mul, mul, ClosedMulAssign; MulAssign, mul_assign); +componentwise_scalarop_impl!(Div, div, ClosedDivAssign; DivAssign, div_assign); macro_rules! left_scalar_mul_impl( ($($T: ty),* $(,)*) => {$( @@ -551,7 +553,7 @@ left_scalar_mul_impl!(u8, u16, u32, u64, usize, i8, i16, i32, i64, isize, f32, f impl<'a, 'b, T, R1: Dim, C1: Dim, R2: Dim, C2: Dim, SA, SB> Mul<&'b Matrix> for &'a Matrix where - T: Scalar + Zero + One + ClosedAdd + ClosedMul, + T: Scalar + Zero + One + ClosedAddAssign + ClosedMulAssign, SA: Storage, SB: Storage, DefaultAllocator: Allocator, @@ -573,7 +575,7 @@ where impl<'a, T, R1: Dim, C1: Dim, R2: Dim, C2: Dim, SA, SB> Mul> for &'a Matrix where - T: Scalar + Zero + One + ClosedAdd + ClosedMul, + T: Scalar + Zero + One + ClosedAddAssign + ClosedMulAssign, SB: Storage, SA: Storage, DefaultAllocator: Allocator, @@ -590,7 +592,7 @@ where impl<'b, T, R1: Dim, C1: Dim, R2: Dim, C2: Dim, SA, SB> Mul<&'b Matrix> for Matrix where - T: Scalar + Zero + One + ClosedAdd + ClosedMul, + T: Scalar + Zero + One + ClosedAddAssign + ClosedMulAssign, SB: Storage, SA: Storage, DefaultAllocator: Allocator, @@ -607,7 +609,7 @@ where impl Mul> for Matrix where - T: Scalar + Zero + One + ClosedAdd + ClosedMul, + T: Scalar + Zero + One + ClosedAddAssign + ClosedMulAssign, SB: Storage, SA: Storage, DefaultAllocator: Allocator, @@ -629,7 +631,7 @@ where R1: Dim, C1: Dim, R2: Dim, - T: Scalar + Zero + One + ClosedAdd + ClosedMul, + T: Scalar + Zero + One + ClosedAddAssign + ClosedMulAssign, SB: Storage, SA: StorageMut + IsContiguous + Clone, // TODO: get rid of the IsContiguous ShapeConstraint: AreMultipliable, @@ -646,7 +648,7 @@ where R1: Dim, C1: Dim, R2: Dim, - T: Scalar + Zero + One + ClosedAdd + ClosedMul, + T: Scalar + Zero + One + ClosedAddAssign + ClosedMulAssign, SB: Storage, SA: StorageMut + IsContiguous + Clone, // TODO: get rid of the IsContiguous ShapeConstraint: AreMultipliable, @@ -662,7 +664,7 @@ where /// # Special multiplications. impl Matrix where - T: Scalar + Zero + One + ClosedAdd + ClosedMul, + T: Scalar + Zero + One + ClosedAddAssign + ClosedMulAssign, SA: Storage, { /// Equivalent to `self.transpose() * rhs`. @@ -799,7 +801,7 @@ where rhs: &Matrix, ) -> OMatrix, DimProd> where - T: ClosedMul, + T: ClosedMulAssign, R1: DimMul, C1: DimMul, SB: Storage, @@ -835,7 +837,7 @@ where impl iter::Product for OMatrix where - T: Scalar + Zero + One + ClosedMul + ClosedAdd, + T: Scalar + Zero + One + ClosedMulAssign + ClosedAddAssign, DefaultAllocator: Allocator, { fn product>>(iter: I) -> OMatrix { @@ -845,7 +847,7 @@ where impl<'a, T, D: DimName> iter::Product<&'a OMatrix> for OMatrix where - T: Scalar + Zero + One + ClosedMul + ClosedAdd, + T: Scalar + Zero + One + ClosedMulAssign + ClosedAddAssign, DefaultAllocator: Allocator, { fn product>>(iter: I) -> OMatrix { diff --git a/src/base/properties.rs b/src/base/properties.rs index ab0ceff2b..0fdfaf019 100644 --- a/src/base/properties.rs +++ b/src/base/properties.rs @@ -2,7 +2,7 @@ use approx::RelativeEq; use num::{One, Zero}; -use simba::scalar::{ClosedAdd, ClosedMul, ComplexField, RealField}; +use simba::scalar::{ClosedAddAssign, ClosedMulAssign, ComplexField, RealField}; use crate::base::allocator::Allocator; use crate::base::dimension::{Dim, DimMin}; @@ -88,7 +88,7 @@ impl> Matrix { #[must_use] pub fn is_orthogonal(&self, eps: T::Epsilon) -> bool where - T: Zero + One + ClosedAdd + ClosedMul + RelativeEq, + T: Zero + One + ClosedAddAssign + ClosedMulAssign + RelativeEq, S: Storage, T::Epsilon: Clone, DefaultAllocator: Allocator + Allocator, diff --git a/src/base/statistics.rs b/src/base/statistics.rs index 85c0f11c3..3837f385f 100644 --- a/src/base/statistics.rs +++ b/src/base/statistics.rs @@ -2,7 +2,7 @@ use crate::allocator::Allocator; use crate::storage::RawStorage; use crate::{Const, DefaultAllocator, Dim, Matrix, OVector, RowOVector, Scalar, VectorView, U1}; use num::{One, Zero}; -use simba::scalar::{ClosedAdd, ClosedMul, Field, SupersetOf}; +use simba::scalar::{ClosedAddAssign, ClosedMulAssign, Field, SupersetOf}; use std::mem::MaybeUninit; /// # Folding on columns and rows @@ -104,7 +104,7 @@ impl> Matrix { #[must_use] pub fn sum(&self) -> T where - T: ClosedAdd + Zero, + T: ClosedAddAssign + Zero, { self.iter().cloned().fold(T::zero(), |a, b| a + b) } @@ -132,7 +132,7 @@ impl> Matrix { #[must_use] pub fn row_sum(&self) -> RowOVector where - T: ClosedAdd + Zero, + T: ClosedAddAssign + Zero, DefaultAllocator: Allocator, { self.compress_rows(|col| col.sum()) @@ -159,7 +159,7 @@ impl> Matrix { #[must_use] pub fn row_sum_tr(&self) -> OVector where - T: ClosedAdd + Zero, + T: ClosedAddAssign + Zero, DefaultAllocator: Allocator, { self.compress_rows_tr(|col| col.sum()) @@ -186,7 +186,7 @@ impl> Matrix { #[must_use] pub fn column_sum(&self) -> OVector where - T: ClosedAdd + Zero, + T: ClosedAddAssign + Zero, DefaultAllocator: Allocator, { let nrows = self.shape_generic().0; @@ -215,7 +215,7 @@ impl> Matrix { #[must_use] pub fn product(&self) -> T where - T: ClosedMul + One, + T: ClosedMulAssign + One, { self.iter().cloned().fold(T::one(), |a, b| a * b) } @@ -243,7 +243,7 @@ impl> Matrix { #[must_use] pub fn row_product(&self) -> RowOVector where - T: ClosedMul + One, + T: ClosedMulAssign + One, DefaultAllocator: Allocator, { self.compress_rows(|col| col.product()) @@ -270,7 +270,7 @@ impl> Matrix { #[must_use] pub fn row_product_tr(&self) -> OVector where - T: ClosedMul + One, + T: ClosedMulAssign + One, DefaultAllocator: Allocator, { self.compress_rows_tr(|col| col.product()) @@ -297,7 +297,7 @@ impl> Matrix { #[must_use] pub fn column_product(&self) -> OVector where - T: ClosedMul + One, + T: ClosedMulAssign + One, DefaultAllocator: Allocator, { let nrows = self.shape_generic().0; diff --git a/src/geometry/abstract_rotation.rs b/src/geometry/abstract_rotation.rs index 4bbabea27..b7ef07878 100644 --- a/src/geometry/abstract_rotation.rs +++ b/src/geometry/abstract_rotation.rs @@ -1,10 +1,10 @@ use crate::geometry::{Rotation, UnitComplex, UnitQuaternion}; use crate::{Const, OVector, Point, SVector, Scalar, SimdRealField, Unit}; -use simba::scalar::ClosedMul; +use simba::scalar::ClosedMulAssign; /// Trait implemented by rotations that can be used inside of an `Isometry` or `Similarity`. -pub trait AbstractRotation: PartialEq + ClosedMul + Clone { +pub trait AbstractRotation: PartialEq + ClosedMulAssign + Clone { /// The rotation identity. fn identity() -> Self; /// The rotation inverse. diff --git a/src/geometry/isometry_ops.rs b/src/geometry/isometry_ops.rs index 074ac025d..fad798d60 100644 --- a/src/geometry/isometry_ops.rs +++ b/src/geometry/isometry_ops.rs @@ -4,7 +4,7 @@ use num::{One, Zero}; use std::ops::{Div, DivAssign, Mul, MulAssign}; -use simba::scalar::{ClosedAdd, ClosedMul}; +use simba::scalar::{ClosedAddAssign, ClosedMulAssign}; use simba::simd::SimdRealField; use crate::base::{SVector, Unit}; diff --git a/src/geometry/isometry_simba.rs b/src/geometry/isometry_simba.rs index ad4823561..9e4246856 100755 --- a/src/geometry/isometry_simba.rs +++ b/src/geometry/isometry_simba.rs @@ -10,14 +10,10 @@ where R: SimdValue + AbstractRotation, R::Element: AbstractRotation, { + const LANES: usize = T::LANES; type Element = Isometry; type SimdBool = T::SimdBool; - #[inline] - fn lanes() -> usize { - T::lanes() - } - #[inline] fn splat(val: Self::Element) -> Self { Isometry::from_parts(Translation::splat(val.translation), R::splat(val.rotation)) diff --git a/src/geometry/op_macros.rs b/src/geometry/op_macros.rs index a4775d2a3..4bdcf9914 100644 --- a/src/geometry/op_macros.rs +++ b/src/geometry/op_macros.rs @@ -21,7 +21,7 @@ macro_rules! md_impl( // Lifetime. $($lives: tt),*) => { impl<$($lives ,)* T $(, $DimsDecl)* $(, const $D: usize)*> $Op<$Rhs> for $Lhs - where T: Scalar + Zero + One + ClosedAdd + ClosedMul $($(+ $ScalarBounds)*)*, + where T: Scalar + Zero + One + ClosedAddAssign + ClosedMulAssign $($(+ $ScalarBounds)*)*, $( $ConstraintType: $ConstraintBound$(<$( $ConstraintBoundParams $( = $EqBound )*),*>)* ),* { type Output = $Result; @@ -112,7 +112,7 @@ macro_rules! md_assign_impl( // Actual implementation and lifetimes. $action: expr; $($lives: tt),*) => { impl<$($lives ,)* T $(, $DimsDecl)* $(, const $D: usize)*> $Op<$Rhs> for $Lhs - where T: Scalar + Zero + One + ClosedAdd + ClosedMul $($(+ $ScalarBounds)*)*, + where T: Scalar + Zero + One + ClosedAddAssign + ClosedMulAssign $($(+ $ScalarBounds)*)*, $($(T::Element: $ElementBounds,)*)* $( $ConstraintType: $ConstraintBound $(<$( $ConstraintBoundParams $( = $EqBound )*),*>)* ),* { diff --git a/src/geometry/point.rs b/src/geometry/point.rs index 5ac9d7a7e..1486d5d9c 100644 --- a/src/geometry/point.rs +++ b/src/geometry/point.rs @@ -15,7 +15,7 @@ use crate::base::allocator::Allocator; use crate::base::dimension::{DimName, DimNameAdd, DimNameSum, U1}; use crate::base::iter::{MatrixIter, MatrixIterMut}; use crate::base::{Const, DefaultAllocator, OVector, Scalar}; -use simba::scalar::{ClosedAdd, ClosedMul, ClosedSub}; +use simba::scalar::{ClosedAddAssign, ClosedMulAssign, ClosedSubAssign}; use std::mem::MaybeUninit; /// A point in an euclidean space. @@ -234,7 +234,7 @@ where #[must_use] pub fn lerp(&self, rhs: &OPoint, t: T) -> OPoint where - T: Scalar + Zero + One + ClosedAdd + ClosedSub + ClosedMul, + T: Scalar + Zero + One + ClosedAddAssign + ClosedSubAssign + ClosedMulAssign, { OPoint { coords: self.coords.lerp(&rhs.coords, t), diff --git a/src/geometry/point_construction.rs b/src/geometry/point_construction.rs index 3a498e744..db5f78701 100644 --- a/src/geometry/point_construction.rs +++ b/src/geometry/point_construction.rs @@ -15,7 +15,7 @@ use crate::{ Const, DimName, OPoint, OVector, Point1, Point2, Point3, Point4, Point5, Point6, Vector1, Vector2, Vector3, Vector4, Vector5, Vector6, }; -use simba::scalar::{ClosedDiv, SupersetOf}; +use simba::scalar::{ClosedDivAssign, SupersetOf}; use crate::geometry::Point; @@ -108,7 +108,7 @@ where #[inline] pub fn from_homogeneous(v: OVector>) -> Option where - T: Scalar + Zero + One + ClosedDiv, + T: Scalar + Zero + One + ClosedDivAssign, D: DimNameAdd, DefaultAllocator: Allocator>, { diff --git a/src/geometry/point_conversion.rs b/src/geometry/point_conversion.rs index b63f43c9b..ac723c6bf 100644 --- a/src/geometry/point_conversion.rs +++ b/src/geometry/point_conversion.rs @@ -1,5 +1,5 @@ use num::{One, Zero}; -use simba::scalar::{ClosedDiv, SubsetOf, SupersetOf}; +use simba::scalar::{ClosedDivAssign, SubsetOf, SupersetOf}; use simba::simd::PrimitiveSimdValue; use crate::base::allocator::Allocator; @@ -45,7 +45,7 @@ impl SubsetOf>> for OPoint where D: DimNameAdd, T1: Scalar, - T2: Scalar + Zero + One + ClosedDiv + SupersetOf, + T2: Scalar + Zero + One + ClosedDivAssign + SupersetOf, DefaultAllocator: Allocator + Allocator>, // + Allocator // + Allocator, diff --git a/src/geometry/point_ops.rs b/src/geometry/point_ops.rs index c0a9a40e5..08567fdd6 100644 --- a/src/geometry/point_ops.rs +++ b/src/geometry/point_ops.rs @@ -3,7 +3,9 @@ use std::ops::{ Add, AddAssign, Div, DivAssign, Index, IndexMut, Mul, MulAssign, Neg, Sub, SubAssign, }; -use simba::scalar::{ClosedAdd, ClosedDiv, ClosedMul, ClosedNeg, ClosedSub}; +use simba::scalar::{ + ClosedAddAssign, ClosedDivAssign, ClosedMulAssign, ClosedNeg, ClosedSubAssign, +}; use crate::base::constraint::{ AreMultipliable, SameNumberOfColumns, SameNumberOfRows, ShapeConstraint, @@ -79,32 +81,32 @@ where */ // Point - Point -add_sub_impl!(Sub, sub, ClosedSub; +add_sub_impl!(Sub, sub, ClosedSubAssign; (D, U1), (D, U1) -> (D, U1) 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; +add_sub_impl!(Sub, sub, ClosedSubAssign; (D, U1), (D, U1) -> (D, U1) 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; +add_sub_impl!(Sub, sub, ClosedSubAssign; (D, U1), (D, U1) -> (D, U1) 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; +add_sub_impl!(Sub, sub, ClosedSubAssign; (D, U1), (D, U1) -> (D, U1) const; for D; where D: DimName, DefaultAllocator: Allocator; self: OPoint, right: OPoint, Output = OVector; self.coords - right.coords; ); // Point - Vector -add_sub_impl!(Sub, sub, ClosedSub; +add_sub_impl!(Sub, sub, ClosedSubAssign; (D1, U1), (D2, U1) -> (D1, U1) const; for D1, D2, SB; @@ -112,7 +114,7 @@ add_sub_impl!(Sub, sub, ClosedSub; self: &'a OPoint, right: &'b Vector, Output = OPoint; Self::Output::from(&self.coords - right); 'a, 'b); -add_sub_impl!(Sub, sub, ClosedSub; +add_sub_impl!(Sub, sub, ClosedSubAssign; (D1, U1), (D2, U1) -> (D1, U1) const; for D1, D2, SB; @@ -120,7 +122,7 @@ add_sub_impl!(Sub, sub, ClosedSub; self: &'a OPoint, right: Vector, Output = OPoint; Self::Output::from(&self.coords - &right); 'a); // TODO: should not be a ref to `right`. -add_sub_impl!(Sub, sub, ClosedSub; +add_sub_impl!(Sub, sub, ClosedSubAssign; (D1, U1), (D2, U1) -> (D1, U1) const; for D1, D2, SB; @@ -128,7 +130,7 @@ add_sub_impl!(Sub, sub, ClosedSub; self: OPoint, right: &'b Vector, Output = OPoint; Self::Output::from(self.coords - right); 'b); -add_sub_impl!(Sub, sub, ClosedSub; +add_sub_impl!(Sub, sub, ClosedSubAssign; (D1, U1), (D2, U1) -> (D1, U1) const; for D1, D2, SB; @@ -137,7 +139,7 @@ add_sub_impl!(Sub, sub, ClosedSub; Self::Output::from(self.coords - right); ); // Point + Vector -add_sub_impl!(Add, add, ClosedAdd; +add_sub_impl!(Add, add, ClosedAddAssign; (D1, U1), (D2, U1) -> (D1, U1) const; for D1, D2, SB; @@ -145,7 +147,7 @@ add_sub_impl!(Add, add, ClosedAdd; self: &'a OPoint, right: &'b Vector, Output = OPoint; Self::Output::from(&self.coords + right); 'a, 'b); -add_sub_impl!(Add, add, ClosedAdd; +add_sub_impl!(Add, add, ClosedAddAssign; (D1, U1), (D2, U1) -> (D1, U1) const; for D1, D2, SB; @@ -153,7 +155,7 @@ add_sub_impl!(Add, add, ClosedAdd; self: &'a OPoint, right: Vector, Output = OPoint; Self::Output::from(&self.coords + &right); 'a); // TODO: should not be a ref to `right`. -add_sub_impl!(Add, add, ClosedAdd; +add_sub_impl!(Add, add, ClosedAddAssign; (D1, U1), (D2, U1) -> (D1, U1) const; for D1, D2, SB; @@ -161,7 +163,7 @@ add_sub_impl!(Add, add, ClosedAdd; self: OPoint, right: &'b Vector, Output = OPoint; Self::Output::from(self.coords + right); 'b); -add_sub_impl!(Add, add, ClosedAdd; +add_sub_impl!(Add, add, ClosedAddAssign; (D1, U1), (D2, U1) -> (D1, U1) const; for D1, D2, SB; @@ -199,8 +201,8 @@ macro_rules! op_assign_impl( ); op_assign_impl!( - AddAssign, add_assign, ClosedAdd; - SubAssign, sub_assign, ClosedSub; + AddAssign, add_assign, ClosedAddAssign; + SubAssign, sub_assign, ClosedSubAssign; ); /* @@ -263,8 +265,8 @@ macro_rules! componentwise_scalarop_impl( } ); -componentwise_scalarop_impl!(Mul, mul, ClosedMul; MulAssign, mul_assign); -componentwise_scalarop_impl!(Div, div, ClosedDiv; DivAssign, div_assign); +componentwise_scalarop_impl!(Mul, mul, ClosedMulAssign; MulAssign, mul_assign); +componentwise_scalarop_impl!(Div, div, ClosedDivAssign; DivAssign, div_assign); macro_rules! left_scalar_mul_impl( ($($T: ty),* $(,)*) => {$( diff --git a/src/geometry/point_simba.rs b/src/geometry/point_simba.rs index ad7433af7..8a62919d6 100644 --- a/src/geometry/point_simba.rs +++ b/src/geometry/point_simba.rs @@ -8,14 +8,10 @@ impl SimdValue for Point where T::Element: Scalar, { + const LANES: usize = T::LANES; type Element = Point; type SimdBool = T::SimdBool; - #[inline] - fn lanes() -> usize { - T::lanes() - } - #[inline] fn splat(val: Self::Element) -> Self { OVector::splat(val.coords).into() diff --git a/src/geometry/quaternion_simba.rs b/src/geometry/quaternion_simba.rs index 162d7a63a..3bfab80b1 100755 --- a/src/geometry/quaternion_simba.rs +++ b/src/geometry/quaternion_simba.rs @@ -8,14 +8,10 @@ impl SimdValue for Quaternion where T::Element: Scalar, { + const LANES: usize = T::LANES; type Element = Quaternion; type SimdBool = T::SimdBool; - #[inline] - fn lanes() -> usize { - T::lanes() - } - #[inline] fn splat(val: Self::Element) -> Self { Vector4::splat(val.coords).into() @@ -51,14 +47,10 @@ impl SimdValue for UnitQuaternion where T::Element: Scalar, { + const LANES: usize = T::LANES; type Element = UnitQuaternion; type SimdBool = T::SimdBool; - #[inline] - fn lanes() -> usize { - T::lanes() - } - #[inline] fn splat(val: Self::Element) -> Self { UnitQuaternion::new_unchecked(Quaternion::splat(val.into_inner())) diff --git a/src/geometry/rotation_construction.rs b/src/geometry/rotation_construction.rs index 84e42693d..7204c0d44 100644 --- a/src/geometry/rotation_construction.rs +++ b/src/geometry/rotation_construction.rs @@ -1,6 +1,6 @@ use num::{One, Zero}; -use simba::scalar::{ClosedAdd, ClosedMul, SupersetOf}; +use simba::scalar::{ClosedAddAssign, ClosedMulAssign, SupersetOf}; use crate::base::{SMatrix, Scalar}; @@ -64,7 +64,7 @@ impl Rotation { impl One for Rotation where - T: Scalar + Zero + One + ClosedAdd + ClosedMul, + T: Scalar + Zero + One + ClosedAddAssign + ClosedMulAssign, { #[inline] fn one() -> Self { diff --git a/src/geometry/rotation_ops.rs b/src/geometry/rotation_ops.rs index 213faa7dd..7471fc71c 100644 --- a/src/geometry/rotation_ops.rs +++ b/src/geometry/rotation_ops.rs @@ -20,7 +20,7 @@ use num::{One, Zero}; use std::ops::{Div, DivAssign, Index, Mul, MulAssign}; -use simba::scalar::{ClosedAdd, ClosedMul}; +use simba::scalar::{ClosedAddAssign, ClosedMulAssign}; use crate::base::allocator::Allocator; use crate::base::constraint::{AreMultipliable, ShapeConstraint}; diff --git a/src/geometry/rotation_simba.rs b/src/geometry/rotation_simba.rs index 39b60aa3f..7802f1d59 100755 --- a/src/geometry/rotation_simba.rs +++ b/src/geometry/rotation_simba.rs @@ -9,14 +9,10 @@ where T: Scalar + SimdValue, T::Element: Scalar, { + const LANES: usize = T::LANES; type Element = Rotation; type SimdBool = T::SimdBool; - #[inline] - fn lanes() -> usize { - T::lanes() - } - #[inline] fn splat(val: Self::Element) -> Self { Rotation::from_matrix_unchecked(OMatrix::splat(val.into_inner())) diff --git a/src/geometry/scale.rs b/src/geometry/scale.rs index 80725f135..10f1bb9bd 100644 --- a/src/geometry/scale.rs +++ b/src/geometry/scale.rs @@ -10,8 +10,8 @@ use crate::base::allocator::Allocator; use crate::base::dimension::{DimNameAdd, DimNameSum, U1}; use crate::base::storage::Owned; use crate::base::{Const, DefaultAllocator, OMatrix, OVector, SVector, Scalar}; -use crate::ClosedDiv; -use crate::ClosedMul; +use crate::ClosedDivAssign; +use crate::ClosedMulAssign; use crate::geometry::Point; @@ -121,7 +121,7 @@ impl Scale { #[must_use = "Did you mean to use try_inverse_mut()?"] pub fn try_inverse(&self) -> Option> where - T: ClosedDiv + One + Zero, + T: ClosedDivAssign + One + Zero, { for i in 0..D { if self.vector[i] == T::zero() { @@ -156,7 +156,7 @@ impl Scale { #[must_use] pub unsafe fn inverse_unchecked(&self) -> Scale where - T: ClosedDiv + One, + T: ClosedDivAssign + One, { self.vector.map(|e| T::one() / e).into() } @@ -184,7 +184,7 @@ impl Scale { #[must_use] pub fn pseudo_inverse(&self) -> Scale where - T: ClosedDiv + One + Zero, + T: ClosedDivAssign + One + Zero, { self.vector .map(|e| { @@ -260,7 +260,7 @@ impl Scale { #[inline] pub fn try_inverse_mut(&mut self) -> bool where - T: ClosedDiv + One + Zero, + T: ClosedDivAssign + One + Zero, { if let Some(v) = self.try_inverse() { self.vector = v.vector; @@ -271,7 +271,7 @@ impl Scale { } } -impl Scale { +impl Scale { /// Translate the given point. /// /// This is the same as the multiplication `self * pt`. @@ -290,7 +290,7 @@ impl Scale { } } -impl Scale { +impl Scale { /// Translate the given point by the inverse of this Scale. /// /// # Example diff --git a/src/geometry/scale_construction.rs b/src/geometry/scale_construction.rs index 02cce69cc..a7e1489c6 100644 --- a/src/geometry/scale_construction.rs +++ b/src/geometry/scale_construction.rs @@ -10,7 +10,7 @@ use rand::{ Rng, }; -use simba::scalar::{ClosedMul, SupersetOf}; +use simba::scalar::{ClosedMulAssign, SupersetOf}; use crate::base::{SVector, Scalar}; use crate::geometry::Scale; @@ -55,7 +55,7 @@ impl Scale { } } -impl One for Scale { +impl One for Scale { #[inline] fn one() -> Self { Self::identity() diff --git a/src/geometry/scale_ops.rs b/src/geometry/scale_ops.rs index b22f7b536..05354f4dd 100644 --- a/src/geometry/scale_ops.rs +++ b/src/geometry/scale_ops.rs @@ -1,6 +1,6 @@ use std::ops::{Mul, MulAssign}; -use simba::scalar::ClosedMul; +use simba::scalar::ClosedMulAssign; use crate::base::constraint::{SameNumberOfColumns, SameNumberOfRows, ShapeConstraint}; use crate::base::dimension::U1; @@ -9,117 +9,117 @@ use crate::base::{Const, SVector, Scalar}; use crate::geometry::{Point, Scale}; // Scale × Scale -add_sub_impl!(Mul, mul, ClosedMul; +add_sub_impl!(Mul, mul, ClosedMulAssign; (Const, U1), (Const, U1) -> (Const, U1) const D; for; where; self: &'a Scale, right: &'b Scale, Output = Scale; Scale::from(self.vector.component_mul(&right.vector)); 'a, 'b); -add_sub_impl!(Mul, mul, ClosedMul; +add_sub_impl!(Mul, mul, ClosedMulAssign; (Const, U1), (Const, U1) -> (Const, U1) const D; for; where; self: &'a Scale, right: Scale, Output = Scale; Scale::from(self.vector.component_mul(&right.vector)); 'a); -add_sub_impl!(Mul, mul, ClosedMul; +add_sub_impl!(Mul, mul, ClosedMulAssign; (Const, U1), (Const, U1) -> (Const, U1) const D; for; where; self: Scale, right: &'b Scale, Output = Scale; Scale::from(self.vector.component_mul(&right.vector)); 'b); -add_sub_impl!(Mul, mul, ClosedMul; +add_sub_impl!(Mul, mul, ClosedMulAssign; (Const, U1), (Const, U1) -> (Const, U1) const D; for; where; self: Scale, right: Scale, Output = Scale; Scale::from(self.vector.component_mul(&right.vector)); ); // Scale × scalar -add_sub_impl!(Mul, mul, ClosedMul; +add_sub_impl!(Mul, mul, ClosedMulAssign; (Const, U1), (Const, U1) -> (Const, U1) const D; for; where; self: &'a Scale, right: T, Output = Scale; Scale::from(&self.vector * right); 'a); -add_sub_impl!(Mul, mul, ClosedMul; +add_sub_impl!(Mul, mul, ClosedMulAssign; (Const, U1), (Const, U1) -> (Const, U1) const D; for; where; self: Scale, right: T, Output = Scale; Scale::from(self.vector * right); ); // Scale × Point -add_sub_impl!(Mul, mul, ClosedMul; +add_sub_impl!(Mul, mul, ClosedMulAssign; (Const, U1), (Const, U1) -> (Const, U1) const D; for; where; self: &'a Scale, right: &'b Point, Output = Point; Point::from(self.vector.component_mul(&right.coords)); 'a, 'b); -add_sub_impl!(Mul, mul, ClosedMul; +add_sub_impl!(Mul, mul, ClosedMulAssign; (Const, U1), (Const, U1) -> (Const, U1) const D; for; where; self: &'a Scale, right: Point, Output = Point; Point::from(self.vector.component_mul(&right.coords)); 'a); -add_sub_impl!(Mul, mul, ClosedMul; +add_sub_impl!(Mul, mul, ClosedMulAssign; (Const, U1), (Const, U1) -> (Const, U1) const D; for; where; self: Scale, right: &'b Point, Output = Point; Point::from(self.vector.component_mul(&right.coords)); 'b); -add_sub_impl!(Mul, mul, ClosedMul; +add_sub_impl!(Mul, mul, ClosedMulAssign; (Const, U1), (Const, U1) -> (Const, U1) const D; for; where; self: Scale, right: Point, Output = Point; Point::from(self.vector.component_mul(&right.coords)); ); // Scale * Vector -add_sub_impl!(Mul, mul, ClosedMul; +add_sub_impl!(Mul, mul, ClosedMulAssign; (Const, U1), (Const, U1) -> (Const, U1) const D; for; where; self: &'a Scale, right: &'b SVector, Output = SVector; self.vector.component_mul(right); 'a, 'b); -add_sub_impl!(Mul, mul, ClosedMul; +add_sub_impl!(Mul, mul, ClosedMulAssign; (Const, U1), (Const, U1) -> (Const, U1) const D; for; where; self: &'a Scale, right: SVector, Output = SVector; self.vector.component_mul(&right); 'a); -add_sub_impl!(Mul, mul, ClosedMul; +add_sub_impl!(Mul, mul, ClosedMulAssign; (Const, U1), (Const, U1) -> (Const, U1) const D; for; where; self: Scale, right: &'b SVector, Output = SVector; self.vector.component_mul(right); 'b); -add_sub_impl!(Mul, mul, ClosedMul; +add_sub_impl!(Mul, mul, ClosedMulAssign; (Const, U1), (Const, U1) -> (Const, U1) const D; for; where; self: Scale, right: SVector, Output = SVector; self.vector.component_mul(&right); ); // Scale *= Scale -add_sub_assign_impl!(MulAssign, mul_assign, ClosedMul; +add_sub_assign_impl!(MulAssign, mul_assign, ClosedMulAssign; const D; self: Scale, right: &'b Scale; self.vector.component_mul_assign(&right.vector); 'b); -add_sub_assign_impl!(MulAssign, mul_assign, ClosedMul; +add_sub_assign_impl!(MulAssign, mul_assign, ClosedMulAssign; const D; self: Scale, right: Scale; self.vector.component_mul_assign(&right.vector); ); // Scale ×= scalar -add_sub_assign_impl!(MulAssign, mul_assign, ClosedMul; +add_sub_assign_impl!(MulAssign, mul_assign, ClosedMulAssign; const D; self: Scale, right: T; self.vector *= right; ); diff --git a/src/geometry/scale_simba.rs b/src/geometry/scale_simba.rs index cb42b715d..8f15d20cb 100755 --- a/src/geometry/scale_simba.rs +++ b/src/geometry/scale_simba.rs @@ -9,14 +9,10 @@ impl SimdValue for Scale where T::Element: Scalar, { + const LANES: usize = T::LANES; type Element = Scale; type SimdBool = T::SimdBool; - #[inline] - fn lanes() -> usize { - T::lanes() - } - #[inline] fn splat(val: Self::Element) -> Self { OVector::splat(val.vector).into() diff --git a/src/geometry/similarity_ops.rs b/src/geometry/similarity_ops.rs index 0c8535b55..b87f17e26 100644 --- a/src/geometry/similarity_ops.rs +++ b/src/geometry/similarity_ops.rs @@ -4,7 +4,7 @@ use num::{One, Zero}; use std::ops::{Div, DivAssign, Mul, MulAssign}; -use simba::scalar::{ClosedAdd, ClosedMul}; +use simba::scalar::{ClosedAddAssign, ClosedMulAssign}; use simba::simd::SimdRealField; use crate::base::{SVector, Scalar}; diff --git a/src/geometry/similarity_simba.rs b/src/geometry/similarity_simba.rs index e4de581d3..dec746cf3 100755 --- a/src/geometry/similarity_simba.rs +++ b/src/geometry/similarity_simba.rs @@ -8,14 +8,10 @@ where R: SimdValue + AbstractRotation, R::Element: AbstractRotation, { + const LANES: usize = T::LANES; type Element = Similarity; type SimdBool = T::SimdBool; - #[inline] - fn lanes() -> usize { - T::lanes() - } - #[inline] fn splat(val: Self::Element) -> Self { let scaling = T::splat(val.scaling()); diff --git a/src/geometry/transform_ops.rs b/src/geometry/transform_ops.rs index acc368cae..a04571e63 100644 --- a/src/geometry/transform_ops.rs +++ b/src/geometry/transform_ops.rs @@ -4,7 +4,7 @@ use num::{One, Zero}; use std::ops::{Div, DivAssign, Index, IndexMut, Mul, MulAssign}; -use simba::scalar::{ClosedAdd, ClosedMul, RealField, SubsetOf}; +use simba::scalar::{ClosedAddAssign, ClosedMulAssign, RealField, SubsetOf}; use crate::base::allocator::Allocator; use crate::base::dimension::{DimNameAdd, DimNameSum, U1}; diff --git a/src/geometry/transform_simba.rs b/src/geometry/transform_simba.rs index 093724831..5d66d1d36 100755 --- a/src/geometry/transform_simba.rs +++ b/src/geometry/transform_simba.rs @@ -14,14 +14,10 @@ where Const: DimNameAdd, DefaultAllocator: Allocator, U1>, DimNameSum, U1>>, { + const LANES: usize = T::LANES; type Element = Transform; type SimdBool = T::SimdBool; - #[inline] - fn lanes() -> usize { - T::lanes() - } - #[inline] fn splat(val: Self::Element) -> Self { Transform::from_matrix_unchecked(OMatrix::splat(val.into_inner())) diff --git a/src/geometry/translation.rs b/src/geometry/translation.rs index 5e04f3761..074a551aa 100644 --- a/src/geometry/translation.rs +++ b/src/geometry/translation.rs @@ -6,7 +6,7 @@ use std::hash; #[cfg(feature = "serde-serialize-no-std")] use serde::{Deserialize, Deserializer, Serialize, Serializer}; -use simba::scalar::{ClosedAdd, ClosedNeg, ClosedSub}; +use simba::scalar::{ClosedAddAssign, ClosedNeg, ClosedSubAssign}; use crate::base::allocator::Allocator; use crate::base::dimension::{DimNameAdd, DimNameSum, U1}; @@ -188,7 +188,7 @@ impl Translation { } } -impl Translation { +impl Translation { /// Translate the given point. /// /// This is the same as the multiplication `self * pt`. @@ -207,7 +207,7 @@ impl Translation { } } -impl Translation { +impl Translation { /// Translate the given point by the inverse of this translation. /// /// # Example diff --git a/src/geometry/translation_construction.rs b/src/geometry/translation_construction.rs index 128937bfd..1c9941427 100644 --- a/src/geometry/translation_construction.rs +++ b/src/geometry/translation_construction.rs @@ -10,7 +10,7 @@ use rand::{ Rng, }; -use simba::scalar::{ClosedAdd, SupersetOf}; +use simba::scalar::{ClosedAddAssign, SupersetOf}; use crate::base::{SVector, Scalar}; use crate::geometry::Translation; @@ -61,7 +61,7 @@ impl Translation { } } -impl One for Translation { +impl One for Translation { #[inline] fn one() -> Self { Self::identity() diff --git a/src/geometry/translation_ops.rs b/src/geometry/translation_ops.rs index 8851183a7..4d133c06b 100644 --- a/src/geometry/translation_ops.rs +++ b/src/geometry/translation_ops.rs @@ -1,6 +1,6 @@ use std::ops::{Div, DivAssign, Mul, MulAssign}; -use simba::scalar::{ClosedAdd, ClosedSub}; +use simba::scalar::{ClosedAddAssign, ClosedSubAssign}; use crate::base::constraint::{SameNumberOfColumns, SameNumberOfRows, ShapeConstraint}; use crate::base::dimension::U1; @@ -9,28 +9,28 @@ use crate::base::{Const, Scalar}; use crate::geometry::{Point, Translation}; // Translation × Translation -add_sub_impl!(Mul, mul, ClosedAdd; +add_sub_impl!(Mul, mul, ClosedAddAssign; (Const, U1), (Const, U1) -> (Const, U1) const D; for; where; self: &'a Translation, right: &'b Translation, Output = Translation; #[allow(clippy::suspicious_arithmetic_impl)] { Translation::from(&self.vector + &right.vector) }; 'a, 'b); -add_sub_impl!(Mul, mul, ClosedAdd; +add_sub_impl!(Mul, mul, ClosedAddAssign; (Const, U1), (Const, U1) -> (Const, U1) const D; for; where; self: &'a Translation, right: Translation, Output = Translation; #[allow(clippy::suspicious_arithmetic_impl)] { Translation::from(&self.vector + right.vector) }; 'a); -add_sub_impl!(Mul, mul, ClosedAdd; +add_sub_impl!(Mul, mul, ClosedAddAssign; (Const, U1), (Const, U1) -> (Const, U1) const D; for; where; self: Translation, right: &'b Translation, Output = Translation; #[allow(clippy::suspicious_arithmetic_impl)] { Translation::from(self.vector + &right.vector) }; 'b); -add_sub_impl!(Mul, mul, ClosedAdd; +add_sub_impl!(Mul, mul, ClosedAddAssign; (Const, U1), (Const, U1) -> (Const, U1) const D; for; where; self: Translation, right: Translation, Output = Translation; @@ -38,28 +38,28 @@ add_sub_impl!(Mul, mul, ClosedAdd; // Translation ÷ Translation // TODO: instead of calling inverse explicitly, could we just add a `mul_tr` or `mul_inv` method? -add_sub_impl!(Div, div, ClosedSub; +add_sub_impl!(Div, div, ClosedSubAssign; (Const, U1), (Const, U1) -> (Const, U1) const D; for; where; self: &'a Translation, right: &'b Translation, Output = Translation; #[allow(clippy::suspicious_arithmetic_impl)] { Translation::from(&self.vector - &right.vector) }; 'a, 'b); -add_sub_impl!(Div, div, ClosedSub; +add_sub_impl!(Div, div, ClosedSubAssign; (Const, U1), (Const, U1) -> (Const, U1) const D; for; where; self: &'a Translation, right: Translation, Output = Translation; #[allow(clippy::suspicious_arithmetic_impl)] { Translation::from(&self.vector - right.vector) }; 'a); -add_sub_impl!(Div, div, ClosedSub; +add_sub_impl!(Div, div, ClosedSubAssign; (Const, U1), (Const, U1) -> (Const, U1) const D; for; where; self: Translation, right: &'b Translation, Output = Translation; #[allow(clippy::suspicious_arithmetic_impl)] { Translation::from(self.vector - &right.vector) }; 'b); -add_sub_impl!(Div, div, ClosedSub; +add_sub_impl!(Div, div, ClosedSubAssign; (Const, U1), (Const, U1) -> (Const, U1) const D; for; where; self: Translation, right: Translation, Output = Translation; @@ -68,52 +68,52 @@ add_sub_impl!(Div, div, ClosedSub; // Translation × Point // TODO: we don't handle properly non-zero origins here. Do we want this to be the intended // behavior? -add_sub_impl!(Mul, mul, ClosedAdd; +add_sub_impl!(Mul, mul, ClosedAddAssign; (Const, U1), (Const, U1) -> (Const, U1) const D; for; where; self: &'a Translation, right: &'b Point, Output = Point; #[allow(clippy::suspicious_arithmetic_impl)] { right + &self.vector }; 'a, 'b); -add_sub_impl!(Mul, mul, ClosedAdd; +add_sub_impl!(Mul, mul, ClosedAddAssign; (Const, U1), (Const, U1) -> (Const, U1) const D; for; where; self: &'a Translation, right: Point, Output = Point; #[allow(clippy::suspicious_arithmetic_impl)] { right + &self.vector }; 'a); -add_sub_impl!(Mul, mul, ClosedAdd; +add_sub_impl!(Mul, mul, ClosedAddAssign; (Const, U1), (Const, U1) -> (Const, U1) const D; for; where; self: Translation, right: &'b Point, Output = Point; #[allow(clippy::suspicious_arithmetic_impl)] { right + self.vector }; 'b); -add_sub_impl!(Mul, mul, ClosedAdd; +add_sub_impl!(Mul, mul, ClosedAddAssign; (Const, U1), (Const, U1) -> (Const, U1) const D; for; where; self: Translation, right: Point, Output = Point; #[allow(clippy::suspicious_arithmetic_impl)] { right + self.vector }; ); // Translation *= Translation -add_sub_assign_impl!(MulAssign, mul_assign, ClosedAdd; +add_sub_assign_impl!(MulAssign, mul_assign, ClosedAddAssign; const D; self: Translation, right: &'b Translation; #[allow(clippy::suspicious_op_assign_impl)] { self.vector += &right.vector }; 'b); -add_sub_assign_impl!(MulAssign, mul_assign, ClosedAdd; +add_sub_assign_impl!(MulAssign, mul_assign, ClosedAddAssign; const D; self: Translation, right: Translation; #[allow(clippy::suspicious_op_assign_impl)] { self.vector += right.vector }; ); -add_sub_assign_impl!(DivAssign, div_assign, ClosedSub; +add_sub_assign_impl!(DivAssign, div_assign, ClosedSubAssign; const D; self: Translation, right: &'b Translation; #[allow(clippy::suspicious_op_assign_impl)] { self.vector -= &right.vector }; 'b); -add_sub_assign_impl!(DivAssign, div_assign, ClosedSub; +add_sub_assign_impl!(DivAssign, div_assign, ClosedSubAssign; const D; self: Translation, right: Translation; #[allow(clippy::suspicious_op_assign_impl)] { self.vector -= right.vector }; ); diff --git a/src/geometry/translation_simba.rs b/src/geometry/translation_simba.rs index 7f7f7ebf5..a4df7799b 100755 --- a/src/geometry/translation_simba.rs +++ b/src/geometry/translation_simba.rs @@ -9,14 +9,10 @@ impl SimdValue for Translation where T::Element: Scalar, { + const LANES: usize = T::LANES; type Element = Translation; type SimdBool = T::SimdBool; - #[inline] - fn lanes() -> usize { - T::lanes() - } - #[inline] fn splat(val: Self::Element) -> Self { OVector::splat(val.vector).into() diff --git a/src/geometry/unit_complex_simba.rs b/src/geometry/unit_complex_simba.rs index 156cd63ac..14d89ec57 100755 --- a/src/geometry/unit_complex_simba.rs +++ b/src/geometry/unit_complex_simba.rs @@ -10,14 +10,10 @@ impl SimdValue for UnitComplex where T::Element: SimdRealField, { + const LANES: usize = T::LANES; type Element = UnitComplex; type SimdBool = T::SimdBool; - #[inline] - fn lanes() -> usize { - T::lanes() - } - #[inline] fn splat(val: Self::Element) -> Self { Unit::new_unchecked(Complex::splat(val.into_inner())) diff --git a/src/lib.rs b/src/lib.rs index 48662e87c..dac098272 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -165,7 +165,8 @@ use num::{One, Signed, Zero}; use base::allocator::Allocator; pub use num_complex::Complex; pub use simba::scalar::{ - ClosedAdd, ClosedDiv, ClosedMul, ClosedSub, ComplexField, Field, RealField, + ClosedAddAssign, ClosedDivAssign, ClosedMulAssign, ClosedSubAssign, ComplexField, Field, + RealField, }; pub use simba::simd::{SimdBool, SimdComplexField, SimdPartialOrd, SimdRealField, SimdValue}; @@ -206,7 +207,7 @@ pub fn zero() -> T { #[inline] pub fn wrap(mut val: T, min: T, max: T) -> T where - T: Copy + PartialOrd + ClosedAdd + ClosedSub, + T: Copy + PartialOrd + ClosedAddAssign + ClosedSubAssign, { assert!(min < max, "Invalid wrapping bounds."); let width = max - min; diff --git a/src/linalg/exp.rs b/src/linalg/exp.rs index 1560297c6..afd906f40 100644 --- a/src/linalg/exp.rs +++ b/src/linalg/exp.rs @@ -430,7 +430,7 @@ where let abs_c_recip = choose_2m_m * factorial(2 * m + 1); let alpha = a_abs_onenorm / one_norm(a); - let alpha: f64 = try_convert(alpha).unwrap() / abs_c_recip as f64; + let alpha: f64 = try_convert::<_, f64>(alpha).unwrap() / abs_c_recip as f64; let u = 2_f64.powf(-53.0); let log2_alpha_div_u = (alpha / u).log2(); @@ -523,7 +523,7 @@ where let mut s = if eta_5 == T::RealField::zero() { 0 } else { - let l2 = try_convert((eta_5 / theta_13).log2().ceil()).unwrap(); + let l2 = try_convert::<_, f64>((eta_5 / theta_13).log2().ceil()).unwrap(); if l2 < 0.0 { 0 diff --git a/src/linalg/mod.rs b/src/linalg/mod.rs index 0209f9b16..ac1cbb9b2 100644 --- a/src/linalg/mod.rs +++ b/src/linalg/mod.rs @@ -37,14 +37,10 @@ mod udu; pub use self::bidiagonal::*; pub use self::cholesky::*; pub use self::col_piv_qr::*; -pub use self::convolution::*; -#[cfg(feature = "std")] -pub use self::exp::*; pub use self::full_piv_lu::*; pub use self::hessenberg::*; pub use self::lu::*; pub use self::permutation_sequence::*; -pub use self::pow::*; pub use self::qr::*; pub use self::schur::*; pub use self::svd::*; diff --git a/src/linalg/pow.rs b/src/linalg/pow.rs index 9d5673ee1..c6ff74aed 100644 --- a/src/linalg/pow.rs +++ b/src/linalg/pow.rs @@ -6,11 +6,11 @@ use crate::{ DefaultAllocator, DimMin, Matrix, OMatrix, Scalar, }; use num::{One, Zero}; -use simba::scalar::{ClosedAdd, ClosedMul}; +use simba::scalar::{ClosedAddAssign, ClosedMulAssign}; impl Matrix where - T: Scalar + Zero + One + ClosedAdd + ClosedMul, + T: Scalar + Zero + One + ClosedAddAssign + ClosedMulAssign, D: DimMin, S: StorageMut, DefaultAllocator: Allocator + Allocator, @@ -56,7 +56,7 @@ where impl> Matrix where - T: Scalar + Zero + One + ClosedAdd + ClosedMul, + T: Scalar + Zero + One + ClosedAddAssign + ClosedMulAssign, D: DimMin, S: StorageMut, DefaultAllocator: Allocator + Allocator, diff --git a/src/sparse/cs_matrix.rs b/src/sparse/cs_matrix.rs index 1240d5c1f..1c00c10b5 100644 --- a/src/sparse/cs_matrix.rs +++ b/src/sparse/cs_matrix.rs @@ -1,5 +1,5 @@ use num::Zero; -use simba::scalar::ClosedAdd; +use simba::scalar::ClosedAddAssign; use std::iter; use std::marker::PhantomData; use std::ops::Range; @@ -294,7 +294,7 @@ where vals: Vec, ) -> Self where - T: Zero + ClosedAdd, + T: Zero + ClosedAddAssign, DefaultAllocator: Allocator, { assert_eq!(ncols.value(), p.len(), "Invalid inptr size."); @@ -333,7 +333,7 @@ where } /* -impl CsMatrix { +impl CsMatrix { pub(crate) fn from_parts( nrows: usize, ncols: usize, @@ -501,7 +501,7 @@ where // Remove duplicate entries on a sorted CsMatrix. pub(crate) fn dedup(&mut self) where - T: Zero + ClosedAdd, + T: Zero + ClosedAddAssign, { let mut curr_i = 0; diff --git a/src/sparse/cs_matrix_conversion.rs b/src/sparse/cs_matrix_conversion.rs index e17925f95..21c950bdb 100644 --- a/src/sparse/cs_matrix_conversion.rs +++ b/src/sparse/cs_matrix_conversion.rs @@ -1,5 +1,5 @@ use num::Zero; -use simba::scalar::ClosedAdd; +use simba::scalar::ClosedAddAssign; use crate::allocator::Allocator; use crate::sparse::cs_utils; @@ -7,7 +7,7 @@ use crate::sparse::{CsMatrix, CsStorage}; use crate::storage::Storage; use crate::{DefaultAllocator, Dim, Dyn, Matrix, OMatrix, Scalar}; -impl<'a, T: Scalar + Zero + ClosedAdd> CsMatrix { +impl<'a, T: Scalar + Zero + ClosedAddAssign> CsMatrix { /// Creates a column-compressed sparse matrix from a sparse matrix in triplet form. pub fn from_triplet( nrows: usize, @@ -20,7 +20,7 @@ impl<'a, T: Scalar + Zero + ClosedAdd> CsMatrix { } } -impl<'a, T: Scalar + Zero + ClosedAdd, R: Dim, C: Dim> CsMatrix +impl<'a, T: Scalar + Zero + ClosedAddAssign, R: Dim, C: Dim> CsMatrix where DefaultAllocator: Allocator + Allocator, { diff --git a/src/sparse/cs_matrix_ops.rs b/src/sparse/cs_matrix_ops.rs index b1192f867..b54f0454f 100644 --- a/src/sparse/cs_matrix_ops.rs +++ b/src/sparse/cs_matrix_ops.rs @@ -1,5 +1,5 @@ use num::{One, Zero}; -use simba::scalar::{ClosedAdd, ClosedMul}; +use simba::scalar::{ClosedAddAssign, ClosedMulAssign}; use std::ops::{Add, Mul}; use crate::allocator::Allocator; @@ -20,7 +20,7 @@ impl> CsMatrix { res: &mut CsMatrix, ) -> usize where - T: ClosedAdd + ClosedMul, + T: ClosedAddAssign + ClosedMulAssign, DefaultAllocator: Allocator, { for (i, val) in self.data.column_entries(j) { @@ -76,7 +76,9 @@ impl CsVector { } */ -impl> Vector { +impl> + Vector +{ /// Perform a sparse axpy operation: `self = alpha * x + beta * self` operation. pub fn axpy_cs(&mut self, alpha: T, x: &CsVector, beta: T) where @@ -126,7 +128,7 @@ impl> Vect impl<'a, 'b, T, R1, R2, C1, C2, S1, S2> Mul<&'b CsMatrix> for &'a CsMatrix where - T: Scalar + ClosedAdd + ClosedMul + Zero, + T: Scalar + ClosedAddAssign + ClosedMulAssign + Zero, R1: Dim, C1: Dim, R2: Dim, @@ -219,7 +221,7 @@ where impl<'a, 'b, T, R1, R2, C1, C2, S1, S2> Add<&'b CsMatrix> for &'a CsMatrix where - T: Scalar + ClosedAdd + ClosedMul + Zero + One, + T: Scalar + ClosedAddAssign + ClosedMulAssign + Zero + One, R1: Dim, C1: Dim, R2: Dim, @@ -287,7 +289,7 @@ where impl<'a, 'b, T, R, C, S> Mul for CsMatrix where - T: Scalar + ClosedAdd + ClosedMul + Zero, + T: Scalar + ClosedAddAssign + ClosedMulAssign + Zero, R: Dim, C: Dim, S: CsStorageMut,