一个超定方程组,例如 A x = b Ax = b Ax=b,没有解。在这种情况下,在 A x − b Ax-b Ax−b尽可能小的意义上,搜索最接近解的向量 x x x是有意义的。该 x x x称为最小二乘解(如果使用欧几里得范数)。
此处使用的三种求解方法为:SVD分解,QR分解,正规矩阵(normal equation)。在这三种方程中,SVD分解通常准确率最高,但是速度最慢;正规矩阵速度最快,但是准确率最低;QR分解位于两者之间。
求解问题
Eigen::MatrixXd A = Eigen::MatrixXd::Random(3, 2);
std::cout << "Here is the matrix A:\n" << A << std::endl;
Eigen::VectorXd b = Eigen::VectorXd::Random(3);
std::cout << "Here is the right hand side b:\n" << b.