src/nalgebra_support.rs

branch
dev
changeset 62
d8305c9b6fdf
parent 60
848ecc05becf
child 63
f7b87d84864d
--- a/src/nalgebra_support.rs	Tue Dec 31 08:30:43 2024 -0500
+++ b/src/nalgebra_support.rs	Sat Dec 21 23:32:20 2024 -0500
@@ -89,6 +89,7 @@
 where SM: StorageMut<E,M> + Clone, SV1: Storage<E,M> + Clone,
       M : Dim, E : Scalar + Zero + One + Float,
       DefaultAllocator : Allocator<M> {
+    type Owned = OVector<E, M>;
 
     #[inline]
     fn axpy<I : Instance<Vector<E,M,SV1>>>(&mut self, α : E, x : I, β : E) {
@@ -99,6 +100,16 @@
     fn copy_from<I : Instance<Vector<E,M,SV1>>>(&mut self, y : I) {
         y.eval(|ỹ| Matrix::copy_from(self, ỹ))
     }
+
+    #[inline]
+    fn set_zero(&mut self) {
+        self.iter_mut().for_each(|e| *e = E::ZERO);
+    }
+
+    #[inline]
+    fn similar_origin(&self) -> Self::Owned {
+        OVector::zeros_generic(M::from_usize(self.len()), Const)
+    }
 }
 
 /* Implemented automatically as Euclidean.
@@ -191,11 +202,6 @@
     type Output = OVector<E, M>;
     
     #[inline]
-    fn similar_origin(&self) -> OVector<E, M> {
-        OVector::zeros_generic(M::from_usize(self.len()), Const)
-    }
-
-    #[inline]
     fn norm2_squared(&self) -> E {
         Vector::<E,M,S>::norm_squared(self)
     }

mercurial