summaryrefslogtreecommitdiff
path: root/lib/matrix.rb
diff options
context:
space:
mode:
authormarcandre <marcandre@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2010-04-01 18:06:08 +0000
committermarcandre <marcandre@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2010-04-01 18:06:08 +0000
commit5ef335319e925422adad386b9a3395b38c705a7b (patch)
treee81c34cf8927f2c847ccd3c2f79a724bb98e8d73 /lib/matrix.rb
parent729941da390cb317feb6772204d1630a21705c12 (diff)
* lib/matrix.rb: Matrix.determinant: raise on rectangular matrices
[ruby-core:28271] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@27160 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'lib/matrix.rb')
-rw-r--r--lib/matrix.rb12
1 files changed, 6 insertions, 6 deletions
diff --git a/lib/matrix.rb b/lib/matrix.rb
index 18f53b7316..dbae755204 100644
--- a/lib/matrix.rb
+++ b/lib/matrix.rb
@@ -717,8 +717,8 @@ class Matrix
#++
#
- # Returns the determinant of the matrix. If the matrix is not square, the
- # result is 0. This method's algorithm is Gaussian elimination method
+ # Returns the determinant of the matrix.
+ # This method's algorithm is Gaussian elimination method
# and using Numeric#quo(). Beware that using Float values, with their
# usual lack of precision, can affect the value returned by this method. Use
# Rational values or Matrix#det_e instead if this is important to you.
@@ -727,7 +727,7 @@ class Matrix
# => 45.0
#
def determinant
- return 0 unless square?
+ Matrix.Raise ErrDimensionMismatch unless square?
size = row_size
a = to_a
@@ -757,8 +757,8 @@ class Matrix
alias det determinant
#
- # Returns the determinant of the matrix. If the matrix is not square, the
- # result is 0. This method's algorithm is Gaussian elimination method.
+ # Returns the determinant of the matrix.
+ # This method's algorithm is Gaussian elimination method.
# This method uses Euclidean algorithm. If all elements are integer,
# really exact value. But, if an element is a float, can't return
# exact value.
@@ -767,7 +767,7 @@ class Matrix
# => 63
#
def determinant_e
- return 0 unless square?
+ Matrix.Raise ErrDimensionMismatch unless square?
size = row_size
a = to_a