LLT_example.cpp 519 B

123456789101112
  1. MatrixXd A(3,3);
  2. A << 4,-1,2, -1,6,0, 2,0,5;
  3. cout << "The matrix A is" << endl << A << endl;
  4. LLT<MatrixXd> lltOfA(A); // compute the Cholesky decomposition of A
  5. MatrixXd L = lltOfA.matrixL(); // retrieve factor L in the decomposition
  6. // The previous two lines can also be written as "L = A.llt().matrixL()"
  7. cout << "The Cholesky factor L is" << endl << L << endl;
  8. cout << "To check this, let us compute L * L.transpose()" << endl;
  9. cout << L * L.transpose() << endl;
  10. cout << "This should equal the matrix A" << endl;