This forum has been archived. All content is frozen. Please use KDE Discuss instead.

Cholesky factorization

Tags: None
(comma "," separated)
izabelain
Registered Member
Posts
6
Karma
0

Cholesky factorization

Mon Nov 07, 2011 3:33 pm
Hi,

I would like to find Cholesky factorization of a 2x2 matrix.
Please help me how may I do it by using Eigen....
Thanks in advance.
jitseniesen
Registered Member
Posts
204
Karma
2

Re: Cholesky factorization

Mon Nov 07, 2011 4:45 pm
Here is an example:

Code: Select all
#include <Eigen/Cholesky>
#include <iostream>

using namespace Eigen;
using namespace std;

int main()
{
  Matrix2d A;
  A << 4,-1,-1,5;
  cout << "The matrix A is" << endl << A << endl;

  LLT<Matrix2d> lltOfA(A); // compute the Cholesky decomposition of A
  Matrix2d L = lltOfA.matrixL(); // retrieve factor L  in the decomposition
  // The previous two lines can also be written as "L = A.llt().matrixL()"

  cout << "The Cholesky factor L is" << endl << L << endl;
  cout << "To check this, let us compute L * L.transpose()" << endl;
  cout << L * L.transpose() << endl;
  cout << "This should equal the matrix A";
}


See http://eigen.tuxfamily.org/dox/classEigen_1_1LLT.html for a list of methods for the LLT class. You may also be interested in the LDLT class, which uses pivoting and is thus more stable; see http://eigen.tuxfamily.org/dox/classEigen_1_1LDLT.html for that. The tutorial page on decompositions at http://eigen.tuxfamily.org/dox/Tutorial ... gebra.html may also be useful.
izabelain
Registered Member
Posts
6
Karma
0

Re: Cholesky factorization

Mon Nov 07, 2011 6:08 pm
great....thank you so much.


Bookmarks



Who is online

Registered users: Bing [Bot], Google [Bot], Yahoo [Bot]