2010-06-30 22:11:55 +08:00
|
|
|
#include <iostream>
|
|
|
|
#include <Eigen/Dense>
|
|
|
|
|
|
|
|
int main() {
|
2021-12-08 03:57:38 +08:00
|
|
|
Eigen::Matrix2f A, b;
|
|
|
|
Eigen::LLT<Eigen::Matrix2f> llt;
|
2010-06-30 22:11:55 +08:00
|
|
|
A << 2, -1, -1, 3;
|
|
|
|
b << 1, 2, 3, 1;
|
2021-12-08 03:57:38 +08:00
|
|
|
std::cout << "Here is the matrix A:\n" << A << std::endl;
|
|
|
|
std::cout << "Here is the right hand side b:\n" << b << std::endl;
|
|
|
|
std::cout << "Computing LLT decomposition..." << std::endl;
|
2010-06-30 22:11:55 +08:00
|
|
|
llt.compute(A);
|
2021-12-08 03:57:38 +08:00
|
|
|
std::cout << "The solution is:\n" << llt.solve(b) << std::endl;
|
2010-06-30 22:11:55 +08:00
|
|
|
A(1, 1)++;
|
2021-12-08 03:57:38 +08:00
|
|
|
std::cout << "The matrix A is now:\n" << A << std::endl;
|
|
|
|
std::cout << "Computing LLT decomposition..." << std::endl;
|
2010-06-30 22:11:55 +08:00
|
|
|
llt.compute(A);
|
2021-12-08 03:57:38 +08:00
|
|
|
std::cout << "The solution is now:\n" << llt.solve(b) << std::endl;
|
2010-06-30 22:11:55 +08:00
|
|
|
}
|