Simple Matrix class
Wed Jan 24 22:07:16 CET 2007
"Paul McGuire" <ptmcg at austin.rr.com> writes:
> Dang, I thought I was testing the results sufficiently! What is the
> accuracy problem? In my test cases, I've randomly created test
> matrices, inverted, then multiplied, then compared to the identity
> matrix, with the only failures being when I start with a singular
> matrix, which shouldn't invert anyway.
There's a lot of ill-conditioned matrices that you won't hit at
random, that aren't singular, but that are nonetheless very stressful
for numerical inversion. The Hilbert matrix a[i,j]=1/(i+j+1) is a
well known example.
If you're taking exponential time to invert matrices (sounds like
you're recursively using Cramer's Rule or something) that doesn't
begin to be reasonable even for very small systems, in terms of
accuracy as well as speed. It's a pure math construct that's not of
much practical value in numerics.
You might look at the Numerical Recipes books for clear descriptions
of how to do this stuff in the real world. Maybe the experts here
will jump on me for recommending those books since I think the serious
numerics crowd scoffs at them (they were written by scientists rather
than numerical analysts) but at least from my uneducated perspective,
I found them very readable and well-motivated.
More information about the Python-list