[Matrix-SIG] Eigenvalues return array

Konrad Hinsen hinsen@cnrs-orleans.fr
Mon, 7 Dec 1998 19:07:05 +0100


> eigenvals = LinearAlgebra.eigenvalues(a)
> print eigenvals # This prints 'array([ 1. , -0.3])'
> 
> print Numeric.equal(eigenvals, 1.0) # This prints 'array([0, 0])'

That is probably an accuracy problem. Try

  print eigenvals - 1.

I bet it won't print the first element as zero! In other words, the
first eigenvalue is one up to the precision used for printing, but not
exactly.

In practice, it is rarely useful in numerical algorithms to test floating
point numbers for equality. If you want to test for "very close to one",
you should use

   Numeric.less(Numeric.fabs(eigenvals-1.), 1.e-10)

or whatever precision you want.
-- 
-------------------------------------------------------------------------------
Konrad Hinsen                            | E-Mail: hinsen@cnrs-orleans.fr
Centre de Biophysique Moleculaire (CNRS) | Tel.: +33-2.38.25.55.69
Rue Charles Sadron                       | Fax:  +33-2.38.63.15.17
45071 Orleans Cedex 2                    | Deutsch/Esperanto/English/
France                                   | Nederlands/Francais
-------------------------------------------------------------------------------