[#2367] Standard libraries — Dave Thomas <dave@...>

From ruby-dev summary:

60 messages 2004/02/11

[#2397] PATCH: deprecate cgi-lib, getopts, importenv, parsearg from standard library — Gavin Sinclair <gsinclair@...>

Index: cgi-lib.rb

15 messages 2004/02/12

[#2465] PATCH: OpenStruct#initialize to yield self — Gavin Sinclair <gsinclair@...>

This is a common approach I use to object initialization; I don't know

24 messages 2004/02/19

Re: Problems in mathn, rational, complex, matrix

From: Gavin Sinclair <gsinclair@...>
Date: 2004-02-01 09:11:50 UTC
List: ruby-core #2322
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


In This Thread