From ef83d7a928ef9d998dc9cf9cb86649cdd9ffceea Mon Sep 17 00:00:00 2001 From: marcandre Date: Mon, 17 May 2010 21:09:31 +0000 Subject: [PATCH] * lib/matrix.rb (determinant): Trivial optimization (thanks to Benoit Daloze) git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@27868 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- lib/matrix.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/matrix.rb b/lib/matrix.rb index ee26cb94d0..b98fc85839 100644 --- a/lib/matrix.rb +++ b/lib/matrix.rb @@ -747,12 +747,12 @@ class Matrix when 2 + m[0][0] * m[1][1] - m[0][1] * m[1][0] when 3 - m0 = m[0]; m1 = m[1]; m2 = m[2] + m0, m1, m2 = m + m0[0] * m1[1] * m2[2] - m0[0] * m1[2] * m2[1] \ - m0[1] * m1[0] * m2[2] + m0[1] * m1[2] * m2[0] \ + m0[2] * m1[0] * m2[1] - m0[2] * m1[1] * m2[0] when 4 - m0 = m[0]; m1 = m[1]; m2 = m[2]; m3 = m[3] + m0, m1, m2, m3 = m + m0[0] * m1[1] * m2[2] * m3[3] - m0[0] * m1[1] * m2[3] * m3[2] \ - m0[0] * m1[2] * m2[1] * m3[3] + m0[0] * m1[2] * m2[3] * m3[1] \ + m0[0] * m1[3] * m2[1] * m3[2] - m0[0] * m1[3] * m2[2] * m3[1] \