-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
sparse matrix eigs, svds fails #1573
Comments
Likely same issue as #918. |
Another thing. The eigenvectors seem to be random. Also, there are some problems with symmetry.
|
Does it work on matlab? |
Oh it is for small matrices. Perhaps just fall to eig/svd for less than 20. |
@andreasnoackjensen I do not think I have implemented the symmetric drivers from ARPACK. Should be easy to do, and once the SymmetricMatrix stuff is sorted out, it should be convenient to use as well. |
@JeffBezanson This isn't the same issue as #918. The obscure error code means that the number of columns in A is less than the number of singular values requested, which defaults to 6. I'll commit a fix once I have tested it. |
@ViralBShah I think the symmetric driver is implemented. The function tests for symmetry and calls saupd if it is. But the problem is that I there is a bug in at least
looks symmetric, but
and it is not the floating point problem
Hm. Two (1,4) elements. Finally, even though
|
Of course it gets a little more complicated. ``nev`, the number of eigenvalues or singular values requested must be less than the size of a square matrix or the number of columns in a rectangular matrix. So for speye(4) the best you can do is to get 3 singular values.
With
which I think is unmodified from @viralshah 's original. The second condition in the Anyway, if I comment out that I'll commit and let me know if I have botched things up. |
The case from #918 still fails.
From dnaupd.f: @andreasnoackjensen I guess it was a long time back I implemented this - and haven't looked at it recently. Seems like the issues you have discovered are sparse related, and should be a separate issue. |
These are the constraints on NEV and NCV. As a result, NEV should be at most N-2, and NCV should be at most N. If these constraints are not satisfied, I would much rather return an error, and suggest that the user use Also, how many Arnoldi vectors should we use in general? Currently, the code tries to use 2*NEV Arnoldi vectors, if the problem permits. What should it really do?
|
On Thu, Nov 22, 2012 at 4:04 AM, Viral B. Shah [email protected]:
|
This is not just about getting all the eigenvalues for small 4x4 matrices. It also applies to getting all the eigenvalues or singular values for an nxn matrix. Just falling back on eig/svd leads to the use of a different algorithm in a non-transparent way, with performance characteristics that are hard to predict. |
Is it really that bad? If somebody writes
either for performance or to avoid the exception. It might make sense to give an error instead of horribly bad performance that will be hard to track down. But in that case, it should only kick in for large sizes where the performance is a real problem, and work for 4x4. |
The issue is not about 4x4, but about providing more than n-2 eigenvalues and eigenvectors - if I have understood the ARPACK documentation correctly. Is it so bad that eigs and svds give only n-2 eigenvalues and eigenvectors? |
BTW, the new eig that we are going to have is going to support fewer than n eigenvalues, if I have understood @andreasnoackjensen correctly. |
@ViralBShah Correct, but only for symmetric matrices. And the new solver is fast (but is not merged in this form yet so you cannot run the following). julia> load("arpack")
julia> A=sprandn(1000,1000,0.1);Asym=A'A;
julia> min([@elapsed eigs(Asym) for i = 1:5])
1.3453099727630615
julia> min([@elapsed eigs(full(Asym)) for i = 1:5])
0.34864091873168945
julia> min([@elapsed (Z=Array(Float64, 1000, 6); LAPACK.syevr!('V', 'I', 'U', full(Asym), 0.0, 0.0, 995, 1000, Z, -1.0)) for i = 1:5])
0.2948329448699951
julia> Z=Array(Float64, 1000, 6); vals = LAPACK.syevr!('V', 'I', 'U', full(Asym), 0.0, 0.0, 995, 1000, Z, -1.0);
julia> norm(abs(eigs(Asym)[2]) - abs(Z))
8.550264651753738e-13
julia> norm(eigs(Asym)[1] - vals)
1.5701547587165274e-12 I vote for a unified (in |
You still need |
Why can't |
Without http://www.mathworks.in/help/matlab/ref/eigs.html We would then end up where we are in |
My idea was to simplify the eigenvalue front end by removing and the s in The point is that when using Maybe front ends for different PACKs should be given different names even though the mathematical problem they solve is the same, but for many problems there have been chosen otherwise. |
+1 for Andreas' proposal. I actually think that would be welcomed by many Matlab users even though there would initially be a little bit of friction. "Wait, what? I don't need to think about sparse vs. dense in this code? Ok." |
It is not that Hence, the question really is if all of this can be stuck into |
Mathematica allows for a Method option which defaults to AUTOMATIC, but can also be If you read the online documentation it is written in such a manner as to protect the user from too much Automatic goes like this: Any of the commands Eigenvalues, Eigenvectors, and Eigensystem can have an optional |
We will only be able to do something about this after keyword args. Even |
9aff106 adds support for keyword arguments for |
eigs and svds run into trouble computing too many eigenvalues/singular values
not sure if this is expected behavior
julia> load("sparse.jl")
julia> load("suitesparse.jl")
julia> load("arpack.jl")
julia> A=speye(4)
4x4 sparse matrix with 4 nonzeros:
[1, 1] = 1.0
[2, 2] = 1.0
[3, 3] = 1.0
[4, 4] = 1.0
julia> svds(A)
error code -3 from ARPACK saupd
in svds at /home/jeffb/julia/extras/arpack.jl:230
in svds at /home/jeffb/julia/extras/arpack.jl:259
julia> eigs(A)
Compute fewer eigenvalues using eigs(A, k)
in eigs at /home/jeffb/julia/extras/arpack.jl:83
in eigs at /home/jeffb/julia/extras/arpack.jl:187
julia> eigs(A,2)
([1.0, 1.0],
4x2 Float64 Array:
-0.0760132 -0.534781
-0.521881 0.360963
0.539126 0.685331
-0.656662 0.337693)
The text was updated successfully, but these errors were encountered: