eigen/doc/examples/TutorialLinAlgSVDSolve.cpp

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

12 lines
431 B
C++
Raw Normal View History

2010-10-15 21:44:43 +08:00
#include <iostream>
#include <Eigen/Dense>
int main() {
Eigen::MatrixXf A = Eigen::MatrixXf::Random(3, 2);
std::cout << "Here is the matrix A:\n" << A << std::endl;
Eigen::VectorXf b = Eigen::VectorXf::Random(3);
std::cout << "Here is the right hand side b:\n" << b << std::endl;
std::cout << "The least-squares solution is:\n"
2023-03-09 01:04:59 +08:00
<< A.bdcSvd(Eigen::ComputeThinU | Eigen::ComputeThinV).solve(b) << std::endl;
2010-10-15 21:44:43 +08:00
}