From: Gavin Sinclair Date: 2004-02-01T18:11:50+09:00 Subject: Re: Problems in mathn, rational, complex, matrix On Sunday, February 1, 2004, 7:02:31 PM, Mathieu wrote: >> The stdlib documentation drew my attention with the Matrix >> class example for determinant. >> http://www.ruby-doc.org/stdlib/libdoc/matrix/rdoc/classes/Matrix.html#M000064 >> Matrix[[7,6], [3,9]].determinant >> => 63 >> Call me a geek, but I instantly saw that this was the wrong >> answer. > You have to do Matrix[[7.0,6.0],[3.0,9.0]], or the equivalent thing with > Rationals. For the determinant to be meaningful, the Matrix must not be > filled with Integers. I'm way behind you in the mathematics (snipped), but I remember taking the determinant of integer matrices at university. I'd say that Ruby should do the same thing, however it is implemented. It is not Ruby's custom to expose computers' limitations on mathematics (e.g. overflow errors). > If "mathn" modifies Integer#/, then it surely breaks other libraries that > rely on Integer#/ returning an Integer or at least rounding down. I agree, but I don't think mathn does that. Gavin