Cholesky分解(Cholesky decomposition / Cholesky )

Cholesky decomposition

In linear algebra, the Cholesky decomposition or Cholesky is a decomposition of a Hermitian, positive-definite matrix into the product of a lower triangular matrix and its conjugate transpose.

Cholesky 分解是把一个对称正定的矩阵表示成一个下三角矩阵L和其转置的乘积的分解。

wiki
https://en.wikipedia.org/wiki/Cholesky_decomposition
MATLAB
https://www.mathworks.com/help/matlab/ref/chol.html?s_tid=gn_loc_drop#responsive_offcanvas
Cplusplus
https://eigen.tuxfamily.org/dox/classEigen_1_1LLT.html

#include <iostream>
#include <vector>
#include <Eigen/Dense>
using namespace std;
using namespace Eigen;

int main()
{
  MatrixXd A(3,3);
  A << 4,-1,2, -1,6,0, 2,0,5;
  cout << "The matrix A is" << endl << A << endl;
  LLT<MatrixXd> lltOfA(A); // compute the Cholesky decomposition of A

  //cout << "lltofA" << endl << lltOfA(A) << endl;

  MatrixXd 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" << endl;
}

MATLAB Cholesky分解

>> A = [4 -1 2 ; -1 6 0 ; 2 0 5 ]

A =

   4  -1   2
  -1   6   0
   2   0   5

>> L = chol(A,'lower')

L =

   2.00000   0.00000   0.00000
  -0.50000   2.39792   0.00000
   1.00000   0.20851   1.98910

>> B = L * L'

B =

   4.0000e+00  -1.0000e+00   2.0000e+00
  -1.0000e+00   6.0000e+00  -2.5602e-17
   2.0000e+00  -2.5602e-17   5.0000e+00

>>

posted on 2018-02-27 14:15  lion_zheng  阅读(1067)  评论(0编辑  收藏  举报

导航