octave-maintainers
[Top][All Lists]
Advanced

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

Re: eigs compatibility


From: Daniel J Sebald
Subject: Re: eigs compatibility
Date: Thu, 04 Jul 2013 14:03:21 -0500
User-agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.2.24) Gecko/20111108 Fedora/3.1.16-1.fc14 Thunderbird/3.1.16

On 07/03/2013 04:17 PM, Rik wrote:
On 07/03/2013 12:08 PM, address@hidden wrote:
Message: 7
Date: Wed, 03 Jul 2013 15:08:04 -0400
From: "John W. Eaton"<address@hidden>
To: Jordi Guti?rrez Hermoso<address@hidden>
Cc: David Bateman<address@hidden>,        octave maintainers mailing list
        <address@hidden>
Subject: Re: eigs fails for scalars and 2x2 matrices
Message-ID:<address@hidden>
Content-Type: text/plain; charset=UTF-8; format=flowed

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?
Seems like a low value compatibility item.  'eigs' is supposed to be for
determining a few eigenvectors of a very large, sparse matrix.  Asking it
for the eigenvalues of a 2x2 matrix is attempting to use a sledge hammer to
swat a fly.  I would be more inclined to just check the dimensions of the
input and if it is less than 10 print a warning suggesting that the user
consider 'eig' for their problem.  However, if someone is paying for this
compatibility fix then your method seems reasonable.

I guess a sparse matrix of 2x2 isn't really all that sparse. Anyway, if it is important to have compatibility or just handle all dimensions, and it is only 2x2 and 1x1 that must be dealt with, rather than require a different math package be used to offer those results, it might be just as easy to write out the formulas for the solution to the eigenvalues. If one were to study the math, it probably breaks down into some simple inversion formulas which aren't so challenging until getting above 3x3. Why isn't there support in the sparse math package?

Dan


reply via email to

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