src/nalgebra_support.rs

branch
dev
changeset 63
f7b87d84864d
parent 62
d8305c9b6fdf
child 64
4f6ca107ccb1
equal deleted inserted replaced
62:d8305c9b6fdf 63:f7b87d84864d
1 /*! 1 /*!
2 Integration with nalgebra. 2 Integration with nalgebra.
3 3
4 This module mainly implements [`Euclidean`], [`Norm`], [`Dot`], [`Linear`], etc. for [`nalgebra`] 4 This module mainly implements [`Euclidean`], [`Norm`], [`Linear`], etc. for [`nalgebra`]
5 matrices and vectors. 5 matrices and vectors.
6 It also provides [`ToNalgebraRealField`] as a vomit-inducingly ugly workaround to nalgebra 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 7 force-feeding its own versions of the same basic mathematical methods on `f32` and `f64` as
8 [`num_traits`] does. 8 [`num_traits`] does.
9 */ 9 */
148 type Adjoint<'a> = OMatrix<E,M,N> where SM : 'a; 148 type Adjoint<'a> = OMatrix<E,M,N> where SM : 'a;
149 149
150 #[inline] 150 #[inline]
151 fn adjoint(&self) -> Self::Adjoint<'_> { 151 fn adjoint(&self) -> Self::Adjoint<'_> {
152 Matrix::adjoint(self) 152 Matrix::adjoint(self)
153 }
154 }
155
156 impl<E,M,S,Si> Dot<Vector<E,M,Si>,E>
157 for Vector<E,M,S>
158 where M : Dim,
159 E : Float + Scalar + Zero + One,
160 S : Storage<E,M>,
161 Si : Storage<E,M>,
162 DefaultAllocator : Allocator<M> {
163
164 #[inline]
165 fn dot(&self, other : &Vector<E,M,Si>) -> E {
166 Vector::<E,M,S>::dot(self, other)
167 } 153 }
168 } 154 }
169 155
170 /// This function is [`nalgebra::EuclideanNorm::metric_distance`] without the `sqrt`. 156 /// This function is [`nalgebra::EuclideanNorm::metric_distance`] without the `sqrt`.
171 #[inline] 157 #[inline]
198 S : StorageMut<E,M> + Clone, 184 S : StorageMut<E,M> + Clone,
199 E : Float + Scalar + Zero + One + RealField, 185 E : Float + Scalar + Zero + One + RealField,
200 DefaultAllocator : Allocator<M> { 186 DefaultAllocator : Allocator<M> {
201 187
202 type Output = OVector<E, M>; 188 type Output = OVector<E, M>;
203 189
190 #[inline]
191 fn dot<I : Instance<Self>>(&self, other : I) -> E {
192 Vector::<E,M,S>::dot(self, other.ref_instance())
193 }
194
204 #[inline] 195 #[inline]
205 fn norm2_squared(&self) -> E { 196 fn norm2_squared(&self) -> E {
206 Vector::<E,M,S>::norm_squared(self) 197 Vector::<E,M,S>::norm_squared(self)
207 } 198 }
208 199

mercurial