This is the sort of code I’d like to write in pure Ruby, rather than
having to call a C library for efficiency. The matrix I generated is
quite ill-conditioned. It’s quite possible that a “standard” floating
point numerical determinant or matrix inversion routine would choke on
it, while the combination of “matrix”, “mathn” and “rational” I used
had no problem with it. In short, I’m willing to pay for rational
arithmetic and correct results, but not for an inefficient
interpreter.So if someone is going to rewrite Matrix in C, they
need to do the underlying arithmetic too.
There are some theoretical considerations about exact arithmetic, made
processor-effiicient, in two papers:
E. Kaltofen and V. Pan.
Processor efficient parallel solution of linear systems over an
abstract
field.
In Proc. SPAA '91 3rd Ann. ACM Symp. Parallel Algor. Architecture,
pages
180-191, New York, N.Y., 1991. ACM Press
E. Kaltofen and V. Pan.
Processor-efficient parallel solution of linear systems II: the
positive
characteristic and singular cases.
In Proc. 33rd Annual Symp. Foundations of Comp. Sci., pages 714-723,
Los
Alamitos, California, 1992. IEEE Computer Society Press.
These can be downloaded from
http://www4.ncsu.edu/~kaltofen/bibliography/index.html#SECTION00022000000000000000
(http://www4.ncsu.edu/~kaltofen/bibliography/index.html#SECTION00022000000000000000)
From the website, it looks as if these algorithms were implemented in
LINBOX: a generic library for exact black box linear algebra. The
homepage
including downloads can be found at www.linalg.org
(http://www.linalg.org/) .
Best regards,
Axel