@@ -292,6 +292,42 @@ vec_abs(const G3VectorQuat &a)
292292 return out;
293293}
294294
295+ static G3VectorDouble
296+ vec_norm (const G3VectorQuat &a)
297+ {
298+ G3VectorDouble out (a.size ());
299+ for (unsigned i = 0 ; i < a.size (); i++)
300+ out[i] = a[i].norm ();
301+ return out;
302+ }
303+
304+ static G3VectorDouble
305+ vec_vnorm (const G3VectorQuat &a)
306+ {
307+ G3VectorDouble out (a.size ());
308+ for (unsigned i = 0 ; i < a.size (); i++)
309+ out[i] = a[i].vnorm ();
310+ return out;
311+ }
312+
313+ static G3VectorDouble
314+ vec_dot3 (const G3VectorQuat &a, const Quat &q)
315+ {
316+ G3VectorDouble out (a.size ());
317+ for (unsigned i = 0 ; i < a.size (); i++)
318+ out[i] = a[i].dot3 (q);
319+ return out;
320+ }
321+
322+ static G3VectorQuat
323+ vec_cross3 (const G3VectorQuat &a, const Quat &q)
324+ {
325+ G3VectorQuat out (a.size ());
326+ for (unsigned i = 0 ; i < a.size (); i++)
327+ out[i] = a[i].cross3 (q);
328+ return out;
329+ }
330+
295331static G3VectorQuat
296332vec_neg (const G3VectorQuat &a)
297333{
@@ -317,6 +353,46 @@ ts_abs(const G3TimestreamQuat &a)
317353 return out;
318354}
319355
356+ static G3Timestream
357+ ts_norm (const G3TimestreamQuat &a)
358+ {
359+ G3Timestream out (a.size ());
360+ out.start = a.start ; out.stop = a.stop ;
361+ for (unsigned i = 0 ; i < a.size (); i++)
362+ out[i] = a[i].norm ();
363+ return out;
364+ }
365+
366+ static G3Timestream
367+ ts_vnorm (const G3TimestreamQuat &a)
368+ {
369+ G3Timestream out (a.size ());
370+ out.start = a.start ; out.stop = a.stop ;
371+ for (unsigned i = 0 ; i < a.size (); i++)
372+ out[i] = a[i].vnorm ();
373+ return out;
374+ }
375+
376+ static G3Timestream
377+ ts_dot3 (const G3TimestreamQuat &a, const Quat &q)
378+ {
379+ G3Timestream out (a.size ());
380+ out.start = a.start ; out.stop = a.stop ;
381+ for (unsigned i = 0 ; i < a.size (); i++)
382+ out[i] = a[i].dot3 (q);
383+ return out;
384+ }
385+
386+ static G3TimestreamQuat
387+ ts_cross3 (const G3TimestreamQuat &a, const Quat &q)
388+ {
389+ G3TimestreamQuat out (a.size ());
390+ out.start = a.start ; out.stop = a.stop ;
391+ for (unsigned i = 0 ; i < a.size (); i++)
392+ out[i] = a[i].cross3 (q);
393+ return out;
394+ }
395+
320396static G3Timestream
321397ts_real (const G3TimestreamQuat &a)
322398{
@@ -877,7 +953,7 @@ PYBINDINGS("core", scope)
877953 .def (" __str__" , quat_str)
878954 .def (" __repr__" , quat_repr)
879955 .def (" norm" , &Quat::norm, " Return the Cayley norm of the quaternion" )
880- .def (" vnorm" , &Quat::norm , " Return the Cayley norm of the "
956+ .def (" vnorm" , &Quat::vnorm , " Return the Cayley norm of the "
881957 " unreal (vector) part of the quaternion" )
882958 .def (" abs" , &Quat::abs, " Return the Euclidean norm of the quaternion" )
883959 .def (" dot3" , &Quat::dot3, " Dot product of last three entries" )
@@ -917,6 +993,10 @@ PYBINDINGS("core", scope)
917993 .def (" __abs__" , vec_abs)
918994 .def (" __neg__" , vec_neg)
919995 .def (" abs" , vec_abs, " Return the Euclidean norm of each quaternion" )
996+ .def (" norm" , &vec_norm, " Return the Cayley norm of each quaternion" )
997+ .def (" vnorm" , &vec_vnorm, " Return the Cayley norm of the unreal (vector) part of each quaternion" )
998+ .def (" dot3" , &vec_dot3, " Dot product of last three entries of each quaternion with the input" )
999+ .def (" cross3" , &vec_cross3, " Cross product of last three entries of each quaternion with the input" )
9201000 .def_property_readonly (" real" , vec_real,
9211001 " Return the real (scalar) part of each quaternion" )
9221002 ;
@@ -946,6 +1026,10 @@ PYBINDINGS("core", scope)
9461026 .def (" __abs__" , ts_abs)
9471027 .def (" __neg__" , ts_neg)
9481028 .def (" abs" , ts_abs, " Return the Euclidean norm of each quaternion" )
1029+ .def (" norm" , &ts_norm, " Return the Cayley norm of each quaternion" )
1030+ .def (" vnorm" , &ts_vnorm, " Return the Cayley norm of the unreal (vector) part of each quaternion" )
1031+ .def (" dot3" , &ts_dot3, " Dot product of last three entries of each quaternion with the input" )
1032+ .def (" cross3" , &ts_cross3, " Cross product of last three entries of each quaternion with the input" )
9491033 .def_property_readonly (" real" , ts_real,
9501034 " Return the real (scalar) part of each quaternion" )
9511035 .def_readwrite (" start" , &G3TimestreamQuat::start,
0 commit comments