まつもと ゆきひろです

以下のような報告が来たのですが、どうなんでしょう?

要旨:

m = Matrix[[10, 5,10],
           [10, 5, 0],
           [ 1, 1, 1]]

のとき

m.det

が50になるが、-50ではないかと。

(私のところでは100になるんですが...)

------- Start of forwarded message -------
Delivered-To: matz / netlab.jp
Date: Thu, 21 Nov 2002 09:30:25 -0700
From: Hans Fugal <hans / fugal.net>
Subject: matrix.rb bug
To: matz / netlab.jp

Consider the following matrix
m = Matrix[[10, 5,10],
           [10, 5, 0],
           [ 1, 1, 1]]

The determinant should be -50, according to my HP calculator.  m.det
returns 50.

If I construct the matrix out of floats, m.det returns -50.0. If I
include one float in the matrix it may or may not return the right
answer, depending on where the float is.

some irb output:
irb(main):001:0> require 'matrix'
true
irb(main):002:0> Matrix[[10,5,10],[0,5,10],[1,1,1]].det
50
irb(main):003:0> Matrix[[10,5,10],[0,5,10],[1.0,1,1]].det
- -50.0
irb(main):004:0> Matrix[[10,5,10],[0,5,10],[1,1.0,1]].det
- -50.0
irb(main):005:0> Matrix[[10,5,10],[0,5,10],[1,1,1.0]].det
50.0

- -- 
 Hans Fugal                 | If more of us valued food and cheer and
 http://hans.fugal.net/     | song above hoarded gold, it would be a
 jabber: hans / fugal.net     | merrier world.  
                            |         -- J.R.R. Tolkien
- ---------------------------------------------------------------------
GnuPG Fingerprint: 6940 87C5 6610 567F 1E95  CB5E FC98 E8CD E0AA D460

------- End of forwarded message -------