[petsc-users] SLEPC - Hermitian matrix gives complex eigenvalues

Jose E. Roman jroman at dsic.upv.es
Thu Sep 14 03:33:01 CDT 2017


> El 14 sept 2017, a las 0:27, Pandey, Siddhant <spandey2 at wpi.edu> escribió:
> 
> Hello all,
> 
> I am diagonalizing a hermitian matrix (MatIsHermitian = 1 up to a tolerance of 1e-15) using krylovschur, with EPS_TARGET_MAGNITUDE = 0, but getting complex eigenvalues. Also, I am getting seemingly spurious eigenvalues of magnitude very close to 0, whose relative errors are much larger than my set tolerance. Can anyone indicate what might be the cause and possible solutions.
> 
> I have attached the files eps_view, A_mat_binary, and B_mat_binary files, which show the settings I have used, and contain the A and B matrices respectively (in binary).
> 
> The eigenvalues I get are:
> 
>   #     
>          
>      Eigenvalue
>  —       ----------------------------------------------------------------
>   0         0.0000000000000077  + i -0.0000000000000000
>   1         0.0000000000000265  + i -0.0000000000000008
>   2         0.0000000000000340  + i 0.0000000000000002
>   3         0.0000000000000373  + i 0.0000000000000001
>   4         0.0000000000000444  + i -0.0000000000000007
>   5         0.0000000000000448  + i -0.0000000000000017
>   6         0.0000000000000470  + i 0.0000000000000002
>   7         0.0000000000000489  + i 0.0000000000000030
>   8         0.0000000000000548  + i 0.0000000000000006
>   9         0.0000000000000585  + i 0.0000000000000001
>   10       0.0000000000000643  + i 0.0000000000000005
>   11       0.0000000000000714  + i -0.0000000000000008
>   12       0.0000000000000750  + i -0.0000000000000019
>   13       0.0000000000000752  + i 0.0000000000000031
>   14       0.0000000000000769  + i -0.0000000000000002
>   15       0.0000000000000784  + i -0.0000000000000037
>   16       0.0000000000000860  + i 0.0000000000000002
>   17       0.0000000000000880  + i -0.0000000000000004
>   18       0.0000000000000968  + i -0.0000000000000001
>   19       0.0000000000000979  + i 0.0000000000000013
>   20       0.0000000000001045  + i -0.0000000000000001
>   21       0.0000000000001150  + i -0.0000000000000011
>   22       0.0000000000001348  + i -0.0000000000000012
>   23       0.0000000000001446  + i -0.0000000000000019
>   24       0.0000000000001454  + i 0.0000000000000011
>   25       0.0000000000001555  + i 0.0000000000000003
>   26       0.0000000000002513  + i -0.0000000000000009
>   27       5.0908854514230413  + i -0.0022004178122762
>   28       5.2768106039842175  + i 0.1043464906789375
>   29       5.3003883062604187  + i -0.0757735907905433
>   30       11.5143655883932929 + i 0.0049838692042474
>   31       11.8821523259838653 + i -0.1475608751440501
>   32       11.9515216995487101 + i 0.1857395729336506
>   33       12.0909362158339384 + i 0.0049114285397287
>   34       12.0905704159492675 + i -0.1522880348537981
>   35       12.2205398661469111 + i -0.0781999802933937
>   36       12.4807156964720480 + i -0.2850122604907908
>   37       12.6082849940660289 + i 0.0560456679728079
>   38       12.9384278480576125 + i 0.0238826907631012
>   39       17.5230234731441357 + i -0.1824807274488794
>   40       17.5503678395543901 + i 0.1785356473404145
>   41       17.6933953160112409 + i -0.0626631055149425
>   42       19.1692824404480930 + i -0.6351729266691462
>   43       19.4158452684509797 + i 0.3151965488807310
>   44       19.6020750507704591 + i -0.2559887580276014
>   45       19.6443102906562181 + i 1.1005601705485646
>   46       19.7948713379697452 + i 0.1230015140422697
>   47       19.8791098474284347 + i -0.1943322911563744
>   48       20.1268732265661860 + i -0.0340890856219265
>   49       20.1368588182453898 + i 0.2673370459460956
> 
> 
> Thanks in advance,
> Sidd
> Worcester Polytechnic, U.S.A.
> <A_mat_binary><B_mat_binary><eps_view_pre.txt>

Your B matrix has full rank, but rank(A)=1002. This means your eigenproblem has 27 zero eigenvalues. So no wonder that you get tiny eigenvalues (they are numerically zero in the working precision).

