"Replaced" Scalar{Add, Sub, Mul, Div} by operator overloading.

Those traits are not really removed since rust cannot handle those multiple operator overloading
very well yet, making them sometimes unuseable on generic code.
This commit is contained in:
Sébastien Crozet 2013-09-14 21:11:43 +02:00
parent e3a1d56e58
commit 514bf74efe
11 changed files with 1261 additions and 408 deletions

View File

@ -9,7 +9,6 @@ use traits::dot::Dot;
use traits::norm::Norm; use traits::norm::Norm;
use traits::iterable::{Iterable, IterableMut}; use traits::iterable::{Iterable, IterableMut};
use traits::translation::Translation; use traits::translation::Translation;
use traits::scalar_op::{ScalarAdd, ScalarSub};
/// Vector with a dimension unknown at compile-time. /// Vector with a dimension unknown at compile-time.
#[deriving(Eq, ToStr, Clone)] #[deriving(Eq, ToStr, Clone)]
@ -246,34 +245,6 @@ impl<N: Div<N, N>> Div<N, DVec<N>> for DVec<N> {
} }
} }
impl<N: Add<N, N>> ScalarAdd<N> for DVec<N> {
#[inline]
fn scalar_add(&self, s: &N) -> DVec<N> {
DVec { at: self.at.iter().map(|a| a + *s).collect() }
}
#[inline]
fn scalar_add_inplace(&mut self, s: &N) {
for i in range(0u, self.at.len()) {
self.at[i] = self.at[i] + *s;
}
}
}
impl<N: Sub<N, N>> ScalarSub<N> for DVec<N> {
#[inline]
fn scalar_sub(&self, s: &N) -> DVec<N> {
DVec { at: self.at.iter().map(|a| a - *s).collect() }
}
#[inline]
fn scalar_sub_inplace(&mut self, s: &N) {
for i in range(0u, self.at.len()) {
self.at[i] = self.at[i] - *s;
}
}
}
impl<N: Add<N, N> + Neg<N> + Clone> Translation<DVec<N>> for DVec<N> { impl<N: Add<N, N> + Neg<N> + Clone> Translation<DVec<N>> for DVec<N> {
#[inline] #[inline]
fn translation(&self) -> DVec<N> { fn translation(&self) -> DVec<N> {

View File

@ -30,6 +30,7 @@ pub use traits::comp::absolute_rotate::AbsoluteRotate;
// structs // structs
pub use dmat::DMat; pub use dmat::DMat;
mod metal;
mod mat_macros; mod mat_macros;
/// Special identity matrix. All its operation are no-ops. /// Special identity matrix. All its operation are no-ops.
@ -55,14 +56,74 @@ pub struct Mat1<N> {
} }
double_dispatch_binop_decl_trait!(Mat1, Mat1MulRhs) double_dispatch_binop_decl_trait!(Mat1, Mat1MulRhs)
double_dispatch_binop_decl_trait!(Mat1, Mat1DivRhs)
double_dispatch_binop_decl_trait!(Mat1, Mat1AddRhs)
double_dispatch_binop_decl_trait!(Mat1, Mat1SubRhs)
mul_redispatch_impl!(Mat1, Mat1MulRhs)
div_redispatch_impl!(Mat1, Mat1DivRhs)
add_redispatch_impl!(Mat1, Mat1AddRhs)
sub_redispatch_impl!(Mat1, Mat1SubRhs)
mat_impl!(Mat1, m11) mat_impl!(Mat1, m11)
mat_cast_impl!(Mat1, m11) mat_cast_impl!(Mat1, m11)
add_impl!(Mat1, m11) add_impl!(Mat1, Mat1AddRhs, m11)
sub_impl!(Mat1, m11) sub_impl!(Mat1, Mat1SubRhs, m11)
scalar_mul_impl!(Mat1, m11)
scalar_div_impl!(Mat1, m11) scalar_mul_impl!(Mat1, f64, Mat1MulRhs, m11)
scalar_add_impl!(Mat1, m11) scalar_mul_impl!(Mat1, f32, Mat1MulRhs, m11)
scalar_sub_impl!(Mat1, m11) scalar_mul_impl!(Mat1, i64, Mat1MulRhs, m11)
scalar_mul_impl!(Mat1, i32, Mat1MulRhs, m11)
scalar_mul_impl!(Mat1, i16, Mat1MulRhs, m11)
scalar_mul_impl!(Mat1, i8, Mat1MulRhs, m11)
scalar_mul_impl!(Mat1, u64, Mat1MulRhs, m11)
scalar_mul_impl!(Mat1, u32, Mat1MulRhs, m11)
scalar_mul_impl!(Mat1, u16, Mat1MulRhs, m11)
scalar_mul_impl!(Mat1, u8, Mat1MulRhs, m11)
scalar_mul_impl!(Mat1, float, Mat1MulRhs, m11)
scalar_mul_impl!(Mat1, uint, Mat1MulRhs, m11)
scalar_mul_impl!(Mat1, int, Mat1MulRhs, m11)
scalar_div_impl!(Mat1, f64, Mat1DivRhs, m11)
scalar_div_impl!(Mat1, f32, Mat1DivRhs, m11)
scalar_div_impl!(Mat1, i64, Mat1DivRhs, m11)
scalar_div_impl!(Mat1, i32, Mat1DivRhs, m11)
scalar_div_impl!(Mat1, i16, Mat1DivRhs, m11)
scalar_div_impl!(Mat1, i8, Mat1DivRhs, m11)
scalar_div_impl!(Mat1, u64, Mat1DivRhs, m11)
scalar_div_impl!(Mat1, u32, Mat1DivRhs, m11)
scalar_div_impl!(Mat1, u16, Mat1DivRhs, m11)
scalar_div_impl!(Mat1, u8, Mat1DivRhs, m11)
scalar_div_impl!(Mat1, float, Mat1DivRhs, m11)
scalar_div_impl!(Mat1, uint, Mat1DivRhs, m11)
scalar_div_impl!(Mat1, int, Mat1DivRhs, m11)
scalar_add_impl!(Mat1, f64, Mat1AddRhs, m11)
scalar_add_impl!(Mat1, f32, Mat1AddRhs, m11)
scalar_add_impl!(Mat1, i64, Mat1AddRhs, m11)
scalar_add_impl!(Mat1, i32, Mat1AddRhs, m11)
scalar_add_impl!(Mat1, i16, Mat1AddRhs, m11)
scalar_add_impl!(Mat1, i8, Mat1AddRhs, m11)
scalar_add_impl!(Mat1, u64, Mat1AddRhs, m11)
scalar_add_impl!(Mat1, u32, Mat1AddRhs, m11)
scalar_add_impl!(Mat1, u16, Mat1AddRhs, m11)
scalar_add_impl!(Mat1, u8, Mat1AddRhs, m11)
scalar_add_impl!(Mat1, float, Mat1AddRhs, m11)
scalar_add_impl!(Mat1, uint, Mat1AddRhs, m11)
scalar_add_impl!(Mat1, int, Mat1AddRhs, m11)
scalar_sub_impl!(Mat1, f64, Mat1SubRhs, m11)
scalar_sub_impl!(Mat1, f32, Mat1SubRhs, m11)
scalar_sub_impl!(Mat1, i64, Mat1SubRhs, m11)
scalar_sub_impl!(Mat1, i32, Mat1SubRhs, m11)
scalar_sub_impl!(Mat1, i16, Mat1SubRhs, m11)
scalar_sub_impl!(Mat1, i8, Mat1SubRhs, m11)
scalar_sub_impl!(Mat1, u64, Mat1SubRhs, m11)
scalar_sub_impl!(Mat1, u32, Mat1SubRhs, m11)
scalar_sub_impl!(Mat1, u16, Mat1SubRhs, m11)
scalar_sub_impl!(Mat1, u8, Mat1SubRhs, m11)
scalar_sub_impl!(Mat1, float, Mat1SubRhs, m11)
scalar_sub_impl!(Mat1, uint, Mat1SubRhs, m11)
scalar_sub_impl!(Mat1, int, Mat1SubRhs, m11)
absolute_impl!(Mat1, m11) absolute_impl!(Mat1, m11)
one_impl!(Mat1, One::one) one_impl!(Mat1, One::one)
iterable_impl!(Mat1, 1) iterable_impl!(Mat1, 1)
@ -70,10 +131,9 @@ iterable_mut_impl!(Mat1, 1)
at_fast_impl!(Mat1, 1) at_fast_impl!(Mat1, 1)
dim_impl!(Mat1, 1) dim_impl!(Mat1, 1)
indexable_impl!(Mat1, 1) indexable_impl!(Mat1, 1)
mul_redispatch_impl!(Mat1, Mat1MulRhs)
mat_mul_mat_impl!(Mat1, Mat1MulRhs, 1) mat_mul_mat_impl!(Mat1, Mat1MulRhs, 1)
rmul_impl!(Mat1, Vec1, 1) rmul_impl!(Mat1, Vec1, 1)
lmul_impl!(Mat1, Vec1, 1) vec_mul_mat_impl!(Mat1, Vec1, Mat1MulRhs, 1)
transform_impl!(Mat1, Vec1) transform_impl!(Mat1, Vec1)
// (specialized) inv_impl!(Mat1, 1) // (specialized) inv_impl!(Mat1, 1)
transpose_impl!(Mat1, 1) transpose_impl!(Mat1, 1)
@ -92,22 +152,77 @@ pub struct Mat2<N> {
m21: N, m22: N m21: N, m22: N
} }
double_dispatch_binop_decl_trait!(Mat2, Mat2MulRhs)
double_dispatch_binop_decl_trait!(Mat2, Mat2DivRhs)
double_dispatch_binop_decl_trait!(Mat2, Mat2AddRhs)
double_dispatch_binop_decl_trait!(Mat2, Mat2SubRhs)
mul_redispatch_impl!(Mat2, Mat2MulRhs)
div_redispatch_impl!(Mat2, Mat2DivRhs)
add_redispatch_impl!(Mat2, Mat2AddRhs)
sub_redispatch_impl!(Mat2, Mat2SubRhs)
mat_impl!(Mat2, m11, m12, mat_impl!(Mat2, m11, m12,
m21, m22) m21, m22)
mat_cast_impl!(Mat2, m11, m12, mat_cast_impl!(Mat2, m11, m12,
m21, m22) m21, m22)
add_impl!(Mat2, m11, m12, add_impl!(Mat2, Mat2AddRhs, m11, m12, m21, m22)
m21, m22) sub_impl!(Mat2, Mat2SubRhs, m11, m12, m21, m22)
sub_impl!(Mat2, m11, m12,
m21, m22) scalar_mul_impl!(Mat2, f64, Mat2MulRhs, m11, m12, m21, m22)
scalar_mul_impl!(Mat2, m11, m12, scalar_mul_impl!(Mat2, f32, Mat2MulRhs, m11, m12, m21, m22)
m21, m22) scalar_mul_impl!(Mat2, i64, Mat2MulRhs, m11, m12, m21, m22)
scalar_div_impl!(Mat2, m11, m12, scalar_mul_impl!(Mat2, i32, Mat2MulRhs, m11, m12, m21, m22)
m21, m22) scalar_mul_impl!(Mat2, i16, Mat2MulRhs, m11, m12, m21, m22)
scalar_add_impl!(Mat2, m11, m12, scalar_mul_impl!(Mat2, i8, Mat2MulRhs, m11, m12, m21, m22)
m21, m22) scalar_mul_impl!(Mat2, u64, Mat2MulRhs, m11, m12, m21, m22)
scalar_sub_impl!(Mat2, m11, m12, scalar_mul_impl!(Mat2, u32, Mat2MulRhs, m11, m12, m21, m22)
m21, m22) scalar_mul_impl!(Mat2, u16, Mat2MulRhs, m11, m12, m21, m22)
scalar_mul_impl!(Mat2, u8, Mat2MulRhs, m11, m12, m21, m22)
scalar_mul_impl!(Mat2, float, Mat2MulRhs, m11, m12, m21, m22)
scalar_mul_impl!(Mat2, uint, Mat2MulRhs, m11, m12, m21, m22)
scalar_mul_impl!(Mat2, int, Mat2MulRhs, m11, m12, m21, m22)
scalar_div_impl!(Mat2, f64, Mat2DivRhs, m11, m12, m21, m22)
scalar_div_impl!(Mat2, f32, Mat2DivRhs, m11, m12, m21, m22)
scalar_div_impl!(Mat2, i64, Mat2DivRhs, m11, m12, m21, m22)
scalar_div_impl!(Mat2, i32, Mat2DivRhs, m11, m12, m21, m22)
scalar_div_impl!(Mat2, i16, Mat2DivRhs, m11, m12, m21, m22)
scalar_div_impl!(Mat2, i8, Mat2DivRhs, m11, m12, m21, m22)
scalar_div_impl!(Mat2, u64, Mat2DivRhs, m11, m12, m21, m22)
scalar_div_impl!(Mat2, u32, Mat2DivRhs, m11, m12, m21, m22)
scalar_div_impl!(Mat2, u16, Mat2DivRhs, m11, m12, m21, m22)
scalar_div_impl!(Mat2, u8, Mat2DivRhs, m11, m12, m21, m22)
scalar_div_impl!(Mat2, float, Mat2DivRhs, m11, m12, m21, m22)
scalar_div_impl!(Mat2, uint, Mat2DivRhs, m11, m12, m21, m22)
scalar_div_impl!(Mat2, int, Mat2DivRhs, m11, m12, m21, m22)
scalar_add_impl!(Mat2, f64, Mat2AddRhs, m11, m12, m21, m22)
scalar_add_impl!(Mat2, f32, Mat2AddRhs, m11, m12, m21, m22)
scalar_add_impl!(Mat2, i64, Mat2AddRhs, m11, m12, m21, m22)
scalar_add_impl!(Mat2, i32, Mat2AddRhs, m11, m12, m21, m22)
scalar_add_impl!(Mat2, i16, Mat2AddRhs, m11, m12, m21, m22)
scalar_add_impl!(Mat2, i8, Mat2AddRhs, m11, m12, m21, m22)
scalar_add_impl!(Mat2, u64, Mat2AddRhs, m11, m12, m21, m22)
scalar_add_impl!(Mat2, u32, Mat2AddRhs, m11, m12, m21, m22)
scalar_add_impl!(Mat2, u16, Mat2AddRhs, m11, m12, m21, m22)
scalar_add_impl!(Mat2, u8, Mat2AddRhs, m11, m12, m21, m22)
scalar_add_impl!(Mat2, float, Mat2AddRhs, m11, m12, m21, m22)
scalar_add_impl!(Mat2, uint, Mat2AddRhs, m11, m12, m21, m22)
scalar_add_impl!(Mat2, int, Mat2AddRhs, m11, m12, m21, m22)
scalar_sub_impl!(Mat2, f64, Mat2SubRhs, m11, m12, m21, m22)
scalar_sub_impl!(Mat2, f32, Mat2SubRhs, m11, m12, m21, m22)
scalar_sub_impl!(Mat2, i64, Mat2SubRhs, m11, m12, m21, m22)
scalar_sub_impl!(Mat2, i32, Mat2SubRhs, m11, m12, m21, m22)
scalar_sub_impl!(Mat2, i16, Mat2SubRhs, m11, m12, m21, m22)
scalar_sub_impl!(Mat2, i8, Mat2SubRhs, m11, m12, m21, m22)
scalar_sub_impl!(Mat2, u64, Mat2SubRhs, m11, m12, m21, m22)
scalar_sub_impl!(Mat2, u32, Mat2SubRhs, m11, m12, m21, m22)
scalar_sub_impl!(Mat2, u16, Mat2SubRhs, m11, m12, m21, m22)
scalar_sub_impl!(Mat2, u8, Mat2SubRhs, m11, m12, m21, m22)
scalar_sub_impl!(Mat2, float, Mat2SubRhs, m11, m12, m21, m22)
scalar_sub_impl!(Mat2, uint, Mat2SubRhs, m11, m12, m21, m22)
scalar_sub_impl!(Mat2, int, Mat2SubRhs, m11, m12, m21, m22)
absolute_impl!(Mat2, m11, m12, absolute_impl!(Mat2, m11, m12,
m21, m22) m21, m22)
one_impl!(Mat2, One::one, Zero::zero, one_impl!(Mat2, One::one, Zero::zero,
@ -139,33 +254,91 @@ pub struct Mat3<N> {
m31: N, m32: N, m33: N m31: N, m32: N, m33: N
} }
double_dispatch_binop_decl_trait!(Mat3, Mat3MulRhs)
double_dispatch_binop_decl_trait!(Mat3, Mat3DivRhs)
double_dispatch_binop_decl_trait!(Mat3, Mat3AddRhs)
double_dispatch_binop_decl_trait!(Mat3, Mat3SubRhs)
mul_redispatch_impl!(Mat3, Mat3MulRhs)
div_redispatch_impl!(Mat3, Mat3DivRhs)
add_redispatch_impl!(Mat3, Mat3AddRhs)
sub_redispatch_impl!(Mat3, Mat3SubRhs)
mat_impl!(Mat3, m11, m12, m13, mat_impl!(Mat3, m11, m12, m13,
m21, m22, m23, m21, m22, m23,
m31, m32, m33) m31, m32, m33)
mat_cast_impl!(Mat3, m11, m12, m13, mat_cast_impl!(Mat3, m11, m12, m13,
m21, m22, m23, m21, m22, m23,
m31, m32, m33) m31, m32, m33)
add_impl!(Mat3, m11, m12, m13, add_impl!(Mat3, Mat3AddRhs,
m11, m12, m13,
m21, m22, m23, m21, m22, m23,
m31, m32, m33) m31, m32, m33
sub_impl!(Mat3, m11, m12, m13, )
sub_impl!(Mat3, Mat3SubRhs,
m11, m12, m13,
m21, m22, m23, m21, m22, m23,
m31, m32, m33) m31, m32, m33
scalar_mul_impl!(Mat3, m11, m12, m13, )
scalar_mul_impl!(Mat3, f64, Mat3MulRhs, m11, m12, m13, m21, m22, m23, m31, m32, m33)
scalar_mul_impl!(Mat3, f32, Mat3MulRhs, m11, m12, m13, m21, m22, m23, m31, m32, m33)
scalar_mul_impl!(Mat3, i64, Mat3MulRhs, m11, m12, m13, m21, m22, m23, m31, m32, m33)
scalar_mul_impl!(Mat3, i32, Mat3MulRhs, m11, m12, m13, m21, m22, m23, m31, m32, m33)
scalar_mul_impl!(Mat3, i16, Mat3MulRhs, m11, m12, m13, m21, m22, m23, m31, m32, m33)
scalar_mul_impl!(Mat3, i8, Mat3MulRhs, m11, m12, m13, m21, m22, m23, m31, m32, m33)
scalar_mul_impl!(Mat3, u64, Mat3MulRhs, m11, m12, m13, m21, m22, m23, m31, m32, m33)
scalar_mul_impl!(Mat3, u32, Mat3MulRhs, m11, m12, m13, m21, m22, m23, m31, m32, m33)
scalar_mul_impl!(Mat3, u16, Mat3MulRhs, m11, m12, m13, m21, m22, m23, m31, m32, m33)
scalar_mul_impl!(Mat3, u8, Mat3MulRhs, m11, m12, m13, m21, m22, m23, m31, m32, m33)
scalar_mul_impl!(Mat3, float, Mat3MulRhs, m11, m12, m13, m21, m22, m23, m31, m32, m33)
scalar_mul_impl!(Mat3, uint, Mat3MulRhs, m11, m12, m13, m21, m22, m23, m31, m32, m33)
scalar_mul_impl!(Mat3, int, Mat3MulRhs, m11, m12, m13, m21, m22, m23, m31, m32, m33)
scalar_div_impl!(Mat3, f64, Mat3DivRhs, m11, m12, m13, m21, m22, m23, m31, m32, m33)
scalar_div_impl!(Mat3, f32, Mat3DivRhs, m11, m12, m13, m21, m22, m23, m31, m32, m33)
scalar_div_impl!(Mat3, i64, Mat3DivRhs, m11, m12, m13, m21, m22, m23, m31, m32, m33)
scalar_div_impl!(Mat3, i32, Mat3DivRhs, m11, m12, m13, m21, m22, m23, m31, m32, m33)
scalar_div_impl!(Mat3, i16, Mat3DivRhs, m11, m12, m13, m21, m22, m23, m31, m32, m33)
scalar_div_impl!(Mat3, i8, Mat3DivRhs, m11, m12, m13, m21, m22, m23, m31, m32, m33)
scalar_div_impl!(Mat3, u64, Mat3DivRhs, m11, m12, m13, m21, m22, m23, m31, m32, m33)
scalar_div_impl!(Mat3, u32, Mat3DivRhs, m11, m12, m13, m21, m22, m23, m31, m32, m33)
scalar_div_impl!(Mat3, u16, Mat3DivRhs, m11, m12, m13, m21, m22, m23, m31, m32, m33)
scalar_div_impl!(Mat3, u8, Mat3DivRhs, m11, m12, m13, m21, m22, m23, m31, m32, m33)
scalar_div_impl!(Mat3, float, Mat3DivRhs, m11, m12, m13, m21, m22, m23, m31, m32, m33)
scalar_div_impl!(Mat3, uint, Mat3DivRhs, m11, m12, m13, m21, m22, m23, m31, m32, m33)
scalar_div_impl!(Mat3, int, Mat3DivRhs, m11, m12, m13, m21, m22, m23, m31, m32, m33)
scalar_add_impl!(Mat3, f64, Mat3AddRhs, m11, m12, m13, m21, m22, m23, m31, m32, m33)
scalar_add_impl!(Mat3, f32, Mat3AddRhs, m11, m12, m13, m21, m22, m23, m31, m32, m33)
scalar_add_impl!(Mat3, i64, Mat3AddRhs, m11, m12, m13, m21, m22, m23, m31, m32, m33)
scalar_add_impl!(Mat3, i32, Mat3AddRhs, m11, m12, m13, m21, m22, m23, m31, m32, m33)
scalar_add_impl!(Mat3, i16, Mat3AddRhs, m11, m12, m13, m21, m22, m23, m31, m32, m33)
scalar_add_impl!(Mat3, i8, Mat3AddRhs, m11, m12, m13, m21, m22, m23, m31, m32, m33)
scalar_add_impl!(Mat3, u64, Mat3AddRhs, m11, m12, m13, m21, m22, m23, m31, m32, m33)
scalar_add_impl!(Mat3, u32, Mat3AddRhs, m11, m12, m13, m21, m22, m23, m31, m32, m33)
scalar_add_impl!(Mat3, u16, Mat3AddRhs, m11, m12, m13, m21, m22, m23, m31, m32, m33)
scalar_add_impl!(Mat3, u8, Mat3AddRhs, m11, m12, m13, m21, m22, m23, m31, m32, m33)
scalar_add_impl!(Mat3, float, Mat3AddRhs, m11, m12, m13, m21, m22, m23, m31, m32, m33)
scalar_add_impl!(Mat3, uint, Mat3AddRhs, m11, m12, m13, m21, m22, m23, m31, m32, m33)
scalar_add_impl!(Mat3, int, Mat3AddRhs, m11, m12, m13, m21, m22, m23, m31, m32, m33)
scalar_sub_impl!(Mat3, f64, Mat3SubRhs, m11, m12, m13, m21, m22, m23, m31, m32, m33)
scalar_sub_impl!(Mat3, f32, Mat3SubRhs, m11, m12, m13, m21, m22, m23, m31, m32, m33)
scalar_sub_impl!(Mat3, i64, Mat3SubRhs, m11, m12, m13, m21, m22, m23, m31, m32, m33)
scalar_sub_impl!(Mat3, i32, Mat3SubRhs, m11, m12, m13, m21, m22, m23, m31, m32, m33)
scalar_sub_impl!(Mat3, i16, Mat3SubRhs, m11, m12, m13, m21, m22, m23, m31, m32, m33)
scalar_sub_impl!(Mat3, i8, Mat3SubRhs, m11, m12, m13, m21, m22, m23, m31, m32, m33)
scalar_sub_impl!(Mat3, u64, Mat3SubRhs, m11, m12, m13, m21, m22, m23, m31, m32, m33)
scalar_sub_impl!(Mat3, u32, Mat3SubRhs, m11, m12, m13, m21, m22, m23, m31, m32, m33)
scalar_sub_impl!(Mat3, u16, Mat3SubRhs, m11, m12, m13, m21, m22, m23, m31, m32, m33)
scalar_sub_impl!(Mat3, u8, Mat3SubRhs, m11, m12, m13, m21, m22, m23, m31, m32, m33)
scalar_sub_impl!(Mat3, float, Mat3SubRhs, m11, m12, m13, m21, m22, m23, m31, m32, m33)
scalar_sub_impl!(Mat3, uint, Mat3SubRhs, m11, m12, m13, m21, m22, m23, m31, m32, m33)
scalar_sub_impl!(Mat3, int, Mat3SubRhs, m11, m12, m13, m21, m22, m23, m31, m32, m33)
absolute_impl!(Mat3,
m11, m12, m13,
m21, m22, m23, m21, m22, m23,
m31, m32, m33) m31, m32, m33
scalar_div_impl!(Mat3, m11, m12, m13, )
m21, m22, m23,
m31, m32, m33)
scalar_add_impl!(Mat3, m11, m12, m13,
m21, m22, m23,
m31, m32, m33)
scalar_sub_impl!(Mat3, m11, m12, m13,
m21, m22, m23,
m31, m32, m33)
absolute_impl!(Mat3, m11, m12, m13,
m21, m22, m23,
m31, m32, m33)
one_impl!(Mat3, One::one , Zero::zero, Zero::zero, one_impl!(Mat3, One::one , Zero::zero, Zero::zero,
Zero::zero, One::one , Zero::zero, Zero::zero, One::one , Zero::zero,
Zero::zero, Zero::zero, One::one) Zero::zero, Zero::zero, One::one)
@ -198,6 +371,13 @@ pub struct Mat4<N> {
} }
double_dispatch_binop_decl_trait!(Mat4, Mat4MulRhs) double_dispatch_binop_decl_trait!(Mat4, Mat4MulRhs)
double_dispatch_binop_decl_trait!(Mat4, Mat4DivRhs)
double_dispatch_binop_decl_trait!(Mat4, Mat4AddRhs)
double_dispatch_binop_decl_trait!(Mat4, Mat4SubRhs)
mul_redispatch_impl!(Mat4, Mat4MulRhs)
div_redispatch_impl!(Mat4, Mat4DivRhs)
add_redispatch_impl!(Mat4, Mat4AddRhs)
sub_redispatch_impl!(Mat4, Mat4SubRhs)
mat_impl!(Mat4, mat_impl!(Mat4,
m11, m12, m13, m14, m11, m12, m13, m14,
m21, m22, m23, m24, m21, m22, m23, m24,
@ -210,42 +390,119 @@ mat_cast_impl!(Mat4,
m31, m32, m33, m34, m31, m32, m33, m34,
m41, m42, m43, m44 m41, m42, m43, m44
) )
add_impl!(Mat4, add_impl!(Mat4, Mat4AddRhs,
m11, m12, m13, m14, m11, m12, m13, m14,
m21, m22, m23, m24, m21, m22, m23, m24,
m31, m32, m33, m34, m31, m32, m33, m34,
m41, m42, m43, m44 m41, m42, m43, m44
) )
sub_impl!(Mat4, sub_impl!(Mat4, Mat4SubRhs,
m11, m12, m13, m14,
m21, m22, m23, m24,
m31, m32, m33, m34,
m41, m42, m43, m44
)
scalar_mul_impl!(Mat4,
m11, m12, m13, m14,
m21, m22, m23, m24,
m31, m32, m33, m34,
m41, m42, m43, m44
)
scalar_div_impl!(Mat4,
m11, m12, m13, m14,
m21, m22, m23, m24,
m31, m32, m33, m34,
m41, m42, m43, m44
)
scalar_add_impl!(Mat4,
m11, m12, m13, m14,
m21, m22, m23, m24,
m31, m32, m33, m34,
m41, m42, m43, m44
)
scalar_sub_impl!(Mat4,
m11, m12, m13, m14, m11, m12, m13, m14,
m21, m22, m23, m24, m21, m22, m23, m24,
m31, m32, m33, m34, m31, m32, m33, m34,
m41, m42, m43, m44 m41, m42, m43, m44
) )
scalar_mul_impl!(Mat4, f64, Mat4MulRhs, m11, m12, m13, m14, m21, m22, m23, m24, m31, m32, m33, m34,
m41, m42, m43, m44)
scalar_mul_impl!(Mat4, f32, Mat4MulRhs, m11, m12, m13, m14, m21, m22, m23, m24, m31, m32, m33, m34,
m41, m42, m43, m44)
scalar_mul_impl!(Mat4, i64, Mat4MulRhs, m11, m12, m13, m14, m21, m22, m23, m24, m31, m32, m33, m34,
m41, m42, m43, m44)
scalar_mul_impl!(Mat4, i32, Mat4MulRhs, m11, m12, m13, m14, m21, m22, m23, m24, m31, m32, m33, m34,
m41, m42, m43, m44)
scalar_mul_impl!(Mat4, i16, Mat4MulRhs, m11, m12, m13, m14, m21, m22, m23, m24, m31, m32, m33, m34,
m41, m42, m43, m44)
scalar_mul_impl!(Mat4, i8, Mat4MulRhs, m11, m12, m13, m14, m21, m22, m23, m24, m31, m32, m33, m34,
m41, m42, m43, m44)
scalar_mul_impl!(Mat4, u32, Mat4MulRhs, m11, m12, m13, m14, m21, m22, m23, m24, m31, m32, m33, m34,
m41, m42, m43, m44)
scalar_mul_impl!(Mat4, u16, Mat4MulRhs, m11, m12, m13, m14, m21, m22, m23, m24, m31, m32, m33, m34,
m41, m42, m43, m44)
scalar_mul_impl!(Mat4, u8, Mat4MulRhs, m11, m12, m13, m14, m21, m22, m23, m24, m31, m32, m33, m34,
m41, m42, m43, m44)
scalar_mul_impl!(Mat4, float, Mat4MulRhs, m11, m12, m13, m14, m21, m22, m23, m24, m31, m32, m33, m34,
m41, m42, m43, m44)
scalar_mul_impl!(Mat4, uint, Mat4MulRhs, m11, m12, m13, m14, m21, m22, m23, m24, m31, m32, m33, m34,
m41, m42, m43, m44)
scalar_mul_impl!(Mat4, int, Mat4MulRhs, m11, m12, m13, m14, m21, m22, m23, m24, m31, m32, m33, m34,
m41, m42, m43, m44)
scalar_div_impl!(Mat4, f64, Mat4DivRhs, m11, m12, m13, m14, m21, m22, m23, m24, m31, m32, m33, m34,
m41, m42, m43, m44)
scalar_div_impl!(Mat4, f32, Mat4DivRhs, m11, m12, m13, m14, m21, m22, m23, m24, m31, m32, m33, m34,
m41, m42, m43, m44)
scalar_div_impl!(Mat4, i64, Mat4DivRhs, m11, m12, m13, m14, m21, m22, m23, m24, m31, m32, m33, m34,
m41, m42, m43, m44)
scalar_div_impl!(Mat4, i32, Mat4DivRhs, m11, m12, m13, m14, m21, m22, m23, m24, m31, m32, m33, m34,
m41, m42, m43, m44)
scalar_div_impl!(Mat4, i16, Mat4DivRhs, m11, m12, m13, m14, m21, m22, m23, m24, m31, m32, m33, m34,
m41, m42, m43, m44)
scalar_div_impl!(Mat4, i8, Mat4DivRhs, m11, m12, m13, m14, m21, m22, m23, m24, m31, m32, m33, m34,
m41, m42, m43, m44)
scalar_div_impl!(Mat4, u32, Mat4DivRhs, m11, m12, m13, m14, m21, m22, m23, m24, m31, m32, m33, m34,
m41, m42, m43, m44)
scalar_div_impl!(Mat4, u16, Mat4DivRhs, m11, m12, m13, m14, m21, m22, m23, m24, m31, m32, m33, m34,
m41, m42, m43, m44)
scalar_div_impl!(Mat4, u8, Mat4DivRhs, m11, m12, m13, m14, m21, m22, m23, m24, m31, m32, m33, m34,
m41, m42, m43, m44)
scalar_div_impl!(Mat4, float, Mat4DivRhs, m11, m12, m13, m14, m21, m22, m23, m24, m31, m32, m33, m34,
m41, m42, m43, m44)
scalar_div_impl!(Mat4, uint, Mat4DivRhs, m11, m12, m13, m14, m21, m22, m23, m24, m31, m32, m33, m34,
m41, m42, m43, m44)
scalar_div_impl!(Mat4, int, Mat4DivRhs, m11, m12, m13, m14, m21, m22, m23, m24, m31, m32, m33, m34,
m41, m42, m43, m44)
scalar_add_impl!(Mat4, f64, Mat4AddRhs, m11, m12, m13, m14, m21, m22, m23, m24, m31, m32, m33, m34,
m41, m42, m43, m44)
scalar_add_impl!(Mat4, f32, Mat4AddRhs, m11, m12, m13, m14, m21, m22, m23, m24, m31, m32, m33, m34,
m41, m42, m43, m44)
scalar_add_impl!(Mat4, i64, Mat4AddRhs, m11, m12, m13, m14, m21, m22, m23, m24, m31, m32, m33, m34,
m41, m42, m43, m44)
scalar_add_impl!(Mat4, i32, Mat4AddRhs, m11, m12, m13, m14, m21, m22, m23, m24, m31, m32, m33, m34,
m41, m42, m43, m44)
scalar_add_impl!(Mat4, i16, Mat4AddRhs, m11, m12, m13, m14, m21, m22, m23, m24, m31, m32, m33, m34,
m41, m42, m43, m44)
scalar_add_impl!(Mat4, i8, Mat4AddRhs, m11, m12, m13, m14, m21, m22, m23, m24, m31, m32, m33, m34,
m41, m42, m43, m44)
scalar_add_impl!(Mat4, u32, Mat4AddRhs, m11, m12, m13, m14, m21, m22, m23, m24, m31, m32, m33, m34,
m41, m42, m43, m44)
scalar_add_impl!(Mat4, u16, Mat4AddRhs, m11, m12, m13, m14, m21, m22, m23, m24, m31, m32, m33, m34,
m41, m42, m43, m44)
scalar_add_impl!(Mat4, u8, Mat4AddRhs, m11, m12, m13, m14, m21, m22, m23, m24, m31, m32, m33, m34,
m41, m42, m43, m44)
scalar_add_impl!(Mat4, float, Mat4AddRhs, m11, m12, m13, m14, m21, m22, m23, m24, m31, m32, m33, m34,
m41, m42, m43, m44)
scalar_add_impl!(Mat4, uint, Mat4AddRhs, m11, m12, m13, m14, m21, m22, m23, m24, m31, m32, m33, m34,
m41, m42, m43, m44)
scalar_add_impl!(Mat4, int, Mat4AddRhs, m11, m12, m13, m14, m21, m22, m23, m24, m31, m32, m33, m34,
m41, m42, m43, m44)
scalar_sub_impl!(Mat4, f64, Mat4SubRhs, m11, m12, m13, m14, m21, m22, m23, m24, m31, m32, m33, m34,
m41, m42, m43, m44)
scalar_sub_impl!(Mat4, f32, Mat4SubRhs, m11, m12, m13, m14, m21, m22, m23, m24, m31, m32, m33, m34,
m41, m42, m43, m44)
scalar_sub_impl!(Mat4, i64, Mat4SubRhs, m11, m12, m13, m14, m21, m22, m23, m24, m31, m32, m33, m34,
m41, m42, m43, m44)
scalar_sub_impl!(Mat4, i32, Mat4SubRhs, m11, m12, m13, m14, m21, m22, m23, m24, m31, m32, m33, m34,
m41, m42, m43, m44)
scalar_sub_impl!(Mat4, i16, Mat4SubRhs, m11, m12, m13, m14, m21, m22, m23, m24, m31, m32, m33, m34,
m41, m42, m43, m44)
scalar_sub_impl!(Mat4, i8, Mat4SubRhs, m11, m12, m13, m14, m21, m22, m23, m24, m31, m32, m33, m34,
m41, m42, m43, m44)
scalar_sub_impl!(Mat4, u32, Mat4SubRhs, m11, m12, m13, m14, m21, m22, m23, m24, m31, m32, m33, m34,
m41, m42, m43, m44)
scalar_sub_impl!(Mat4, u16, Mat4SubRhs, m11, m12, m13, m14, m21, m22, m23, m24, m31, m32, m33, m34,
m41, m42, m43, m44)
scalar_sub_impl!(Mat4, u8, Mat4SubRhs, m11, m12, m13, m14, m21, m22, m23, m24, m31, m32, m33, m34,
m41, m42, m43, m44)
scalar_sub_impl!(Mat4, float, Mat4SubRhs, m11, m12, m13, m14, m21, m22, m23, m24, m31, m32, m33, m34,
m41, m42, m43, m44)
scalar_sub_impl!(Mat4, uint, Mat4SubRhs, m11, m12, m13, m14, m21, m22, m23, m24, m31, m32, m33, m34,
m41, m42, m43, m44)
scalar_sub_impl!(Mat4, int, Mat4SubRhs, m11, m12, m13, m14, m21, m22, m23, m24, m31, m32, m33, m34,
m41, m42, m43, m44)
absolute_impl!(Mat4, absolute_impl!(Mat4,
m11, m12, m13, m14, m11, m12, m13, m14,
m21, m22, m23, m24, m21, m22, m23, m24,
@ -261,10 +518,9 @@ iterable_mut_impl!(Mat4, 4)
dim_impl!(Mat4, 4) dim_impl!(Mat4, 4)
indexable_impl!(Mat4, 4) indexable_impl!(Mat4, 4)
at_fast_impl!(Mat4, 4) at_fast_impl!(Mat4, 4)
mul_redispatch_impl!(Mat4, Mat4MulRhs)
mat_mul_mat_impl!(Mat4, Mat4MulRhs, 4) mat_mul_mat_impl!(Mat4, Mat4MulRhs, 4)
rmul_impl!(Mat4, Vec4, 4) rmul_impl!(Mat4, Vec4, 4)
lmul_impl!(Mat4, Vec4, 4) vec_mul_mat_impl!(Mat4, Vec4, Mat4MulRhs, 4)
transform_impl!(Mat4, Vec4) transform_impl!(Mat4, Vec4)
inv_impl!(Mat4, 4) inv_impl!(Mat4, 4)
transpose_impl!(Mat4, 4) transpose_impl!(Mat4, 4)
@ -287,6 +543,13 @@ pub struct Mat5<N> {
} }
double_dispatch_binop_decl_trait!(Mat5, Mat5MulRhs) double_dispatch_binop_decl_trait!(Mat5, Mat5MulRhs)
double_dispatch_binop_decl_trait!(Mat5, Mat5DivRhs)
double_dispatch_binop_decl_trait!(Mat5, Mat5AddRhs)
double_dispatch_binop_decl_trait!(Mat5, Mat5SubRhs)
mul_redispatch_impl!(Mat5, Mat5MulRhs)
div_redispatch_impl!(Mat5, Mat5DivRhs)
add_redispatch_impl!(Mat5, Mat5AddRhs)
sub_redispatch_impl!(Mat5, Mat5SubRhs)
mat_impl!(Mat5, mat_impl!(Mat5,
m11, m12, m13, m14, m15, m11, m12, m13, m14, m15,
m21, m22, m23, m24, m25, m21, m22, m23, m24, m25,
@ -315,57 +578,136 @@ one_impl!(Mat5,
Zero::zero, Zero::zero, Zero::zero, One::one , Zero::zero, Zero::zero, Zero::zero, Zero::zero, One::one , Zero::zero,
Zero::zero, Zero::zero, Zero::zero, Zero::zero, One::one Zero::zero, Zero::zero, Zero::zero, Zero::zero, One::one
) )
add_impl!(Mat5, add_impl!(Mat5, Mat5AddRhs,
m11, m12, m13, m14, m15, m11, m12, m13, m14, m15,
m21, m22, m23, m24, m25, m21, m22, m23, m24, m25,
m31, m32, m33, m34, m35, m31, m32, m33, m34, m35,
m41, m42, m43, m44, m45, m41, m42, m43, m44, m45,
m51, m52, m53, m54, m55 m51, m52, m53, m54, m55
) )
sub_impl!(Mat5, sub_impl!(Mat5, Mat5SubRhs,
m11, m12, m13, m14, m15,
m21, m22, m23, m24, m25,
m31, m32, m33, m34, m35,
m41, m42, m43, m44, m45,
m51, m52, m53, m54, m55
)
scalar_mul_impl!(Mat5,
m11, m12, m13, m14, m15,
m21, m22, m23, m24, m25,
m31, m32, m33, m34, m35,
m41, m42, m43, m44, m45,
m51, m52, m53, m54, m55
)
scalar_div_impl!(Mat5,
m11, m12, m13, m14, m15,
m21, m22, m23, m24, m25,
m31, m32, m33, m34, m35,
m41, m42, m43, m44, m45,
m51, m52, m53, m54, m55
)
scalar_add_impl!(Mat5,
m11, m12, m13, m14, m15,
m21, m22, m23, m24, m25,
m31, m32, m33, m34, m35,
m41, m42, m43, m44, m45,
m51, m52, m53, m54, m55
)
scalar_sub_impl!(Mat5,
m11, m12, m13, m14, m15, m11, m12, m13, m14, m15,
m21, m22, m23, m24, m25, m21, m22, m23, m24, m25,
m31, m32, m33, m34, m35, m31, m32, m33, m34, m35,
m41, m42, m43, m44, m45, m41, m42, m43, m44, m45,
m51, m52, m53, m54, m55 m51, m52, m53, m54, m55
) )
scalar_mul_impl!(Mat5, f64, Mat5MulRhs, m11, m12, m13, m14, m15, m21, m22, m23, m24, m25,
m31, m32, m33, m34, m35, m41, m42, m43, m44, m45, m51, m52, m53, m54, m55)
scalar_mul_impl!(Mat5, f32, Mat5MulRhs, m11, m12, m13, m14, m15, m21, m22, m23, m24, m25,
m31, m32, m33, m34, m35, m41, m42, m43, m44, m45, m51, m52, m53, m54, m55)
scalar_mul_impl!(Mat5, i64, Mat5MulRhs, m11, m12, m13, m14, m15, m21, m22, m23, m24, m25,
m31, m32, m33, m34, m35, m41, m42, m43, m44, m45, m51, m52, m53, m54, m55)
scalar_mul_impl!(Mat5, i32, Mat5MulRhs, m11, m12, m13, m14, m15, m21, m22, m23, m24, m25,
m31, m32, m33, m34, m35, m41, m42, m43, m44, m45, m51, m52, m53, m54, m55)
scalar_mul_impl!(Mat5, i16, Mat5MulRhs, m11, m12, m13, m14, m15, m21, m22, m23, m24, m25,
m31, m32, m33, m34, m35, m41, m42, m43, m44, m45, m51, m52, m53, m54, m55)
scalar_mul_impl!(Mat5, i8, Mat5MulRhs, m11, m12, m13, m14, m15, m21, m22, m23, m24, m25,
m31, m32, m33, m34, m35, m41, m42, m43, m44, m45, m51, m52, m53, m54, m55)
scalar_mul_impl!(Mat5, u64, Mat5MulRhs, m11, m12, m13, m14, m15, m21, m22, m23, m24, m25,
m31, m32, m33, m34, m35, m41, m42, m43, m44, m45, m51, m52, m53, m54, m55)
scalar_mul_impl!(Mat5, u32, Mat5MulRhs, m11, m12, m13, m14, m15, m21, m22, m23, m24, m25,
m31, m32, m33, m34, m35, m41, m42, m43, m44, m45, m51, m52, m53, m54, m55)
scalar_mul_impl!(Mat5, u16, Mat5MulRhs, m11, m12, m13, m14, m15, m21, m22, m23, m24, m25,
m31, m32, m33, m34, m35, m41, m42, m43, m44, m45, m51, m52, m53, m54, m55)
scalar_mul_impl!(Mat5, u8, Mat5MulRhs, m11, m12, m13, m14, m15, m21, m22, m23, m24, m25,
m31, m32, m33, m34, m35, m41, m42, m43, m44, m45, m51, m52, m53, m54, m55)
scalar_mul_impl!(Mat5, float, Mat5MulRhs, m11, m12, m13, m14, m15, m21, m22, m23, m24, m25,
m31, m32, m33, m34, m35, m41, m42, m43, m44, m45, m51, m52, m53, m54, m55)
scalar_mul_impl!(Mat5, uint, Mat5MulRhs, m11, m12, m13, m14, m15, m21, m22, m23, m24, m25,
m31, m32, m33, m34, m35, m41, m42, m43, m44, m45, m51, m52, m53, m54, m55)
scalar_mul_impl!(Mat5, int, Mat5MulRhs, m11, m12, m13, m14, m15, m21, m22, m23, m24, m25,
m31, m32, m33, m34, m35, m41, m42, m43, m44, m45, m51, m52, m53, m54, m55)
scalar_div_impl!(Mat5, f64, Mat5DivRhs, m11, m12, m13, m14, m15, m21, m22, m23, m24, m25,
m31, m32, m33, m34, m35, m41, m42, m43, m44, m45, m51, m52, m53, m54, m55)
scalar_div_impl!(Mat5, f32, Mat5DivRhs, m11, m12, m13, m14, m15, m21, m22, m23, m24, m25,
m31, m32, m33, m34, m35, m41, m42, m43, m44, m45, m51, m52, m53, m54, m55)
scalar_div_impl!(Mat5, i64, Mat5DivRhs, m11, m12, m13, m14, m15, m21, m22, m23, m24, m25,
m31, m32, m33, m34, m35, m41, m42, m43, m44, m45, m51, m52, m53, m54, m55)
scalar_div_impl!(Mat5, i32, Mat5DivRhs, m11, m12, m13, m14, m15, m21, m22, m23, m24, m25,
m31, m32, m33, m34, m35, m41, m42, m43, m44, m45, m51, m52, m53, m54, m55)
scalar_div_impl!(Mat5, i16, Mat5DivRhs, m11, m12, m13, m14, m15, m21, m22, m23, m24, m25,
m31, m32, m33, m34, m35, m41, m42, m43, m44, m45, m51, m52, m53, m54, m55)
scalar_div_impl!(Mat5, i8, Mat5DivRhs, m11, m12, m13, m14, m15, m21, m22, m23, m24, m25,
m31, m32, m33, m34, m35, m41, m42, m43, m44, m45, m51, m52, m53, m54, m55)
scalar_div_impl!(Mat5, u64, Mat5DivRhs, m11, m12, m13, m14, m15, m21, m22, m23, m24, m25,
m31, m32, m33, m34, m35, m41, m42, m43, m44, m45, m51, m52, m53, m54, m55)
scalar_div_impl!(Mat5, u32, Mat5DivRhs, m11, m12, m13, m14, m15, m21, m22, m23, m24, m25,
m31, m32, m33, m34, m35, m41, m42, m43, m44, m45, m51, m52, m53, m54, m55)
scalar_div_impl!(Mat5, u16, Mat5DivRhs, m11, m12, m13, m14, m15, m21, m22, m23, m24, m25,
m31, m32, m33, m34, m35, m41, m42, m43, m44, m45, m51, m52, m53, m54, m55)
scalar_div_impl!(Mat5, u8, Mat5DivRhs, m11, m12, m13, m14, m15, m21, m22, m23, m24, m25,
m31, m32, m33, m34, m35, m41, m42, m43, m44, m45, m51, m52, m53, m54, m55)
scalar_div_impl!(Mat5, float, Mat5DivRhs, m11, m12, m13, m14, m15, m21, m22, m23, m24, m25,
m31, m32, m33, m34, m35, m41, m42, m43, m44, m45, m51, m52, m53, m54, m55)
scalar_div_impl!(Mat5, uint, Mat5DivRhs, m11, m12, m13, m14, m15, m21, m22, m23, m24, m25,
m31, m32, m33, m34, m35, m41, m42, m43, m44, m45, m51, m52, m53, m54, m55)
scalar_div_impl!(Mat5, int, Mat5DivRhs, m11, m12, m13, m14, m15, m21, m22, m23, m24, m25,
m31, m32, m33, m34, m35, m41, m42, m43, m44, m45, m51, m52, m53, m54, m55)
scalar_add_impl!(Mat5, f64, Mat5AddRhs, m11, m12, m13, m14, m15, m21, m22, m23, m24, m25,
m31, m32, m33, m34, m35, m41, m42, m43, m44, m45, m51, m52, m53, m54, m55)
scalar_add_impl!(Mat5, f32, Mat5AddRhs, m11, m12, m13, m14, m15, m21, m22, m23, m24, m25,
m31, m32, m33, m34, m35, m41, m42, m43, m44, m45, m51, m52, m53, m54, m55)
scalar_add_impl!(Mat5, i64, Mat5AddRhs, m11, m12, m13, m14, m15, m21, m22, m23, m24, m25,
m31, m32, m33, m34, m35, m41, m42, m43, m44, m45, m51, m52, m53, m54, m55)
scalar_add_impl!(Mat5, i32, Mat5AddRhs, m11, m12, m13, m14, m15, m21, m22, m23, m24, m25,
m31, m32, m33, m34, m35, m41, m42, m43, m44, m45, m51, m52, m53, m54, m55)
scalar_add_impl!(Mat5, i16, Mat5AddRhs, m11, m12, m13, m14, m15, m21, m22, m23, m24, m25,
m31, m32, m33, m34, m35, m41, m42, m43, m44, m45, m51, m52, m53, m54, m55)
scalar_add_impl!(Mat5, i8, Mat5AddRhs, m11, m12, m13, m14, m15, m21, m22, m23, m24, m25,
m31, m32, m33, m34, m35, m41, m42, m43, m44, m45, m51, m52, m53, m54, m55)
scalar_add_impl!(Mat5, u64, Mat5AddRhs, m11, m12, m13, m14, m15, m21, m22, m23, m24, m25,
m31, m32, m33, m34, m35, m41, m42, m43, m44, m45, m51, m52, m53, m54, m55)
scalar_add_impl!(Mat5, u32, Mat5AddRhs, m11, m12, m13, m14, m15, m21, m22, m23, m24, m25,
m31, m32, m33, m34, m35, m41, m42, m43, m44, m45, m51, m52, m53, m54, m55)
scalar_add_impl!(Mat5, u16, Mat5AddRhs, m11, m12, m13, m14, m15, m21, m22, m23, m24, m25,
m31, m32, m33, m34, m35, m41, m42, m43, m44, m45, m51, m52, m53, m54, m55)
scalar_add_impl!(Mat5, u8, Mat5AddRhs, m11, m12, m13, m14, m15, m21, m22, m23, m24, m25,
m31, m32, m33, m34, m35, m41, m42, m43, m44, m45, m51, m52, m53, m54, m55)
scalar_add_impl!(Mat5, float, Mat5AddRhs, m11, m12, m13, m14, m15, m21, m22, m23, m24, m25,
m31, m32, m33, m34, m35, m41, m42, m43, m44, m45, m51, m52, m53, m54, m55)
scalar_add_impl!(Mat5, uint, Mat5AddRhs, m11, m12, m13, m14, m15, m21, m22, m23, m24, m25,
m31, m32, m33, m34, m35, m41, m42, m43, m44, m45, m51, m52, m53, m54, m55)
scalar_add_impl!(Mat5, int, Mat5AddRhs, m11, m12, m13, m14, m15, m21, m22, m23, m24, m25,
m31, m32, m33, m34, m35, m41, m42, m43, m44, m45, m51, m52, m53, m54, m55)
scalar_sub_impl!(Mat5, f64, Mat5SubRhs, m11, m12, m13, m14, m15, m21, m22, m23, m24, m25,
m31, m32, m33, m34, m35, m41, m42, m43, m44, m45, m51, m52, m53, m54, m55)
scalar_sub_impl!(Mat5, f32, Mat5SubRhs, m11, m12, m13, m14, m15, m21, m22, m23, m24, m25,
m31, m32, m33, m34, m35, m41, m42, m43, m44, m45, m51, m52, m53, m54, m55)
scalar_sub_impl!(Mat5, i64, Mat5SubRhs, m11, m12, m13, m14, m15, m21, m22, m23, m24, m25,
m31, m32, m33, m34, m35, m41, m42, m43, m44, m45, m51, m52, m53, m54, m55)
scalar_sub_impl!(Mat5, i32, Mat5SubRhs, m11, m12, m13, m14, m15, m21, m22, m23, m24, m25,
m31, m32, m33, m34, m35, m41, m42, m43, m44, m45, m51, m52, m53, m54, m55)
scalar_sub_impl!(Mat5, i16, Mat5SubRhs, m11, m12, m13, m14, m15, m21, m22, m23, m24, m25,
m31, m32, m33, m34, m35, m41, m42, m43, m44, m45, m51, m52, m53, m54, m55)
scalar_sub_impl!(Mat5, i8, Mat5SubRhs, m11, m12, m13, m14, m15, m21, m22, m23, m24, m25,
m31, m32, m33, m34, m35, m41, m42, m43, m44, m45, m51, m52, m53, m54, m55)
scalar_sub_impl!(Mat5, u64, Mat5SubRhs, m11, m12, m13, m14, m15, m21, m22, m23, m24, m25,
m31, m32, m33, m34, m35, m41, m42, m43, m44, m45, m51, m52, m53, m54, m55)
scalar_sub_impl!(Mat5, u32, Mat5SubRhs, m11, m12, m13, m14, m15, m21, m22, m23, m24, m25,
m31, m32, m33, m34, m35, m41, m42, m43, m44, m45, m51, m52, m53, m54, m55)
scalar_sub_impl!(Mat5, u16, Mat5SubRhs, m11, m12, m13, m14, m15, m21, m22, m23, m24, m25,
m31, m32, m33, m34, m35, m41, m42, m43, m44, m45, m51, m52, m53, m54, m55)
scalar_sub_impl!(Mat5, u8, Mat5SubRhs, m11, m12, m13, m14, m15, m21, m22, m23, m24, m25,
m31, m32, m33, m34, m35, m41, m42, m43, m44, m45, m51, m52, m53, m54, m55)
scalar_sub_impl!(Mat5, float, Mat5SubRhs, m11, m12, m13, m14, m15, m21, m22, m23, m24, m25,
m31, m32, m33, m34, m35, m41, m42, m43, m44, m45, m51, m52, m53, m54, m55)
scalar_sub_impl!(Mat5, uint, Mat5SubRhs, m11, m12, m13, m14, m15, m21, m22, m23, m24, m25,
m31, m32, m33, m34, m35, m41, m42, m43, m44, m45, m51, m52, m53, m54, m55)
scalar_sub_impl!(Mat5, int, Mat5SubRhs, m11, m12, m13, m14, m15, m21, m22, m23, m24, m25,
m31, m32, m33, m34, m35, m41, m42, m43, m44, m45, m51, m52, m53, m54, m55)
iterable_impl!(Mat5, 5) iterable_impl!(Mat5, 5)
iterable_mut_impl!(Mat5, 5) iterable_mut_impl!(Mat5, 5)
dim_impl!(Mat5, 5) dim_impl!(Mat5, 5)
indexable_impl!(Mat5, 5) indexable_impl!(Mat5, 5)
at_fast_impl!(Mat5, 5) at_fast_impl!(Mat5, 5)
mul_redispatch_impl!(Mat5, Mat5MulRhs)
mat_mul_mat_impl!(Mat5, Mat5MulRhs, 5) mat_mul_mat_impl!(Mat5, Mat5MulRhs, 5)
rmul_impl!(Mat5, Vec5, 5) rmul_impl!(Mat5, Vec5, 5)
lmul_impl!(Mat5, Vec5, 5) vec_mul_mat_impl!(Mat5, Vec5, Mat5MulRhs, 5)
transform_impl!(Mat5, Vec5) transform_impl!(Mat5, Vec5)
inv_impl!(Mat5, 5) inv_impl!(Mat5, 5)
transpose_impl!(Mat5, 5) transpose_impl!(Mat5, 5)
@ -389,6 +731,13 @@ pub struct Mat6<N> {
} }
double_dispatch_binop_decl_trait!(Mat6, Mat6MulRhs) double_dispatch_binop_decl_trait!(Mat6, Mat6MulRhs)
double_dispatch_binop_decl_trait!(Mat6, Mat6DivRhs)
double_dispatch_binop_decl_trait!(Mat6, Mat6AddRhs)
double_dispatch_binop_decl_trait!(Mat6, Mat6SubRhs)
mul_redispatch_impl!(Mat6, Mat6MulRhs)
div_redispatch_impl!(Mat6, Mat6DivRhs)
add_redispatch_impl!(Mat6, Mat6AddRhs)
sub_redispatch_impl!(Mat6, Mat6SubRhs)
mat_impl!(Mat6, mat_impl!(Mat6,
m11, m12, m13, m14, m15, m16, m11, m12, m13, m14, m15, m16,
m21, m22, m23, m24, m25, m26, m21, m22, m23, m24, m25, m26,
@ -405,7 +754,7 @@ mat_cast_impl!(Mat6,
m51, m52, m53, m54, m55, m56, m51, m52, m53, m54, m55, m56,
m61, m62, m63, m64, m65, m66 m61, m62, m63, m64, m65, m66
) )
add_impl!(Mat6, add_impl!(Mat6, Mat6AddRhs,
m11, m12, m13, m14, m15, m16, m11, m12, m13, m14, m15, m16,
m21, m22, m23, m24, m25, m26, m21, m22, m23, m24, m25, m26,
m31, m32, m33, m34, m35, m36, m31, m32, m33, m34, m35, m36,
@ -413,47 +762,7 @@ add_impl!(Mat6,
m51, m52, m53, m54, m55, m56, m51, m52, m53, m54, m55, m56,
m61, m62, m63, m64, m65, m66 m61, m62, m63, m64, m65, m66
) )
sub_impl!(Mat6, sub_impl!(Mat6, Mat6SubRhs,
m11, m12, m13, m14, m15, m16,
m21, m22, m23, m24, m25, m26,
m31, m32, m33, m34, m35, m36,
m41, m42, m43, m44, m45, m46,
m51, m52, m53, m54, m55, m56,
m61, m62, m63, m64, m65, m66
)
scalar_mul_impl!(Mat6,
m11, m12, m13, m14, m15, m16,
m21, m22, m23, m24, m25, m26,
m31, m32, m33, m34, m35, m36,
m41, m42, m43, m44, m45, m46,
m51, m52, m53, m54, m55, m56,
m61, m62, m63, m64, m65, m66
)
scalar_div_impl!(Mat6,
m11, m12, m13, m14, m15, m16,
m21, m22, m23, m24, m25, m26,
m31, m32, m33, m34, m35, m36,
m41, m42, m43, m44, m45, m46,
m51, m52, m53, m54, m55, m56,
m61, m62, m63, m64, m65, m66
)
scalar_add_impl!(Mat6,
m11, m12, m13, m14, m15, m16,
m21, m22, m23, m24, m25, m26,
m31, m32, m33, m34, m35, m36,
m41, m42, m43, m44, m45, m46,
m51, m52, m53, m54, m55, m56,
m61, m62, m63, m64, m65, m66
)
scalar_sub_impl!(Mat6,
m11, m12, m13, m14, m15, m16,
m21, m22, m23, m24, m25, m26,
m31, m32, m33, m34, m35, m36,
m41, m42, m43, m44, m45, m46,
m51, m52, m53, m54, m55, m56,
m61, m62, m63, m64, m65, m66
)
absolute_impl!(Mat6,
m11, m12, m13, m14, m15, m16, m11, m12, m13, m14, m15, m16,
m21, m22, m23, m24, m25, m26, m21, m22, m23, m24, m25, m26,
m31, m32, m33, m34, m35, m36, m31, m32, m33, m34, m35, m36,
@ -461,6 +770,171 @@ absolute_impl!(Mat6,
m51, m52, m53, m54, m55, m56, m51, m52, m53, m54, m55, m56,
m61, m62, m63, m64, m65, m66 m61, m62, m63, m64, m65, m66
) )
scalar_mul_impl!(Mat6, f64, Mat6MulRhs, m11, m12, m13, m14, m15, m16, m21, m22, m23, m24, m25, m26,
m31, m32, m33, m34, m35, m36, m41, m42, m43, m44, m45, m46, m51, m52, m53, m54, m55, m56,
m61, m62, m63, m64, m65, m66)
scalar_mul_impl!(Mat6, f32, Mat6MulRhs, m11, m12, m13, m14, m15, m16, m21, m22, m23, m24, m25, m26,
m31, m32, m33, m34, m35, m36, m41, m42, m43, m44, m45, m46, m51, m52, m53, m54, m55, m56,
m61, m62, m63, m64, m65, m66)
scalar_mul_impl!(Mat6, i64, Mat6MulRhs, m11, m12, m13, m14, m15, m16, m21, m22, m23, m24, m25, m26,
m31, m32, m33, m34, m35, m36, m41, m42, m43, m44, m45, m46, m51, m52, m53, m54, m55, m56,
m61, m62, m63, m64, m65, m66)
scalar_mul_impl!(Mat6, i32, Mat6MulRhs, m11, m12, m13, m14, m15, m16, m21, m22, m23, m24, m25, m26,
m31, m32, m33, m34, m35, m36, m41, m42, m43, m44, m45, m46, m51, m52, m53, m54, m55, m56,
m61, m62, m63, m64, m65, m66)
scalar_mul_impl!(Mat6, i16, Mat6MulRhs, m11, m12, m13, m14, m15, m16, m21, m22, m23, m24, m25, m26,
m31, m32, m33, m34, m35, m36, m41, m42, m43, m44, m45, m46, m51, m52, m53, m54, m55, m56,
m61, m62, m63, m64, m65, m66)
scalar_mul_impl!(Mat6, i8, Mat6MulRhs, m11, m12, m13, m14, m15, m16, m21, m22, m23, m24, m25, m26,
m31, m32, m33, m34, m35, m36, m41, m42, m43, m44, m45, m46, m51, m52, m53, m54, m55, m56,
m61, m62, m63, m64, m65, m66)
scalar_mul_impl!(Mat6, u64, Mat6MulRhs, m11, m12, m13, m14, m15, m16, m21, m22, m23, m24, m25, m26,
m31, m32, m33, m34, m35, m36, m41, m42, m43, m44, m45, m46, m51, m52, m53, m54, m55, m56,
m61, m62, m63, m64, m65, m66)
scalar_mul_impl!(Mat6, u32, Mat6MulRhs, m11, m12, m13, m14, m15, m16, m21, m22, m23, m24, m25, m26,
m31, m32, m33, m34, m35, m36, m41, m42, m43, m44, m45, m46, m51, m52, m53, m54, m55, m56,
m61, m62, m63, m64, m65, m66)
scalar_mul_impl!(Mat6, u16, Mat6MulRhs, m11, m12, m13, m14, m15, m16, m21, m22, m23, m24, m25, m26,
m31, m32, m33, m34, m35, m36, m41, m42, m43, m44, m45, m46, m51, m52, m53, m54, m55, m56,
m61, m62, m63, m64, m65, m66)
scalar_mul_impl!(Mat6, u8, Mat6MulRhs, m11, m12, m13, m14, m15, m16, m21, m22, m23, m24, m25, m26,
m31, m32, m33, m34, m35, m36, m41, m42, m43, m44, m45, m46, m51, m52, m53, m54, m55, m56,
m61, m62, m63, m64, m65, m66)
scalar_mul_impl!(Mat6, float, Mat6MulRhs, m11, m12, m13, m14, m15, m16, m21, m22, m23, m24, m25, m26,
m31, m32, m33, m34, m35, m36, m41, m42, m43, m44, m45, m46, m51, m52, m53, m54, m55, m56,
m61, m62, m63, m64, m65, m66)
scalar_mul_impl!(Mat6, uint, Mat6MulRhs, m11, m12, m13, m14, m15, m16, m21, m22, m23, m24, m25, m26,
m31, m32, m33, m34, m35, m36, m41, m42, m43, m44, m45, m46, m51, m52, m53, m54, m55, m56,
m61, m62, m63, m64, m65, m66)
scalar_mul_impl!(Mat6, int, Mat6MulRhs, m11, m12, m13, m14, m15, m16, m21, m22, m23, m24, m25, m26,
m31, m32, m33, m34, m35, m36, m41, m42, m43, m44, m45, m46, m51, m52, m53, m54, m55, m56,
m61, m62, m63, m64, m65, m66)
scalar_div_impl!(Mat6, f64, Mat6DivRhs, m11, m12, m13, m14, m15, m16, m21, m22, m23, m24, m25, m26,
m31, m32, m33, m34, m35, m36, m41, m42, m43, m44, m45, m46, m51, m52, m53, m54, m55, m56,
m61, m62, m63, m64, m65, m66)
scalar_div_impl!(Mat6, f32, Mat6DivRhs, m11, m12, m13, m14, m15, m16, m21, m22, m23, m24, m25, m26,
m31, m32, m33, m34, m35, m36, m41, m42, m43, m44, m45, m46, m51, m52, m53, m54, m55, m56,
m61, m62, m63, m64, m65, m66)
scalar_div_impl!(Mat6, i64, Mat6DivRhs, m11, m12, m13, m14, m15, m16, m21, m22, m23, m24, m25, m26,
m31, m32, m33, m34, m35, m36, m41, m42, m43, m44, m45, m46, m51, m52, m53, m54, m55, m56,
m61, m62, m63, m64, m65, m66)
scalar_div_impl!(Mat6, i32, Mat6DivRhs, m11, m12, m13, m14, m15, m16, m21, m22, m23, m24, m25, m26,
m31, m32, m33, m34, m35, m36, m41, m42, m43, m44, m45, m46, m51, m52, m53, m54, m55, m56,
m61, m62, m63, m64, m65, m66)
scalar_div_impl!(Mat6, i16, Mat6DivRhs, m11, m12, m13, m14, m15, m16, m21, m22, m23, m24, m25, m26,
m31, m32, m33, m34, m35, m36, m41, m42, m43, m44, m45, m46, m51, m52, m53, m54, m55, m56,
m61, m62, m63, m64, m65, m66)
scalar_div_impl!(Mat6, i8, Mat6DivRhs, m11, m12, m13, m14, m15, m16, m21, m22, m23, m24, m25, m26,
m31, m32, m33, m34, m35, m36, m41, m42, m43, m44, m45, m46, m51, m52, m53, m54, m55, m56,
m61, m62, m63, m64, m65, m66)
scalar_div_impl!(Mat6, u64, Mat6DivRhs, m11, m12, m13, m14, m15, m16, m21, m22, m23, m24, m25, m26,
m31, m32, m33, m34, m35, m36, m41, m42, m43, m44, m45, m46, m51, m52, m53, m54, m55, m56,
m61, m62, m63, m64, m65, m66)
scalar_div_impl!(Mat6, u32, Mat6DivRhs, m11, m12, m13, m14, m15, m16, m21, m22, m23, m24, m25, m26,
m31, m32, m33, m34, m35, m36, m41, m42, m43, m44, m45, m46, m51, m52, m53, m54, m55, m56,
m61, m62, m63, m64, m65, m66)
scalar_div_impl!(Mat6, u16, Mat6DivRhs, m11, m12, m13, m14, m15, m16, m21, m22, m23, m24, m25, m26,
m31, m32, m33, m34, m35, m36, m41, m42, m43, m44, m45, m46, m51, m52, m53, m54, m55, m56,
m61, m62, m63, m64, m65, m66)
scalar_div_impl!(Mat6, u8, Mat6DivRhs, m11, m12, m13, m14, m15, m16, m21, m22, m23, m24, m25, m26,
m31, m32, m33, m34, m35, m36, m41, m42, m43, m44, m45, m46, m51, m52, m53, m54, m55, m56,
m61, m62, m63, m64, m65, m66)
scalar_div_impl!(Mat6, float, Mat6DivRhs, m11, m12, m13, m14, m15, m16, m21, m22, m23, m24, m25, m26,
m31, m32, m33, m34, m35, m36, m41, m42, m43, m44, m45, m46, m51, m52, m53, m54, m55, m56,
m61, m62, m63, m64, m65, m66)
scalar_div_impl!(Mat6, uint, Mat6DivRhs, m11, m12, m13, m14, m15, m16, m21, m22, m23, m24, m25, m26,
m31, m32, m33, m34, m35, m36, m41, m42, m43, m44, m45, m46, m51, m52, m53, m54, m55, m56,
m61, m62, m63, m64, m65, m66)
scalar_div_impl!(Mat6, int, Mat6DivRhs, m11, m12, m13, m14, m15, m16, m21, m22, m23, m24, m25, m26,
m31, m32, m33, m34, m35, m36, m41, m42, m43, m44, m45, m46, m51, m52, m53, m54, m55, m56,
m61, m62, m63, m64, m65, m66)
scalar_add_impl!(Mat6, f64, Mat6AddRhs, m11, m12, m13, m14, m15, m16, m21, m22, m23, m24, m25, m26,
m31, m32, m33, m34, m35, m36, m41, m42, m43, m44, m45, m46, m51, m52, m53, m54, m55, m56,
m61, m62, m63, m64, m65, m66)
scalar_add_impl!(Mat6, f32, Mat6AddRhs, m11, m12, m13, m14, m15, m16, m21, m22, m23, m24, m25, m26,
m31, m32, m33, m34, m35, m36, m41, m42, m43, m44, m45, m46, m51, m52, m53, m54, m55, m56,
m61, m62, m63, m64, m65, m66)
scalar_add_impl!(Mat6, i64, Mat6AddRhs, m11, m12, m13, m14, m15, m16, m21, m22, m23, m24, m25, m26,
m31, m32, m33, m34, m35, m36, m41, m42, m43, m44, m45, m46, m51, m52, m53, m54, m55, m56,
m61, m62, m63, m64, m65, m66)
scalar_add_impl!(Mat6, i32, Mat6AddRhs, m11, m12, m13, m14, m15, m16, m21, m22, m23, m24, m25, m26,
m31, m32, m33, m34, m35, m36, m41, m42, m43, m44, m45, m46, m51, m52, m53, m54, m55, m56,
m61, m62, m63, m64, m65, m66)
scalar_add_impl!(Mat6, i16, Mat6AddRhs, m11, m12, m13, m14, m15, m16, m21, m22, m23, m24, m25, m26,
m31, m32, m33, m34, m35, m36, m41, m42, m43, m44, m45, m46, m51, m52, m53, m54, m55, m56,
m61, m62, m63, m64, m65, m66)
scalar_add_impl!(Mat6, i8, Mat6AddRhs, m11, m12, m13, m14, m15, m16, m21, m22, m23, m24, m25, m26,
m31, m32, m33, m34, m35, m36, m41, m42, m43, m44, m45, m46, m51, m52, m53, m54, m55, m56,
m61, m62, m63, m64, m65, m66)
scalar_add_impl!(Mat6, u64, Mat6AddRhs, m11, m12, m13, m14, m15, m16, m21, m22, m23, m24, m25, m26,
m31, m32, m33, m34, m35, m36, m41, m42, m43, m44, m45, m46, m51, m52, m53, m54, m55, m56,
m61, m62, m63, m64, m65, m66)
scalar_add_impl!(Mat6, u32, Mat6AddRhs, m11, m12, m13, m14, m15, m16, m21, m22, m23, m24, m25, m26,
m31, m32, m33, m34, m35, m36, m41, m42, m43, m44, m45, m46, m51, m52, m53, m54, m55, m56,
m61, m62, m63, m64, m65, m66)
scalar_add_impl!(Mat6, u16, Mat6AddRhs, m11, m12, m13, m14, m15, m16, m21, m22, m23, m24, m25, m26,
m31, m32, m33, m34, m35, m36, m41, m42, m43, m44, m45, m46, m51, m52, m53, m54, m55, m56,
m61, m62, m63, m64, m65, m66)
scalar_add_impl!(Mat6, u8, Mat6AddRhs, m11, m12, m13, m14, m15, m16, m21, m22, m23, m24, m25, m26,
m31, m32, m33, m34, m35, m36, m41, m42, m43, m44, m45, m46, m51, m52, m53, m54, m55, m56,
m61, m62, m63, m64, m65, m66)
scalar_add_impl!(Mat6, float, Mat6AddRhs, m11, m12, m13, m14, m15, m16, m21, m22, m23, m24, m25, m26,
m31, m32, m33, m34, m35, m36, m41, m42, m43, m44, m45, m46, m51, m52, m53, m54, m55, m56,
m61, m62, m63, m64, m65, m66)
scalar_add_impl!(Mat6, uint, Mat6AddRhs, m11, m12, m13, m14, m15, m16, m21, m22, m23, m24, m25, m26,
m31, m32, m33, m34, m35, m36, m41, m42, m43, m44, m45, m46, m51, m52, m53, m54, m55, m56,
m61, m62, m63, m64, m65, m66)
scalar_add_impl!(Mat6, int, Mat6AddRhs, m11, m12, m13, m14, m15, m16, m21, m22, m23, m24, m25, m26,
m31, m32, m33, m34, m35, m36, m41, m42, m43, m44, m45, m46, m51, m52, m53, m54, m55, m56,
m61, m62, m63, m64, m65, m66)
scalar_sub_impl!(Mat6, f64, Mat6SubRhs, m11, m12, m13, m14, m15, m16, m21, m22, m23, m24, m25, m26,
m31, m32, m33, m34, m35, m36, m41, m42, m43, m44, m45, m46, m51, m52, m53, m54, m55, m56,
m61, m62, m63, m64, m65, m66)
scalar_sub_impl!(Mat6, f32, Mat6SubRhs, m11, m12, m13, m14, m15, m16, m21, m22, m23, m24, m25, m26,
m31, m32, m33, m34, m35, m36, m41, m42, m43, m44, m45, m46, m51, m52, m53, m54, m55, m56,
m61, m62, m63, m64, m65, m66)
scalar_sub_impl!(Mat6, i64, Mat6SubRhs, m11, m12, m13, m14, m15, m16, m21, m22, m23, m24, m25, m26,
m31, m32, m33, m34, m35, m36, m41, m42, m43, m44, m45, m46, m51, m52, m53, m54, m55, m56,
m61, m62, m63, m64, m65, m66)
scalar_sub_impl!(Mat6, i32, Mat6SubRhs, m11, m12, m13, m14, m15, m16, m21, m22, m23, m24, m25, m26,
m31, m32, m33, m34, m35, m36, m41, m42, m43, m44, m45, m46, m51, m52, m53, m54, m55, m56,
m61, m62, m63, m64, m65, m66)
scalar_sub_impl!(Mat6, i16, Mat6SubRhs, m11, m12, m13, m14, m15, m16, m21, m22, m23, m24, m25, m26,
m31, m32, m33, m34, m35, m36, m41, m42, m43, m44, m45, m46, m51, m52, m53, m54, m55, m56,
m61, m62, m63, m64, m65, m66)
scalar_sub_impl!(Mat6, i8, Mat6SubRhs, m11, m12, m13, m14, m15, m16, m21, m22, m23, m24, m25, m26,
m31, m32, m33, m34, m35, m36, m41, m42, m43, m44, m45, m46, m51, m52, m53, m54, m55, m56,
m61, m62, m63, m64, m65, m66)
scalar_sub_impl!(Mat6, u64, Mat6SubRhs, m11, m12, m13, m14, m15, m16, m21, m22, m23, m24, m25, m26,
m31, m32, m33, m34, m35, m36, m41, m42, m43, m44, m45, m46, m51, m52, m53, m54, m55, m56,
m61, m62, m63, m64, m65, m66)
scalar_sub_impl!(Mat6, u32, Mat6SubRhs, m11, m12, m13, m14, m15, m16, m21, m22, m23, m24, m25, m26,
m31, m32, m33, m34, m35, m36, m41, m42, m43, m44, m45, m46, m51, m52, m53, m54, m55, m56,
m61, m62, m63, m64, m65, m66)
scalar_sub_impl!(Mat6, u16, Mat6SubRhs, m11, m12, m13, m14, m15, m16, m21, m22, m23, m24, m25, m26,
m31, m32, m33, m34, m35, m36, m41, m42, m43, m44, m45, m46, m51, m52, m53, m54, m55, m56,
m61, m62, m63, m64, m65, m66)
scalar_sub_impl!(Mat6, u8, Mat6SubRhs, m11, m12, m13, m14, m15, m16, m21, m22, m23, m24, m25, m26,
m31, m32, m33, m34, m35, m36, m41, m42, m43, m44, m45, m46, m51, m52, m53, m54, m55, m56,
m61, m62, m63, m64, m65, m66)
scalar_sub_impl!(Mat6, float, Mat6SubRhs, m11, m12, m13, m14, m15, m16, m21, m22, m23, m24, m25, m26,
m31, m32, m33, m34, m35, m36, m41, m42, m43, m44, m45, m46, m51, m52, m53, m54, m55, m56,
m61, m62, m63, m64, m65, m66)
scalar_sub_impl!(Mat6, uint, Mat6SubRhs, m11, m12, m13, m14, m15, m16, m21, m22, m23, m24, m25, m26,
m31, m32, m33, m34, m35, m36, m41, m42, m43, m44, m45, m46, m51, m52, m53, m54, m55, m56,
m61, m62, m63, m64, m65, m66)
scalar_sub_impl!(Mat6, int, Mat6SubRhs, m11, m12, m13, m14, m15, m16, m21, m22, m23, m24, m25, m26,
m31, m32, m33, m34, m35, m36, m41, m42, m43, m44, m45, m46, m51, m52, m53, m54, m55, m56,
m61, m62, m63, m64, m65, m66)
absolute_impl!(Mat6, m11, m12, m13, m14, m15, m16, m21, m22, m23, m24, m25, m26,
m31, m32, m33, m34, m35, m36, m41, m42, m43, m44, m45, m46, m51, m52, m53, m54, m55, m56,
m61, m62, m63, m64, m65, m66)
one_impl!(Mat6, one_impl!(Mat6,
One::one , Zero::zero, Zero::zero, Zero::zero, Zero::zero, Zero::zero, One::one , Zero::zero, Zero::zero, Zero::zero, Zero::zero, Zero::zero,
Zero::zero, One::one , Zero::zero, Zero::zero, Zero::zero, Zero::zero, Zero::zero, One::one , Zero::zero, Zero::zero, Zero::zero, Zero::zero,
@ -474,10 +948,9 @@ iterable_mut_impl!(Mat6, 6)
dim_impl!(Mat6, 6) dim_impl!(Mat6, 6)
indexable_impl!(Mat6, 6) indexable_impl!(Mat6, 6)
at_fast_impl!(Mat6, 6) at_fast_impl!(Mat6, 6)
mul_redispatch_impl!(Mat6, Mat6MulRhs)
mat_mul_mat_impl!(Mat6, Mat6MulRhs, 6) mat_mul_mat_impl!(Mat6, Mat6MulRhs, 6)
rmul_impl!(Mat6, Vec6, 6) rmul_impl!(Mat6, Vec6, 6)
lmul_impl!(Mat6, Vec6, 6) vec_mul_mat_impl!(Mat6, Vec6, Mat6MulRhs, 6)
transform_impl!(Mat6, Vec6) transform_impl!(Mat6, Vec6)
inv_impl!(Mat6, 6) inv_impl!(Mat6, 6)
transpose_impl!(Mat6, 6) transpose_impl!(Mat6, 6)

View File

@ -44,10 +44,10 @@ macro_rules! mat_cast_impl(
) )
macro_rules! add_impl( macro_rules! add_impl(
($t: ident, $comp0: ident $(,$compN: ident)*) => ( ($t: ident, $trhs: ident, $comp0: ident $(,$compN: ident)*) => (
impl<N: Add<N, N>> Add<$t<N>, $t<N>> for $t<N> { impl<N: Clone + Add<N, N>> $trhs<N, $t<N>> for $t<N> {
#[inline] #[inline]
fn add(&self, other: &$t<N>) -> $t<N> { fn $trhs(&self, other: &$t<N>) -> $t<N> {
$t::new(self.$comp0 + other.$comp0 $(, self.$compN + other.$compN)*) $t::new(self.$comp0 + other.$comp0 $(, self.$compN + other.$compN)*)
} }
} }
@ -55,69 +55,55 @@ macro_rules! add_impl(
) )
macro_rules! sub_impl( macro_rules! sub_impl(
($t: ident, $comp0: ident $(,$compN: ident)*) => ( ($t: ident, $trhs: ident, $comp0: ident $(,$compN: ident)*) => (
impl<N: Sub<N, N>> Sub<$t<N>, $t<N>> for $t<N> { impl<N: Clone + Sub<N, N>> $trhs<N, $t<N>> for $t<N> {
#[inline] #[inline]
fn sub(&self, other: &$t<N>) -> $t<N> { fn $trhs(&self, other: &$t<N>) -> $t<N> {
$t::new(self.$comp0 - other.$comp0 $(, self.$compN - other.$compN )*) $t::new(other.$comp0 - self.$comp0 $(, other.$compN - self.$compN)*)
} }
} }
) )
) )
macro_rules! scalar_mul_impl( macro_rules! scalar_mul_impl(
($t: ident, $comp0: ident $(,$compN: ident)*) => ( ($t: ident, $n: ident, $trhs: ident, $comp0: ident $(,$compN: ident)*) => (
impl<N: Mul<N, N>> $t<N> { impl $trhs<$n, $t<$n>> for $n {
#[inline] #[inline]
/// Scalar multiplication of each component of this matrix by a scalar. fn $trhs(&self, s: &$t<$n>) -> $t<$n> {
pub fn scalar_mul(&self, other: &N) -> $t<N> { $t::new(s.$comp0 * *self $(, s.$compN * *self)*)
$t::new(self.$comp0 * *other $(, self.$compN * *other )*)
} }
} }
) )
) )
macro_rules! scalar_div_impl( macro_rules! scalar_div_impl(
($t: ident, $comp0: ident $(,$compN: ident)*) => ( ($t: ident, $n: ident, $trhs: ident, $comp0: ident $(,$compN: ident)*) => (
impl<N: Div<N, N>> $t<N> { impl $trhs<$n, $t<$n>> for $n {
#[inline] #[inline]
/// Scalar division of each component of this matrix by a scalar. fn $trhs(&self, s: &$t<$n>) -> $t<$n> {
pub fn scalar_div(&self, other: &N) -> $t<N> { $t::new(s.$comp0 / *self $(, s.$compN / *self)*)
$t::new(self.$comp0 / *other $(, self.$compN / *other )*)
} }
} }
) )
) )
macro_rules! scalar_add_impl( macro_rules! scalar_add_impl(
($t: ident, $comp0: ident $(,$compN: ident)*) => ( ($t: ident, $n: ident, $trhs: ident, $comp0: ident $(,$compN: ident)*) => (
impl<N: Add<N, N>> ScalarAdd<N> for $t<N> { impl $trhs<$n, $t<$n>> for $n {
#[inline] #[inline]
fn scalar_add(&self, other: &N) -> $t<N> { fn $trhs(&self, s: &$t<$n>) -> $t<$n> {
$t::new(self.$comp0 + *other $(, self.$compN + *other )*) $t::new(s.$comp0 + *self $(, s.$compN + *self)*)
}
#[inline]
fn scalar_add_inplace(&mut self, other: &N) {
self.$comp0 = self.$comp0 + *other;
$(self.$compN = self.$compN + *other; )*
} }
} }
) )
) )
macro_rules! scalar_sub_impl( macro_rules! scalar_sub_impl(
($t: ident, $comp0: ident $(,$compN: ident)*) => ( ($t: ident, $n: ident, $trhs: ident, $comp0: ident $(,$compN: ident)*) => (
impl<N: Sub<N, N>> ScalarSub<N> for $t<N> { impl $trhs<$n, $t<$n>> for $n {
#[inline] #[inline]
fn scalar_sub(&self, other: &N) -> $t<N> { fn $trhs(&self, s: &$t<$n>) -> $t<$n> {
$t::new(self.$comp0 - *other $(, self.$compN - *other )*) $t::new(s.$comp0 - *self $(, s.$compN - *self)*)
}
#[inline]
fn scalar_sub_inplace(&mut self, other: &N) {
self.$comp0 = self.$comp0 - *other;
$(self.$compN = self.$compN - *other; )*
} }
} }
) )
@ -292,28 +278,6 @@ macro_rules! col_impl(
) )
) )
// Create the traits needed to do fancy operator oveloading.
// This is a meta version of
// http://smallcultfollowing.com/babysteps/blog/2012/10/04/refining-traits-slash-impls/
macro_rules! double_dispatch_binop_decl_trait(
($t: ident, $trhs: ident) => (
pub trait $trhs<N, Res> {
fn $trhs(&self, other: &$t<N>) -> Res;
}
)
)
macro_rules! mul_redispatch_impl(
($t: ident, $trhs: ident) => (
impl<N: Clone + Num, Rhs: $trhs<N, Res>, Res> Mul<Rhs, Res> for $t<N> {
#[inline]
fn mul(&self, other: &Rhs) -> Res {
other.$trhs(self)
}
}
)
)
macro_rules! mat_mul_mat_impl( macro_rules! mat_mul_mat_impl(
($t: ident, $trhs: ident, $dim: expr) => ( ($t: ident, $trhs: ident, $dim: expr) => (
impl<N: Clone + Num> $trhs<N, $t<N>> for $t<N> { impl<N: Clone + Num> $trhs<N, $t<N>> for $t<N> {
@ -364,17 +328,17 @@ macro_rules! rmul_impl(
) )
) )
macro_rules! lmul_impl( macro_rules! vec_mul_mat_impl(
($t: ident, $v: ident, $dim: expr) => ( ($t: ident, $v: ident, $trhs: ident, $dim: expr) => (
impl<N: Clone + Num> LMul<$v<N>> for $t<N> { impl<N: Clone + Num> $trhs<N, $v<N>> for $v<N> {
#[inline] #[inline]
fn lmul(&self, other: &$v<N>) -> $v<N> { fn $trhs(&self, other: &$t<N>) -> $v<N> {
let mut res : $v<N> = Zero::zero(); let mut res : $v<N> = Zero::zero();
for i in range(0u, $dim) { for i in range(0u, $dim) {
for j in range(0u, $dim) { for j in range(0u, $dim) {
unsafe { unsafe {
let val = res.at_fast(i) + other.at_fast(j) * self.at_fast((j, i)); let val = self.at_fast(i) + self.at_fast(j) * other.at_fast((j, i));
res.set_fast(i, val) res.set_fast(i, val)
} }
} }

View File

@ -1,6 +1,6 @@
use std::num::{Zero, One}; use std::num::{Zero, One};
use vec::{Vec2, Vec3}; use vec::{Vec2, Vec3};
use mat::{Mat1, Mat2, Mat3, Inv, Row, Col, RMul, LMul}; use mat::{Mat1, Mat2, Mat3, Inv, Row, Col, RMul, LMul, Mat3MulRhs, Mat2MulRhs};
use mat; use mat;
// some specializations: // some specializations:
@ -189,34 +189,34 @@ impl<N: Clone> Col<Vec3<N>> for Mat3<N> {
} }
} }
impl<N: Mul<N, N> + Add<N, N>> Mul<Mat3<N>, Mat3<N>> for Mat3<N> { impl<N: Mul<N, N> + Add<N, N>> Mat3MulRhs<N, Mat3<N>> for Mat3<N> {
#[inline] #[inline]
fn mul(&self, other: &Mat3<N>) -> Mat3<N> { fn Mat3MulRhs(&self, other: &Mat3<N>) -> Mat3<N> {
Mat3::new( Mat3::new(
self.m11 * other.m11 + self.m12 * other.m21 + self.m13 * other.m31, other.m11 * self.m11 + other.m12 * self.m21 + other.m13 * self.m31,
self.m11 * other.m12 + self.m12 * other.m22 + self.m13 * other.m32, other.m11 * self.m12 + other.m12 * self.m22 + other.m13 * self.m32,
self.m11 * other.m13 + self.m12 * other.m23 + self.m13 * other.m33, other.m11 * self.m13 + other.m12 * self.m23 + other.m13 * self.m33,
self.m21 * other.m11 + self.m22 * other.m21 + self.m23 * other.m31, other.m21 * self.m11 + other.m22 * self.m21 + other.m23 * self.m31,
self.m21 * other.m12 + self.m22 * other.m22 + self.m23 * other.m32, other.m21 * self.m12 + other.m22 * self.m22 + other.m23 * self.m32,
self.m21 * other.m13 + self.m22 * other.m23 + self.m23 * other.m33, other.m21 * self.m13 + other.m22 * self.m23 + other.m23 * self.m33,
self.m31 * other.m11 + self.m32 * other.m21 + self.m33 * other.m31, other.m31 * self.m11 + other.m32 * self.m21 + other.m33 * self.m31,
self.m31 * other.m12 + self.m32 * other.m22 + self.m33 * other.m32, other.m31 * self.m12 + other.m32 * self.m22 + other.m33 * self.m32,
self.m31 * other.m13 + self.m32 * other.m23 + self.m33 * other.m33 other.m31 * self.m13 + other.m32 * self.m23 + other.m33 * self.m33
) )
} }
} }
impl<N: Mul<N, N> + Add<N, N>> Mul<Mat2<N>, Mat2<N>> for Mat2<N> { impl<N: Mul<N, N> + Add<N, N>> Mat2MulRhs<N, Mat2<N>> for Mat2<N> {
#[inline(always)] #[inline(always)]
fn mul(&self, other: &Mat2<N>) -> Mat2<N> { fn Mat2MulRhs(&self, other: &Mat2<N>) -> Mat2<N> {
Mat2::new( Mat2::new(
self.m11 * other.m11 + self.m12 * other.m21, other.m11 * self.m11 + other.m12 * self.m21,
self.m11 * other.m12 + self.m12 * other.m22, other.m11 * self.m12 + other.m12 * self.m22,
self.m21 * other.m11 + self.m22 * other.m21, other.m21 * self.m11 + other.m22 * self.m21,
self.m21 * other.m12 + self.m22 * other.m22 other.m21 * self.m12 + other.m22 * self.m22
) )
} }
} }

62
src/metal.rs Normal file
View File

@ -0,0 +1,62 @@
#[macro_escape];
// Create the traits needed to do fancy operator oveloading.
// This is a meta version of
// http://smallcultfollowing.com/babysteps/blog/2012/10/04/refining-traits-slash-impls/
//
// Hopefully future version of the language will make this useless.
macro_rules! double_dispatch_binop_decl_trait(
($t: ident, $trhs: ident) => (
pub trait $trhs<N, Res> {
fn $trhs(&self, other: &$t<N>) -> Res;
}
)
)
// Macro driving the `Mul` trait to use the related trait for double redispatch.
macro_rules! mul_redispatch_impl(
($t: ident, $trhs: ident) => (
impl<N, Rhs: $trhs<N, Res>, Res> Mul<Rhs, Res> for $t<N> {
#[inline(always)]
fn mul(&self, other: &Rhs) -> Res {
other.$trhs(self)
}
}
)
)
// Macro driving the `Div` trait to use the related trait for double redispatch.
macro_rules! div_redispatch_impl(
($t: ident, $trhs: ident) => (
impl<N, Rhs: $trhs<N, Res>, Res> Div<Rhs, Res> for $t<N> {
#[inline(always)]
fn div(&self, other: &Rhs) -> Res {
other.$trhs(self)
}
}
)
)
// Macro driving the `Div` trait to use the related trait for double redispatch.
macro_rules! add_redispatch_impl(
($t: ident, $trhs: ident) => (
impl<N, Rhs: $trhs<N, Res>, Res> Add<Rhs, Res> for $t<N> {
#[inline(always)]
fn add(&self, other: &Rhs) -> Res {
other.$trhs(self)
}
}
)
)
// Macro driving the `Div` trait to use the related trait for double redispatch.
macro_rules! sub_redispatch_impl(
($t: ident, $trhs: ident) => (
impl<N, Rhs: $trhs<N, Res>, Res> Sub<Rhs, Res> for $t<N> {
#[inline(always)]
fn sub(&self, other: &Rhs) -> Res {
other.$trhs(self)
}
}
)
)

View File

@ -41,8 +41,8 @@ macro_rules! test_scalar_op_impl(
assert!(((v1 * n) / n).approx_eq(&v1)); assert!(((v1 * n) / n).approx_eq(&v1));
assert!(((v1 / n) * n).approx_eq(&v1)); assert!(((v1 / n) * n).approx_eq(&v1));
assert!(v1.scalar_sub(&n).scalar_add(&n).approx_eq(&v1)); assert!(((v1 - n) + n).approx_eq(&v1));
assert!(v1.scalar_add(&n).scalar_sub(&n).approx_eq(&v1)); assert!(((v1 + n) - n).approx_eq(&v1));
let mut v1 : $t = random(); let mut v1 : $t = random();
let v0 : $t = v1.clone(); let v0 : $t = v1.clone();

View File

@ -1,12 +1,24 @@
// XXX: those traits should not exist since there is generalized operator overloading of Add and
// Sub.
// However, using the same trait multiple time as a trait bound (ex: impl<T: Add<N, V> + Add<V, V>)
// does not work properly, mainly because the way we are doing generalized operator overloading is
// verry hacky.
//
// Hopefull, this will be fixed on the future.
/** /**
* Trait of objects having an addition with a scalar. * Trait of objects having an addition with a scalar.
*/ */
pub trait ScalarAdd<N> { pub trait ScalarAdd<N> {
/// Gets the result of an addition by a scalar. /// Gets the result of an addition by a scalar.
fn scalar_add(&self, &N) -> Self; fn add_s(&self, &N) -> Self;
}
/// In-place version of `scalar_add`. impl<N, T: Add<N, T>> ScalarAdd<N> for T {
fn scalar_add_inplace(&mut self, &N); /// Gets the result of an addition by a scalar.
fn add_s(&self, n: &N) -> T {
*self + *n
}
} }
/** /**
@ -14,8 +26,12 @@ pub trait ScalarAdd<N> {
*/ */
pub trait ScalarSub<N> { pub trait ScalarSub<N> {
/// Gets the result of a subtraction by a scalar. /// Gets the result of a subtraction by a scalar.
fn scalar_sub(&self, &N) -> Self; fn sub_s(&self, &N) -> Self;
}
/// In-place version of `scalar_sub`.
fn scalar_sub_inplace(&mut self, &N); impl<N, T: Sub<N, T>> ScalarSub<N> for T {
/// Gets the result of an subition by a scalar.
fn sub_s(&self, n: &N) -> T {
*self - *n
}
} }

View File

@ -8,6 +8,9 @@ use traits::scalar_op::{ScalarAdd, ScalarSub};
use traits::dot::Dot; use traits::dot::Dot;
use traits::norm::Norm; use traits::norm::Norm;
// XXX: we keep ScalarAdd and ScalarSub here to avoid trait impl conflict (overriding) between the
// different Add/Sub traits. This is _so_ unfortunate…
// NOTE: cant call that `Vector` because it conflicts with std::Vector // NOTE: cant call that `Vector` because it conflicts with std::Vector
/// Trait grouping most common operations on vectors. /// Trait grouping most common operations on vectors.
pub trait Vec<N>: Dim + Sub<Self, Self> + Add<Self, Self> + Neg<Self> + Zero + Eq + Mul<N, Self> pub trait Vec<N>: Dim + Sub<Self, Self> + Add<Self, Self> + Neg<Self> + Zero + Eq + Mul<N, Self>

View File

@ -1,3 +1,5 @@
#[doc(hidden)]; // we hide doc to not have to document the $trhs double dispatch trait.
use std::cast; use std::cast;
use std::num::{Zero, One, Algebraic, Bounded}; use std::num::{Zero, One, Algebraic, Bounded};
use std::rand::Rng; use std::rand::Rng;
@ -26,6 +28,7 @@ pub use traits::norm::Norm;
// structs // structs
pub use dvec::DVec; pub use dvec::DVec;
mod metal;
mod vec_macros; mod vec_macros;
/// Vector of dimension 0. /// Vector of dimension 0.
@ -39,6 +42,14 @@ pub struct Vec1<N> {
x: N x: N
} }
double_dispatch_binop_decl_trait!(Vec1, Vec1MulRhs)
double_dispatch_binop_decl_trait!(Vec1, Vec1DivRhs)
double_dispatch_binop_decl_trait!(Vec1, Vec1AddRhs)
double_dispatch_binop_decl_trait!(Vec1, Vec1SubRhs)
mul_redispatch_impl!(Vec1, Vec1MulRhs)
div_redispatch_impl!(Vec1, Vec1DivRhs)
add_redispatch_impl!(Vec1, Vec1AddRhs)
sub_redispatch_impl!(Vec1, Vec1SubRhs)
new_impl!(Vec1, x) new_impl!(Vec1, x)
ord_impl!(Vec1, x) ord_impl!(Vec1, x)
orderable_impl!(Vec1, x) orderable_impl!(Vec1, x)
@ -50,16 +61,64 @@ new_repeat_impl!(Vec1, val, x)
dim_impl!(Vec1, 1) dim_impl!(Vec1, 1)
container_impl!(Vec1) container_impl!(Vec1)
// (specialized) basis_impl!(Vec1, 1) // (specialized) basis_impl!(Vec1, 1)
add_impl!(Vec1, x) add_impl!(Vec1, Vec1AddRhs, x)
sub_impl!(Vec1, x) sub_impl!(Vec1, Vec1SubRhs, x)
neg_impl!(Vec1, x) neg_impl!(Vec1, x)
dot_impl!(Vec1, x) dot_impl!(Vec1, x)
scalar_mul_impl!(Vec1, x) scalar_mul_impl!(Vec1, f64, Vec1MulRhs, x)
scalar_div_impl!(Vec1, x) scalar_mul_impl!(Vec1, f32, Vec1MulRhs, x)
scalar_add_impl!(Vec1, x) scalar_mul_impl!(Vec1, u64, Vec1MulRhs, x)
scalar_sub_impl!(Vec1, x) scalar_mul_impl!(Vec1, u32, Vec1MulRhs, x)
scalar_mul_impl!(Vec1, u16, Vec1MulRhs, x)
scalar_mul_impl!(Vec1, u8, Vec1MulRhs, x)
scalar_mul_impl!(Vec1, i64, Vec1MulRhs, x)
scalar_mul_impl!(Vec1, i32, Vec1MulRhs, x)
scalar_mul_impl!(Vec1, i16, Vec1MulRhs, x)
scalar_mul_impl!(Vec1, i8, Vec1MulRhs, x)
scalar_mul_impl!(Vec1, float, Vec1MulRhs, x)
scalar_mul_impl!(Vec1, uint, Vec1MulRhs, x)
scalar_mul_impl!(Vec1, int, Vec1MulRhs, x)
scalar_div_impl!(Vec1, f64, Vec1DivRhs, x)
scalar_div_impl!(Vec1, f32, Vec1DivRhs, x)
scalar_div_impl!(Vec1, u64, Vec1DivRhs, x)
scalar_div_impl!(Vec1, u32, Vec1DivRhs, x)
scalar_div_impl!(Vec1, u16, Vec1DivRhs, x)
scalar_div_impl!(Vec1, u8, Vec1DivRhs, x)
scalar_div_impl!(Vec1, i64, Vec1DivRhs, x)
scalar_div_impl!(Vec1, i32, Vec1DivRhs, x)
scalar_div_impl!(Vec1, i16, Vec1DivRhs, x)
scalar_div_impl!(Vec1, i8, Vec1DivRhs, x)
scalar_div_impl!(Vec1, float, Vec1DivRhs, x)
scalar_div_impl!(Vec1, uint, Vec1DivRhs, x)
scalar_div_impl!(Vec1, int, Vec1DivRhs, x)
scalar_add_impl!(Vec1, f64, Vec1AddRhs, x)
scalar_add_impl!(Vec1, f32, Vec1AddRhs, x)
scalar_add_impl!(Vec1, u64, Vec1AddRhs, x)
scalar_add_impl!(Vec1, u32, Vec1AddRhs, x)
scalar_add_impl!(Vec1, u16, Vec1AddRhs, x)
scalar_add_impl!(Vec1, u8, Vec1AddRhs, x)
scalar_add_impl!(Vec1, i64, Vec1AddRhs, x)
scalar_add_impl!(Vec1, i32, Vec1AddRhs, x)
scalar_add_impl!(Vec1, i16, Vec1AddRhs, x)
scalar_add_impl!(Vec1, i8, Vec1AddRhs, x)
scalar_add_impl!(Vec1, float, Vec1AddRhs, x)
scalar_add_impl!(Vec1, uint, Vec1AddRhs, x)
scalar_add_impl!(Vec1, int, Vec1AddRhs, x)
scalar_sub_impl!(Vec1, f64, Vec1SubRhs, x)
scalar_sub_impl!(Vec1, f32, Vec1SubRhs, x)
scalar_sub_impl!(Vec1, u64, Vec1SubRhs, x)
scalar_sub_impl!(Vec1, u32, Vec1SubRhs, x)
scalar_sub_impl!(Vec1, u16, Vec1SubRhs, x)
scalar_sub_impl!(Vec1, u8, Vec1SubRhs, x)
scalar_sub_impl!(Vec1, i64, Vec1SubRhs, x)
scalar_sub_impl!(Vec1, i32, Vec1SubRhs, x)
scalar_sub_impl!(Vec1, i16, Vec1SubRhs, x)
scalar_sub_impl!(Vec1, i8, Vec1SubRhs, x)
scalar_sub_impl!(Vec1, float, Vec1SubRhs, x)
scalar_sub_impl!(Vec1, uint, Vec1SubRhs, x)
scalar_sub_impl!(Vec1, int, Vec1SubRhs, x)
translation_impl!(Vec1) translation_impl!(Vec1)
norm_impl!(Vec1) norm_impl!(Vec1, x)
approx_eq_impl!(Vec1, x) approx_eq_impl!(Vec1, x)
round_impl!(Vec1, x) round_impl!(Vec1, x)
one_impl!(Vec1) one_impl!(Vec1)
@ -82,6 +141,14 @@ pub struct Vec2<N> {
y: N y: N
} }
double_dispatch_binop_decl_trait!(Vec2, Vec2MulRhs)
double_dispatch_binop_decl_trait!(Vec2, Vec2DivRhs)
double_dispatch_binop_decl_trait!(Vec2, Vec2AddRhs)
double_dispatch_binop_decl_trait!(Vec2, Vec2SubRhs)
mul_redispatch_impl!(Vec2, Vec2MulRhs)
div_redispatch_impl!(Vec2, Vec2DivRhs)
add_redispatch_impl!(Vec2, Vec2AddRhs)
sub_redispatch_impl!(Vec2, Vec2SubRhs)
new_impl!(Vec2, x, y) new_impl!(Vec2, x, y)
ord_impl!(Vec2, x, y) ord_impl!(Vec2, x, y)
orderable_impl!(Vec2, x, y) orderable_impl!(Vec2, x, y)
@ -93,16 +160,64 @@ new_repeat_impl!(Vec2, val, x, y)
dim_impl!(Vec2, 2) dim_impl!(Vec2, 2)
container_impl!(Vec2) container_impl!(Vec2)
// (specialized) basis_impl!(Vec2, 1) // (specialized) basis_impl!(Vec2, 1)
add_impl!(Vec2, x, y) add_impl!(Vec2, Vec2AddRhs, x, y)
sub_impl!(Vec2, x, y) sub_impl!(Vec2, Vec2SubRhs, x, y)
neg_impl!(Vec2, x, y) neg_impl!(Vec2, x, y)
dot_impl!(Vec2, x, y) dot_impl!(Vec2, x, y)
scalar_mul_impl!(Vec2, x, y) scalar_mul_impl!(Vec2, f64, Vec2MulRhs, x, y)
scalar_div_impl!(Vec2, x, y) scalar_mul_impl!(Vec2, f32, Vec2MulRhs, x, y)
scalar_add_impl!(Vec2, x, y) scalar_mul_impl!(Vec2, u64, Vec2MulRhs, x, y)
scalar_sub_impl!(Vec2, x, y) scalar_mul_impl!(Vec2, u32, Vec2MulRhs, x, y)
scalar_mul_impl!(Vec2, u16, Vec2MulRhs, x, y)
scalar_mul_impl!(Vec2, u8, Vec2MulRhs, x, y)
scalar_mul_impl!(Vec2, i64, Vec2MulRhs, x, y)
scalar_mul_impl!(Vec2, i32, Vec2MulRhs, x, y)
scalar_mul_impl!(Vec2, i16, Vec2MulRhs, x, y)
scalar_mul_impl!(Vec2, i8, Vec2MulRhs, x, y)
scalar_mul_impl!(Vec2, float, Vec2MulRhs, x, y)
scalar_mul_impl!(Vec2, uint, Vec2MulRhs, x, y)
scalar_mul_impl!(Vec2, int, Vec2MulRhs, x, y)
scalar_div_impl!(Vec2, f64, Vec2DivRhs, x, y)
scalar_div_impl!(Vec2, f32, Vec2DivRhs, x, y)
scalar_div_impl!(Vec2, u64, Vec2DivRhs, x, y)
scalar_div_impl!(Vec2, u32, Vec2DivRhs, x, y)
scalar_div_impl!(Vec2, u16, Vec2DivRhs, x, y)
scalar_div_impl!(Vec2, u8, Vec2DivRhs, x, y)
scalar_div_impl!(Vec2, i64, Vec2DivRhs, x, y)
scalar_div_impl!(Vec2, i32, Vec2DivRhs, x, y)
scalar_div_impl!(Vec2, i16, Vec2DivRhs, x, y)
scalar_div_impl!(Vec2, i8, Vec2DivRhs, x, y)
scalar_div_impl!(Vec2, float, Vec2DivRhs, x, y)
scalar_div_impl!(Vec2, uint, Vec2DivRhs, x, y)
scalar_div_impl!(Vec2, int, Vec2DivRhs, x, y)
scalar_add_impl!(Vec2, f64, Vec2AddRhs, x, y)
scalar_add_impl!(Vec2, f32, Vec2AddRhs, x, y)
scalar_add_impl!(Vec2, u64, Vec2AddRhs, x, y)
scalar_add_impl!(Vec2, u32, Vec2AddRhs, x, y)
scalar_add_impl!(Vec2, u16, Vec2AddRhs, x, y)
scalar_add_impl!(Vec2, u8, Vec2AddRhs, x, y)
scalar_add_impl!(Vec2, i64, Vec2AddRhs, x, y)
scalar_add_impl!(Vec2, i32, Vec2AddRhs, x, y)
scalar_add_impl!(Vec2, i16, Vec2AddRhs, x, y)
scalar_add_impl!(Vec2, i8, Vec2AddRhs, x, y)
scalar_add_impl!(Vec2, float, Vec2AddRhs, x, y)
scalar_add_impl!(Vec2, uint, Vec2AddRhs, x, y)
scalar_add_impl!(Vec2, int, Vec2AddRhs, x, y)
scalar_sub_impl!(Vec2, f64, Vec2SubRhs, x, y)
scalar_sub_impl!(Vec2, f32, Vec2SubRhs, x, y)
scalar_sub_impl!(Vec2, u64, Vec2SubRhs, x, y)
scalar_sub_impl!(Vec2, u32, Vec2SubRhs, x, y)
scalar_sub_impl!(Vec2, u16, Vec2SubRhs, x, y)
scalar_sub_impl!(Vec2, u8, Vec2SubRhs, x, y)
scalar_sub_impl!(Vec2, i64, Vec2SubRhs, x, y)
scalar_sub_impl!(Vec2, i32, Vec2SubRhs, x, y)
scalar_sub_impl!(Vec2, i16, Vec2SubRhs, x, y)
scalar_sub_impl!(Vec2, i8, Vec2SubRhs, x, y)
scalar_sub_impl!(Vec2, float, Vec2SubRhs, x, y)
scalar_sub_impl!(Vec2, uint, Vec2SubRhs, x, y)
scalar_sub_impl!(Vec2, int, Vec2SubRhs, x, y)
translation_impl!(Vec2) translation_impl!(Vec2)
norm_impl!(Vec2) norm_impl!(Vec2, x, y)
approx_eq_impl!(Vec2, x, y) approx_eq_impl!(Vec2, x, y)
round_impl!(Vec2, x, y) round_impl!(Vec2, x, y)
one_impl!(Vec2) one_impl!(Vec2)
@ -127,6 +242,14 @@ pub struct Vec3<N> {
z: N z: N
} }
double_dispatch_binop_decl_trait!(Vec3, Vec3MulRhs)
double_dispatch_binop_decl_trait!(Vec3, Vec3DivRhs)
double_dispatch_binop_decl_trait!(Vec3, Vec3AddRhs)
double_dispatch_binop_decl_trait!(Vec3, Vec3SubRhs)
mul_redispatch_impl!(Vec3, Vec3MulRhs)
div_redispatch_impl!(Vec3, Vec3DivRhs)
add_redispatch_impl!(Vec3, Vec3AddRhs)
sub_redispatch_impl!(Vec3, Vec3SubRhs)
new_impl!(Vec3, x, y, z) new_impl!(Vec3, x, y, z)
ord_impl!(Vec3, x, y, z) ord_impl!(Vec3, x, y, z)
orderable_impl!(Vec3, x, y, z) orderable_impl!(Vec3, x, y, z)
@ -138,16 +261,67 @@ new_repeat_impl!(Vec3, val, x, y, z)
dim_impl!(Vec3, 3) dim_impl!(Vec3, 3)
container_impl!(Vec3) container_impl!(Vec3)
// (specialized) basis_impl!(Vec3, 1) // (specialized) basis_impl!(Vec3, 1)
add_impl!(Vec3, x, y, z) add_impl!(Vec3, Vec3AddRhs, x, y, z)
sub_impl!(Vec3, x, y, z) sub_impl!(Vec3, Vec3SubRhs, x, y, z)
neg_impl!(Vec3, x, y, z) neg_impl!(Vec3, x, y, z)
dot_impl!(Vec3, x, y, z) dot_impl!(Vec3, x, y, z)
scalar_mul_impl!(Vec3, x, y, z) scalar_mul_impl!(Vec3, f64, Vec3MulRhs, x, y, z)
scalar_div_impl!(Vec3, x, y, z) scalar_mul_impl!(Vec3, f32, Vec3MulRhs, x, y, z)
scalar_add_impl!(Vec3, x, y, z) scalar_mul_impl!(Vec3, u64, Vec3MulRhs, x, y, z)
scalar_sub_impl!(Vec3, x, y, z) scalar_mul_impl!(Vec3, u32, Vec3MulRhs, x, y, z)
scalar_mul_impl!(Vec3, u16, Vec3MulRhs, x, y, z)
scalar_mul_impl!(Vec3, u8, Vec3MulRhs, x, y, z)
scalar_mul_impl!(Vec3, i64, Vec3MulRhs, x, y, z)
scalar_mul_impl!(Vec3, i32, Vec3MulRhs, x, y, z)
scalar_mul_impl!(Vec3, i16, Vec3MulRhs, x, y, z)
scalar_mul_impl!(Vec3, i8, Vec3MulRhs, x, y, z)
scalar_mul_impl!(Vec3, float, Vec3MulRhs, x, y, z)
scalar_mul_impl!(Vec3, uint, Vec3MulRhs, x, y, z)
scalar_mul_impl!(Vec3, int, Vec3MulRhs, x, y, z)
scalar_div_impl!(Vec3, f64, Vec3DivRhs, x, y, z)
scalar_div_impl!(Vec3, f32, Vec3DivRhs, x, y, z)
scalar_div_impl!(Vec3, u64, Vec3DivRhs, x, y, z)
scalar_div_impl!(Vec3, u32, Vec3DivRhs, x, y, z)
scalar_div_impl!(Vec3, u16, Vec3DivRhs, x, y, z)
scalar_div_impl!(Vec3, u8, Vec3DivRhs, x, y, z)
scalar_div_impl!(Vec3, i64, Vec3DivRhs, x, y, z)
scalar_div_impl!(Vec3, i32, Vec3DivRhs, x, y, z)
scalar_div_impl!(Vec3, i16, Vec3DivRhs, x, y, z)
scalar_div_impl!(Vec3, i8, Vec3DivRhs, x, y, z)
scalar_div_impl!(Vec3, float, Vec3DivRhs, x, y, z)
scalar_div_impl!(Vec3, uint, Vec3DivRhs, x, y, z)
scalar_div_impl!(Vec3, int, Vec3DivRhs, x, y, z)
scalar_add_impl!(Vec3, f64, Vec3AddRhs, x, y, z)
scalar_add_impl!(Vec3, f32, Vec3AddRhs, x, y, z)
scalar_add_impl!(Vec3, u64, Vec3AddRhs, x, y, z)
scalar_add_impl!(Vec3, u32, Vec3AddRhs, x, y, z)
scalar_add_impl!(Vec3, u16, Vec3AddRhs, x, y, z)
scalar_add_impl!(Vec3, u8, Vec3AddRhs, x, y, z)
scalar_add_impl!(Vec3, i64, Vec3AddRhs, x, y, z)
scalar_add_impl!(Vec3, i32, Vec3AddRhs, x, y, z)
scalar_add_impl!(Vec3, i16, Vec3AddRhs, x, y, z)
scalar_add_impl!(Vec3, i8, Vec3AddRhs, x, y, z)
scalar_add_impl!(Vec3, float, Vec3AddRhs, x, y, z)
scalar_add_impl!(Vec3, uint, Vec3AddRhs, x, y, z)
scalar_add_impl!(Vec3, int, Vec3AddRhs, x, y, z)
scalar_sub_impl!(Vec3, f64, Vec3SubRhs, x, y, z)
scalar_sub_impl!(Vec3, f32, Vec3SubRhs, x, y, z)
scalar_sub_impl!(Vec3, u64, Vec3SubRhs, x, y, z)
scalar_sub_impl!(Vec3, u32, Vec3SubRhs, x, y, z)
scalar_sub_impl!(Vec3, u16, Vec3SubRhs, x, y, z)
scalar_sub_impl!(Vec3, u8, Vec3SubRhs, x, y, z)
scalar_sub_impl!(Vec3, i64, Vec3SubRhs, x, y, z)
scalar_sub_impl!(Vec3, i32, Vec3SubRhs, x, y, z)
scalar_sub_impl!(Vec3, i16, Vec3SubRhs, x, y, z)
scalar_sub_impl!(Vec3, i8, Vec3SubRhs, x, y, z)
scalar_sub_impl!(Vec3, float, Vec3SubRhs, x, y, z)
scalar_sub_impl!(Vec3, uint, Vec3SubRhs, x, y, z)
scalar_sub_impl!(Vec3, int, Vec3SubRhs, x, y, z)
translation_impl!(Vec3) translation_impl!(Vec3)
norm_impl!(Vec3) norm_impl!(Vec3, x, y ,z)
approx_eq_impl!(Vec3, x, y, z) approx_eq_impl!(Vec3, x, y, z)
round_impl!(Vec3, x, y, z) round_impl!(Vec3, x, y, z)
one_impl!(Vec3) one_impl!(Vec3)
@ -182,6 +356,14 @@ impl<N: Clone> PVec3<N> {
} }
} }
double_dispatch_binop_decl_trait!(PVec3, PVec3MulRhs)
double_dispatch_binop_decl_trait!(PVec3, PVec3DivRhs)
double_dispatch_binop_decl_trait!(PVec3, PVec3AddRhs)
double_dispatch_binop_decl_trait!(PVec3, PVec3SubRhs)
mul_redispatch_impl!(PVec3, PVec3MulRhs)
div_redispatch_impl!(PVec3, PVec3DivRhs)
add_redispatch_impl!(PVec3, PVec3AddRhs)
sub_redispatch_impl!(PVec3, PVec3SubRhs)
ord_impl!(PVec3, x, y, z) ord_impl!(PVec3, x, y, z)
orderable_impl!(PVec3, x, y, z) orderable_impl!(PVec3, x, y, z)
vec_axis_impl!(PVec3, x, y, z) vec_axis_impl!(PVec3, x, y, z)
@ -192,16 +374,64 @@ new_repeat_impl!(PVec3, val, x, y, z, _unused)
dim_impl!(PVec3, 3) dim_impl!(PVec3, 3)
container_impl!(PVec3) container_impl!(PVec3)
// (specialized) basis_impl!(PVec3, 1) // (specialized) basis_impl!(PVec3, 1)
add_impl!(PVec3, x, y, z) add_impl!(PVec3, PVec3AddRhs, x, y, z)
sub_impl!(PVec3, x, y, z) sub_impl!(PVec3, PVec3SubRhs, x, y, z)
neg_impl!(PVec3, x, y, z) neg_impl!(PVec3, x, y, z)
dot_impl!(PVec3, x, y, z) dot_impl!(PVec3, x, y, z)
scalar_mul_impl!(PVec3, x, y, z) scalar_mul_impl!(PVec3, f64, PVec3MulRhs, x, y, z)
scalar_div_impl!(PVec3, x, y, z) scalar_mul_impl!(PVec3, f32, PVec3MulRhs, x, y, z)
scalar_add_impl!(PVec3, x, y, z) scalar_mul_impl!(PVec3, u64, PVec3MulRhs, x, y, z)
scalar_sub_impl!(PVec3, x, y, z) scalar_mul_impl!(PVec3, u32, PVec3MulRhs, x, y, z)
scalar_mul_impl!(PVec3, u16, PVec3MulRhs, x, y, z)
scalar_mul_impl!(PVec3, u8, PVec3MulRhs, x, y, z)
scalar_mul_impl!(PVec3, i64, PVec3MulRhs, x, y, z)
scalar_mul_impl!(PVec3, i32, PVec3MulRhs, x, y, z)
scalar_mul_impl!(PVec3, i16, PVec3MulRhs, x, y, z)
scalar_mul_impl!(PVec3, i8, PVec3MulRhs, x, y, z)
scalar_mul_impl!(PVec3, float, PVec3MulRhs, x, y, z)
scalar_mul_impl!(PVec3, uint, PVec3MulRhs, x, y, z)
scalar_mul_impl!(PVec3, int, PVec3MulRhs, x, y, z)
scalar_div_impl!(PVec3, f64, PVec3DivRhs, x, y, z)
scalar_div_impl!(PVec3, f32, PVec3DivRhs, x, y, z)
scalar_div_impl!(PVec3, u64, PVec3DivRhs, x, y, z)
scalar_div_impl!(PVec3, u32, PVec3DivRhs, x, y, z)
scalar_div_impl!(PVec3, u16, PVec3DivRhs, x, y, z)
scalar_div_impl!(PVec3, u8, PVec3DivRhs, x, y, z)
scalar_div_impl!(PVec3, i64, PVec3DivRhs, x, y, z)
scalar_div_impl!(PVec3, i32, PVec3DivRhs, x, y, z)
scalar_div_impl!(PVec3, i16, PVec3DivRhs, x, y, z)
scalar_div_impl!(PVec3, i8, PVec3DivRhs, x, y, z)
scalar_div_impl!(PVec3, float, PVec3DivRhs, x, y, z)
scalar_div_impl!(PVec3, uint, PVec3DivRhs, x, y, z)
scalar_div_impl!(PVec3, int, PVec3DivRhs, x, y, z)
scalar_add_impl!(PVec3, f64, PVec3AddRhs, x, y, z)
scalar_add_impl!(PVec3, f32, PVec3AddRhs, x, y, z)
scalar_add_impl!(PVec3, u64, PVec3AddRhs, x, y, z)
scalar_add_impl!(PVec3, u32, PVec3AddRhs, x, y, z)
scalar_add_impl!(PVec3, u16, PVec3AddRhs, x, y, z)
scalar_add_impl!(PVec3, u8, PVec3AddRhs, x, y, z)
scalar_add_impl!(PVec3, i64, PVec3AddRhs, x, y, z)
scalar_add_impl!(PVec3, i32, PVec3AddRhs, x, y, z)
scalar_add_impl!(PVec3, i16, PVec3AddRhs, x, y, z)
scalar_add_impl!(PVec3, i8, PVec3AddRhs, x, y, z)
scalar_add_impl!(PVec3, float, PVec3AddRhs, x, y, z)
scalar_add_impl!(PVec3, uint, PVec3AddRhs, x, y, z)
scalar_add_impl!(PVec3, int, PVec3AddRhs, x, y, z)
scalar_sub_impl!(PVec3, f64, PVec3SubRhs, x, y, z)
scalar_sub_impl!(PVec3, f32, PVec3SubRhs, x, y, z)
scalar_sub_impl!(PVec3, u64, PVec3SubRhs, x, y, z)
scalar_sub_impl!(PVec3, u32, PVec3SubRhs, x, y, z)
scalar_sub_impl!(PVec3, u16, PVec3SubRhs, x, y, z)
scalar_sub_impl!(PVec3, u8, PVec3SubRhs, x, y, z)
scalar_sub_impl!(PVec3, i64, PVec3SubRhs, x, y, z)
scalar_sub_impl!(PVec3, i32, PVec3SubRhs, x, y, z)
scalar_sub_impl!(PVec3, i16, PVec3SubRhs, x, y, z)
scalar_sub_impl!(PVec3, i8, PVec3SubRhs, x, y, z)
scalar_sub_impl!(PVec3, float, PVec3SubRhs, x, y, z)
scalar_sub_impl!(PVec3, uint, PVec3SubRhs, x, y, z)
scalar_sub_impl!(PVec3, int, PVec3SubRhs, x, y, z)
translation_impl!(PVec3) translation_impl!(PVec3)
norm_impl!(PVec3) norm_impl!(PVec3, x, y, z)
approx_eq_impl!(PVec3, x, y, z) approx_eq_impl!(PVec3, x, y, z)
round_impl!(PVec3, x, y, z) round_impl!(PVec3, x, y, z)
one_impl!(PVec3) one_impl!(PVec3)
@ -230,6 +460,14 @@ pub struct Vec4<N> {
w: N w: N
} }
double_dispatch_binop_decl_trait!(Vec4, Vec4MulRhs)
double_dispatch_binop_decl_trait!(Vec4, Vec4DivRhs)
double_dispatch_binop_decl_trait!(Vec4, Vec4AddRhs)
double_dispatch_binop_decl_trait!(Vec4, Vec4SubRhs)
mul_redispatch_impl!(Vec4, Vec4MulRhs)
div_redispatch_impl!(Vec4, Vec4DivRhs)
add_redispatch_impl!(Vec4, Vec4AddRhs)
sub_redispatch_impl!(Vec4, Vec4SubRhs)
new_impl!(Vec4, x, y, z, w) new_impl!(Vec4, x, y, z, w)
ord_impl!(Vec4, x, y, z, w) ord_impl!(Vec4, x, y, z, w)
orderable_impl!(Vec4, x, y, z, w) orderable_impl!(Vec4, x, y, z, w)
@ -240,17 +478,65 @@ at_fast_impl!(Vec4, 4)
new_repeat_impl!(Vec4, val, x, y, z, w) new_repeat_impl!(Vec4, val, x, y, z, w)
dim_impl!(Vec4, 4) dim_impl!(Vec4, 4)
container_impl!(Vec4) container_impl!(Vec4)
basis_impl!(Vec4, 4) basis_impl!(Vec4, Vec4MulRhs, 4)
add_impl!(Vec4, x, y, z, w) add_impl!(Vec4, Vec4AddRhs, x, y, z, w)
sub_impl!(Vec4, x, y, z, w) sub_impl!(Vec4, Vec4SubRhs, x, y, z, w)
neg_impl!(Vec4, x, y, z, w) neg_impl!(Vec4, x, y, z, w)
dot_impl!(Vec4, x, y, z, w) dot_impl!(Vec4, x, y, z, w)
scalar_mul_impl!(Vec4, x, y, z, w) scalar_mul_impl!(Vec4, f64, Vec4MulRhs, x, y, z, w)
scalar_div_impl!(Vec4, x, y, z, w) scalar_mul_impl!(Vec4, f32, Vec4MulRhs, x, y, z, w)
scalar_add_impl!(Vec4, x, y, z, w) scalar_mul_impl!(Vec4, u64, Vec4MulRhs, x, y, z, w)
scalar_sub_impl!(Vec4, x, y, z, w) scalar_mul_impl!(Vec4, u32, Vec4MulRhs, x, y, z, w)
scalar_mul_impl!(Vec4, u16, Vec4MulRhs, x, y, z, w)
scalar_mul_impl!(Vec4, u8, Vec4MulRhs, x, y, z, w)
scalar_mul_impl!(Vec4, i64, Vec4MulRhs, x, y, z, w)
scalar_mul_impl!(Vec4, i32, Vec4MulRhs, x, y, z, w)
scalar_mul_impl!(Vec4, i16, Vec4MulRhs, x, y, z, w)
scalar_mul_impl!(Vec4, i8, Vec4MulRhs, x, y, z, w)
scalar_mul_impl!(Vec4, float, Vec4MulRhs, x, y, z, w)
scalar_mul_impl!(Vec4, uint, Vec4MulRhs, x, y, z, w)
scalar_mul_impl!(Vec4, int, Vec4MulRhs, x, y, z, w)
scalar_div_impl!(Vec4, f64, Vec4DivRhs, x, y, z, w)
scalar_div_impl!(Vec4, f32, Vec4DivRhs, x, y, z, w)
scalar_div_impl!(Vec4, u64, Vec4DivRhs, x, y, z, w)
scalar_div_impl!(Vec4, u32, Vec4DivRhs, x, y, z, w)
scalar_div_impl!(Vec4, u16, Vec4DivRhs, x, y, z, w)
scalar_div_impl!(Vec4, u8, Vec4DivRhs, x, y, z, w)
scalar_div_impl!(Vec4, i64, Vec4DivRhs, x, y, z, w)
scalar_div_impl!(Vec4, i32, Vec4DivRhs, x, y, z, w)
scalar_div_impl!(Vec4, i16, Vec4DivRhs, x, y, z, w)
scalar_div_impl!(Vec4, i8, Vec4DivRhs, x, y, z, w)
scalar_div_impl!(Vec4, float, Vec4DivRhs, x, y, z, w)
scalar_div_impl!(Vec4, uint, Vec4DivRhs, x, y, z, w)
scalar_div_impl!(Vec4, int, Vec4DivRhs, x, y, z, w)
scalar_add_impl!(Vec4, f64, Vec4AddRhs, x, y, z, w)
scalar_add_impl!(Vec4, f32, Vec4AddRhs, x, y, z, w)
scalar_add_impl!(Vec4, u64, Vec4AddRhs, x, y, z, w)
scalar_add_impl!(Vec4, u32, Vec4AddRhs, x, y, z, w)
scalar_add_impl!(Vec4, u16, Vec4AddRhs, x, y, z, w)
scalar_add_impl!(Vec4, u8, Vec4AddRhs, x, y, z, w)
scalar_add_impl!(Vec4, i64, Vec4AddRhs, x, y, z, w)
scalar_add_impl!(Vec4, i32, Vec4AddRhs, x, y, z, w)
scalar_add_impl!(Vec4, i16, Vec4AddRhs, x, y, z, w)
scalar_add_impl!(Vec4, i8, Vec4AddRhs, x, y, z, w)
scalar_add_impl!(Vec4, float, Vec4AddRhs, x, y, z, w)
scalar_add_impl!(Vec4, uint, Vec4AddRhs, x, y, z, w)
scalar_add_impl!(Vec4, int, Vec4AddRhs, x, y, z, w)
scalar_sub_impl!(Vec4, f64, Vec4SubRhs, x, y, z, w)
scalar_sub_impl!(Vec4, f32, Vec4SubRhs, x, y, z, w)
scalar_sub_impl!(Vec4, u64, Vec4SubRhs, x, y, z, w)
scalar_sub_impl!(Vec4, u32, Vec4SubRhs, x, y, z, w)
scalar_sub_impl!(Vec4, u16, Vec4SubRhs, x, y, z, w)
scalar_sub_impl!(Vec4, u8, Vec4SubRhs, x, y, z, w)
scalar_sub_impl!(Vec4, i64, Vec4SubRhs, x, y, z, w)
scalar_sub_impl!(Vec4, i32, Vec4SubRhs, x, y, z, w)
scalar_sub_impl!(Vec4, i16, Vec4SubRhs, x, y, z, w)
scalar_sub_impl!(Vec4, i8, Vec4SubRhs, x, y, z, w)
scalar_sub_impl!(Vec4, float, Vec4SubRhs, x, y, z, w)
scalar_sub_impl!(Vec4, uint, Vec4SubRhs, x, y, z, w)
scalar_sub_impl!(Vec4, int, Vec4SubRhs, x, y, z, w)
translation_impl!(Vec4) translation_impl!(Vec4)
norm_impl!(Vec4) norm_impl!(Vec4, x, y, z, w)
approx_eq_impl!(Vec4, x, y, z, w) approx_eq_impl!(Vec4, x, y, z, w)
round_impl!(Vec4, x, y, z, w) round_impl!(Vec4, x, y, z, w)
one_impl!(Vec4) one_impl!(Vec4)
@ -279,6 +565,14 @@ pub struct Vec5<N> {
a: N a: N
} }
double_dispatch_binop_decl_trait!(Vec5, Vec5MulRhs)
double_dispatch_binop_decl_trait!(Vec5, Vec5DivRhs)
double_dispatch_binop_decl_trait!(Vec5, Vec5AddRhs)
double_dispatch_binop_decl_trait!(Vec5, Vec5SubRhs)
mul_redispatch_impl!(Vec5, Vec5MulRhs)
div_redispatch_impl!(Vec5, Vec5DivRhs)
add_redispatch_impl!(Vec5, Vec5AddRhs)
sub_redispatch_impl!(Vec5, Vec5SubRhs)
new_impl!(Vec5, x, y, z, w, a) new_impl!(Vec5, x, y, z, w, a)
ord_impl!(Vec5, x, y, z, w, a) ord_impl!(Vec5, x, y, z, w, a)
orderable_impl!(Vec5, x, y, z, w, a) orderable_impl!(Vec5, x, y, z, w, a)
@ -289,17 +583,65 @@ at_fast_impl!(Vec5, 5)
new_repeat_impl!(Vec5, val, x, y, z, w, a) new_repeat_impl!(Vec5, val, x, y, z, w, a)
dim_impl!(Vec5, 5) dim_impl!(Vec5, 5)
container_impl!(Vec5) container_impl!(Vec5)
basis_impl!(Vec5, 5) basis_impl!(Vec5, Vec5MulRhs, 5)
add_impl!(Vec5, x, y, z, w, a) add_impl!(Vec5, Vec5AddRhs, x, y, z, w, a)
sub_impl!(Vec5, x, y, z, w, a) sub_impl!(Vec5, Vec5SubRhs, x, y, z, w, a)
neg_impl!(Vec5, x, y, z, w, a) neg_impl!(Vec5, x, y, z, w, a)
dot_impl!(Vec5, x, y, z, w, a) dot_impl!(Vec5, x, y, z, w, a)
scalar_mul_impl!(Vec5, x, y, z, w, a) scalar_mul_impl!(Vec5, f64, Vec5MulRhs, x, y, z, w, a)
scalar_div_impl!(Vec5, x, y, z, w, a) scalar_mul_impl!(Vec5, f32, Vec5MulRhs, x, y, z, w, a)
scalar_add_impl!(Vec5, x, y, z, w, a) scalar_mul_impl!(Vec5, u64, Vec5MulRhs, x, y, z, w, a)
scalar_sub_impl!(Vec5, x, y, z, w, a) scalar_mul_impl!(Vec5, u32, Vec5MulRhs, x, y, z, w, a)
scalar_mul_impl!(Vec5, u16, Vec5MulRhs, x, y, z, w, a)
scalar_mul_impl!(Vec5, u8, Vec5MulRhs, x, y, z, w, a)
scalar_mul_impl!(Vec5, i64, Vec5MulRhs, x, y, z, w, a)
scalar_mul_impl!(Vec5, i32, Vec5MulRhs, x, y, z, w, a)
scalar_mul_impl!(Vec5, i16, Vec5MulRhs, x, y, z, w, a)
scalar_mul_impl!(Vec5, i8, Vec5MulRhs, x, y, z, w, a)
scalar_mul_impl!(Vec5, float, Vec5MulRhs, x, y, z, w, a)
scalar_mul_impl!(Vec5, uint, Vec5MulRhs, x, y, z, w, a)
scalar_mul_impl!(Vec5, int, Vec5MulRhs, x, y, z, w, a)
scalar_div_impl!(Vec5, f64, Vec5DivRhs, x, y, z, w, a)
scalar_div_impl!(Vec5, f32, Vec5DivRhs, x, y, z, w, a)
scalar_div_impl!(Vec5, u64, Vec5DivRhs, x, y, z, w, a)
scalar_div_impl!(Vec5, u32, Vec5DivRhs, x, y, z, w, a)
scalar_div_impl!(Vec5, u16, Vec5DivRhs, x, y, z, w, a)
scalar_div_impl!(Vec5, u8, Vec5DivRhs, x, y, z, w, a)
scalar_div_impl!(Vec5, i64, Vec5DivRhs, x, y, z, w, a)
scalar_div_impl!(Vec5, i32, Vec5DivRhs, x, y, z, w, a)
scalar_div_impl!(Vec5, i16, Vec5DivRhs, x, y, z, w, a)
scalar_div_impl!(Vec5, i8, Vec5DivRhs, x, y, z, w, a)
scalar_div_impl!(Vec5, float, Vec5DivRhs, x, y, z, w, a)
scalar_div_impl!(Vec5, uint, Vec5DivRhs, x, y, z, w, a)
scalar_div_impl!(Vec5, int, Vec5DivRhs, x, y, z, w, a)
scalar_add_impl!(Vec5, f64, Vec5AddRhs, x, y, z, w, a)
scalar_add_impl!(Vec5, f32, Vec5AddRhs, x, y, z, w, a)
scalar_add_impl!(Vec5, u64, Vec5AddRhs, x, y, z, w, a)
scalar_add_impl!(Vec5, u32, Vec5AddRhs, x, y, z, w, a)
scalar_add_impl!(Vec5, u16, Vec5AddRhs, x, y, z, w, a)
scalar_add_impl!(Vec5, u8, Vec5AddRhs, x, y, z, w, a)
scalar_add_impl!(Vec5, i64, Vec5AddRhs, x, y, z, w, a)
scalar_add_impl!(Vec5, i32, Vec5AddRhs, x, y, z, w, a)
scalar_add_impl!(Vec5, i16, Vec5AddRhs, x, y, z, w, a)
scalar_add_impl!(Vec5, i8, Vec5AddRhs, x, y, z, w, a)
scalar_add_impl!(Vec5, float, Vec5AddRhs, x, y, z, w, a)
scalar_add_impl!(Vec5, uint, Vec5AddRhs, x, y, z, w, a)
scalar_add_impl!(Vec5, int, Vec5AddRhs, x, y, z, w, a)
scalar_sub_impl!(Vec5, f64, Vec5SubRhs, x, y, z, w, a)
scalar_sub_impl!(Vec5, f32, Vec5SubRhs, x, y, z, w, a)
scalar_sub_impl!(Vec5, u64, Vec5SubRhs, x, y, z, w, a)
scalar_sub_impl!(Vec5, u32, Vec5SubRhs, x, y, z, w, a)
scalar_sub_impl!(Vec5, u16, Vec5SubRhs, x, y, z, w, a)
scalar_sub_impl!(Vec5, u8, Vec5SubRhs, x, y, z, w, a)
scalar_sub_impl!(Vec5, i64, Vec5SubRhs, x, y, z, w, a)
scalar_sub_impl!(Vec5, i32, Vec5SubRhs, x, y, z, w, a)
scalar_sub_impl!(Vec5, i16, Vec5SubRhs, x, y, z, w, a)
scalar_sub_impl!(Vec5, i8, Vec5SubRhs, x, y, z, w, a)
scalar_sub_impl!(Vec5, float, Vec5SubRhs, x, y, z, w, a)
scalar_sub_impl!(Vec5, uint, Vec5SubRhs, x, y, z, w, a)
scalar_sub_impl!(Vec5, int, Vec5SubRhs, x, y, z, w, a)
translation_impl!(Vec5) translation_impl!(Vec5)
norm_impl!(Vec5) norm_impl!(Vec5, x, y, z, w, a)
approx_eq_impl!(Vec5, x, y, z, w, a) approx_eq_impl!(Vec5, x, y, z, w, a)
round_impl!(Vec5, x, y, z, w, a) round_impl!(Vec5, x, y, z, w, a)
one_impl!(Vec5) one_impl!(Vec5)
@ -330,6 +672,14 @@ pub struct Vec6<N> {
b: N b: N
} }
double_dispatch_binop_decl_trait!(Vec6, Vec6MulRhs)
double_dispatch_binop_decl_trait!(Vec6, Vec6DivRhs)
double_dispatch_binop_decl_trait!(Vec6, Vec6AddRhs)
double_dispatch_binop_decl_trait!(Vec6, Vec6SubRhs)
mul_redispatch_impl!(Vec6, Vec6MulRhs)
div_redispatch_impl!(Vec6, Vec6DivRhs)
add_redispatch_impl!(Vec6, Vec6AddRhs)
sub_redispatch_impl!(Vec6, Vec6SubRhs)
new_impl!(Vec6, x, y, z, w, a, b) new_impl!(Vec6, x, y, z, w, a, b)
ord_impl!(Vec6, x, y, z, w, a, b) ord_impl!(Vec6, x, y, z, w, a, b)
orderable_impl!(Vec6, x, y, z, w, a, b) orderable_impl!(Vec6, x, y, z, w, a, b)
@ -340,17 +690,65 @@ at_fast_impl!(Vec6, 6)
new_repeat_impl!(Vec6, val, x, y, z, w, a, b) new_repeat_impl!(Vec6, val, x, y, z, w, a, b)
dim_impl!(Vec6, 6) dim_impl!(Vec6, 6)
container_impl!(Vec6) container_impl!(Vec6)
basis_impl!(Vec6, 6) basis_impl!(Vec6, Vec6MulRhs, 6)
add_impl!(Vec6, x, y, z, w, a, b) add_impl!(Vec6, Vec6AddRhs, x, y, z, w, a, b)
sub_impl!(Vec6, x, y, z, w, a, b) sub_impl!(Vec6, Vec6SubRhs, x, y, z, w, a, b)
neg_impl!(Vec6, x, y, z, w, a, b) neg_impl!(Vec6, x, y, z, w, a, b)
dot_impl!(Vec6, x, y, z, w, a, b) dot_impl!(Vec6, x, y, z, w, a, b)
scalar_mul_impl!(Vec6, x, y, z, w, a, b) scalar_mul_impl!(Vec6, f64, Vec6MulRhs, x, y, z, w, a, b)
scalar_div_impl!(Vec6, x, y, z, w, a, b) scalar_mul_impl!(Vec6, f32, Vec6MulRhs, x, y, z, w, a, b)
scalar_add_impl!(Vec6, x, y, z, w, a, b) scalar_mul_impl!(Vec6, u64, Vec6MulRhs, x, y, z, w, a, b)
scalar_sub_impl!(Vec6, x, y, z, w, a, b) scalar_mul_impl!(Vec6, u32, Vec6MulRhs, x, y, z, w, a, b)
scalar_mul_impl!(Vec6, u16, Vec6MulRhs, x, y, z, w, a, b)
scalar_mul_impl!(Vec6, u8, Vec6MulRhs, x, y, z, w, a, b)
scalar_mul_impl!(Vec6, i64, Vec6MulRhs, x, y, z, w, a, b)
scalar_mul_impl!(Vec6, i32, Vec6MulRhs, x, y, z, w, a, b)
scalar_mul_impl!(Vec6, i16, Vec6MulRhs, x, y, z, w, a, b)
scalar_mul_impl!(Vec6, i8, Vec6MulRhs, x, y, z, w, a, b)
scalar_mul_impl!(Vec6, float, Vec6MulRhs, x, y, z, w, a, b)
scalar_mul_impl!(Vec6, uint, Vec6MulRhs, x, y, z, w, a, b)
scalar_mul_impl!(Vec6, int, Vec6MulRhs, x, y, z, w, a, b)
scalar_div_impl!(Vec6, f64, Vec6DivRhs, x, y, z, w, a, b)
scalar_div_impl!(Vec6, f32, Vec6DivRhs, x, y, z, w, a, b)
scalar_div_impl!(Vec6, u64, Vec6DivRhs, x, y, z, w, a, b)
scalar_div_impl!(Vec6, u32, Vec6DivRhs, x, y, z, w, a, b)
scalar_div_impl!(Vec6, u16, Vec6DivRhs, x, y, z, w, a, b)
scalar_div_impl!(Vec6, u8, Vec6DivRhs, x, y, z, w, a, b)
scalar_div_impl!(Vec6, i64, Vec6DivRhs, x, y, z, w, a, b)
scalar_div_impl!(Vec6, i32, Vec6DivRhs, x, y, z, w, a, b)
scalar_div_impl!(Vec6, i16, Vec6DivRhs, x, y, z, w, a, b)
scalar_div_impl!(Vec6, i8, Vec6DivRhs, x, y, z, w, a, b)
scalar_div_impl!(Vec6, float, Vec6DivRhs, x, y, z, w, a, b)
scalar_div_impl!(Vec6, uint, Vec6DivRhs, x, y, z, w, a, b)
scalar_div_impl!(Vec6, int, Vec6DivRhs, x, y, z, w, a, b)
scalar_add_impl!(Vec6, f64, Vec6AddRhs, x, y, z, w, a, b)
scalar_add_impl!(Vec6, f32, Vec6AddRhs, x, y, z, w, a, b)
scalar_add_impl!(Vec6, u64, Vec6AddRhs, x, y, z, w, a, b)
scalar_add_impl!(Vec6, u32, Vec6AddRhs, x, y, z, w, a, b)
scalar_add_impl!(Vec6, u16, Vec6AddRhs, x, y, z, w, a, b)
scalar_add_impl!(Vec6, u8, Vec6AddRhs, x, y, z, w, a, b)
scalar_add_impl!(Vec6, i64, Vec6AddRhs, x, y, z, w, a, b)
scalar_add_impl!(Vec6, i32, Vec6AddRhs, x, y, z, w, a, b)
scalar_add_impl!(Vec6, i16, Vec6AddRhs, x, y, z, w, a, b)
scalar_add_impl!(Vec6, i8, Vec6AddRhs, x, y, z, w, a, b)
scalar_add_impl!(Vec6, float, Vec6AddRhs, x, y, z, w, a, b)
scalar_add_impl!(Vec6, uint, Vec6AddRhs, x, y, z, w, a, b)
scalar_add_impl!(Vec6, int, Vec6AddRhs, x, y, z, w, a, b)
scalar_sub_impl!(Vec6, f64, Vec6SubRhs, x, y, z, w, a, b)
scalar_sub_impl!(Vec6, f32, Vec6SubRhs, x, y, z, w, a, b)
scalar_sub_impl!(Vec6, u64, Vec6SubRhs, x, y, z, w, a, b)
scalar_sub_impl!(Vec6, u32, Vec6SubRhs, x, y, z, w, a, b)
scalar_sub_impl!(Vec6, u16, Vec6SubRhs, x, y, z, w, a, b)
scalar_sub_impl!(Vec6, u8, Vec6SubRhs, x, y, z, w, a, b)
scalar_sub_impl!(Vec6, i64, Vec6SubRhs, x, y, z, w, a, b)
scalar_sub_impl!(Vec6, i32, Vec6SubRhs, x, y, z, w, a, b)
scalar_sub_impl!(Vec6, i16, Vec6SubRhs, x, y, z, w, a, b)
scalar_sub_impl!(Vec6, i8, Vec6SubRhs, x, y, z, w, a, b)
scalar_sub_impl!(Vec6, float, Vec6SubRhs, x, y, z, w, a, b)
scalar_sub_impl!(Vec6, uint, Vec6SubRhs, x, y, z, w, a, b)
scalar_sub_impl!(Vec6, int, Vec6SubRhs, x, y, z, w, a, b)
translation_impl!(Vec6) translation_impl!(Vec6)
norm_impl!(Vec6) norm_impl!(Vec6, x, y, z, w, a, b)
approx_eq_impl!(Vec6, x, y, z, w, a, b) approx_eq_impl!(Vec6, x, y, z, w, a, b)
round_impl!(Vec6, x, y, z, w, a, b) round_impl!(Vec6, x, y, z, w, a, b)
one_impl!(Vec6) one_impl!(Vec6)

View File

@ -7,7 +7,6 @@ use traits::iterable::{Iterable, IterableMut};
use traits::basis::Basis; use traits::basis::Basis;
use traits::dim::Dim; use traits::dim::Dim;
use traits::translation::Translation; use traits::translation::Translation;
use traits::scalar_op::{ScalarAdd, ScalarSub};
use traits::indexable::Indexable; use traits::indexable::Indexable;
use traits::dot::Dot; use traits::dot::Dot;
use traits::norm::Norm; use traits::norm::Norm;
@ -75,16 +74,16 @@ impl<N> Basis for vec::Vec0<N> {
fn orthonormal_subspace_basis(&self, _: &fn(vec::Vec0<N>) -> bool) { } fn orthonormal_subspace_basis(&self, _: &fn(vec::Vec0<N>) -> bool) { }
} }
impl<N: Clone + Add<N,N>> Add<vec::Vec0<N>, vec::Vec0<N>> for vec::Vec0<N> { impl<N, T> Add<T, vec::Vec0<N>> for vec::Vec0<N> {
#[inline] #[inline]
fn add(&self, _: &vec::Vec0<N>) -> vec::Vec0<N> { fn add(&self, _: &T) -> vec::Vec0<N> {
vec::Vec0 vec::Vec0
} }
} }
impl<N: Clone + Sub<N,N>> Sub<vec::Vec0<N>, vec::Vec0<N>> for vec::Vec0<N> { impl<N, T> Sub<T, vec::Vec0<N>> for vec::Vec0<N> {
#[inline] #[inline]
fn sub(&self, _: &vec::Vec0<N>) -> vec::Vec0<N> { fn sub(&self, _: &T) -> vec::Vec0<N> {
vec::Vec0 vec::Vec0
} }
} }
@ -108,40 +107,20 @@ impl<N: Num + Clone> Dot<N> for vec::Vec0<N> {
} }
} }
impl<N: Mul<N, N>> Mul<N, vec::Vec0<N>> for vec::Vec0<N> { impl<N, T> Mul<T, vec::Vec0<N>> for vec::Vec0<N> {
#[inline] #[inline]
fn mul(&self, _: &N) -> vec::Vec0<N> { fn mul(&self, _: &T) -> vec::Vec0<N> {
vec::Vec0 vec::Vec0
} }
} }
impl<N: Div<N, N>> Div<N, vec::Vec0<N>> for vec::Vec0<N> { impl<N, T> Div<T, vec::Vec0<N>> for vec::Vec0<N> {
#[inline] #[inline]
fn div(&self, _: &N) -> vec::Vec0<N> { fn div(&self, _: &T) -> vec::Vec0<N> {
vec::Vec0 vec::Vec0
} }
} }
impl<N: Add<N, N>> ScalarAdd<N> for vec::Vec0<N> {
#[inline]
fn scalar_add(&self, _: &N) -> vec::Vec0<N> {
vec::Vec0
}
#[inline]
fn scalar_add_inplace(&mut self, _: &N) { }
}
impl<N: Sub<N, N>> ScalarSub<N> for vec::Vec0<N> {
#[inline]
fn scalar_sub(&self, _: &N) -> vec::Vec0<N> {
vec::Vec0
}
#[inline]
fn scalar_sub_inplace(&mut self, _: &N) { }
}
impl<N: Clone + Add<N, N> + Neg<N>> Translation<vec::Vec0<N>> for vec::Vec0<N> { impl<N: Clone + Add<N, N> + Neg<N>> Translation<vec::Vec0<N>> for vec::Vec0<N> {
#[inline] #[inline]
fn translation(&self) -> vec::Vec0<N> { fn translation(&self) -> vec::Vec0<N> {

View File

@ -212,8 +212,8 @@ macro_rules! container_impl(
) )
macro_rules! basis_impl( macro_rules! basis_impl(
($t: ident, $dim: expr) => ( ($t: ident, $trhs: ident, $dim: expr) => (
impl<N: Clone + Num + Algebraic + ApproxEq<N>> Basis for $t<N> { impl<N: Clone + Num + Algebraic + ApproxEq<N> + $trhs<N, $t<N>>> Basis for $t<N> {
#[inline] #[inline]
fn canonical_basis(f: &fn($t<N>) -> bool) { fn canonical_basis(f: &fn($t<N>) -> bool) {
for i in range(0u, $dim) { for i in range(0u, $dim) {
@ -266,10 +266,10 @@ macro_rules! basis_impl(
) )
macro_rules! add_impl( macro_rules! add_impl(
($t: ident, $comp0: ident $(,$compN: ident)*) => ( ($t: ident, $trhs: ident, $comp0: ident $(,$compN: ident)*) => (
impl<N: Clone + Add<N, N>> Add<$t<N>, $t<N>> for $t<N> { impl<N: Clone + Add<N, N>> $trhs<N, $t<N>> for $t<N> {
#[inline] #[inline]
fn add(&self, other: &$t<N>) -> $t<N> { fn $trhs(&self, other: &$t<N>) -> $t<N> {
$t::new(self.$comp0 + other.$comp0 $(, self.$compN + other.$compN)*) $t::new(self.$comp0 + other.$comp0 $(, self.$compN + other.$compN)*)
} }
} }
@ -277,11 +277,11 @@ macro_rules! add_impl(
) )
macro_rules! sub_impl( macro_rules! sub_impl(
($t: ident, $comp0: ident $(,$compN: ident)*) => ( ($t: ident, $trhs: ident, $comp0: ident $(,$compN: ident)*) => (
impl<N: Clone + Sub<N, N>> Sub<$t<N>, $t<N>> for $t<N> { impl<N: Clone + Sub<N, N>> $trhs<N, $t<N>> for $t<N> {
#[inline] #[inline]
fn sub(&self, other: &$t<N>) -> $t<N> { fn $trhs(&self, other: &$t<N>) -> $t<N> {
$t::new(self.$comp0 - other.$comp0 $(, self.$compN - other.$compN)*) $t::new(other.$comp0 - self.$comp0 $(, other.$compN - self.$compN)*)
} }
} }
) )
@ -315,56 +315,44 @@ macro_rules! dot_impl(
) )
macro_rules! scalar_mul_impl( macro_rules! scalar_mul_impl(
($t: ident, $comp0: ident $(,$compN: ident)*) => ( ($t: ident, $n: ident, $trhs: ident, $comp0: ident $(,$compN: ident)*) => (
impl<N: Clone + Mul<N, N>> Mul<N, $t<N>> for $t<N> { impl $trhs<$n, $t<$n>> for $n {
#[inline] #[inline]
fn mul(&self, s: &N) -> $t<N> { fn $trhs(&self, s: &$t<$n>) -> $t<$n> {
$t::new(self.$comp0 * *s $(, self.$compN * *s)*) $t::new(s.$comp0 * *self $(, s.$compN * *self)*)
} }
} }
) )
) )
macro_rules! scalar_div_impl( macro_rules! scalar_div_impl(
($t: ident, $comp0: ident $(,$compN: ident)*) => ( ($t: ident, $n: ident, $trhs: ident, $comp0: ident $(,$compN: ident)*) => (
impl<N: Clone + Div<N, N>> Div<N, $t<N>> for $t<N> { impl $trhs<$n, $t<$n>> for $n {
#[inline] #[inline]
fn div(&self, s: &N) -> $t<N> { fn $trhs(&self, s: &$t<$n>) -> $t<$n> {
$t::new(self.$comp0 / *s $(, self.$compN / *s)*) $t::new(s.$comp0 / *self $(, s.$compN / *self)*)
} }
} }
) )
) )
macro_rules! scalar_add_impl( macro_rules! scalar_add_impl(
($t: ident, $comp0: ident $(,$compN: ident)*) => ( ($t: ident, $n: ident, $trhs: ident, $comp0: ident $(,$compN: ident)*) => (
impl<N: Clone + Add<N, N>> ScalarAdd<N> for $t<N> { impl $trhs<$n, $t<$n>> for $n {
#[inline] #[inline]
fn scalar_add(&self, s: &N) -> $t<N> { fn $trhs(&self, s: &$t<$n>) -> $t<$n> {
$t::new(self.$comp0 + *s $(, self.$compN + *s)*) $t::new(s.$comp0 + *self $(, s.$compN + *self)*)
}
#[inline]
fn scalar_add_inplace(&mut self, s: &N) {
self.$comp0 = self.$comp0 + *s;
$(self.$compN = self.$compN + *s;)*
} }
} }
) )
) )
macro_rules! scalar_sub_impl( macro_rules! scalar_sub_impl(
($t: ident, $comp0: ident $(,$compN: ident)*) => ( ($t: ident, $n: ident, $trhs: ident, $comp0: ident $(,$compN: ident)*) => (
impl<N: Clone + Sub<N, N>> ScalarSub<N> for $t<N> { impl $trhs<$n, $t<$n>> for $n {
#[inline] #[inline]
fn scalar_sub(&self, s: &N) -> $t<N> { fn $trhs(&self, s: &$t<$n>) -> $t<$n> {
$t::new(self.$comp0 - *s $(, self.$compN - *s)*) $t::new(s.$comp0 - *self $(, s.$compN - *self)*)
}
#[inline]
fn scalar_sub_inplace(&mut self, s: &N) {
self.$comp0 = self.$comp0 - *s;
$(self.$compN = self.$compN - *s;)*
} }
} }
) )
@ -402,7 +390,7 @@ macro_rules! translation_impl(
) )
macro_rules! norm_impl( macro_rules! norm_impl(
($t: ident) => ( ($t: ident, $comp0: ident $(,$compN: ident)*) => (
impl<N: Clone + Num + Algebraic> Norm<N> for $t<N> { impl<N: Clone + Num + Algebraic> Norm<N> for $t<N> {
#[inline] #[inline]
fn sqnorm(&self) -> N { fn sqnorm(&self) -> N {
@ -427,7 +415,8 @@ macro_rules! norm_impl(
fn normalize(&mut self) -> N { fn normalize(&mut self) -> N {
let l = self.norm(); let l = self.norm();
*self = *self / l; self.$comp0 = self.$comp0 / l;
$(self.$compN = self.$compN / l;)*
l l
} }
@ -542,10 +531,8 @@ macro_rules! from_homogeneous_impl(
fn from(v: &$t2<N>) -> $t<N> { fn from(v: &$t2<N>) -> $t<N> {
let mut res: $t<N> = Zero::zero(); let mut res: $t<N> = Zero::zero();
res.$comp0 = v.$comp0.clone(); res.$comp0 = v.$comp0.clone() / v.$extra;
$( res.$compN = v.$compN.clone(); )* $( res.$compN = v.$compN.clone() / v.$extra; )*
res = res / v.$extra;
res res
} }