fix wide_dot and wide_length_squared
This commit is contained in:
parent
d38d103399
commit
3ccc19f768
@ -11,15 +11,15 @@ macro_rules! impl_wide_operations {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
impl<T:Copy+fixed_wide::wide::WideMul<Output=T>+std::ops::Add<Output=T>> $struct<T> {
|
impl<U:std::ops::Add<Output=U>,T:Copy+fixed_wide::wide::WideMul<Output=U>> $struct<T> {
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn wide_dot(&self, other: &Self) -> <T as fixed_wide::wide::WideMul>::Output {
|
pub fn wide_dot(self, other: Self) -> U {
|
||||||
$crate::sum_repeating!(
|
$crate::sum_repeating!(
|
||||||
$( + (self.$field.wide_mul(other.$field)) ) +
|
$( + (self.$field.wide_mul(other.$field)) ) +
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
pub fn length_squared(&self) -> <T as fixed_wide::wide::WideMul>::Output {
|
pub fn wide_length_squared(&self) -> U {
|
||||||
let squared = Self {
|
let squared = $struct {
|
||||||
$( $field: self.$field.wide_mul(self.$field) ), +
|
$( $field: self.$field.wide_mul(self.$field) ), +
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -34,3 +34,23 @@ fn wide_vec3(){
|
|||||||
|
|
||||||
assert_eq!(v3,Vector3::from_value(Planar64Wide3::from(3i128.pow(8))));
|
assert_eq!(v3,Vector3::from_value(Planar64Wide3::from(3i128.pow(8))));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn wide_vec3_dot(){
|
||||||
|
let v=Vector3::from_value(Planar64::from(3));
|
||||||
|
let v1=v.wide_mul(v);
|
||||||
|
let v2=v1.wide_mul(v1);
|
||||||
|
let v3=v2.wide_dot(v2);
|
||||||
|
|
||||||
|
assert_eq!(v3,Planar64Wide3::from(3i128.pow(8)*3));
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn wide_vec3_length_squared(){
|
||||||
|
let v=Vector3::from_value(Planar64::from(3));
|
||||||
|
let v1=v.wide_mul(v);
|
||||||
|
let v2=v1.wide_mul(v1);
|
||||||
|
let v3=v2.wide_length_squared();
|
||||||
|
|
||||||
|
assert_eq!(v3,Planar64Wide3::from(3i128.pow(8)*3));
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user