ruby-changes:15276
From: marcandre <ko1@a...>
Date: Fri, 2 Apr 2010 03:06:43 +0900 (JST)
Subject: [ruby-changes:15276] Ruby:r27160 (trunk): * lib/matrix.rb: Matrix.determinant: raise on rectangular matrices
marcandre 2010-04-02 03:06:08 +0900 (Fri, 02 Apr 2010) New Revision: 27160 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=27160 Log: * lib/matrix.rb: Matrix.determinant: raise on rectangular matrices [ruby-core:28271] Modified files: trunk/lib/matrix.rb Index: lib/matrix.rb =================================================================== --- lib/matrix.rb (revision 27159) +++ lib/matrix.rb (revision 27160) @@ -717,8 +717,8 @@ #++ # - # 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 @@ # => 45.0 # def determinant - return 0 unless square? + Matrix.Raise ErrDimensionMismatch unless square? size = row_size a = to_a @@ -757,8 +757,8 @@ 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 @@ # => 63 # def determinant_e - return 0 unless square? + Matrix.Raise ErrDimensionMismatch unless square? size = row_size a = to_a -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/