本文整理汇总了C++中MatrixXf::jacobiSvd方法的典型用法代码示例。如果您正苦于以下问题:C++ MatrixXf::jacobiSvd方法的具体用法?C++ MatrixXf::jacobiSvd怎么用?C++ MatrixXf::jacobiSvd使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MatrixXf
的用法示例。
在下文中一共展示了MatrixXf::jacobiSvd方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main
int main()
{
MatrixXf A = MatrixXf::Random(3, 2);
cout << "Here is the matrix A:\n" << A << endl;
VectorXf b = VectorXf::Random(3);
cout << "Here is the right hand side b:\n" << b << endl;
cout << "The least-squares solution is:\n"
<< A.jacobiSvd(ComputeThinU | ComputeThinV).solve(b) << endl;
}
示例2: TestLeastSquares
void TestLeastSquares() {
MatrixXf A = MatrixXf::Random(10, 2);
VectorXf b = VectorXf::Random(10);
Vector2f x;
std::cout << "=============================" << std::endl;
std::cout << "Testing least squares solvers" << std::endl;
std::cout << "=============================" << std::endl;
x = A.jacobiSvd(ComputeThinU | ComputeThinV).solve(b);
std::cout << "Solution using Jacobi SVD = " << x.transpose() << std::endl;
x = A.colPivHouseholderQr().solve(b);
std::cout << "Solution using column pivoting Householder QR = " << x.transpose() << std::endl;
// If the matrix A is ill-conditioned, then this is not a good method
x = (A.transpose() * A).ldlt().solve(A.transpose() * b);
std::cout << "Solution using normal equation = " << x.transpose() << std::endl;
}