holy wide dot batman

This commit is contained in:
Quaternions 2024-08-28 10:04:58 -07:00
parent 4ae391e9fd
commit e1368962c1
2 changed files with 10 additions and 5 deletions

View File

@ -11,13 +11,17 @@ macro_rules! impl_wide_operations {
} }
} }
} }
impl<U:std::ops::Add<Output=U>,T:Copy+fixed_wide_traits::wide::WideMul<Output=U>> $struct<T> { impl<V:core::ops::Add<Output=V>,U,T:fixed_wide_traits::wide::WideMul<U,Output=V>> fixed_wide_traits::wide::WideDot<$struct<U>> for $struct<T> {
type Output=V;
#[inline] #[inline]
pub fn wide_dot(self, other: Self) -> U { fn wide_dot(self, rhs: $struct<U>) -> Self::Output {
$crate::sum_repeating!( $crate::sum_repeating!(
$( + (self.$field.wide_mul(other.$field)) ) + $( + (self.$field.wide_mul(rhs.$field)) ) +
) )
} }
}
impl<U:std::ops::Add<Output=U>,T:Copy+fixed_wide_traits::wide::WideMul<Output=U>> $struct<T> {
#[inline]
pub fn wide_length_squared(&self) -> U { pub fn wide_length_squared(&self) -> U {
let squared = $struct { let squared = $struct {
$( $field: self.$field.wide_mul(self.$field) ), + $( $field: self.$field.wide_mul(self.$field) ), +

View File

@ -1,4 +1,5 @@
use fixed_wide_traits::wide::WideMul; use fixed_wide_traits::wide::WideMul;
use fixed_wide_traits::wide::WideDot;
use crate::Vector3; use crate::Vector3;