From bfe318aff5cd619006abf8e8d87c455a7073124e Mon Sep 17 00:00:00 2001 From: Brendan Zabarauskas Date: Wed, 7 Nov 2012 11:07:13 +1000 Subject: [PATCH] Add explanation to matrix multiplication --- src/matrix.rs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/matrix.rs b/src/matrix.rs index 2d4ea8b..307c327 100644 --- a/src/matrix.rs +++ b/src/matrix.rs @@ -698,6 +698,9 @@ pub impl Mat4: SquareMatrix { #[inline(always)] pure fn mul_m(other: &Mat4) -> Mat4 { + // Surprisingly when building with optimisation turned on this is actually + // faster than writing out the matrix multiplication in expanded form. + // If you don't believe me, see ./test/performance/matrix_mul.rs Mat4::new(self.row(0).dot(&other.col(0)), self.row(1).dot(&other.col(0)), self.row(2).dot(&other.col(0)), self.row(3).dot(&other.col(0)), self.row(0).dot(&other.col(1)), self.row(1).dot(&other.col(1)), self.row(2).dot(&other.col(1)), self.row(3).dot(&other.col(1)), self.row(0).dot(&other.col(2)), self.row(1).dot(&other.col(2)), self.row(2).dot(&other.col(2)), self.row(3).dot(&other.col(2)),