犰狳库c ++解决不一致的线性方程

armadillo library c++ solve the linear equation that is inconsistent

我正在使用犰狳库 我尝试使用此代码来求解线性方程组 我输入了一个应该不一致的案例,但它输出了方程的解!
我试试这个

x+y=3,
4 x + 4 y = 10

这是代码

mat A(2,2);
vec B(2);
A << 1 << 1 << endr
  << 4 << 4 << endr;
B << 3 << endr
  << 10 << endr;
vec Ans;
Ans = solve(A,B);
cout << Ans << endl;

文档中说,如果找不到解决方案,它将抛出异常

If no solution is found:
X = solve(A,B) resets X and throws a std::runtime_error exception solve(X,A,B) resets X and returns a bool set to false (exception is not thrown)

所以当我解决不一致时我应该怎么做,它应该抛出异常或 return false 或任何正确的方法
提前致谢

默认情况下,犰狳尝试寻找 singular matrix A:

的近似解
warning: solve(): system seems singular; attempting approx solution
   1.2647
   1.2647

您应该使用 solve_opts::no_approx 选项禁用此行为:

Ans = solve(A,B,solve_opts::no_approx);

请参阅 solve() 的文档。