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