TutorialInplaceLU.cpp File Reference

Go to the source code of this file.

Functions

int main ()
 

Variables

init init_obj
 

Function Documentation

◆ main()

int main ( )

Definition at line 9 of file TutorialInplaceLU.cpp.

10 {
11  Eigen::MatrixXd A(2,2);
12  A << 2, -1, 1, 3;
13  std::cout << "Here is the input matrix A before decomposition:\n" << A << "\n";
14  std::cout << "[init]\n";
15 
16  std::cout << "[declaration]\n";
18  std::cout << "Here is the input matrix A after decomposition:\n" << A << "\n";
19  std::cout << "[declaration]\n";
20 
21  std::cout << "[matrixLU]\n";
22  std::cout << "Here is the matrix storing the L and U factors:\n" << lu.matrixLU() << "\n";
23  std::cout << "[matrixLU]\n";
24 
25  std::cout << "[solve]\n";
26  Eigen::MatrixXd A0(2,2); A0 << 2, -1, 1, 3;
27  Eigen::VectorXd b(2); b << 1, 2;
28  Eigen::VectorXd x = lu.solve(b);
29  std::cout << "Residual: " << (A0 * x - b).norm() << "\n";
30  std::cout << "[solve]\n";
31 
32  std::cout << "[modifyA]\n";
33  A << 3, 4, -2, 1;
34  x = lu.solve(b);
35  std::cout << "Residual: " << (A0 * x - b).norm() << "\n";
36  std::cout << "[modifyA]\n";
37 
38  std::cout << "[recompute]\n";
39  A0 = A; // save A
40  lu.compute(A);
41  x = lu.solve(b);
42  std::cout << "Residual: " << (A0 * x - b).norm() << "\n";
43  std::cout << "[recompute]\n";
44 
45  std::cout << "[recompute_bis0]\n";
46  Eigen::MatrixXd A1(2,2);
47  A1 << 5,-2,3,4;
48  lu.compute(A1);
49  std::cout << "Here is the input matrix A1 after decomposition:\n" << A1 << "\n";
50  std::cout << "[recompute_bis0]\n";
51 
52  std::cout << "[recompute_bis1]\n";
53  x = lu.solve(b);
54  std::cout << "Residual: " << (A1 * x - b).norm() << "\n";
55  std::cout << "[recompute_bis1]\n";
56 
57 }
Array< int, 3, 1 > b
MatrixXcf A
The matrix class, also used for vectors and row-vectors.
Definition: Matrix.h:182
LU decomposition of a matrix with partial pivoting, and related features.
Definition: PartialPivLU.h:80
cout<< "Here is the matrix m:"<< endl<< m<< endl;Eigen::FullPivLU< Matrix5x3 > lu(m)

Variable Documentation

◆ init_obj

init init_obj

Definition at line 5 of file TutorialInplaceLU.cpp.