JuliaLinearAlgebra / IterativeSolvers.jl

Iterative algorithms for solving linear systems, eigensystems, and singular value problems
MIT License
394 stars 106 forks source link

lobpcg throws error for non-positive definiteness #316

Open fredrikekre opened 2 years ago

fredrikekre commented 2 years ago

Taken from the test suit which is currently failing:

using IterativeSolvers

A = Float32[
    21.962786 1.4833882 0.21581084 0.45571166 0.74517167 1.1193731 0.25749892 1.3517505 0.18381447 1.0681943
    1.4833882 20.00386 0.72662705 1.7235297 0.64777404 1.480941 0.96281075 0.48083097 1.3185633 1.1447084
    0.21581084 0.72662705 20.57441 0.6739896 1.3619598 0.9507286 1.0981764 0.67328894 0.78507507 1.6430001
    0.45571166 1.7235297 0.6739896 21.068693 0.55732477 1.5396118 0.8253338 1.0251237 1.4075768 0.87435734
    0.74517167 0.64777404 1.3619598 0.55732477 20.433136 0.5870526 0.85003483 1.5908186 1.3562183 1.5675161
    1.1193731 1.480941 0.9507286 1.5396118 0.5870526 21.428747 0.40523893 1.3066325 1.0889214 1.6802719
    0.25749892 0.96281075 1.0981764 0.8253338 0.85003483 0.40523893 21.584705 0.24645764 0.6943433 0.85728854
    1.3517505 0.48083097 0.67328894 1.0251237 1.5908186 1.3066325 0.24645764 21.22726 1.4825046 0.9748377
    0.18381447 1.3185633 0.78507507 1.4075768 1.3562183 1.0889214 0.6943433 1.4825046 20.508791 0.69401336
    1.0681943 1.1447084 1.6430001 0.87435734 1.5675161 1.6802719 0.85728854 0.9748377 0.69401336 20.555178
]

B = Float32[
    20.724804 0.8785407 1.484901 0.364142 0.2808147 1.3026264 0.07068437 1.1553006 1.0015647 0.71801186
    0.8785407 21.353834 0.53060615 1.4030783 1.0841415 1.0243318 0.9167048 1.164545 1.2608967 1.6707416
    1.484901 0.53060615 21.860508 0.20592105 1.9104576 1.3720789 1.1911132 1.5058928 1.6848136 0.70514435
    0.364142 1.4030783 0.20592105 21.776304 0.9354136 1.4514796 1.8885474 1.0959218 0.6837329 1.6448011
    0.2808147 1.0841415 1.9104576 0.9354136 20.953478 1.6269939 0.9993142 0.3767581 0.79928476 0.8016052
    1.3026264 1.0243318 1.3720789 1.4514796 1.6269939 21.329576 0.5938283 0.66347265 1.3490194 0.75018036
    0.07068437 0.9167048 1.1911132 1.8885474 0.9993142 0.5938283 20.353855 0.7671128 0.6813122 0.47481853
    1.1553006 1.164545 1.5058928 1.0959218 0.3767581 0.66347265 0.7671128 21.152452 1.2080661 1.3369143
    1.0015647 1.2608967 1.6848136 0.6837329 0.79928476 1.3490194 0.6813122 1.2080661 21.719643 1.3874302
    0.71801186 1.6707416 0.70514435 1.6448011 0.8016052 0.75018036 0.47481853 1.3369143 1.3874302 21.133402
]

b = Float32[
    0.23655403 0.6062175; 0.7060932 0.9239733; 0.2400735 0.34902388; 0.32333612 0.11735982; 0.2430389 0.029232562;
    0.80052435 0.34792954; 0.39707696 0.106615126; 0.83043045 0.18224674; 0.99440753 0.7946706; 0.9211004 0.18224639
]

tol = IterativeSolvers.default_tolerance(Float32)

largest = true

lobpcg(A, B, largest, b; tol=tol, maxiter=Inf, log=true)