eigs behaviour for small matrices

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

eigs behaviour for small matrices

Jordi Gutiérrez Hermoso-2
While porting Matlab code, I noticed that someone had used eigs for a
2x2 matrix, which produces an error to use eig instead. I patched the
code to do that, but I inadverently introduced a bug because I forgot
that eigs sorts its eigenvalues but eig does not.

Should eigs be patched to call eig for small matrices and just sort
them? Also, for the case of when you need all eigenvalues, should eigs
just silently call eig instead of warning about it?

- Jordi G. H.
Reply | Threaded
Open this post in threaded view
|

Re: eigs behaviour for small matrices

David Bateman
On 07/24/2011 09:10 PM, Jordi Gutiérrez Hermoso wrote:

> While porting Matlab code, I noticed that someone had used eigs for a
> 2x2 matrix, which produces an error to use eig instead. I patched the
> code to do that, but I inadverently introduced a bug because I forgot
> that eigs sorts its eigenvalues but eig does not.
>
> Should eigs be patched to call eig for small matrices and just sort
> them? Also, for the case of when you need all eigenvalues, should eigs
> just silently call eig instead of warning about it?
>
> - Jordi G. H.
>

The sorting rules aren't that obvious as the order of the values
returned might be largest eignevalue first, smallest first or even
sorted relative to a distance from a particular eigenvalue. So if matlab
does this it might be better to relax the error in eigs-base.cc to a
warning and letter ARPACK do the work.

David