I'm new to ARPACK, I downloaded a script like the following
import time
import numpy as np
from scipy.linalg import eigh
from scipy.sparse.linalg import eigs
np.set_printoptions(suppress=True)
n=30
rstart=0
rend=n
A=np.zeros(shape=(n,n))
# first row
if rstart == 0:
A[0, :2] = [2, -1]
rstart += 1
# last row
if rend == n:
A[n-1, -2:] = [-1, 2]
rend -= 1
# other rows
for i in range(rstart, rend):
A[i, i-1:i+2] = [-1, 2, -1]
A[0,8]=30
start_time = time.time()
evals_large, evecs_large = eigs(A, 10, sigma=3.6766133, which='LM')
print evals_large
end_time=time.time()-start_time
print(" Elapsed time: %12f seconds " % end_time)
It solves a very simple eigenvalue problem (The matrix A
there is not symmetric, I set A[0,8]
to be 30
). The 3 eigenvalues closest to 3.6766133
(sigma=3.6766133
in the setting) according to the ARPACK results are
[ 3.68402411+0.j 3.82005897+0.j 3.51120293+0.j]
Then I go to MATLAB, and solve the same eigenvalue problem, and the results are
4.144524409923138 + 0.000000000000000i
3.642801014184622 + 0.497479798520641i
3.642801014184622 - 0.497479798520641i
2.372392770347609 + 0.762183281789166i
2.372392770347609 - 0.762183281789166i
3.979221766266502 + 0.000000000000000i
3.918541441830947 + 0.000000000000000i
3.820058967057387 + 0.000000000000000i
3.684024113506185 + 0.000000000000000i
3.511202932803536 + 0.000000000000000i
3.307439963195127 + 0.000000000000000i
3.080265978640102 + 0.000000000000000i
2.832849552917550 + 0.000000000000000i
2.565972630556613 + 0.000000000000000i
2.283744793210587 + 0.000000000000000i
1.996972474451519 + 0.000000000000000i
0.927737801889518 + 0.670252740725955i
0.927737801889518 - 0.670252740725955i
1.714561796881689 + 0.000000000000000i
-0.015193770830045 + 0.264703483268519i
-0.015193770830045 - 0.264703483268519i
1.438919271663752 + 0.000000000000000i
0.019951101383019 + 0.000000000000000i
0.080534338862828 + 0.000000000000000i
0.181591307101504 + 0.000000000000000i
0.318955140475174 + 0.000000000000000i
0.488231021129767 + 0.000000000000000i
0.688030188040126 + 0.000000000000000i
1.171318650526539 + 0.000000000000000i
0.917612528393044 + 0.000000000000000i
Apparently, the second mode 3.642801014184622 + 0.497479798520641i
is more close to sigma=3.6766133
, but ARPACK didn't pick it out.
What could be the problem? Could you help me figure this out? Thanks a lot.