# [SciPy-user] generalized eigenvalue problem for sparse matrices

Neilen Marais nmarais@sun.ac...
Tue Apr 15 07:54:35 CDT 2008

```Abinav,

On Tue, 15 Apr 2008 01:50:20 +0530, abhinav sarkar wrote:

> Hi
>  n = 3
>  h = 1.0/(n+1)
>
>  a = 1
>  Pr = 7.0
>  Ra = 1000
>
>  A = get_A_mat(n, h, a, Pr, Ra)
>  M = get_M_mat(n, h, a, Pr, Ra)
>
>  sigma = 10.0
^^^
I think you're looking for -10.

>  B = A - sigma*M
>  s = dsolve.splu(B)
>  e, v = ARPACK_gen_eigs(M.matvec, s.solve, 2*n, sigma, 2, 'LR')
^^
You may try futzing around with this parameter.

Anyway, I did play around a bit with your example and never really got a
good answer. But my experience has been that ARPACK doesn't really work
well with small matrices. Try a bigger problem and see if things turn out
better, I mean, obviously you don't need a sparse solver to solve a 6x6
matrix system ;). You may also find that if you force Matlab to do this
problem using a sparse solver you'll run into the same issues.
Unfortunately I don't know enough about the ARPACK routines to give more
insight. They do work quite well on my problems, where the eigenvalues
are always positive.

>  which also seems to be correct to me. Please tell if the method I am
>  using is correct or not and why am I not getting correct solutions. Is
>  the ARPACK_gen_eigs broken? Or is there a problem in my code?

Seems OK, but I'm no expert ;)

Regards
Neilen

>
>  Regards
>  --
>  Abhinav Sarkar
>  Deptt. of Mechanical Engg.
>  Indian Institute of Technology, Kharagpur India
>
>  Web: http://claimid.com/abhin4v