octave-maintainers
[Top][All Lists]
Advanced

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

Re: new snapshot?


From: Michael D. Godfrey
Subject: Re: new snapshot?
Date: Sun, 28 Feb 2010 08:58:43 -0800
User-agent: Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.6; en-US; rv:1.9.1.8) Gecko/20100216 Thunderbird/3.0.2

On 2/28/10 6:19 AM, David Bateman wrote:
Michael D. Godfrey wrote:
On 2/26/10 2:28 PM, John W. Eaton wrote:
> On 26-Feb-2010, Michael D. Godfrey wrote:
>
> | On 2/26/10 10:15 AM, Jaroslav Hajek wrote:
> | > Are you sure? This is exactly the opposite of what I get. Sometimes
> | > the assert fails with
> | >
> | > !!!!! test failed
> | > assert (s (k:-1:1),s2,1e-10) expected
> | >     38.060
> | >     38.060
> | >     38.034
> | >     38.034
> | >     38.015
> | >     38.015
> | >     38.004
> | > but got
> | >     38.060
> | >     38.034
> | >     38.034
> | >     38.015
> | >     38.015
> | >     38.004
> | >     38.004
> | > maximum absolute error 0.0263523 exceeds tolerance 1e-10
> | >
> | > and the latter result is correct, AFAIK.
> | >
> | > > | The latter result is s2 in the test. This is what I get too. s2, > | computed from:
> | [u2,s2,v2,flag] = svds(a,k,0);
> | s2 = diag(s2);
> | is correct. It is the "expected" vector that is wrong. This comes from: > | a = > | sparse([3:n,1:n,1:(n-2)],[1:(n-2),1:n,3:n],[ones(1,n-2),0.4*n*ones(1,n),ones(1,n-2)]);
> | [u,s,v] = svd(full(a));
> | s = diag(s);
> | [dum, idx] = sort(abs(s));
> | s = s(idx);
> | > | Agree?
>
> The problem is with svds, not svd on the full matrix.  I should have
> put the arguments to assert in the opposite order.
>
> Sorry for the confusion,
>
> jwe
> A bit more reading of svds.m finds that if sigma=0, it calls eigs requesting 2*k eigenvalues instead of k. This helps to explain things, but still does not isolate exactly why in one case eigs returns extra eigenvalues but in another context,
with the same arguments, it returns k eigenvalues.

In any case, it now appears that my suggested change of sigma from 0 to 0.05
is appropriate in order to prevent "extra" eigenvalues.

Michael

The function svds creates the matrix [0, b; b', 0] and finds the eigenvalues of this matrix and the positive eigenvalues of this matrix are the singular values of b. Note that the eigenvalues of [0,b;b',0] are symmetric about 0 and so if we want the singular values with sigma of zero then we have to call eigs with 2*k and ignore the negative values. In fact with small values of sigma, one of the negative eigenvalues of [0,b;b',0] might be closer to sigma than the k singular values of b that are desired. The only way to avoid this issue would be to always call eigs with 2*k but at the cost of at least two times more iterations in eigs.. When writing svds I chose speed over a guarantee that svds would return the right value as the case described should be relatively rare in real life.. This however doesn't explain the original issue..

D.


--
David Bateman address@hidden
35 rue Gambetta                              +33 1 46 04 02 18 (Home)
92100 Boulogne-Billancourt FRANCE            +33 6 72 01 06 33 (Mob)

I understand this and agree with your last statement. It would be good to try to resolve the underlying inconsistency. However, in the test that is failing, use of a small non-zero sigma in the call to svds is not unreasonable for the reason that you described in the code.

Michael


reply via email to

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