Simplify nalgebra trait bounds further dev

Fri, 05 Sep 2025 01:09:21 -0500

author
Tuomo Valkonen <tuomov@iki.fi>
date
Fri, 05 Sep 2025 01:09:21 -0500
branch
dev
changeset 181
f159287bc191
parent 180
ec5a811eab09
child 182
71fa6d3df947

Simplify nalgebra trait bounds further

src/nalgebra_support.rs file | annotate | diff | comparison | revisions
--- a/src/nalgebra_support.rs	Fri Sep 05 01:02:53 2025 -0500
+++ b/src/nalgebra_support.rs	Fri Sep 05 01:09:21 2025 -0500
@@ -18,10 +18,10 @@
 use nalgebra::base::dimension::*;
 use nalgebra::{
     ArrayStorage, ClosedAddAssign, ClosedMulAssign, DefaultAllocator, Dim, LpNorm, Matrix,
-    MatrixView, OMatrix, OVector, RawStorage, RealField, Scalar, SimdComplexField, Storage,
-    StorageMut, UniformNorm, VecStorage, Vector, ViewStorage, ViewStorageMut, U1,
+    MatrixView, OMatrix, OVector, RawStorage, RealField, SimdComplexField, Storage, StorageMut,
+    UniformNorm, VecStorage, Vector, ViewStorage, ViewStorageMut, U1,
 };
-use num_traits::identities::{One, Zero};
+use num_traits::identities::Zero;
 use std::ops::Mul;
 
 impl<S, M, N, E> Ownable for Matrix<E, M, N, S>
@@ -29,7 +29,7 @@
     S: Storage<E, M, N>,
     M: Dim,
     N: Dim,
-    E: Scalar + Zero + One,
+    E: Float,
     DefaultAllocator: Allocator<M, N>,
 {
     type OwnedVariant = OMatrix<E, M, N>;
@@ -63,7 +63,7 @@
     DimEq<Dyn, S::RStride> + DimEq<Dyn, S::CStride>
 where
     S: RawStorage<E, N, M>,
-    E: Scalar,
+    E: Float,
     N: Dim,
     M: Dim,
     DefaultAllocator: Allocator<N, M>,
@@ -73,7 +73,7 @@
 impl<E, M> StridesOk<E, Dyn, M, VecStorage<E, Dyn, M>> for ShapeConstraint
 where
     M: Dim,
-    E: Scalar,
+    E: Float,
     DefaultAllocator: Allocator<Dyn, M>,
 {
 }
@@ -81,7 +81,7 @@
 impl<E, const N: usize, const M: usize> StridesOk<E, Const<N>, Const<M>, ArrayStorage<E, N, M>>
     for ShapeConstraint
 where
-    E: Scalar,
+    E: Float,
 {
 }
 
@@ -91,16 +91,16 @@
         where
             N: Dim,
             M: Dim,
-            E: Scalar,
-             DefaultAllocator: Allocator<N, M>,
+            E: Float,
+            DefaultAllocator: Allocator<N, M>,
         {
         }
         impl<'a, E, N, M, $($qual)*> StridesOk<E, N, M, ViewStorageMut<'a, E, N, M, $R, $C>> for ShapeConstraint
         where
             N: Dim,
             M: Dim,
-            E: Scalar,
-             DefaultAllocator: Allocator<N, M>,
+            E: Float,
+            DefaultAllocator: Allocator<N, M>,
         {
         }
     };
@@ -116,7 +116,7 @@
     SM: Storage<E, N, M>,
     N: Dim,
     M: Dim,
