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