blob: 46fb4070450149dc6e411cc516d4ccaedc2d5284 [file] [log] [blame]
Brian Silverman72890c22015-09-19 14:37:37 -04001MatrixXd A(3,3);
2A << 4,-1,2, -1,6,0, 2,0,5;
3cout << "The matrix A is" << endl << A << endl;
4
5LLT<MatrixXd> lltOfA(A); // compute the Cholesky decomposition of A
6MatrixXd L = lltOfA.matrixL(); // retrieve factor L in the decomposition
7// The previous two lines can also be written as "L = A.llt().matrixL()"
8
9cout << "The Cholesky factor L is" << endl << L << endl;
10cout << "To check this, let us compute L * L.transpose()" << endl;
11cout << L * L.transpose() << endl;
12cout << "This should equal the matrix A" << endl;