-    E: Scalar + Zero + One + Copy,
+    E: Float,
     DefaultAllocator: Allocator<N, M>,
     ShapeConstraint: StridesOk<E, N, M>,
 {
@@ -132,7 +132,7 @@
     S: Storage<E, M, K>,
     M: Dim,
     K: Dim,
-    E: Scalar + Zero + One + Copy,
+    E: Float,
     DefaultAllocator: Allocator<M, K>,
     ShapeConstraint: StridesOk<E, M, K>,
 {
@@ -160,7 +160,7 @@
     S2: Storage<E, M, K>,
     M: Dim,
     K: Dim,
-    E: Scalar + Zero + One + Copy,
+    E: Float,
     DefaultAllocator: Allocator<M, K>,
     ShapeConstraint: StridesOk<E, M, K, S2> + StridesOk<E, M, K>,
 {
@@ -205,7 +205,7 @@
     S2: Storage<E, M, K>,
     M: Dim,
     K: Dim,
-    E: Scalar + Zero + One + Copy,
+    E: Float,
     DefaultAllocator: Allocator<M, K>,
     ShapeConstraint: StridesOk<E, M, K, S2> + StridesOk<E, M, K>,
 {
@@ -249,7 +249,7 @@
     SM: Storage<E, M, K>,
     M: Dim,
     K: Dim,
-    E: Scalar + Zero + One + Copy,
+    E: Float,
     DefaultAllocator: Allocator<M, K>,
     ShapeConstraint: StridesOk<E, M, K, SM> + StridesOk<E, M, K>,
 {
@@ -293,7 +293,7 @@
     N: Dim,
     M: Dim,
     K: Dim,
-    E: Scalar + Zero + One + Copy + ClosedMulAssign + ClosedAddAssign,
+    E: Float,
     DefaultAllocator: Allocator<M, K> + Allocator<N, K>,
     ShapeConstraint: StridesOk<E, M, K> + StridesOk<E, N, K>,
 {
@@ -311,7 +311,7 @@
     N: Dim,
     M: Dim,
     K: Dim,
-    E: Scalar + Zero + One + Copy + ClosedMulAssign + ClosedAddAssign,
+    E: Float + ClosedMulAssign + ClosedAddAssign,
     DefaultAllocator: Allocator<N, K> + Allocator<M, K>,
     ShapeConstraint: StridesOk<E, M, K> + StridesOk<E, N, K>,
 {
@@ -324,7 +324,7 @@
     N: Dim,
     M: Dim,
     K: Dim,
-    E: Scalar + Zero + One + Float,
+    E: Float,
     DefaultAllocator: Allocator<N, K> + Allocator<M, K>,
     ShapeConstraint: StridesOk<E, M, K> + StridesOk<E, N, K>,
 {
@@ -346,7 +346,7 @@
     S: Storage<E, M, N>,
     M: Dim,
     N: Dim,
-    E: Scalar + Zero + One + Float,
+    E: Float,
     DefaultAllocator: Allocator<M, N>,
     ShapeConstraint: StridesOk<E, M, N>,
 {
@@ -367,7 +367,7 @@
     S: StorageMut<E, M, N>,
     M: Dim,
     N: Dim,
-    E: Scalar + Zero + One + Float,
+    E: Float,
     DefaultAllocator: Allocator<M, N>,
     ShapeConstraint: StridesOk<E, M, N>,
 {
@@ -412,7 +412,7 @@
 where
     SM: StorageMut<E, M>,
     M: Dim,
-    E: Scalar + Zero + One + Float + RealField,
+    E: Float + RealField,
     DefaultAllocator: Allocator<M>,
     ShapeConstraint: StridesOk<E, M>,
 {
@@ -428,7 +428,7 @@
 where
     SM: StorageMut<E, M>,
     M: Dim,
-    E: Scalar + Zero + One + Copy + Float + RealField,
+    E: Float + RealField,
     DefaultAllocator: Allocator<M>,
     ShapeConstraint: StridesOk<E, M>,
 {
@@ -445,7 +445,7 @@
     N: Dim,
     M: Dim,
     K: Dim,
-    E: Scalar + Zero + One + Copy + SimdComplexField,
+    E: Float + RealField,
     DefaultAllocator: Allocator<N, K> + Allocator<M, K> + Allocator<M, N>,
     ShapeConstraint: StridesOk<E, N, K> + StridesOk<E, M, K>,
 {
@@ -489,7 +489,7 @@
     M: Dim,
     N: Dim,
     S: Storage<E, M, N>,
-    E: Float + Scalar + Zero + One + RealField,
+    E: Float + RealField,
     DefaultAllocator: Allocator<M, N>,
     ShapeConstraint: StridesOk<E, M, N>,
 {
@@ -515,7 +515,7 @@
 where
     M: DimName,
     S: Storage<E, M>,
-    E: Float + Scalar + Zero + One + RealField,
+    E: Float + RealField,
     DefaultAllocator: Allocator<M>,
     ShapeConstraint: StridesOk<E, M>,
 {
@@ -531,7 +531,7 @@
     M: Dim,
     N: Dim,
     S: Storage<E, M, N>,
-    E: Float + Scalar + Zero + One + RealField,
+    E: Float + RealField,
     DefaultAllocator: Allocator<M, N>,
     ShapeConstraint: StridesOk<E, M, N>,
 {
@@ -553,7 +553,7 @@
     M: Dim,
     N: Dim,
     S: Storage<E, M, N>,
-    E: Float + Scalar + Zero + One + RealField,
+    E: Float + RealField,
     DefaultAllocator: Allocator<M, N>,
     ShapeConstraint: StridesOk<E, M, N>,
 {
@@ -569,7 +569,7 @@
 where
     M: Dim,
     S: Storage<E, M>,
-    E: Float + Scalar + Zero + One + RealField,
+    E: Float + RealField,
 {
     #[inline]
     fn norm(&self, _: L1) -> E {
@@ -581,7 +581,7 @@
 where
     M: Dim,
     S: Storage<E, M>,
-    E: Float + Scalar + Zero + One + RealField,
+    E: Float + RealField,
     DefaultAllocator: Allocator<M>,
     ShapeConstraint: StridesOk<E, M>,
 {
@@ -596,7 +596,7 @@
     M: Dim,
     N: Dim,
     S: Storage<E, M, N>,
-    E: Float + Scalar + Zero + One + RealField,
+    E: Float + RealField,
 {
     #[inline]
     fn norm(&self, _: L2) -> E {
@@ -609,7 +609,7 @@
     M: Dim,
     N: Dim,
     S: Storage<E, M, N>,
-    E: Float + Scalar + Zero + One + RealField,
+    E: Float + RealField,
     DefaultAllocator: Allocator<M, N>,
     ShapeConstraint: StridesOk<E, M, N>,
 {
@@ -624,7 +624,7 @@
     M: Dim,
     N: Dim,
     S: Storage<E, M, N>,
-    E: Float + Scalar + Zero + One + RealField,
+    E: Float + RealField,
 {
     #[inline]
     fn norm(&self, _: Linfinity) -> E {
@@ -637,7 +637,7 @@
     M: Dim,
     N: Dim,
     S: Storage<E, M, N>,
-    E: Float + Scalar + Zero + One + RealField,
+    E: Float + RealField,
     DefaultAllocator: Allocator<M, N>,
     ShapeConstraint: StridesOk<E, M, N>,
 {

mercurial