Since you problem is Hermitian, you should solve it as such, adding -eps_gen_hermitian. Then the accuracy will be a bit better. Still, the relative error for the tiny eigenvalues will be large (division by zero), but you can see that the *absolute* error shows that the eigenvector is computed correctly. See output below.

Another thing is that since your A matrix is singular, you should not use target=0, because then the solver will invert matrix A. MUMPS is good at working with singular matrices, but still the error will propagate to the computed eigensolutions. You have to move away from zero, e.g. target=0.1

Finally, do not set ncv=1029. By doing this, the built subspace is equal to the whole space of the original problem, so the cost will be even higher than calling LAPACK directly on your matrices. Let SLEPc choose the ncv value.

Jose


$ ./ex7 -f1 ~/tmp/pandey/A_mat_binary -f2 ~/tmp/pandey/B_mat_binary -st_pc_factor_mat_solver_package mumps -st_type sinvert -eps_target 0.1 -eps_nev 50 -eps_error_absolute ::ascii_info_detail

Generalized eigenproblem stored in file.

 Reading COMPLEX matrices from binary files...
 ---------------------- --------------------
            k                ||Ax-kBx||
 ---------------------- --------------------
   0.000000+0.000000i       7.65812e-12
   0.000000-0.000000i       2.78585e-12
   0.000000-0.000000i       6.30965e-12
   0.000000+0.000000i       1.90477e-12
   0.000000-0.000000i       4.18541e-12
   0.000000+0.000000i       2.90717e-12
   0.000000+0.000000i       2.90732e-12
   0.000000-0.000000i       6.69097e-12
   0.000000+0.000000i       2.01707e-12
   0.000000-0.000000i        6.2849e-12
   0.000000-0.000000i       6.30369e-12
   0.000000-0.000000i       6.79209e-12
   0.000000+0.000000i        3.3761e-12
   0.000000-0.000000i       6.19772e-12
   0.000000+0.000000i       3.87231e-12
   0.000000-0.000000i       2.75338e-12
   0.000000+0.000000i       9.50872e-12
   0.000000-0.000000i       4.59981e-12
   0.000000-0.000000i       7.62071e-13
   0.000000-0.000000i       7.24146e-12
   0.000000+0.000000i       2.98146e-12
   0.000000-0.000000i       1.49165e-12
   0.000000-0.000000i       1.33641e-12
   0.000000-0.000000i       3.02551e-12
   0.000000-0.000000i       1.76448e-12
   0.000000+0.000000i       2.03659e-12
   0.000000-0.000000i       5.71796e-12
   5.238680+0.000000i       3.67926e-11
   5.238680+0.000000i       3.85213e-11
   5.238680+0.000000i        3.3809e-11
   12.047661+0.000000i       3.74891e-11
   12.047661+0.000000i       3.36437e-11
   12.047661+0.000000i       4.68278e-11
   12.079279+0.000000i       4.27835e-11
   12.079279+0.000000i       7.02149e-11
   12.079279-0.000000i       1.14514e-10
   12.954275+0.000000i       1.13398e-10
   12.954275-0.000000i        1.0298e-10
   12.955799-0.000000i        6.2543e-11
   17.515033+0.000000i       1.25423e-10
   17.515033-0.000000i       6.11696e-11
   17.647490+0.000000i       2.56307e-10
   19.770424-0.000000i       1.43313e-07
   19.770424-0.000000i        4.1167e-11
   19.770424-0.000000i       7.67294e-11
   19.770424-0.000000i       5.92692e-11
   19.770424+0.000000i       7.66231e-11
   19.770424+0.000000i       9.85743e-11
   20.199838+0.000000i       8.37107e-11
   20.199838+0.000000i       3.56701e-11
   20.199838-0.000000i       8.82029e-11
   20.199838-0.000000i       8.52395e-11
   20.199838-0.000000i       8.82165e-11
   20.199838-0.000000i       4.32813e-07
   24.112262+0.000000i       2.25578e-10
   24.112262-0.000000i       1.27094e-10
   24.112262+0.000000i       1.14679e-10
   24.227579-0.000000i       9.77701e-11
   24.227579+0.000000i       1.41993e-10
   24.227579-0.000000i       1.84562e-10
   29.035473-0.000000i       2.69505e-10
   29.035473-0.000000i       1.72167e-10
   29.035473-0.000000i       1.87434e-10
   29.649484-0.000000i       2.44039e-10
   29.649484-0.000000i       3.84759e-10
   32.112699+0.000000i       1.35182e-10
   32.112699+0.000000i       1.91162e-10
   32.112699-0.000000i       3.58118e-10
   32.115257+0.000000i       3.58743e-10
   32.115257-0.000000i       3.46267e-10
   32.115257+0.000000i       4.55903e-10
   50.121754+0.000000i       6.04554e-10
   50.121754-0.000000i       6.26139e-10
 ---------------------- --------------------
 Number of iterations of the method: 3
 Number of linear iterations of the method: 168
 Solution method: krylovschur

 Number of requested eigenvalues: 50
 Stopping condition: tol=1e-08, maxit=100
 Linear eigensolve converged (73 eigenpairs) due to CONVERGED_TOL; iterations 3
 ---------------------- --------------------
            k             ||Ax-kBx||/||kx||
 ---------------------- --------------------
   0.000000+0.000000i           31.3252
   0.000000-0.000000i           18.2211
   0.000000-0.000000i            44.631
   0.000000+0.000000i            13.836
   0.000000-0.000000i           30.8722
   0.000000+0.000000i           26.1132
   0.000000+0.000000i           28.6077
   0.000000-0.000000i           74.5526
   0.000000+0.000000i           23.1291
   0.000000-0.000000i           74.0475
   0.000000-0.000000i           74.7671
   0.000000-0.000000i            90.664
   0.000000+0.000000i           45.6476
   0.000000-0.000000i           84.4024
   0.000000+0.000000i           55.9734
   0.000000-0.000000i           42.2662
   0.000000+0.000000i           155.367
   0.000000-0.000000i            82.083
   0.000000-0.000000i            14.409
   0.000000-0.000000i           163.883
   0.000000+0.000000i           70.2693
   0.000000-0.000000i           38.2544
   0.000000-0.000000i           35.2561
   0.000000-0.000000i           87.8327
   0.000000-0.000000i           73.0972
   0.000000+0.000000i           102.899
   0.000000-0.000000i           841.374
   5.238680+0.000000i       7.02326e-12
   5.238680+0.000000i       7.35325e-12
   5.238680+0.000000i       6.45373e-12
   12.047661+0.000000i       3.11174e-12
   12.047661+0.000000i       2.79255e-12
   12.047661+0.000000i       3.88688e-12
   12.079279+0.000000i       3.54189e-12
   12.079279+0.000000i       5.81284e-12
   12.079279-0.000000i       9.48017e-12
   12.954275+0.000000i       8.75372e-12
   12.954275-0.000000i       7.94948e-12
   12.955799-0.000000i       4.82741e-12
   17.515033+0.000000i       7.16088e-12
   17.515033-0.000000i       3.49241e-12
   17.647490+0.000000i       1.45237e-11
   19.770424-0.000000i       7.24883e-09
   19.770424-0.000000i       2.08225e-12
   19.770424-0.000000i       3.88102e-12
   19.770424-0.000000i       2.99787e-12
   19.770424+0.000000i       3.87565e-12
   19.770424+0.000000i       4.98595e-12
   20.199838+0.000000i       4.14413e-12
   20.199838+0.000000i       1.76586e-12
   20.199838-0.000000i       4.36652e-12
   20.199838-0.000000i       4.21981e-12
   20.199838-0.000000i       4.36719e-12
   20.199838-0.000000i       2.14265e-08
   24.112262+0.000000i       9.35532e-12
   24.112262-0.000000i       5.27091e-12
   24.112262+0.000000i       4.75603e-12
   24.227579-0.000000i       4.03549e-12
   24.227579+0.000000i        5.8608e-12
   24.227579-0.000000i       7.61787e-12
   29.035473-0.000000i       9.28191e-12
   29.035473-0.000000i       5.92953e-12
   29.035473-0.000000i       6.45536e-12
   29.649484-0.000000i       8.23079e-12
   29.649484-0.000000i       1.29769e-11
   32.112699+0.000000i       4.20961e-12
   32.112699+0.000000i       5.95285e-12
   32.112699-0.000000i       1.11519e-11
   32.115257+0.000000i       1.11705e-11
   32.115257-0.000000i        1.0782e-11
   32.115257+0.000000i       1.41958e-11
   50.121754+0.000000i       1.20617e-11
   50.121754-0.000000i       1.24924e-11
 ---------------------- --------------------




More information about the petsc-users mailing list