octave-maintainers
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: eigs fails for scalars and 2x2 matrices


From: John W. Eaton
Subject: Re: eigs fails for scalars and 2x2 matrices
Date: Wed, 03 Jul 2013 15:08:04 -0400
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:10.0.12) Gecko/20130116 Icedove/10.0.12

On 06/26/2013 09:59 AM, Jordi GutiƩrrez Hermoso wrote:
On 26 June 2013 04:28, John W. Eaton<address@hidden>  wrote:
eigs fails for scalars and 2x2 matrices, apparently intentionally
given the error message.  Is this a limitation of ARPACK?  Should we
work around this problem by calling eig for these cases?

This was Bateman's response:

     
https://mailman.cae.wisc.edu/pipermail/octave-maintainers/2011-July/024272.html

OK, to make the discussion easier to follow, I'm reproducing that
message here and I'm adding David to the Cc: line since he wrote
the eigs function in Octave.

  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

It does seem that eigs in Matlab works for small matrices.

I'm not sure that it will work to change the error to a warning and
ask ARPACK to do the job because ARPACK doesn't seem to be able to
return all eigenvalues, and in Matlab, eigs (rand (2)) returns 2
eigenvalues.  It also seems that it only starts warning when the size
of the matrix is greater than 8.

I agree that getting all the sorting options right will take some
effort.  It seems like the easiest way to deal with this would be to
write a wrapper eigs.m function that checks the size of the input
matrix (or matrices) and the number of requested eigenvalues and then
calls the current eigs function if possible, otherwise issues a
warning (if appropriate) and calls eig + sort as directed by the
options.

Does that seem like a reasonable solution?  If so, I'll take a shot at
doing it.  If not, do you see a better way?

jwe


reply via email to

[Prev in Thread] Current Thread [Next in Thread]