[aus.wanted] Wanted: C matrix handling functions

david@erm.oz (David Hayward) (01/10/91)

I am looking for some public domain C code to do the following:

1) Calculate the determinant of a matrix.
2) Calculate the inverse of a matrix.

If someone has code or knows where to get it, I would greatly appreciate it if
you could get in touch with me.

David Hayward
---
Earth Resource Mapping, 316 Churchill Ave, Subiaco, Western Australia 6008
Phone: +61 9 388 2900   Fax: +61 9 388 2901
ACSnet: david@erm.oz.au

dodson@convex.COM (Dave Dodson) (01/11/91)

In article <1206@erm.oz> david@erm.oz (David Hayward) writes:
>I am looking for some public domain C code to do the following:
>1) Calculate the determinant of a matrix.
>2) Calculate the inverse of a matrix.
>
>If someone has code or knows where to get it, I would greatly appreciate it if
>you could get in touch with me.

Try "Numerical Recipes in C".  The code is not in the public domain, but
is widely available and I think buying a book and maybe the accompanying
floppy disk gives you the right to use the code for non-commercial use.

Be advised, however, that it is almost never really necessary or even
desirable to compute either the determinant or the inverse of a matrix.
While papers and reference books extensively use the notation "det(A) = 0"
to mean "A is singular," there are both more efficient and more reliable
methods for detecting singularity.  Similarly, the notation "A^(-1) * b"
is often used to mean "the solution of the system of linear equations
A * x = b."  It is more efficient and more accurate to compute the solution
directly than to invert the coefficient matrix and multiply the inverse
times the right-hand-side vector.  This is true even if there are many
systems of equations, all using the same coefficient matrix; the matrix
may be factored once and the systems may be solved from the factors just
as efficiently--and more accurately--than by matrix multiplication by the
inverse.

----------------------------------------------------------------------

Dave Dodson		                             dodson@convex.COM
Convex Computer Corporation      Richardson, Texas      (214) 497-4234