JuliaLinearAlgebra / Arpack.jl

Julia Wrappers for the arpack-ng Fortran library
https://arpack.julialinearalgebra.org/stable
MIT License
69 stars 29 forks source link

eigs() doesn't work in my computer, but works in another one. (Arpack 0.5.4) #147

Open AlvaroPY opened 1 year ago

AlvaroPY commented 1 year ago

Probably this is not related with the package itself, but I would greatly appreciate your help. I have the same code running in two different computers with the same version of Julia (1.7.2) and Arpack (0.5.4). In one computer, everything works well (I have two instances of EVPs, one generalized with dense complex non-Hermitian matrices and the other, generalized with sparse real symmetric positive definite matrices). I've compared to eigen() from LinearAlgebra and ArnoldiMethod and the solutions are ok. But in the other computer, I have constantly the following error:

XYAUPD_Exception: Maximum number of iterations taken. All possible eigenvalues of OP has been found.
│ IPARAM(5) returns the number of wanted converged Ritz values.

Since eigs() from Arpack is faster than ArnoldiMethod, I would like to use it in my computer.

PetrKryslUCSD commented 1 year ago

Generalized EVP with symmetric positive (semi-)definite sparse matrices. Arpack 0.5.4 fails to converge, 0.5.3 converges. Called as

evals, evecs, convinfo = eigs(Symmetric(K+OmegaShift*M), Symmetric(M); nev=neigvs, which=:SM, explicittransform=:none)

The error is

┌ Error: XYAUPD_Exception: Maximum number of iterations taken. All possible eigenvalues of OP has been found.                                                                                                           
│ IPARAM(5) returns the number of wanted converged Ritz values.                                             
│   info = 1                   
PetrKryslUCSD commented 1 year ago

@AlvaroPY : Could you try 0.5.3 please?

AlvaroPY commented 1 year ago

Thank you!! With Arpack 0.5.3, at every first run I have another type of error:

┌ Error: XYEUPD_Exception: The Schur form computed by LAPACK routine lahqr could not be reordered by LAPACK routine trsen.
│ Re-enter subroutine neupd with IPARAM(5)NCV and increase the size of the arrays DR and DI to have dimension 
at least dimension NCV and allocate at least NCV columns for Z.
│ NOTE: Not necessary if Z and V share the same space. Please notify the authors if this error occurs.        
│   info = 1
└ @ Arpack C:\Users\agavilan\.julia\packages\Arpack\pLziT\src\libarpack.jl:89

But at the following runs everything goes well with Arpack 0.5.3, in both of my computers. Should I close this issue ? Because downgrading solved my problem, but with Arpack 0.5.4 I still have different behaviors in both computers.

PetrKryslUCSD commented 1 year ago

I suspect the reasons for the failure of 0.5.4 to work for :SM are here: image and image There are also these changes that may be relevant: image

maxwellforfun commented 1 year ago

I've been having the same error but for the :LM option. My sparse matrix will trigger the automatic shift-and-invert (on both 5.3 and 5.4 versions), and I think that could be related to the commit on libarpack shown by @PetrKryslUCSD. The omission of the dot when inverting on the composed dmap function may be causing issues? (Not sure if at that spot it deals with a matrix or a scalar)

PetrKryslUCSD commented 1 year ago

@AlvaroPY Could you rename present issue to reflect that 0.5.4 version is broken. And create a new issue for 0.5.3?

PetrKryslUCSD commented 1 year ago

This repository appears to have lost its maintainers. I would suggest to switch to ArnoldiMethod.jl.

AlvaroPY commented 1 year ago

@AlvaroPY Could you rename present issue to reflect that 0.5.4 version is broken. And create a new issue for 0.5.3?

I will do it now! And thanks for the suggestion. Since my last post here I decided to continue on with ArnoldiMethod.jl (KrylovKit.jl having some limitations with non-Hermitian generalized EVP) rather than downgrading to Arpack 0.5.3, despite some efficiency advantage with the latter.

maxwellforfun commented 1 year ago

I had some free time and tried some tests. Seems that (at least for my case) the culprit was after performing the shift and invert, and switching from LM to SM (to preserve the originally intended eigenvalue search), a new conditional (the second capture from @PetrKryslUCSD ) would also change the whichstring to SM instead of preserving the LM value.

I've created a fork reverting that conditional, and for my case now it works. @AlvaroPY, could you try if the fork works for your case?

marianoarnaiz commented 1 year ago

Hi. Is 0.5.0 Version around? I need it :(

jishnub commented 1 year ago

You should certainly be able to install version v0.5.0 as pkg> add Arpack@0.5.0. However, you might want to switch to ArnoldiMethod.jl unless you specifically require Arpack

PetrKryslUCSD commented 8 months ago

I take it back. ArnoldiMethod apparently does not converge for symmetric, spd pencil. The eigenvectors are bad. https://github.com/JuliaLinearAlgebra/ArnoldiMethod.jl/issues/114