libeigen/eigen!2652 Closes #998, #2142, #301, #1822, #1959, #805, #462, #308, #2146, #1335, #634, #81, and #46
15 lines
515 B
C++
15 lines
515 B
C++
// SPDX-FileCopyrightText: The Eigen Authors
|
|
// SPDX-License-Identifier: MPL-2.0
|
|
|
|
#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"
|
|
<< A.bdcSvd<Eigen::ComputeThinU | Eigen::ComputeThinV>().solve(b) << std::endl;
|
|
}
|