Bug #2770: Matrix: determinant for rectangular matrices should raise an error [patch]
http://redmine.ruby-lang.org/issues/show/2770

Author: Marc-Andre Lafortune
Status: Assigned, Priority: Normal
Assigned to: Keiju Ishitsuka, Category: lib, Target version: 1.9.2
ruby -v: ruby 1.9.2dev (2010-01-13 trunk 26316) [x86_64-darwin10.2.0]

Keiju,

$ rubydev -r matrix -e "puts Matrix[[1], [2], [3]].determinant"
0

This corresponds to the documentation, but is not mathematically valid, since the determinant for rectangular matrices is not defined (at least for now! http://bit.ly/bwW7Gs )

I believe an error should be thrown, similar to:
$ rubydev -r matrix -e "puts Matrix[[1], [2], [3]].trace"
/usr/local/rubydev/lib/ruby/1.9.1/matrix.rb:837:in `trace': Matrix dimension mismatch (ExceptionForMatrix::ErrDimensionMismatch)
	from -e:1:in `<main>'

Since this is an API change, I attached a patch and will wait for your approval before committing.


----------------------------------------
http://redmine.ruby-lang.org