Wed, 03 Sep 2025 19:37:15 -0500
Can only do nalgebra matrix ops for OMatrix (but ok through Instance) to avoid having to specify types
| src/nalgebra_support.rs | file | annotate | diff | comparison | revisions |
--- a/src/nalgebra_support.rs Wed Sep 03 17:59:24 2025 -0500 +++ b/src/nalgebra_support.rs Wed Sep 03 19:37:15 2025 -0500 @@ -222,64 +222,56 @@ } } -impl<SM, SV, N, M, K, E> Mapping<Matrix<E, M, K, SV>> for Matrix<E, N, M, SM> +impl<SM, N, M, K, E> Mapping<OMatrix<E, M, K>> for Matrix<E, N, M, SM> where SM: Storage<E, N, M>, - SV: Storage<E, M, K>, N: Dim, M: Dim, K: Dim, E: Scalar + Zero + One + Copy + ClosedMulAssign + ClosedAddAssign, DefaultAllocator: Allocator<N, K> + Allocator<M, K> + Allocator<N, M>, - ShapeConstraint: StridesOk<E, N, M, SM> + StridesOk<E, M, K, SV> + StridesOk<E, N, K>, + ShapeConstraint: StridesOk<E, N, M, SM> + StridesOk<E, M, K> + StridesOk<E, N, K>, { type Codomain = OMatrix<E, N, K>; #[inline] - fn apply<I: Instance<Matrix<E, M, K, SV>>>(&self, x: I) -> Self::Codomain { + fn apply<I: Instance<OMatrix<E, M, K>>>(&self, x: I) -> Self::Codomain { x.either(|owned| self.mul(owned), |refr| self.mul(refr)) } } -impl<'a, SM, SV, N, M, K, E> Linear<Matrix<E, M, K, SV>> for Matrix<E, N, M, SM> +impl<'a, SM, N, M, K, E> Linear<OMatrix<E, M, K>> for Matrix<E, N, M, SM> where SM: Storage<E, N, M>, - SV: Storage<E, M, K>, N: Dim, M: Dim, K: Dim, E: Scalar + Zero + One + Copy + ClosedMulAssign + ClosedAddAssign, DefaultAllocator: Allocator<N, K> + Allocator<M, K> + Allocator<N, M>, - ShapeConstraint: StridesOk<E, N, M, SM> + StridesOk<E, M, K, SV> + StridesOk<E, N, K>, + ShapeConstraint: StridesOk<E, N, M, SM> + StridesOk<E, M, K> + StridesOk<E, N, K>, { } -impl<SM, SV1, SV2, N, M, K, E> GEMV<E, Matrix<E, M, K, SV1>, Matrix<E, N, K, SV2>> - for Matrix<E, N, M, SM> +impl<SM, SV2, N, M, K, E> GEMV<E, OMatrix<E, M, K>, Matrix<E, N, K, SV2>> for Matrix<E, N, M, SM> where SM: Storage<E, N, M>, - SV1: Storage<E, M, K>, SV2: StorageMut<E, N, K>, N: Dim, M: Dim, K: Dim, E: Scalar + Zero + One + Float, DefaultAllocator: Allocator<N, K> + Allocator<M, K> + Allocator<N, M>, - ShapeConstraint: StridesOk<E, N, M, SM> + StridesOk<E, M, K, SV1> + StridesOk<E, N, K, SV2>, + ShapeConstraint: StridesOk<E, N, M, SM> + StridesOk<E, N, K, SV2> + StridesOk<E, M, K>, { #[inline] - fn gemv<I: Instance<Matrix<E, M, K, SV1>>>( - &self, - y: &mut Matrix<E, N, K, SV2>, - α: E, - x: I, - β: E, + fn gemv<I: Instance<OMatrix<E, M, K>>>( + &self, y: &mut Matrix<E, N, K, SV2>, α: E, x: I, β: E ) { x.eval(|x̃| Matrix::gemm(y, α, self, x̃, β)) } #[inline] - fn apply_mut<'a, I: Instance<Matrix<E, M, K, SV1>>>(&self, y: &mut Matrix<E, N, K, SV2>, x: I) { + fn apply_mut<'a, I: Instance<OMatrix<E, M, K>>>(&self, y: &mut Matrix<E, N, K, SV2>, x: I) { x.eval(|x̃| self.mul_to(x̃, y)) } } @@ -381,21 +373,16 @@ } } -impl<'own, SV1, SV2, SM, N, M, K, E> Adjointable<Matrix<E, M, K, SV1>, Matrix<E, N, K, SV2>> - for Matrix<E, N, M, SM> +impl<'own, SM, N, M, K, E> Adjointable<OMatrix<E, M, K>, OMatrix<E, N, K>> for Matrix<E, N, M, SM> where SM: Storage<E, N, M>, - SV1: Storage<E, M, K> + Clone, - SV2: Storage<E, N, K> + Clone, N: Dim, M: Dim, K: Dim, E: Scalar + Zero + One + Copy + SimdComplexField, DefaultAllocator: Allocator<N, K> + Allocator<M, K> + Allocator<N, M> + Allocator<M, N>, - ShapeConstraint: StridesOk<E, N, M, SM> - + StridesOk<E, M, K, SV1> - + StridesOk<E, N, K, SV2> - + StridesOk<E, M, N>, + ShapeConstraint: + StridesOk<E, N, M, SM> + StridesOk<E, N, K> + StridesOk<E, M, N> + StridesOk<E, M, K>, { type AdjointCodomain = OMatrix<E, M, K>; type Adjoint<'a>