Closed wo80 closed 4 years ago
To clarify: the main problem I see here is that Spectra returns after 33 iterations with compinfo SUCCESSFUL.
I guess this is an easy fix: The roles of A
and B
are different in the two solvers.
ShiftInvert
:
// A * x = lambda * B * x, A is symmetric, B is positive definite
// A is dense, B is sparse
using OpType = SymShiftInvert<double, Eigen::Dense, Eigen::Sparse>;
using BOpType = SparseSymMatProd<double>;
OpType op(A, B);
BOpType Bop(B);
Buckling
:
// K * x = lambda * KG * x, K is positive definite, KG is symmetric
// K is sparse, KG is dense
using OpType = SymShiftInvert<double, Eigen::Sparse, Eigen::Dense>;
using BOpType = SparseSymMatProd<double>;
OpType op(K, KG);
BOpType Bop(K);
In this case, both matrices are spd, so this shouldn't be the problem.
Btw, I'm comparing results with the tests from ARPACK++:
Matrix A from examples/matrices/sym/lsmatrxc.h Matrix B from examples/matrices/sym/lsmatrxd.h
Shift-invert mode test from examples/superlu/sym/lsymgshf.cc Buckling mode test from examples/superlu/sym/lsymgbkl.cc
I mean, BOpType
is B
in the shift-and-invert mode, and is K
in the buckling mode.
Ok, I see, this does make a difference. But now the shift-invert mode does not converge at all.
I'm (still) working on a C wrapper for Spectra. Maybe you can have a short look at the relevant code: https://github.com/wo80/vs-spectra/blob/master/src/Visual%20Studio/shared/libspectra/spectra_di_sg.cpp#L80
Buckling and Caley mode work fine, but the regular shift-invert mode just doesn't ...
I had selection set to SortRule::SmallestMagn
. Now it works as expected. Thanks!
I started testing your latest code from the 1.y.z branch and found a problem. I'm solving a generalized problem using shift-invert and buckling mode with shift 1.0. While ARPACK gives the correct result for both modes
Spectra fails using the shift-invert mode, while the buckling mode succeeds:
Here's the relevant code:
The test matrices are stored in MatrixMarket format: A.txt B.txt