Wed, 03 Sep 2025 09:52:30 -0500
convexity etc. fubar
| 5 | 1 | /*! |
| 2 | Integration with nalgebra. | |
| 3 | ||
|
63
f7b87d84864d
Extra reflexivity and hilbert-like requirements for Euclidean. Fuse Dot into Euclidean.
Tuomo Valkonen <tuomov@iki.fi>
parents:
62
diff
changeset
|
4 | This module mainly implements [`Euclidean`], [`Norm`], [`Linear`], etc. for [`nalgebra`] |
| 5 | 5 | matrices and vectors. |
| 6 | It also provides [`ToNalgebraRealField`] as a vomit-inducingly ugly workaround to nalgebra | |
| 7 | force-feeding its own versions of the same basic mathematical methods on `f32` and `f64` as | |
| 8 | [`num_traits`] does. | |
| 9 | */ | |
| 0 | 10 | |
|
124
6aa955ad8122
Transpose loc parameters to allow f64 defaults
Tuomo Valkonen <tuomov@iki.fi>
parents:
70
diff
changeset
|
11 | use crate::euclidean::*; |
| 162 | 12 | use crate::instance::{Decomposition, Instance, MyCow, Ownable, Space}; |
|
124
6aa955ad8122
Transpose loc parameters to allow f64 defaults
Tuomo Valkonen <tuomov@iki.fi>
parents:
70
diff
changeset
|
13 | use crate::linops::*; |
|
6aa955ad8122
Transpose loc parameters to allow f64 defaults
Tuomo Valkonen <tuomov@iki.fi>
parents:
70
diff
changeset
|
14 | use crate::norms::*; |
|
6aa955ad8122
Transpose loc parameters to allow f64 defaults
Tuomo Valkonen <tuomov@iki.fi>
parents:
70
diff
changeset
|
15 | use crate::types::Float; |
|
6aa955ad8122
Transpose loc parameters to allow f64 defaults
Tuomo Valkonen <tuomov@iki.fi>
parents:
70
diff
changeset
|
16 | use nalgebra::base::allocator::Allocator; |
| 158 | 17 | use nalgebra::base::constraint::{DimEq, SameNumberOfColumns, SameNumberOfRows, ShapeConstraint}; |
|
124
6aa955ad8122
Transpose loc parameters to allow f64 defaults
Tuomo Valkonen <tuomov@iki.fi>
parents:
70
diff
changeset
|
18 | use nalgebra::base::dimension::*; |
| 0 | 19 | use nalgebra::{ |
| 156 | 20 | ClosedAddAssign, ClosedMulAssign, DefaultAllocator, Dim, LpNorm, Matrix, MatrixView, OMatrix, |
| 158 | 21 | OVector, RawStorage, RealField, Scalar, SimdComplexField, Storage, StorageMut, UniformNorm, |
| 159 | 22 | Vector, U1, |
| 0 | 23 | }; |
|
124
6aa955ad8122
Transpose loc parameters to allow f64 defaults
Tuomo Valkonen <tuomov@iki.fi>
parents:
70
diff
changeset
|
24 | use num_traits::identities::{One, Zero}; |
| 0 | 25 | use std::ops::Mul; |
| 26 | ||
| 150 | 27 | impl<S, M, N, E> Ownable for Matrix<E, M, N, S> |
| 28 | where | |
| 29 | S: Storage<E, M, N>, | |
| 30 | M: Dim, | |
| 31 | N: Dim, | |
| 32 | E: Scalar + Zero + One, | |
| 33 | DefaultAllocator: Allocator<M, N>, | |
| 34 | { | |
| 35 | type OwnedVariant = OMatrix<E, M, N>; | |
| 36 | ||
| 37 | #[inline] | |
| 38 | fn into_owned(self) -> Self::OwnedVariant { | |
| 39 | Matrix::into_owned(self) | |
| 40 | } | |
| 41 | ||
| 42 | /// Returns an owned instance of a reference. | |
| 43 | fn clone_owned(&self) -> Self::OwnedVariant { | |
| 44 | Matrix::clone_owned(self) | |
| 45 | } | |
| 162 | 46 | |
| 47 | fn cow_owned<'b>(self) -> MyCow<'b, Self::OwnedVariant> | |
| 48 | where | |
| 49 | Self: 'b, | |
| 50 | { | |
| 51 | todo!() | |
| 52 | //MyCow::owned(self.into_owned()) | |
| 53 | } | |
| 150 | 54 | } |
| 55 | ||
| 159 | 56 | trait StridesOk<E, N, M = U1, S = <DefaultAllocator as Allocator<N, M>>::Buffer<E>>: |
| 57 | DimEq<Dyn, S::RStride> | |
| 58 | + DimEq<Dyn, S::CStride> | |
| 59 | + DimEq<Dyn, <<DefaultAllocator as Allocator<N, M>>::Buffer<E> as RawStorage<E, N, M>>::RStride> | |
| 60 | + DimEq<Dyn, <<DefaultAllocator as Allocator<N, M>>::Buffer<E> as RawStorage<E, N, M>>::CStride> | |
| 61 | where | |
| 62 | S: RawStorage<E, N, M>, | |
| 63 | E: Scalar, | |
| 64 | N: Dim, | |
| 65 | M: Dim, | |
| 66 | DefaultAllocator: Allocator<N, M>, | |
| 67 | { | |
| 68 | } | |
| 69 | ||
| 70 | impl<S, E, N, M> StridesOk<E, N, M, S> for ShapeConstraint | |
| 71 | where | |
| 72 | ShapeConstraint: DimEq<Dyn, S::RStride> | |
| 73 | + DimEq<Dyn, S::CStride> | |
| 74 | + DimEq< | |
| 75 | Dyn, | |
| 76 | <<DefaultAllocator as Allocator<N, M>>::Buffer<E> as RawStorage<E, N, M>>::RStride, | |
| 77 | > + DimEq< | |
| 78 | Dyn, | |
| 79 | <<DefaultAllocator as Allocator<N, M>>::Buffer<E> as RawStorage<E, N, M>>::CStride, | |
| 80 | >, | |
| 81 | S: Storage<E, N, M>, | |
| 82 | E: Scalar, | |
| 83 | N: Dim, | |
| 84 | M: Dim, | |
| 85 | DefaultAllocator: Allocator<N, M>, | |
| 86 | { | |
| 87 | } | |
| 88 | ||
|
124
6aa955ad8122
Transpose loc parameters to allow f64 defaults
Tuomo Valkonen <tuomov@iki.fi>
parents:
70
diff
changeset
|
89 | impl<SM, N, M, E> Space for Matrix<E, N, M, SM> |
|
59
9226980e45a7
Significantly simplify Mapping / Apply through Instance
Tuomo Valkonen <tuomov@iki.fi>
parents:
56
diff
changeset
|
90 | where |
| 150 | 91 | SM: Storage<E, N, M>, |
|
124
6aa955ad8122
Transpose loc parameters to allow f64 defaults
Tuomo Valkonen <tuomov@iki.fi>
parents:
70
diff
changeset
|
92 | N: Dim, |
|
6aa955ad8122
Transpose loc parameters to allow f64 defaults
Tuomo Valkonen <tuomov@iki.fi>
parents:
70
diff
changeset
|
93 | M: Dim, |
| 150 | 94 | E: Scalar + Zero + One, |
|
124
6aa955ad8122
Transpose loc parameters to allow f64 defaults
Tuomo Valkonen <tuomov@iki.fi>
parents:
70
diff
changeset
|
95 | DefaultAllocator: Allocator<N, M>, |
| 159 | 96 | ShapeConstraint: StridesOk<E, N, M, SM> + StridesOk<E, N, M>, |
|
59
9226980e45a7
Significantly simplify Mapping / Apply through Instance
Tuomo Valkonen <tuomov@iki.fi>
parents:
56
diff
changeset
|
97 | { |
| 150 | 98 | type OwnedSpace = OMatrix<E, N, M>; |
| 156 | 99 | type Decomp = MatrixDecomposition; |
| 100 | } | |
| 101 | ||
| 102 | #[derive(Copy, Clone, Debug)] | |
| 103 | pub struct MatrixDecomposition; | |
| 104 | ||
|
160
e7920e205785
Viewable hack not needed now
Tuomo Valkonen <tuomov@iki.fi>
parents:
159
diff
changeset
|
105 | impl<E, M, K, S> Decomposition<Matrix<E, M, K, S>> for MatrixDecomposition |
| 156 | 106 | where |
| 158 | 107 | S: Storage<E, M, K>, |
| 156 | 108 | M: Dim, |
| 109 | K: Dim, | |
| 110 | E: Scalar + Zero + One, | |
| 111 | DefaultAllocator: Allocator<M, K>, | |
| 159 | 112 | ShapeConstraint: StridesOk<E, M, K, S> + StridesOk<E, M, K>, |
| 156 | 113 | { |
| 114 | type Decomposition<'b> | |
| 115 | = OMatrix<E, M, K> | |
| 116 | where | |
| 117 | Matrix<E, M, K, S>: 'b; | |
| 118 | type Reference<'b> | |
| 158 | 119 | = MatrixView<'b, E, M, K, Dyn, Dyn> |
| 156 | 120 | where |
| 121 | Matrix<E, M, K, S>: 'b; | |
| 122 | ||
| 123 | #[inline] | |
| 157 | 124 | fn lift<'b>(r: Self::Reference<'b>) -> Self::Decomposition<'b> |
| 125 | where | |
| 126 | S: 'b, | |
| 127 | { | |
| 156 | 128 | r.into_owned() |
| 129 | } | |
| 130 | } | |
| 131 | ||
| 159 | 132 | impl<S1, S2, M, K, E> Instance<Matrix<E, M, K, S1>, MatrixDecomposition> for Matrix<E, M, K, S2> |
| 133 | where | |
|
160
e7920e205785
Viewable hack not needed now
Tuomo Valkonen <tuomov@iki.fi>
parents:
159
diff
changeset
|
134 | S1: Storage<E, M, K>, |
|
e7920e205785
Viewable hack not needed now
Tuomo Valkonen <tuomov@iki.fi>
parents:
159
diff
changeset
|
135 | S2: Storage<E, M, K>, |
| 159 | 136 | M: Dim, |
| 137 | K: Dim, | |
| 138 | E: Scalar + Zero + One, | |
| 139 | DefaultAllocator: Allocator<M, K>, | |
| 140 | ShapeConstraint: StridesOk<E, M, K, S1> + StridesOk<E, M, K, S2>, | |
| 141 | { | |
| 142 | fn eval_decompose<'b, R>(self, f: impl FnOnce(OMatrix<E, M, K>) -> R) -> R | |
| 143 | where | |
| 144 | Self: 'b, | |
| 145 | { | |
| 146 | f(self.into_owned()) | |
| 147 | } | |
| 158 | 148 | |
| 159 | 149 | fn eval_ref_decompose<'b, R>( |
| 150 | &'b self, | |
| 151 | f: impl FnOnce(<MatrixDecomposition as Decomposition<Matrix<E, M, K, S1>>>::Reference<'b>) -> R, | |
| 152 | ) -> R | |
| 153 | where | |
| 154 | Self: 'b, | |
| 155 | Matrix<E, M, K, S1>: 'b, | |
| 156 | { | |
| 157 | f(self.as_view::<M, K, Dyn, Dyn>()) | |
| 158 | } | |
| 156 | 159 | |
| 159 | 160 | #[inline] |
| 161 | fn own(self) -> OMatrix<E, M, K> { | |
| 162 | self.into_owned() | |
| 163 | } | |
|
13
465fa2121ccb
Better Linear and Mapping structure that can provide consuming and reference `apply`.
Tuomo Valkonen <tuomov@iki.fi>
parents:
5
diff
changeset
|
164 | } |
|
465fa2121ccb
Better Linear and Mapping structure that can provide consuming and reference `apply`.
Tuomo Valkonen <tuomov@iki.fi>
parents:
5
diff
changeset
|
165 | |
| 159 | 166 | impl<'a, S1, S2, M, K, E> Instance<Matrix<E, M, K, S1>, MatrixDecomposition> |
| 167 | for &'a Matrix<E, M, K, S2> | |
| 168 | where | |
|
160
e7920e205785
Viewable hack not needed now
Tuomo Valkonen <tuomov@iki.fi>
parents:
159
diff
changeset
|
169 | S1: Storage<E, M, K>, |
|
e7920e205785
Viewable hack not needed now
Tuomo Valkonen <tuomov@iki.fi>
parents:
159
diff
changeset
|
170 | S2: Storage<E, M, K>, |
| 159 | 171 | M: Dim, |
| 172 | K: Dim, | |
| 173 | E: Scalar + Zero + One, | |
| 174 | DefaultAllocator: Allocator<M, K>, | |
| 175 | ShapeConstraint: StridesOk<E, M, K, S1> + StridesOk<E, M, K, S2>, | |
| 176 | { | |
| 177 | fn eval_decompose<'b, R>(self, f: impl FnOnce(OMatrix<E, M, K>) -> R) -> R | |
| 178 | where | |
| 179 | Self: 'b, | |
| 180 | { | |
| 181 | f(self.into_owned()) | |
| 182 | } | |
| 183 | ||
| 184 | fn eval_ref_decompose<'b, R>( | |
| 185 | &'b self, | |
| 186 | f: impl FnOnce(<MatrixDecomposition as Decomposition<Matrix<E, M, K, S1>>>::Reference<'b>) -> R, | |
| 187 | ) -> R | |
| 188 | where | |
| 189 | Self: 'b, | |
| 190 | Matrix<E, M, K, S1>: 'b, | |
| 191 | { | |
| 192 | f((*self).as_view::<M, K, Dyn, Dyn>()) | |
| 193 | } | |
| 194 | ||
| 195 | #[inline] | |
| 196 | fn own(self) -> OMatrix<E, M, K> { | |
| 197 | self.into_owned() | |
| 198 | } | |
| 199 | } | |
| 158 | 200 | |
|
124
6aa955ad8122
Transpose loc parameters to allow f64 defaults
Tuomo Valkonen <tuomov@iki.fi>
parents:
70
diff
changeset
|
201 | impl<SM, SV, N, M, K, E> Mapping<Matrix<E, M, K, SV>> for Matrix<E, N, M, SM> |
|
6aa955ad8122
Transpose loc parameters to allow f64 defaults
Tuomo Valkonen <tuomov@iki.fi>
parents:
70
diff
changeset
|
202 | where |
|
160
e7920e205785
Viewable hack not needed now
Tuomo Valkonen <tuomov@iki.fi>
parents:
159
diff
changeset
|
203 | SM: Storage<E, N, M>, |
|
e7920e205785
Viewable hack not needed now
Tuomo Valkonen <tuomov@iki.fi>
parents:
159
diff
changeset
|
204 | SV: Storage<E, M, K> + Clone, |
|
124
6aa955ad8122
Transpose loc parameters to allow f64 defaults
Tuomo Valkonen <tuomov@iki.fi>
parents:
70
diff
changeset
|
205 | N: Dim, |
|
6aa955ad8122
Transpose loc parameters to allow f64 defaults
Tuomo Valkonen <tuomov@iki.fi>
parents:
70
diff
changeset
|
206 | M: Dim, |
|
6aa955ad8122
Transpose loc parameters to allow f64 defaults
Tuomo Valkonen <tuomov@iki.fi>
parents:
70
diff
changeset
|
207 | K: Dim, |
|
6aa955ad8122
Transpose loc parameters to allow f64 defaults
Tuomo Valkonen <tuomov@iki.fi>
parents:
70
diff
changeset
|
208 | E: Scalar + Zero + One + ClosedAddAssign + ClosedMulAssign, |
| 159 | 209 | DefaultAllocator: Allocator<N, K> + Allocator<M, K> + Allocator<N, M> + Allocator<M, N>, |
| 210 | ShapeConstraint: StridesOk<E, N, M, SM> + StridesOk<E, M, K, SV> + StridesOk<E, N, K>, | |
|
124
6aa955ad8122
Transpose loc parameters to allow f64 defaults
Tuomo Valkonen <tuomov@iki.fi>
parents:
70
diff
changeset
|
211 | { |
|
6aa955ad8122
Transpose loc parameters to allow f64 defaults
Tuomo Valkonen <tuomov@iki.fi>
parents:
70
diff
changeset
|
212 | type Codomain = OMatrix<E, N, K>; |
|
59
9226980e45a7
Significantly simplify Mapping / Apply through Instance
Tuomo Valkonen <tuomov@iki.fi>
parents:
56
diff
changeset
|
213 | |
|
9226980e45a7
Significantly simplify Mapping / Apply through Instance
Tuomo Valkonen <tuomov@iki.fi>
parents:
56
diff
changeset
|
214 | #[inline] |
|
124
6aa955ad8122
Transpose loc parameters to allow f64 defaults
Tuomo Valkonen <tuomov@iki.fi>
parents:
70
diff
changeset
|
215 | fn apply<I: Instance<Matrix<E, M, K, SV>>>(&self, x: I) -> Self::Codomain { |
|
59
9226980e45a7
Significantly simplify Mapping / Apply through Instance
Tuomo Valkonen <tuomov@iki.fi>
parents:
56
diff
changeset
|
216 | x.either(|owned| self.mul(owned), |refr| self.mul(refr)) |
|
9226980e45a7
Significantly simplify Mapping / Apply through Instance
Tuomo Valkonen <tuomov@iki.fi>
parents:
56
diff
changeset
|
217 | } |
|
9226980e45a7
Significantly simplify Mapping / Apply through Instance
Tuomo Valkonen <tuomov@iki.fi>
parents:
56
diff
changeset
|
218 | } |
|
9226980e45a7
Significantly simplify Mapping / Apply through Instance
Tuomo Valkonen <tuomov@iki.fi>
parents:
56
diff
changeset
|
219 | |
|
124
6aa955ad8122
Transpose loc parameters to allow f64 defaults
Tuomo Valkonen <tuomov@iki.fi>
parents:
70
diff
changeset
|
220 | impl<'a, SM, SV, N, M, K, E> Linear<Matrix<E, M, K, SV>> for Matrix<E, N, M, SM> |
|
6aa955ad8122
Transpose loc parameters to allow f64 defaults
Tuomo Valkonen <tuomov@iki.fi>
parents:
70
diff
changeset
|
221 | where |
|
160
e7920e205785
Viewable hack not needed now
Tuomo Valkonen <tuomov@iki.fi>
parents:
159
diff
changeset
|
222 | SM: Storage<E, N, M>, |
|
e7920e205785
Viewable hack not needed now
Tuomo Valkonen <tuomov@iki.fi>
parents:
159
diff
changeset
|
223 | SV: Storage<E, M, K> + Clone, |
|
124
6aa955ad8122
Transpose loc parameters to allow f64 defaults
Tuomo Valkonen <tuomov@iki.fi>
parents:
70
diff
changeset
|
224 | N: Dim, |
|
6aa955ad8122
Transpose loc parameters to allow f64 defaults
Tuomo Valkonen <tuomov@iki.fi>
parents:
70
diff
changeset
|
225 | M: Dim, |
|
6aa955ad8122
Transpose loc parameters to allow f64 defaults
Tuomo Valkonen <tuomov@iki.fi>
parents:
70
diff
changeset
|
226 | K: Dim, |
|
6aa955ad8122
Transpose loc parameters to allow f64 defaults
Tuomo Valkonen <tuomov@iki.fi>
parents:
70
diff
changeset
|
227 | E: Scalar + Zero + One + ClosedAddAssign + ClosedMulAssign, |
| 159 | 228 | DefaultAllocator: Allocator<N, K> + Allocator<M, K> + Allocator<N, M> + Allocator<M, N>, |
| 229 | ShapeConstraint: StridesOk<E, N, M, SM> + StridesOk<E, M, K, SV> + StridesOk<E, N, K>, | |
|
124
6aa955ad8122
Transpose loc parameters to allow f64 defaults
Tuomo Valkonen <tuomov@iki.fi>
parents:
70
diff
changeset
|
230 | { |
| 0 | 231 | } |
| 232 | ||
|
124
6aa955ad8122
Transpose loc parameters to allow f64 defaults
Tuomo Valkonen <tuomov@iki.fi>
parents:
70
diff
changeset
|
233 | impl<SM, SV1, SV2, N, M, K, E> GEMV<E, Matrix<E, M, K, SV1>, Matrix<E, N, K, SV2>> |
|
6aa955ad8122
Transpose loc parameters to allow f64 defaults
Tuomo Valkonen <tuomov@iki.fi>
parents:
70
diff
changeset
|
234 | for Matrix<E, N, M, SM> |
|
6aa955ad8122
Transpose loc parameters to allow f64 defaults
Tuomo Valkonen <tuomov@iki.fi>
parents:
70
diff
changeset
|
235 | where |
|
160
e7920e205785
Viewable hack not needed now
Tuomo Valkonen <tuomov@iki.fi>
parents:
159
diff
changeset
|
236 | SM: Storage<E, N, M>, |
|
e7920e205785
Viewable hack not needed now
Tuomo Valkonen <tuomov@iki.fi>
parents:
159
diff
changeset
|
237 | SV1: Storage<E, M, K> + Clone, |
|
e7920e205785
Viewable hack not needed now
Tuomo Valkonen <tuomov@iki.fi>
parents:
159
diff
changeset
|
238 | SV2: StorageMut<E, N, K>, |
|
124
6aa955ad8122
Transpose loc parameters to allow f64 defaults
Tuomo Valkonen <tuomov@iki.fi>
parents:
70
diff
changeset
|
239 | N: Dim, |
|
6aa955ad8122
Transpose loc parameters to allow f64 defaults
Tuomo Valkonen <tuomov@iki.fi>
parents:
70
diff
changeset
|
240 | M: Dim, |
|
6aa955ad8122
Transpose loc parameters to allow f64 defaults
Tuomo Valkonen <tuomov@iki.fi>
parents:
70
diff
changeset
|
241 | K: Dim, |
|
6aa955ad8122
Transpose loc parameters to allow f64 defaults
Tuomo Valkonen <tuomov@iki.fi>
parents:
70
diff
changeset
|
242 | E: Scalar + Zero + One + Float, |
| 159 | 243 | DefaultAllocator: Allocator<N, K> + Allocator<M, K> + Allocator<N, M> + Allocator<M, N>, |
| 244 | ShapeConstraint: StridesOk<E, N, M, SM> + StridesOk<E, M, K, SV1> + StridesOk<E, N, K, SV2>, | |
|
124
6aa955ad8122
Transpose loc parameters to allow f64 defaults
Tuomo Valkonen <tuomov@iki.fi>
parents:
70
diff
changeset
|
245 | { |
| 0 | 246 | #[inline] |
|
124
6aa955ad8122
Transpose loc parameters to allow f64 defaults
Tuomo Valkonen <tuomov@iki.fi>
parents:
70
diff
changeset
|
247 | fn gemv<I: Instance<Matrix<E, M, K, SV1>>>( |
|
6aa955ad8122
Transpose loc parameters to allow f64 defaults
Tuomo Valkonen <tuomov@iki.fi>
parents:
70
diff
changeset
|
248 | &self, |
|
6aa955ad8122
Transpose loc parameters to allow f64 defaults
Tuomo Valkonen <tuomov@iki.fi>
parents:
70
diff
changeset
|
249 | y: &mut Matrix<E, N, K, SV2>, |
|
6aa955ad8122
Transpose loc parameters to allow f64 defaults
Tuomo Valkonen <tuomov@iki.fi>
parents:
70
diff
changeset
|
250 | α: E, |
|
6aa955ad8122
Transpose loc parameters to allow f64 defaults
Tuomo Valkonen <tuomov@iki.fi>
parents:
70
diff
changeset
|
251 | x: I, |
|
6aa955ad8122
Transpose loc parameters to allow f64 defaults
Tuomo Valkonen <tuomov@iki.fi>
parents:
70
diff
changeset
|
252 | β: E, |
|
59
9226980e45a7
Significantly simplify Mapping / Apply through Instance
Tuomo Valkonen <tuomov@iki.fi>
parents:
56
diff
changeset
|
253 | ) { |
|
9226980e45a7
Significantly simplify Mapping / Apply through Instance
Tuomo Valkonen <tuomov@iki.fi>
parents:
56
diff
changeset
|
254 | x.eval(|x̃| Matrix::gemm(y, α, self, x̃, β)) |
| 0 | 255 | } |
| 256 | ||
| 257 | #[inline] | |
|
124
6aa955ad8122
Transpose loc parameters to allow f64 defaults
Tuomo Valkonen <tuomov@iki.fi>
parents:
70
diff
changeset
|
258 | fn apply_mut<'a, I: Instance<Matrix<E, M, K, SV1>>>(&self, y: &mut Matrix<E, N, K, SV2>, x: I) { |
|
59
9226980e45a7
Significantly simplify Mapping / Apply through Instance
Tuomo Valkonen <tuomov@iki.fi>
parents:
56
diff
changeset
|
259 | x.eval(|x̃| self.mul_to(x̃, y)) |
| 0 | 260 | } |
| 261 | } | |
| 262 | ||
| 150 | 263 | impl<S, M, N, E> VectorSpace for Matrix<E, M, N, S> |
|
124
6aa955ad8122
Transpose loc parameters to allow f64 defaults
Tuomo Valkonen <tuomov@iki.fi>
parents:
70
diff
changeset
|
264 | where |
|
160
e7920e205785
Viewable hack not needed now
Tuomo Valkonen <tuomov@iki.fi>
parents:
159
diff
changeset
|
265 | S: Storage<E, M, N>, |
|
124
6aa955ad8122
Transpose loc parameters to allow f64 defaults
Tuomo Valkonen <tuomov@iki.fi>
parents:
70
diff
changeset
|
266 | M: Dim, |
|
148
26ef556870fd
AXPY for nalgebra matrices, not just vectors
Tuomo Valkonen <tuomov@iki.fi>
parents:
145
diff
changeset
|
267 | N: Dim, |
|
124
6aa955ad8122
Transpose loc parameters to allow f64 defaults
Tuomo Valkonen <tuomov@iki.fi>
parents:
70
diff
changeset
|
268 | E: Scalar + Zero + One + Float, |
|
148
26ef556870fd
AXPY for nalgebra matrices, not just vectors
Tuomo Valkonen <tuomov@iki.fi>
parents:
145
diff
changeset
|
269 | DefaultAllocator: Allocator<M, N>, |
| 159 | 270 | ShapeConstraint: StridesOk<E, M, N, S>, |
|
124
6aa955ad8122
Transpose loc parameters to allow f64 defaults
Tuomo Valkonen <tuomov@iki.fi>
parents:
70
diff
changeset
|
271 | { |
|
129
d2994e34a5f5
Simplify ZeroOp to SimpleZeroOp, only from X to X. Add Prox for ZeroIndicator. Move F parameter to AXPY::Field.
Tuomo Valkonen <tuomov@iki.fi>
parents:
124
diff
changeset
|
272 | type Field = E; |
|
148
26ef556870fd
AXPY for nalgebra matrices, not just vectors
Tuomo Valkonen <tuomov@iki.fi>
parents:
145
diff
changeset
|
273 | type Owned = OMatrix<E, M, N>; |
| 0 | 274 | |
| 275 | #[inline] | |
| 150 | 276 | fn similar_origin(&self) -> Self::Owned { |
| 277 | let (n, m) = self.shape_generic(); | |
| 278 | OMatrix::zeros_generic(n, m) | |
| 279 | } | |
| 280 | } | |
| 281 | ||
| 282 | impl<SM, SV1, M, N, E> AXPY<Matrix<E, M, N, SV1>> for Matrix<E, M, N, SM> | |
| 283 | where | |
|
160
e7920e205785
Viewable hack not needed now
Tuomo Valkonen <tuomov@iki.fi>
parents:
159
diff
changeset
|
284 | SM: StorageMut<E, M, N>, |
|
e7920e205785
Viewable hack not needed now
Tuomo Valkonen <tuomov@iki.fi>
parents:
159
diff
changeset
|
285 | SV1: Storage<E, M, N>, |
| 150 | 286 | M: Dim, |
| 287 | N: Dim, | |
| 288 | E: Scalar + Zero + One + Float, | |
| 289 | DefaultAllocator: Allocator<M, N>, | |
| 159 | 290 | ShapeConstraint: StridesOk<E, M, N, SM> + StridesOk<E, M, N, SV1>, |
| 150 | 291 | { |
| 292 | #[inline] | |
|
148
26ef556870fd
AXPY for nalgebra matrices, not just vectors
Tuomo Valkonen <tuomov@iki.fi>
parents:
145
diff
changeset
|
293 | fn axpy<I: Instance<Matrix<E, M, N, SV1>>>(&mut self, α: E, x: I, β: E) { |
|
26ef556870fd
AXPY for nalgebra matrices, not just vectors
Tuomo Valkonen <tuomov@iki.fi>
parents:
145
diff
changeset
|
294 | x.eval(|x̃| { |
|
26ef556870fd
AXPY for nalgebra matrices, not just vectors
Tuomo Valkonen <tuomov@iki.fi>
parents:
145
diff
changeset
|
295 | assert_eq!(self.ncols(), x̃.ncols()); |
|
26ef556870fd
AXPY for nalgebra matrices, not just vectors
Tuomo Valkonen <tuomov@iki.fi>
parents:
145
diff
changeset
|
296 | // nalgebra does not implement axpy for matrices, and flattenining |
|
26ef556870fd
AXPY for nalgebra matrices, not just vectors
Tuomo Valkonen <tuomov@iki.fi>
parents:
145
diff
changeset
|
297 | // also seems difficult, so loop over columns. |
|
26ef556870fd
AXPY for nalgebra matrices, not just vectors
Tuomo Valkonen <tuomov@iki.fi>
parents:
145
diff
changeset
|
298 | for (mut y, ỹ) in self.column_iter_mut().zip(x̃.column_iter()) { |
|
26ef556870fd
AXPY for nalgebra matrices, not just vectors
Tuomo Valkonen <tuomov@iki.fi>
parents:
145
diff
changeset
|
299 | Vector::axpy(&mut y, α, &ỹ, β) |
|
26ef556870fd
AXPY for nalgebra matrices, not just vectors
Tuomo Valkonen <tuomov@iki.fi>
parents:
145
diff
changeset
|
300 | } |
|
26ef556870fd
AXPY for nalgebra matrices, not just vectors
Tuomo Valkonen <tuomov@iki.fi>
parents:
145
diff
changeset
|
301 | }) |
| 0 | 302 | } |
| 303 | ||
| 304 | #[inline] | |
|
148
26ef556870fd
AXPY for nalgebra matrices, not just vectors
Tuomo Valkonen <tuomov@iki.fi>
parents:
145
diff
changeset
|
305 | fn copy_from<I: Instance<Matrix<E, M, N, SV1>>>(&mut self, y: I) { |
|
59
9226980e45a7
Significantly simplify Mapping / Apply through Instance
Tuomo Valkonen <tuomov@iki.fi>
parents:
56
diff
changeset
|
306 | y.eval(|ỹ| Matrix::copy_from(self, ỹ)) |
| 0 | 307 | } |
|
62
d8305c9b6fdf
Move origin stuff to AXPY form Euclidean
Tuomo Valkonen <tuomov@iki.fi>
parents:
60
diff
changeset
|
308 | |
|
d8305c9b6fdf
Move origin stuff to AXPY form Euclidean
Tuomo Valkonen <tuomov@iki.fi>
parents:
60
diff
changeset
|
309 | #[inline] |
|
d8305c9b6fdf
Move origin stuff to AXPY form Euclidean
Tuomo Valkonen <tuomov@iki.fi>
parents:
60
diff
changeset
|
310 | fn set_zero(&mut self) { |
|
d8305c9b6fdf
Move origin stuff to AXPY form Euclidean
Tuomo Valkonen <tuomov@iki.fi>
parents:
60
diff
changeset
|
311 | self.iter_mut().for_each(|e| *e = E::ZERO); |
|
d8305c9b6fdf
Move origin stuff to AXPY form Euclidean
Tuomo Valkonen <tuomov@iki.fi>
parents:
60
diff
changeset
|
312 | } |
| 0 | 313 | } |
| 314 | ||
|
60
848ecc05becf
More convexity, normed spaces, etc.
Tuomo Valkonen <tuomov@iki.fi>
parents:
59
diff
changeset
|
315 | /* Implemented automatically as Euclidean. |
|
848ecc05becf
More convexity, normed spaces, etc.
Tuomo Valkonen <tuomov@iki.fi>
parents:
59
diff
changeset
|
316 | impl<SM,M,E> Projection<E, L2> for Vector<E,M,SM> |
|
848ecc05becf
More convexity, normed spaces, etc.
Tuomo Valkonen <tuomov@iki.fi>
parents:
59
diff
changeset
|
317 | where SM: StorageMut<E,M> + Clone, |
|
848ecc05becf
More convexity, normed spaces, etc.
Tuomo Valkonen <tuomov@iki.fi>
parents:
59
diff
changeset
|
318 | M : Dim, E : Scalar + Zero + One + Float + RealField, |
|
848ecc05becf
More convexity, normed spaces, etc.
Tuomo Valkonen <tuomov@iki.fi>
parents:
59
diff
changeset
|
319 | DefaultAllocator : Allocator<M> { |
|
848ecc05becf
More convexity, normed spaces, etc.
Tuomo Valkonen <tuomov@iki.fi>
parents:
59
diff
changeset
|
320 | #[inline] |
|
848ecc05becf
More convexity, normed spaces, etc.
Tuomo Valkonen <tuomov@iki.fi>
parents:
59
diff
changeset
|
321 | fn proj_ball_mut(&mut self, ρ : E, _ : L2) { |
|
848ecc05becf
More convexity, normed spaces, etc.
Tuomo Valkonen <tuomov@iki.fi>
parents:
59
diff
changeset
|
322 | let n = self.norm(L2); |
|
848ecc05becf
More convexity, normed spaces, etc.
Tuomo Valkonen <tuomov@iki.fi>
parents:
59
diff
changeset
|
323 | if n > ρ { |
|
848ecc05becf
More convexity, normed spaces, etc.
Tuomo Valkonen <tuomov@iki.fi>
parents:
59
diff
changeset
|
324 | self.iter_mut().for_each(|v| *v *= ρ/n) |
|
848ecc05becf
More convexity, normed spaces, etc.
Tuomo Valkonen <tuomov@iki.fi>
parents:
59
diff
changeset
|
325 | } |
|
848ecc05becf
More convexity, normed spaces, etc.
Tuomo Valkonen <tuomov@iki.fi>
parents:
59
diff
changeset
|
326 | } |
|
848ecc05becf
More convexity, normed spaces, etc.
Tuomo Valkonen <tuomov@iki.fi>
parents:
59
diff
changeset
|
327 | }*/ |
|
848ecc05becf
More convexity, normed spaces, etc.
Tuomo Valkonen <tuomov@iki.fi>
parents:
59
diff
changeset
|
328 | |
|
124
6aa955ad8122
Transpose loc parameters to allow f64 defaults
Tuomo Valkonen <tuomov@iki.fi>
parents:
70
diff
changeset
|
329 | impl<SM, M, E> Projection<E, Linfinity> for Vector<E, M, SM> |
|
6aa955ad8122
Transpose loc parameters to allow f64 defaults
Tuomo Valkonen <tuomov@iki.fi>
parents:
70
diff
changeset
|
330 | where |
|
160
e7920e205785
Viewable hack not needed now
Tuomo Valkonen <tuomov@iki.fi>
parents:
159
diff
changeset
|
331 | SM: StorageMut<E, M> + Clone, |
| 150 | 332 | M: Dim, |
| 333 | E: Scalar + Zero + One + Float + RealField, | |
| 334 | DefaultAllocator: Allocator<M>, | |
| 159 | 335 | ShapeConstraint: StridesOk<E, M, U1, SM>, |
| 150 | 336 | { |
| 337 | #[inline] | |
| 338 | fn proj_ball(self, ρ: E, exp: Linfinity) -> <Self as Space>::OwnedSpace { | |
| 339 | let mut owned = self.into_owned(); | |
| 340 | owned.proj_ball_mut(ρ, exp); | |
| 341 | owned | |
| 342 | } | |
| 343 | } | |
| 344 | ||
| 345 | impl<SM, M, E> ProjectionMut<E, Linfinity> for Vector<E, M, SM> | |
| 346 | where | |
|
160
e7920e205785
Viewable hack not needed now
Tuomo Valkonen <tuomov@iki.fi>
parents:
159
diff
changeset
|
347 | SM: StorageMut<E, M> + Clone, |
|
124
6aa955ad8122
Transpose loc parameters to allow f64 defaults
Tuomo Valkonen <tuomov@iki.fi>
parents:
70
diff
changeset
|
348 | M: Dim, |
|
6aa955ad8122
Transpose loc parameters to allow f64 defaults
Tuomo Valkonen <tuomov@iki.fi>
parents:
70
diff
changeset
|
349 | E: Scalar + Zero + One + Float + RealField, |
|
6aa955ad8122
Transpose loc parameters to allow f64 defaults
Tuomo Valkonen <tuomov@iki.fi>
parents:
70
diff
changeset
|
350 | DefaultAllocator: Allocator<M>, |
| 159 | 351 | ShapeConstraint: StridesOk<E, M, U1, SM>, |
|
124
6aa955ad8122
Transpose loc parameters to allow f64 defaults
Tuomo Valkonen <tuomov@iki.fi>
parents:
70
diff
changeset
|
352 | { |
| 0 | 353 | #[inline] |
|
124
6aa955ad8122
Transpose loc parameters to allow f64 defaults
Tuomo Valkonen <tuomov@iki.fi>
parents:
70
diff
changeset
|
354 | fn proj_ball_mut(&mut self, ρ: E, _: Linfinity) { |
|
6aa955ad8122
Transpose loc parameters to allow f64 defaults
Tuomo Valkonen <tuomov@iki.fi>
parents:
70
diff
changeset
|
355 | self.iter_mut() |
|
6aa955ad8122
Transpose loc parameters to allow f64 defaults
Tuomo Valkonen <tuomov@iki.fi>
parents:
70
diff
changeset
|
356 | .for_each(|v| *v = num_traits::clamp(*v, -ρ, ρ)) |
| 0 | 357 | } |
| 358 | } | |
| 359 | ||
|
124
6aa955ad8122
Transpose loc parameters to allow f64 defaults
Tuomo Valkonen <tuomov@iki.fi>
parents:
70
diff
changeset
|
360 | impl<'own, SV1, SV2, SM, N, M, K, E> Adjointable<Matrix<E, M, K, SV1>, Matrix<E, N, K, SV2>> |
|
6aa955ad8122
Transpose loc parameters to allow f64 defaults
Tuomo Valkonen <tuomov@iki.fi>
parents:
70
diff
changeset
|
361 | for Matrix<E, N, M, SM> |
|
6aa955ad8122
Transpose loc parameters to allow f64 defaults
Tuomo Valkonen <tuomov@iki.fi>
parents:
70
diff
changeset
|
362 | where |
|
160
e7920e205785
Viewable hack not needed now
Tuomo Valkonen <tuomov@iki.fi>
parents:
159
diff
changeset
|
363 | SM: Storage<E, N, M>, |
|
e7920e205785
Viewable hack not needed now
Tuomo Valkonen <tuomov@iki.fi>
parents:
159
diff
changeset
|
364 | SV1: Storage<E, M, K> + Clone, |
|
e7920e205785
Viewable hack not needed now
Tuomo Valkonen <tuomov@iki.fi>
parents:
159
diff
changeset
|
365 | SV2: Storage<E, N, K> + Clone, |
|
124
6aa955ad8122
Transpose loc parameters to allow f64 defaults
Tuomo Valkonen <tuomov@iki.fi>
parents:
70
diff
changeset
|
366 | N: Dim, |
|
6aa955ad8122
Transpose loc parameters to allow f64 defaults
Tuomo Valkonen <tuomov@iki.fi>
parents:
70
diff
changeset
|
367 | M: Dim, |
|
6aa955ad8122
Transpose loc parameters to allow f64 defaults
Tuomo Valkonen <tuomov@iki.fi>
parents:
70
diff
changeset
|
368 | K: Dim, |
|
6aa955ad8122
Transpose loc parameters to allow f64 defaults
Tuomo Valkonen <tuomov@iki.fi>
parents:
70
diff
changeset
|
369 | E: Scalar + Zero + One + SimdComplexField, |
| 159 | 370 | DefaultAllocator: Allocator<N, K> + Allocator<M, K> + Allocator<N, M> + Allocator<M, N>, |
| 371 | ShapeConstraint: StridesOk<E, N, M, SM> | |
| 372 | + StridesOk<E, M, K, SV1> | |
| 373 | + StridesOk<E, N, K, SV2> | |
| 374 | + StridesOk<E, M, N>, | |
|
124
6aa955ad8122
Transpose loc parameters to allow f64 defaults
Tuomo Valkonen <tuomov@iki.fi>
parents:
70
diff
changeset
|
375 | { |
|
6aa955ad8122
Transpose loc parameters to allow f64 defaults
Tuomo Valkonen <tuomov@iki.fi>
parents:
70
diff
changeset
|
376 | type AdjointCodomain = OMatrix<E, M, K>; |
|
6aa955ad8122
Transpose loc parameters to allow f64 defaults
Tuomo Valkonen <tuomov@iki.fi>
parents:
70
diff
changeset
|
377 | type Adjoint<'a> |
|
6aa955ad8122
Transpose loc parameters to allow f64 defaults
Tuomo Valkonen <tuomov@iki.fi>
parents:
70
diff
changeset
|
378 | = OMatrix<E, M, N> |
|
6aa955ad8122
Transpose loc parameters to allow f64 defaults
Tuomo Valkonen <tuomov@iki.fi>
parents:
70
diff
changeset
|
379 | where |
|
6aa955ad8122
Transpose loc parameters to allow f64 defaults
Tuomo Valkonen <tuomov@iki.fi>
parents:
70
diff
changeset
|
380 | SM: 'a; |
| 0 | 381 | |
| 382 | #[inline] | |
| 383 | fn adjoint(&self) -> Self::Adjoint<'_> { | |
| 384 | Matrix::adjoint(self) | |
| 385 | } | |
| 386 | } | |
| 387 | ||
| 388 | /// This function is [`nalgebra::EuclideanNorm::metric_distance`] without the `sqrt`. | |
| 389 | #[inline] | |
| 390 | fn metric_distance_squared<T, R1, C1, S1, R2, C2, S2>( | |
| 391 | /*ed: &EuclideanNorm,*/ | |
| 392 | m1: &Matrix<T, R1, C1, S1>, | |
| 393 | m2: &Matrix<T, R2, C2, S2>, | |
| 394 | ) -> T::SimdRealField | |
| 395 | where | |
|
124
6aa955ad8122
Transpose loc parameters to allow f64 defaults
Tuomo Valkonen <tuomov@iki.fi>
parents:
70
diff
changeset
|
396 | T: SimdComplexField, |
| 0 | 397 | R1: Dim, |
| 398 | C1: Dim, | |
| 399 | S1: Storage<T, R1, C1>, | |
| 400 | R2: Dim, | |
| 401 | C2: Dim, | |
| 402 | S2: Storage<T, R2, C2>, | |
| 403 | ShapeConstraint: SameNumberOfRows<R1, R2> + SameNumberOfColumns<C1, C2>, | |
| 404 | { | |
| 405 | m1.zip_fold(m2, T::SimdRealField::zero(), |acc, a, b| { | |
| 406 | let diff = a - b; | |
| 407 | acc + diff.simd_modulus_squared() | |
| 408 | }) | |
| 409 | } | |
| 410 | ||
| 411 | // TODO: should allow different input storages in `Euclidean`. | |
| 412 | ||
|
124
6aa955ad8122
Transpose loc parameters to allow f64 defaults
Tuomo Valkonen <tuomov@iki.fi>
parents:
70
diff
changeset
|
413 | impl<E, M, S> Euclidean<E> for Vector<E, M, S> |
|
6aa955ad8122
Transpose loc parameters to allow f64 defaults
Tuomo Valkonen <tuomov@iki.fi>
parents:
70
diff
changeset
|
414 | where |
|
6aa955ad8122
Transpose loc parameters to allow f64 defaults
Tuomo Valkonen <tuomov@iki.fi>
parents:
70
diff
changeset
|
415 | M: Dim, |
|
160
e7920e205785
Viewable hack not needed now
Tuomo Valkonen <tuomov@iki.fi>
parents:
159
diff
changeset
|
416 | S: Storage<E, M>, |
|
124
6aa955ad8122
Transpose loc parameters to allow f64 defaults
Tuomo Valkonen <tuomov@iki.fi>
parents:
70
diff
changeset
|
417 | E: Float + Scalar + Zero + One + RealField, |
|
6aa955ad8122
Transpose loc parameters to allow f64 defaults
Tuomo Valkonen <tuomov@iki.fi>
parents:
70
diff
changeset
|
418 | DefaultAllocator: Allocator<M>, |
| 159 | 419 | ShapeConstraint: StridesOk<E, M, U1, S>, |
|
124
6aa955ad8122
Transpose loc parameters to allow f64 defaults
Tuomo Valkonen <tuomov@iki.fi>
parents:
70
diff
changeset
|
420 | { |
| 151 | 421 | type OwnedEuclidean = OVector<E, M>; |
| 422 | ||
|
63
f7b87d84864d
Extra reflexivity and hilbert-like requirements for Euclidean. Fuse Dot into Euclidean.
Tuomo Valkonen <tuomov@iki.fi>
parents:
62
diff
changeset
|
423 | #[inline] |
|
124
6aa955ad8122
Transpose loc parameters to allow f64 defaults
Tuomo Valkonen <tuomov@iki.fi>
parents:
70
diff
changeset
|
424 | fn dot<I: Instance<Self>>(&self, other: I) -> E { |
| 158 | 425 | other.eval_ref_decompose(|ref r| Vector::<E, M, S>::dot(self, r)) |
|
63
f7b87d84864d
Extra reflexivity and hilbert-like requirements for Euclidean. Fuse Dot into Euclidean.
Tuomo Valkonen <tuomov@iki.fi>
parents:
62
diff
changeset
|
426 | } |
|
f7b87d84864d
Extra reflexivity and hilbert-like requirements for Euclidean. Fuse Dot into Euclidean.
Tuomo Valkonen <tuomov@iki.fi>
parents:
62
diff
changeset
|
427 | |
| 0 | 428 | #[inline] |
| 429 | fn norm2_squared(&self) -> E { | |
|
124
6aa955ad8122
Transpose loc parameters to allow f64 defaults
Tuomo Valkonen <tuomov@iki.fi>
parents:
70
diff
changeset
|
430 | Vector::<E, M, S>::norm_squared(self) |
| 0 | 431 | } |
| 432 | ||
| 433 | #[inline] | |
|
124
6aa955ad8122
Transpose loc parameters to allow f64 defaults
Tuomo Valkonen <tuomov@iki.fi>
parents:
70
diff
changeset
|
434 | fn dist2_squared<I: Instance<Self>>(&self, other: I) -> E { |
| 158 | 435 | other.eval_ref_decompose(|ref r| metric_distance_squared(self, r)) |
| 0 | 436 | } |
| 437 | } | |
| 438 | ||
|
124
6aa955ad8122
Transpose loc parameters to allow f64 defaults
Tuomo Valkonen <tuomov@iki.fi>
parents:
70
diff
changeset
|
439 | impl<E, M, S> StaticEuclidean<E> for Vector<E, M, S> |
|
6aa955ad8122
Transpose loc parameters to allow f64 defaults
Tuomo Valkonen <tuomov@iki.fi>
parents:
70
diff
changeset
|
440 | where |
|
6aa955ad8122
Transpose loc parameters to allow f64 defaults
Tuomo Valkonen <tuomov@iki.fi>
parents:
70
diff
changeset
|
441 | M: DimName, |
|
160
e7920e205785
Viewable hack not needed now
Tuomo Valkonen <tuomov@iki.fi>
parents:
159
diff
changeset
|
442 | S: Storage<E, M>, |
|
124
6aa955ad8122
Transpose loc parameters to allow f64 defaults
Tuomo Valkonen <tuomov@iki.fi>
parents:
70
diff
changeset
|
443 | E: Float + Scalar + Zero + One + RealField, |
|
6aa955ad8122
Transpose loc parameters to allow f64 defaults
Tuomo Valkonen <tuomov@iki.fi>
parents:
70
diff
changeset
|
444 | DefaultAllocator: Allocator<M>, |
| 159 | 445 | ShapeConstraint: StridesOk<E, M, U1, S>, |
|
124
6aa955ad8122
Transpose loc parameters to allow f64 defaults
Tuomo Valkonen <tuomov@iki.fi>
parents:
70
diff
changeset
|
446 | { |
| 0 | 447 | #[inline] |
| 448 | fn origin() -> OVector<E, M> { | |
| 449 | OVector::zeros() | |
| 450 | } | |
| 451 | } | |
| 452 | ||
|
60
848ecc05becf
More convexity, normed spaces, etc.
Tuomo Valkonen <tuomov@iki.fi>
parents:
59
diff
changeset
|
453 | /// The default norm for `Vector` is [`L2`]. |
|
124
6aa955ad8122
Transpose loc parameters to allow f64 defaults
Tuomo Valkonen <tuomov@iki.fi>
parents:
70
diff
changeset
|
454 | impl<E, M, S> Normed<E> for Vector<E, M, S> |
|
6aa955ad8122
Transpose loc parameters to allow f64 defaults
Tuomo Valkonen <tuomov@iki.fi>
parents:
70
diff
changeset
|
455 | where |
|
6aa955ad8122
Transpose loc parameters to allow f64 defaults
Tuomo Valkonen <tuomov@iki.fi>
parents:
70
diff
changeset
|
456 | M: Dim, |
|
160
e7920e205785
Viewable hack not needed now
Tuomo Valkonen <tuomov@iki.fi>
parents:
159
diff
changeset
|
457 | S: Storage<E, M>, |
|
124
6aa955ad8122
Transpose loc parameters to allow f64 defaults
Tuomo Valkonen <tuomov@iki.fi>
parents:
70
diff
changeset
|
458 | E: Float + Scalar + Zero + One + RealField, |
|
6aa955ad8122
Transpose loc parameters to allow f64 defaults
Tuomo Valkonen <tuomov@iki.fi>
parents:
70
diff
changeset
|
459 | DefaultAllocator: Allocator<M>, |
| 159 | 460 | ShapeConstraint: StridesOk<E, M, U1, S>, |
|
124
6aa955ad8122
Transpose loc parameters to allow f64 defaults
Tuomo Valkonen <tuomov@iki.fi>
parents:
70
diff
changeset
|
461 | { |
|
60
848ecc05becf
More convexity, normed spaces, etc.
Tuomo Valkonen <tuomov@iki.fi>
parents:
59
diff
changeset
|
462 | type NormExp = L2; |
|
848ecc05becf
More convexity, normed spaces, etc.
Tuomo Valkonen <tuomov@iki.fi>
parents:
59
diff
changeset
|
463 | |
|
848ecc05becf
More convexity, normed spaces, etc.
Tuomo Valkonen <tuomov@iki.fi>
parents:
59
diff
changeset
|
464 | #[inline] |
|
848ecc05becf
More convexity, normed spaces, etc.
Tuomo Valkonen <tuomov@iki.fi>
parents:
59
diff
changeset
|
465 | fn norm_exponent(&self) -> Self::NormExp { |
|
848ecc05becf
More convexity, normed spaces, etc.
Tuomo Valkonen <tuomov@iki.fi>
parents:
59
diff
changeset
|
466 | L2 |
|
848ecc05becf
More convexity, normed spaces, etc.
Tuomo Valkonen <tuomov@iki.fi>
parents:
59
diff
changeset
|
467 | } |
|
848ecc05becf
More convexity, normed spaces, etc.
Tuomo Valkonen <tuomov@iki.fi>
parents:
59
diff
changeset
|
468 | |
|
848ecc05becf
More convexity, normed spaces, etc.
Tuomo Valkonen <tuomov@iki.fi>
parents:
59
diff
changeset
|
469 | #[inline] |
|
848ecc05becf
More convexity, normed spaces, etc.
Tuomo Valkonen <tuomov@iki.fi>
parents:
59
diff
changeset
|
470 | fn is_zero(&self) -> bool { |
|
124
6aa955ad8122
Transpose loc parameters to allow f64 defaults
Tuomo Valkonen <tuomov@iki.fi>
parents:
70
diff
changeset
|
471 | Vector::<E, M, S>::norm_squared(self) == E::ZERO |
|
60
848ecc05becf
More convexity, normed spaces, etc.
Tuomo Valkonen <tuomov@iki.fi>
parents:
59
diff
changeset
|
472 | } |
|
848ecc05becf
More convexity, normed spaces, etc.
Tuomo Valkonen <tuomov@iki.fi>
parents:
59
diff
changeset
|
473 | } |
|
848ecc05becf
More convexity, normed spaces, etc.
Tuomo Valkonen <tuomov@iki.fi>
parents:
59
diff
changeset
|
474 | |
|
124
6aa955ad8122
Transpose loc parameters to allow f64 defaults
Tuomo Valkonen <tuomov@iki.fi>
parents:
70
diff
changeset
|
475 | impl<E, M, S> HasDual<E> for Vector<E, M, S> |
|
6aa955ad8122
Transpose loc parameters to allow f64 defaults
Tuomo Valkonen <tuomov@iki.fi>
parents:
70
diff
changeset
|
476 | where |
|
6aa955ad8122
Transpose loc parameters to allow f64 defaults
Tuomo Valkonen <tuomov@iki.fi>
parents:
70
diff
changeset
|
477 | M: Dim, |
|
160
e7920e205785
Viewable hack not needed now
Tuomo Valkonen <tuomov@iki.fi>
parents:
159
diff
changeset
|
478 | S: Storage<E, M>, |
|
124
6aa955ad8122
Transpose loc parameters to allow f64 defaults
Tuomo Valkonen <tuomov@iki.fi>
parents:
70
diff
changeset
|
479 | E: Float + Scalar + Zero + One + RealField, |
|
6aa955ad8122
Transpose loc parameters to allow f64 defaults
Tuomo Valkonen <tuomov@iki.fi>
parents:
70
diff
changeset
|
480 | DefaultAllocator: Allocator<M>, |
| 159 | 481 | ShapeConstraint: StridesOk<E, M, U1, S>, |
|
124
6aa955ad8122
Transpose loc parameters to allow f64 defaults
Tuomo Valkonen <tuomov@iki.fi>
parents:
70
diff
changeset
|
482 | { |
| 151 | 483 | type DualSpace = OVector<E, M>; |
| 138 | 484 | |
| 485 | fn dual_origin(&self) -> OVector<E, M> { | |
| 486 | OVector::zeros_generic(M::from_usize(self.len()), Const) | |
| 487 | } | |
|
60
848ecc05becf
More convexity, normed spaces, etc.
Tuomo Valkonen <tuomov@iki.fi>
parents:
59
diff
changeset
|
488 | } |
|
848ecc05becf
More convexity, normed spaces, etc.
Tuomo Valkonen <tuomov@iki.fi>
parents:
59
diff
changeset
|
489 | |
|
124
6aa955ad8122
Transpose loc parameters to allow f64 defaults
Tuomo Valkonen <tuomov@iki.fi>
parents:
70
diff
changeset
|
490 | impl<E, M, S> Norm<L1, E> for Vector<E, M, S> |
|
6aa955ad8122
Transpose loc parameters to allow f64 defaults
Tuomo Valkonen <tuomov@iki.fi>
parents:
70
diff
changeset
|
491 | where |
|
6aa955ad8122
Transpose loc parameters to allow f64 defaults
Tuomo Valkonen <tuomov@iki.fi>
parents:
70
diff
changeset
|
492 | M: Dim, |
|
160
e7920e205785
Viewable hack not needed now
Tuomo Valkonen <tuomov@iki.fi>
parents:
159
diff
changeset
|
493 | S: Storage<E, M>, |
|
124
6aa955ad8122
Transpose loc parameters to allow f64 defaults
Tuomo Valkonen <tuomov@iki.fi>
parents:
70
diff
changeset
|
494 | E: Float + Scalar + Zero + One + RealField, |
|
6aa955ad8122
Transpose loc parameters to allow f64 defaults
Tuomo Valkonen <tuomov@iki.fi>
parents:
70
diff
changeset
|
495 | DefaultAllocator: Allocator<M>, |
| 159 | 496 | ShapeConstraint: StridesOk<E, M, U1, S>, |
|
124
6aa955ad8122
Transpose loc parameters to allow f64 defaults
Tuomo Valkonen <tuomov@iki.fi>
parents:
70
diff
changeset
|
497 | { |
| 0 | 498 | #[inline] |
|
124
6aa955ad8122
Transpose loc parameters to allow f64 defaults
Tuomo Valkonen <tuomov@iki.fi>
parents:
70
diff
changeset
|
499 | fn norm(&self, _: L1) -> E { |
| 70 | 500 | nalgebra::Norm::norm(&LpNorm(1), self) |
| 0 | 501 | } |
| 502 | } | |
| 503 | ||
|
145
0b9aecd7bb76
Dist argument order changed to reflect other changes
Tuomo Valkonen <tuomov@iki.fi>
parents:
138
diff
changeset
|
504 | impl<E, M, S> Dist<L1, E> for Vector<E, M, S> |
|
124
6aa955ad8122
Transpose loc parameters to allow f64 defaults
Tuomo Valkonen <tuomov@iki.fi>
parents:
70
diff
changeset
|
505 | where |
|
6aa955ad8122
Transpose loc parameters to allow f64 defaults
Tuomo Valkonen <tuomov@iki.fi>
parents:
70
diff
changeset
|
506 | M: Dim, |
|
160
e7920e205785
Viewable hack not needed now
Tuomo Valkonen <tuomov@iki.fi>
parents:
159
diff
changeset
|
507 | S: Storage<E, M> + Clone, |
|
124
6aa955ad8122
Transpose loc parameters to allow f64 defaults
Tuomo Valkonen <tuomov@iki.fi>
parents:
70
diff
changeset
|
508 | E: Float + Scalar + Zero + One + RealField, |
|
6aa955ad8122
Transpose loc parameters to allow f64 defaults
Tuomo Valkonen <tuomov@iki.fi>
parents:
70
diff
changeset
|
509 | DefaultAllocator: Allocator<M>, |
| 159 | 510 | ShapeConstraint: StridesOk<E, M, U1, S>, |
|
124
6aa955ad8122
Transpose loc parameters to allow f64 defaults
Tuomo Valkonen <tuomov@iki.fi>
parents:
70
diff
changeset
|
511 | { |
| 0 | 512 | #[inline] |
|
124
6aa955ad8122
Transpose loc parameters to allow f64 defaults
Tuomo Valkonen <tuomov@iki.fi>
parents:
70
diff
changeset
|
513 | fn dist<I: Instance<Self>>(&self, other: I, _: L1) -> E { |
| 158 | 514 | other.eval_ref_decompose(|ref r| nalgebra::Norm::metric_distance(&LpNorm(1), self, r)) |
| 0 | 515 | } |
| 516 | } | |
| 517 | ||
|
124
6aa955ad8122
Transpose loc parameters to allow f64 defaults
Tuomo Valkonen <tuomov@iki.fi>
parents:
70
diff
changeset
|
518 | impl<E, M, S> Norm<L2, E> for Vector<E, M, S> |
|
6aa955ad8122
Transpose loc parameters to allow f64 defaults
Tuomo Valkonen <tuomov@iki.fi>
parents:
70
diff
changeset
|
519 | where |
|
6aa955ad8122
Transpose loc parameters to allow f64 defaults
Tuomo Valkonen <tuomov@iki.fi>
parents:
70
diff
changeset
|
520 | M: Dim, |
|
160
e7920e205785
Viewable hack not needed now
Tuomo Valkonen <tuomov@iki.fi>
parents:
159
diff
changeset
|
521 | S: Storage<E, M>, |
|
124
6aa955ad8122
Transpose loc parameters to allow f64 defaults
Tuomo Valkonen <tuomov@iki.fi>
parents:
70
diff
changeset
|
522 | E: Float + Scalar + Zero + One + RealField, |
|
6aa955ad8122
Transpose loc parameters to allow f64 defaults
Tuomo Valkonen <tuomov@iki.fi>
parents:
70
diff
changeset
|
523 | DefaultAllocator: Allocator<M>, |
| 159 | 524 | ShapeConstraint: StridesOk<E, M, U1, S>, |
|
124
6aa955ad8122
Transpose loc parameters to allow f64 defaults
Tuomo Valkonen <tuomov@iki.fi>
parents:
70
diff
changeset
|
525 | { |
| 0 | 526 | #[inline] |
|
124
6aa955ad8122
Transpose loc parameters to allow f64 defaults
Tuomo Valkonen <tuomov@iki.fi>
parents:
70
diff
changeset
|
527 | fn norm(&self, _: L2) -> E { |
| 70 | 528 | nalgebra::Norm::norm(&LpNorm(2), self) |
| 0 | 529 | } |
| 530 | } | |
| 531 | ||
|
145
0b9aecd7bb76
Dist argument order changed to reflect other changes
Tuomo Valkonen <tuomov@iki.fi>
parents:
138
diff
changeset
|
532 | impl<E, M, S> Dist<L2, E> for Vector<E, M, S> |
|
124
6aa955ad8122
Transpose loc parameters to allow f64 defaults
Tuomo Valkonen <tuomov@iki.fi>
parents:
70
diff
changeset
|
533 | where |
|
6aa955ad8122
Transpose loc parameters to allow f64 defaults
Tuomo Valkonen <tuomov@iki.fi>
parents:
70
diff
changeset
|
534 | M: Dim, |
|
160
e7920e205785
Viewable hack not needed now
Tuomo Valkonen <tuomov@iki.fi>
parents:
159
diff
changeset
|
535 | S: Storage<E, M> + Clone, |
|
124
6aa955ad8122
Transpose loc parameters to allow f64 defaults
Tuomo Valkonen <tuomov@iki.fi>
parents:
70
diff
changeset
|
536 | E: Float + Scalar + Zero + One + RealField, |
|
6aa955ad8122
Transpose loc parameters to allow f64 defaults
Tuomo Valkonen <tuomov@iki.fi>
parents:
70
diff
changeset
|
537 | DefaultAllocator: Allocator<M>, |
| 159 | 538 | ShapeConstraint: StridesOk<E, M, U1, S>, |
|
124
6aa955ad8122
Transpose loc parameters to allow f64 defaults
Tuomo Valkonen <tuomov@iki.fi>
parents:
70
diff
changeset
|
539 | { |
| 0 | 540 | #[inline] |
|
124
6aa955ad8122
Transpose loc parameters to allow f64 defaults
Tuomo Valkonen <tuomov@iki.fi>
parents:
70
diff
changeset
|
541 | fn dist<I: Instance<Self>>(&self, other: I, _: L2) -> E { |
| 158 | 542 | other.eval_ref_decompose(|ref r| nalgebra::Norm::metric_distance(&LpNorm(2), self, r)) |
| 0 | 543 | } |
| 544 | } | |
| 545 | ||
|
124
6aa955ad8122
Transpose loc parameters to allow f64 defaults
Tuomo Valkonen <tuomov@iki.fi>
parents:
70
diff
changeset
|
546 | impl<E, M, S> Norm<Linfinity, E> for Vector<E, M, S> |
|
6aa955ad8122
Transpose loc parameters to allow f64 defaults
Tuomo Valkonen <tuomov@iki.fi>
parents:
70
diff
changeset
|
547 | where |
|
6aa955ad8122
Transpose loc parameters to allow f64 defaults
Tuomo Valkonen <tuomov@iki.fi>
parents:
70
diff
changeset
|
548 | M: Dim, |
|
160
e7920e205785
Viewable hack not needed now
Tuomo Valkonen <tuomov@iki.fi>
parents:
159
diff
changeset
|
549 | S: Storage<E, M>, |
|
124
6aa955ad8122
Transpose loc parameters to allow f64 defaults
Tuomo Valkonen <tuomov@iki.fi>
parents:
70
diff
changeset
|
550 | E: Float + Scalar + Zero + One + RealField, |
|
6aa955ad8122
Transpose loc parameters to allow f64 defaults
Tuomo Valkonen <tuomov@iki.fi>
parents:
70
diff
changeset
|
551 | DefaultAllocator: Allocator<M>, |
| 159 | 552 | ShapeConstraint: StridesOk<E, M, U1, S>, |
|
124
6aa955ad8122
Transpose loc parameters to allow f64 defaults
Tuomo Valkonen <tuomov@iki.fi>
parents:
70
diff
changeset
|
553 | { |
| 0 | 554 | #[inline] |
|
124
6aa955ad8122
Transpose loc parameters to allow f64 defaults
Tuomo Valkonen <tuomov@iki.fi>
parents:
70
diff
changeset
|
555 | fn norm(&self, _: Linfinity) -> E { |
| 70 | 556 | nalgebra::Norm::norm(&UniformNorm, self) |
| 0 | 557 | } |
| 558 | } | |
| 559 | ||
|
145
0b9aecd7bb76
Dist argument order changed to reflect other changes
Tuomo Valkonen <tuomov@iki.fi>
parents:
138
diff
changeset
|
560 | impl<E, M, S> Dist<Linfinity, E> for Vector<E, M, S> |
|
124
6aa955ad8122
Transpose loc parameters to allow f64 defaults
Tuomo Valkonen <tuomov@iki.fi>
parents:
70
diff
changeset
|
561 | where |
|
6aa955ad8122
Transpose loc parameters to allow f64 defaults
Tuomo Valkonen <tuomov@iki.fi>
parents:
70
diff
changeset
|
562 | M: Dim, |
|
160
e7920e205785
Viewable hack not needed now
Tuomo Valkonen <tuomov@iki.fi>
parents:
159
diff
changeset
|
563 | S: Storage<E, M> + Clone, |
|
124
6aa955ad8122
Transpose loc parameters to allow f64 defaults
Tuomo Valkonen <tuomov@iki.fi>
parents:
70
diff
changeset
|
564 | E: Float + Scalar + Zero + One + RealField, |
|
6aa955ad8122
Transpose loc parameters to allow f64 defaults
Tuomo Valkonen <tuomov@iki.fi>
parents:
70
diff
changeset
|
565 | DefaultAllocator: Allocator<M>, |
| 159 | 566 | ShapeConstraint: StridesOk<E, M, U1, S>, |
|
124
6aa955ad8122
Transpose loc parameters to allow f64 defaults
Tuomo Valkonen <tuomov@iki.fi>
parents:
70
diff
changeset
|
567 | { |
| 0 | 568 | #[inline] |
|
124
6aa955ad8122
Transpose loc parameters to allow f64 defaults
Tuomo Valkonen <tuomov@iki.fi>
parents:
70
diff
changeset
|
569 | fn dist<I: Instance<Self>>(&self, other: I, _: Linfinity) -> E { |
| 158 | 570 | other.eval_ref_decompose(|ref r| nalgebra::Norm::metric_distance(&UniformNorm, self, r)) |
| 0 | 571 | } |
| 572 | } | |
| 573 | ||
| 5 | 574 | /// Helper trait to hide the symbols of [`nalgebra::RealField`]. |
| 575 | /// | |
| 576 | /// By assuming `ToNalgebraRealField` intead of `nalgebra::RealField` as a trait bound, | |
| 577 | /// functions can piggyback `nalgebra::RealField` without exponsing themselves to it. | |
| 578 | /// Thus methods from [`num_traits`] can be used directly without similarly named methods | |
| 579 | /// from [`nalgebra`] conflicting with them. Only when absolutely necessary to work with | |
| 580 | /// nalgebra, one can convert to the nalgebra view of the same type using the methods of | |
| 581 | /// this trait. | |
|
124
6aa955ad8122
Transpose loc parameters to allow f64 defaults
Tuomo Valkonen <tuomov@iki.fi>
parents:
70
diff
changeset
|
582 | pub trait ToNalgebraRealField: Float { |
| 5 | 583 | /// The nalgebra type corresponding to this type. Usually same as `Self`. |
| 584 | /// | |
| 585 | /// This type only carries `nalgebra` traits. | |
|
124
6aa955ad8122
Transpose loc parameters to allow f64 defaults
Tuomo Valkonen <tuomov@iki.fi>
parents:
70
diff
changeset
|
586 | type NalgebraType: RealField; |
| 5 | 587 | /// The “mixed” type corresponding to this type. Usually same as `Self`. |
| 588 | /// | |
| 589 | /// This type carries both `num_traits` and `nalgebra` traits. | |
|
124
6aa955ad8122
Transpose loc parameters to allow f64 defaults
Tuomo Valkonen <tuomov@iki.fi>
parents:
70
diff
changeset
|
590 | type MixedType: RealField + Float; |
| 0 | 591 | |
| 5 | 592 | /// Convert to the nalgebra view of `self`. |
| 0 | 593 | fn to_nalgebra(self) -> Self::NalgebraType; |
| 5 | 594 | |
| 595 | /// Convert to the mixed (nalgebra and num_traits) view of `self`. | |
| 0 | 596 | fn to_nalgebra_mixed(self) -> Self::MixedType; |
| 597 | ||
| 5 | 598 | /// Convert from the nalgebra view of `self`. |
|
124
6aa955ad8122
Transpose loc parameters to allow f64 defaults
Tuomo Valkonen <tuomov@iki.fi>
parents:
70
diff
changeset
|
599 | fn from_nalgebra(t: Self::NalgebraType) -> Self; |
| 5 | 600 | |
| 601 | /// Convert from the mixed (nalgebra and num_traits) view to `self`. | |
|
124
6aa955ad8122
Transpose loc parameters to allow f64 defaults
Tuomo Valkonen <tuomov@iki.fi>
parents:
70
diff
changeset
|
602 | fn from_nalgebra_mixed(t: Self::MixedType) -> Self; |
| 0 | 603 | } |
| 604 | ||
| 605 | impl ToNalgebraRealField for f32 { | |
| 606 | type NalgebraType = f32; | |
| 607 | type MixedType = f32; | |
| 608 | ||
| 609 | #[inline] | |
|
124
6aa955ad8122
Transpose loc parameters to allow f64 defaults
Tuomo Valkonen <tuomov@iki.fi>
parents:
70
diff
changeset
|
610 | fn to_nalgebra(self) -> Self::NalgebraType { |
|
6aa955ad8122
Transpose loc parameters to allow f64 defaults
Tuomo Valkonen <tuomov@iki.fi>
parents:
70
diff
changeset
|
611 | self |
|
6aa955ad8122
Transpose loc parameters to allow f64 defaults
Tuomo Valkonen <tuomov@iki.fi>
parents:
70
diff
changeset
|
612 | } |
| 0 | 613 | |
| 614 | #[inline] | |
|
124
6aa955ad8122
Transpose loc parameters to allow f64 defaults
Tuomo Valkonen <tuomov@iki.fi>
parents:
70
diff
changeset
|
615 | fn to_nalgebra_mixed(self) -> Self::MixedType { |
|
6aa955ad8122
Transpose loc parameters to allow f64 defaults
Tuomo Valkonen <tuomov@iki.fi>
parents:
70
diff
changeset
|
616 | self |
|
6aa955ad8122
Transpose loc parameters to allow f64 defaults
Tuomo Valkonen <tuomov@iki.fi>
parents:
70
diff
changeset
|
617 | } |
| 0 | 618 | |
| 619 | #[inline] | |
|
124
6aa955ad8122
Transpose loc parameters to allow f64 defaults
Tuomo Valkonen <tuomov@iki.fi>
parents:
70
diff
changeset
|
620 | fn from_nalgebra(t: Self::NalgebraType) -> Self { |
|
6aa955ad8122
Transpose loc parameters to allow f64 defaults
Tuomo Valkonen <tuomov@iki.fi>
parents:
70
diff
changeset
|
621 | t |
|
6aa955ad8122
Transpose loc parameters to allow f64 defaults
Tuomo Valkonen <tuomov@iki.fi>
parents:
70
diff
changeset
|
622 | } |
| 0 | 623 | |
|
124
6aa955ad8122
Transpose loc parameters to allow f64 defaults
Tuomo Valkonen <tuomov@iki.fi>
parents:
70
diff
changeset
|
624 | #[inline] |
|
6aa955ad8122
Transpose loc parameters to allow f64 defaults
Tuomo Valkonen <tuomov@iki.fi>
parents:
70
diff
changeset
|
625 | fn from_nalgebra_mixed(t: Self::MixedType) -> Self { |
|
6aa955ad8122
Transpose loc parameters to allow f64 defaults
Tuomo Valkonen <tuomov@iki.fi>
parents:
70
diff
changeset
|
626 | t |
|
6aa955ad8122
Transpose loc parameters to allow f64 defaults
Tuomo Valkonen <tuomov@iki.fi>
parents:
70
diff
changeset
|
627 | } |
| 0 | 628 | } |
| 629 | ||
| 630 | impl ToNalgebraRealField for f64 { | |
| 631 | type NalgebraType = f64; | |
| 632 | type MixedType = f64; | |
| 633 | ||
| 634 | #[inline] | |
|
124
6aa955ad8122
Transpose loc parameters to allow f64 defaults
Tuomo Valkonen <tuomov@iki.fi>
parents:
70
diff
changeset
|
635 | fn to_nalgebra(self) -> Self::NalgebraType { |
|
6aa955ad8122
Transpose loc parameters to allow f64 defaults
Tuomo Valkonen <tuomov@iki.fi>
parents:
70
diff
changeset
|
636 | self |
|
6aa955ad8122
Transpose loc parameters to allow f64 defaults
Tuomo Valkonen <tuomov@iki.fi>
parents:
70
diff
changeset
|
637 | } |
| 0 | 638 | |
| 639 | #[inline] | |
|
124
6aa955ad8122
Transpose loc parameters to allow f64 defaults
Tuomo Valkonen <tuomov@iki.fi>
parents:
70
diff
changeset
|
640 | fn to_nalgebra_mixed(self) -> Self::MixedType { |
|
6aa955ad8122
Transpose loc parameters to allow f64 defaults
Tuomo Valkonen <tuomov@iki.fi>
parents:
70
diff
changeset
|
641 | self |
|
6aa955ad8122
Transpose loc parameters to allow f64 defaults
Tuomo Valkonen <tuomov@iki.fi>
parents:
70
diff
changeset
|
642 | } |
| 0 | 643 | |
| 644 | #[inline] | |
|
124
6aa955ad8122
Transpose loc parameters to allow f64 defaults
Tuomo Valkonen <tuomov@iki.fi>
parents:
70
diff
changeset
|
645 | fn from_nalgebra(t: Self::NalgebraType) -> Self { |
|
6aa955ad8122
Transpose loc parameters to allow f64 defaults
Tuomo Valkonen <tuomov@iki.fi>
parents:
70
diff
changeset
|
646 | t |
|
6aa955ad8122
Transpose loc parameters to allow f64 defaults
Tuomo Valkonen <tuomov@iki.fi>
parents:
70
diff
changeset
|
647 | } |
| 0 | 648 | |
| 649 | #[inline] | |
|
124
6aa955ad8122
Transpose loc parameters to allow f64 defaults
Tuomo Valkonen <tuomov@iki.fi>
parents:
70
diff
changeset
|
650 | fn from_nalgebra_mixed(t: Self::MixedType) -> Self { |
|
6aa955ad8122
Transpose loc parameters to allow f64 defaults
Tuomo Valkonen <tuomov@iki.fi>
parents:
70
diff
changeset
|
651 | t |
|
6aa955ad8122
Transpose loc parameters to allow f64 defaults
Tuomo Valkonen <tuomov@iki.fi>
parents:
70
diff
changeset
|
652 | } |
| 0 | 653 | } |