diff -r edb95d2b83cc -r d2acaaddd9af src/nalgebra_support.rs --- a/src/nalgebra_support.rs Sun Nov 10 09:02:57 2024 -0500 +++ b/src/nalgebra_support.rs Tue Dec 31 09:12:43 2024 -0500 @@ -56,9 +56,9 @@ } } -impl<'a, SM,SV,N,M,K,E> Linear> for Matrix +impl Linear> for Matrix where SM: Storage, SV: Storage, - N : Dim, M : Dim, K : Dim, E : Scalar + ClosedMul + ClosedAdd + Zero + One, + N : Dim, M : Dim, K : Dim, E : Float + Scalar + ClosedMul + ClosedAdd + Zero + One, DefaultAllocator : Allocator, DefaultAllocator : Allocator, DefaultAllocator : Allocator, @@ -75,12 +75,31 @@ DefaultAllocator : Allocator { #[inline] - fn gemv(&self, y : &mut Matrix, α : E, x : &Matrix, β : E) { + fn gemv(&self, y : &mut Matrix, α : E, x : Matrix, β : E) { + Matrix::gemm(y, α, self, &x, β) + } + + #[inline] + fn apply_mut(&self, y : &mut Matrix, x : Matrix) { + self.mul_to(&x, y) + } +} + +impl<'a, SM,SV1,SV2,N,M,K,E> GEMV, Matrix> for Matrix +where SM: Storage, SV1: Storage, SV2: StorageMut, + N : Dim, M : Dim, K : Dim, E : Scalar + ClosedMul + ClosedAdd + Zero + One + Float, + DefaultAllocator : Allocator, + DefaultAllocator : Allocator, + DefaultAllocator : Allocator, + DefaultAllocator : Allocator { + + #[inline] + fn gemv(&self, y : &mut Matrix, α : E, x : &'a Matrix, β : E) { Matrix::gemm(y, α, self, x, β) } #[inline] - fn apply_mut<'a>(&self, y : &mut Matrix, x : &Matrix) { + fn apply_mut(&self, y : &mut Matrix, x : &'a Matrix) { self.mul_to(x, y) } } @@ -91,17 +110,33 @@ DefaultAllocator : Allocator { #[inline] - fn axpy(&mut self, α : E, x : &Vector, β : E) { + fn axpy(&mut self, α : E, x : Vector, β : E) { + Matrix::axpy(self, α, &x, β) + } + + #[inline] + fn copy_from(&mut self, y : Vector) { + Matrix::copy_from(self, &y) + } +} + +impl<'a, SM,SV1,M,E> AXPY> for Vector +where SM: StorageMut, SV1: Storage, + M : Dim, E : Scalar + ClosedMul + ClosedAdd + Zero + One + Float, + DefaultAllocator : Allocator { + + #[inline] + fn axpy(&mut self, α : E, x : &'a Vector, β : E) { Matrix::axpy(self, α, x, β) } #[inline] - fn copy_from(&mut self, y : &Vector) { + fn copy_from(&mut self, y : &'a Vector) { Matrix::copy_from(self, y) } } -impl Projection for Vector +impl Projection for Vector where SM: StorageMut, M : Dim, E : Scalar + ClosedMul + ClosedAdd + Zero + One + Float + RealField, DefaultAllocator : Allocator { @@ -114,7 +149,8 @@ impl<'own,SV1,SV2,SM,N,M,K,E> Adjointable,Matrix> for Matrix where SM: Storage, SV1: Storage, SV2: Storage, - N : Dim, M : Dim, K : Dim, E : Scalar + ClosedMul + ClosedAdd + Zero + One + SimdComplexField, + N : Dim, M : Dim, K : Dim, + E : Float + Scalar + ClosedMul + ClosedAdd + Zero + One + SimdComplexField, DefaultAllocator : Allocator, DefaultAllocator : Allocator, DefaultAllocator : Allocator, @@ -128,7 +164,7 @@ } } -impl Dot,E> +impl Dot> for Vector where M : Dim, E : Float + Scalar + ClosedMul + ClosedAdd + Zero + One, @@ -137,7 +173,21 @@ DefaultAllocator : Allocator { #[inline] - fn dot(&self, other : &Vector) -> E { + fn dot(&self, other : Vector) -> E { + Vector::::dot(self, &other) + } +} + +impl<'a, E,M,S,Si> Dot<&'a Vector> +for Vector +where M : Dim, + E : Float + Scalar + ClosedMul + ClosedAdd + Zero + One, + S : Storage, + Si : Storage, + DefaultAllocator : Allocator { + + #[inline] + fn dot(&self, other : &'a Vector) -> E { Vector::::dot(self, other) } } @@ -167,7 +217,16 @@ // TODO: should allow different input storages in `Euclidean`. -impl Euclidean +impl HasScalarField +for Matrix +where M : Dim, K : Dim, + S : Storage, + E : Float + Scalar, + DefaultAllocator : Allocator { + type Field = E; +} + +impl Euclidean for Vector where M : Dim, S : StorageMut, @@ -192,7 +251,7 @@ } } -impl StaticEuclidean +impl StaticEuclidean for Vector where M : DimName, S : StorageMut, @@ -205,7 +264,7 @@ } } -impl Norm +impl Norm for Vector where M : Dim, S : StorageMut, @@ -218,7 +277,7 @@ } } -impl Dist +impl Dist for Vector where M : Dim, S : StorageMut, @@ -230,7 +289,7 @@ } } -impl Norm +impl Norm for Vector where M : Dim, S : StorageMut, @@ -243,7 +302,7 @@ } } -impl Dist +impl Dist for Vector where M : Dim, S : StorageMut, @@ -255,7 +314,7 @@ } } -impl Norm +impl Norm for Vector where M : Dim, S : StorageMut, @@ -268,7 +327,7 @@ } } -impl Dist +impl Dist for Vector where M : Dim, S : StorageMut,