octave-maintainers
[Top][All Lists]

## Re: Good eigenvalue/eigenvector test problems for eigs?

 From: David Bateman Subject: Re: Good eigenvalue/eigenvector test problems for eigs? Date: Fri, 22 Sep 2006 22:00:48 +0200 User-agent: Thunderbird 1.5.0.5 (X11/20060817)

```Sebastien Loisel wrote:
> The SVD of that SPD matrix is actually nice. Since it's SPD, its SVD is
> simply its diagonalization (A=U'DU). The eigenvectors U are various
> frequencies of sin and the eigenvalues D are precisely the eigenvalues
> of the second derivative operator, shifted and scaled into [2,6].
>
> On 9/22/06, *David Bateman* <address@hidden
>
>     Sebastien Loisel wrote:
>     > Or maybe you mean it's got double eigenvalues all over the place?
>     The svd of it is pretty ugly, but I don't really see why the doubled
>     eigenvalues should be an issue.. The rooser matrix also has this
>     sort of
>     problem and I can get that to work fine. In any case, I'm now using the
>     wilkinson function to generate test matrices, and have eigs fully
>     working for real symmetric and non-symmetric problems. I still have an
>     issue with convergence of complex eigenvalues, that seems to be a bug in
>     my code as both FreeMat and matlab do not display the same behavior.
>     Give me a few days and I should be able to release a working version of
>     eigs..
>
>     D.
>
>     --
>     David
>     Motorola Labs - Paris                        +33 1 69 35 48 04 (Ph)
>     Parc Les Algorithmes, Commune de St Aubin    +33 6 72 01 06 33 (Mob)
>     91193 Gif-Sur-Yvette FRANCE                  +33 1 69 35 77 01 (Fax)
>
>     The information contained in this communication has been classified as:
>
>     [ ] Motorola Internal Use Only
>     [ ] Motorola Confidential Proprietary
>
>

Yes, its supposed to be well behaved, but consider

octave:1> n=200;
octave:2> A = spdiags([ones(n,1),4*ones(n,1),-ones(n,1)],[-2,0,2],n,n);
octave:3> d0 = eig(A); [dum,idx]=sort(abs(d0)); d0 = d0(idx);
octave:4> opts.disp = 0; d1 = eigs(A,6,'lm',opts)
d1 =

4.0000 - 1.9990i
4.0000 + 1.9990i
4.0000 + 1.9990i
4.0000 - 1.9990i
4.0000 + 1.9961i
4.0000 - 1.9961i

octave:5> d0(end:-1:(end-5))
ans =

-7.2806 + 0.0000i
-7.1793 + 0.0000i
-6.4207 + 0.0000i
5.8174 + 0.0000i
-5.6617 - 0.1134i
-5.6617 + 0.1134i

octave:6> for i=1:6, printf("%g  %g\n", det(A - d0(end-i-1)*eye(n)),
det(A-d1(i)*eye(n))); endfor
2.29431e+204  -4.64368e-18
4.5854e+70  -4.64368e-18
-5.57849e+197  -8.51116e-19
-5.57849e+197  -8.51116e-19
5.36496e+195  -2.88504e-20
4.61667e+194  -2.88504e-20

where the eigs implementation is my own. As you can see the eigenvalues
calculated by the lapack based eig function are not correct, while my
eigs function returns correct eigenvalues, and at my guess their value
seems about right for the largest magnitude eigenvalues. My problem is
how can I have a code to validate the eigs function against a test
matrix, when the eig function for full matrices can't even return the
right results..... So my request for reasonable test matrices. In any
case the wilkinson function seems to be ok, with forcing small
modifications to force different versions of my code to be used..
Interestingly the matrix

A =
spdiags([ones(n,1),4*ones(n,1),[ones(n/2,1);-ones(n/2,1)]],[-2,0,2],n,n);

seems nasty and in fact I was misremembering the plot(abs(svd(A)) of the
above relative to the previous matrix. Both eig and eigs fail for the
above in matlab and octave...

D.

```