BiCGSTAB 调用猜测时迭代次数错误
我正在使用 C++ 和 Eigen 库来通过 BiCGSTAB 求解器求解系统。
#include <Eigen/IterativeLinearSolvers>
在代码中的某个时刻我初始化了矩阵A
和rhs向量rhs
int N = domain.size();
Eigen::SparseMatrix<double, Eigen::RowMajor> M(N, N);
Eigen::VectorXd rhs(N);
rhs.setZero();
M.reserve(storage.supportSizes());
最终创建了求解器并解决了系统
Eigen::BiCGSTAB<decltype(M), Eigen::IncompleteLUT<double>> solver;
solver.setMaxIterations(300);
solver.compute(M);
auto sol = solver.solveWithGuess(rhs, guess);
if (debug) {
print(solver.iterations());
print(solver.error());
}
问题
上面代码的问题是输出不合理
solver.iterations() = 94414646480416;
solver.error() = 6.91858e-310;
即使初始猜测是零向量(这是 BiCGSTAB 的默认方式)。我必须在这里指出,解决系统所需的时间大约是(毫)秒,所以我很确定它没有进行 94414646480416 次迭代。
有谁知道当通过猜测获得解决方案时如何获得迭代次数?
I am using the c++ and Eigen library to solve a system with BiCGSTAB solver.
#include <Eigen/IterativeLinearSolvers>
At some point in the code I initialize the matrix A
and rhs vector rhs
int N = domain.size();
Eigen::SparseMatrix<double, Eigen::RowMajor> M(N, N);
Eigen::VectorXd rhs(N);
rhs.setZero();
M.reserve(storage.supportSizes());
Finally solver is created and system is solved
Eigen::BiCGSTAB<decltype(M), Eigen::IncompleteLUT<double>> solver;
solver.setMaxIterations(300);
solver.compute(M);
auto sol = solver.solveWithGuess(rhs, guess);
if (debug) {
print(solver.iterations());
print(solver.error());
}
Problem
The problem with the above code is that the output is unreasonable
solver.iterations() = 94414646480416;
solver.error() = 6.91858e-310;
even when the initial guess is a vector of zeros (as is the defaulty way for BiCGSTAB). I must point out here, that the the time required to solve the system is a matter of (mili)seconds, so I am quite sure it did not do the 94414646480416 iterations.
Does anybody know how to get the number of iterations when solution is obtained with a guess?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论