From 342817610dd8c4af5dad557d0072cf0c353ecf38 Mon Sep 17 00:00:00 2001 From: Brendan Zabarauskas Date: Wed, 14 Nov 2012 14:00:26 +1000 Subject: [PATCH] Move add_m and sub_m methods --- src/matrix.rs | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/src/matrix.rs b/src/matrix.rs index 6ee48b0..d152cd1 100644 --- a/src/matrix.rs +++ b/src/matrix.rs @@ -54,11 +54,11 @@ pub trait Matrix: Eq, Index, ToPtr { pub trait NumericMatrix: Matrix, Neg { pure fn mul_t(value: T) -> self; pure fn mul_v(other: &ColVec) -> ColVec; + pure fn add_m(other: &self) -> self; + pure fn sub_m(other: &self) -> self; } pub trait NumericMatrix_NxN: NumericMatrix { - pure fn add_m(other: &self) -> self; - pure fn sub_m(other: &self) -> self; pure fn mul_m(other: &self) -> self; pure fn det() -> T; @@ -170,7 +170,7 @@ pub impl Mat2: Matrix, Vec2> { } } -pub impl Mat2: NumericMatrix, Vec2> { +pub impl Mat2: NumericMatrix, Vec2> { #[inline(always)] pure fn neg() -> Mat2 { Mat2::from_cols(-self[0], -self[1]) @@ -187,9 +187,7 @@ pub impl Mat2: NumericMatrix, Vec2> { Vec2::new(self.row(0).dot(other), self.row(1).dot(other)) } -} - -pub impl Mat2: NumericMatrix_NxN> { + #[inline(always)] pure fn add_m(other: &Mat2) -> Mat2 { Mat2::from_cols(self[0].add_v(&other[0]), @@ -201,7 +199,9 @@ pub impl Mat2: NumericMatrix_NxN> { Mat2::from_cols(self[0].sub_v(&other[0]), self[1].sub_v(&other[1])) } - +} + +pub impl Mat2: NumericMatrix_NxN> { #[inline(always)] pure fn mul_m(other: &Mat2) -> Mat2 { Mat2::new(self.row(0).dot(&other.col(0)), self.row(1).dot(&other.col(0)), @@ -420,9 +420,7 @@ pub impl Mat3: NumericMatrix, Vec3> { self.row(1).dot(other), self.row(2).dot(other)) } -} - -pub impl Mat3: NumericMatrix_NxN> { + #[inline(always)] pure fn add_m(other: &Mat3) -> Mat3 { Mat3::from_cols(self[0].add_v(&other[0]), @@ -436,7 +434,9 @@ pub impl Mat3: NumericMatrix_NxN> { self[1].sub_v(&other[1]), self[2].sub_v(&other[2])) } - +} + +pub impl Mat3: NumericMatrix_NxN> { #[inline(always)] pure fn mul_m(other: &Mat3) -> Mat3 { Mat3::new(self.row(0).dot(&other.col(0)), self.row(1).dot(&other.col(0)), self.row(2).dot(&other.col(0)), @@ -731,9 +731,7 @@ pub impl Mat4: NumericMatrix, Vec4> { self.row(2).dot(other), self.row(3).dot(other)) } -} - -pub impl Mat4: NumericMatrix_NxN> { + #[inline(always)] pure fn add_m(other: &Mat4) -> Mat4 { Mat4::from_cols(self[0].add_v(&other[0]), @@ -749,7 +747,9 @@ pub impl Mat4: NumericMatrix_NxN Mat4: NumericMatrix_NxN> { #[inline(always)] pure fn mul_m(other: &Mat4) -> Mat4 { // Surprisingly when building with optimisation turned on this is actually