Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Eigen efficient inverse of symmetric positive definite matrix

In Eigen, if we have symmetric positive definite matrix A then we can calculate the inverse of A by

A.inverse();

or

A.llt().solve(I);

where I is an identity matrix of the same size as A. But is there a more efficient way to calculate the inverse of symmetric positive definite matrix?

For example if we write the Cholesky decomposition of A as A = LL^{T}, then L^{-T} L^{-1} is an inverse of A since A L^{-T} L^{-1} = LL^{T} L^{-T} L^{-1} = I (and where L^{-T} denotes the inverse of the transpose of L).

So we could obtain the Cholesky decomposition of A, calculate its inverse, and then obtain the cross-product of that inverse to find the inverse of A. But my instinct is that calculating these explicit steps will be slower than using A.llt().solve(I) as above.

And before anybody asks, I do indeed need an explicit inverse - it is a calculation for part of a Gibbs sampler.

like image 373
dpritch Avatar asked Jul 28 '16 15:07

dpritch


People also ask

Is the inverse of a symmetric positive definite matrix?

Recall that a symmetric matrix is positive-definite if and only if its eigenvalues are all positive. Thus, since A is positive-definite, the matrix does not have 0 as an eigenvalue. Hence A is invertible.

Is inverse of positive definite matrix positive definite?

The matrix inverse of a positive definite matrix is also positive definite. The definition of positive definiteness is equivalent to the requirement that the determinants associated with all upper-left submatrices are positive.

What is the inverse of a symmetric matrix?

Therefore, the inverse of a symmetric matrix is a symmetric matrix.

What is the inverse of 2x2 matrix?

The inverse of a 2x2 matrix, say A, is a matrix of the same order denoted by A-1 such that AA-1 = A-1A = I, where I is the identity matrix of order 2x2. i.e., I = ⎡⎢⎣1001⎤⎥⎦ [ 1 0 0 1 ] .


1 Answers

With A.llt().solve(I), you assumes A to be a SPD matrix and apply Cholesky decomposition to solve the equation Ax=I. The mathematical procedure of solving the equation is exactly same as your explicit way. So the performance should be same if you do every step correctly.

On the other hand, with A.inverse(), you are doing general matrix inversion, which uses LU decomposition for large matrix. Thus the performance should be lower than A.llt().solve(I);.

like image 181
kangshiyin Avatar answered Sep 29 '22 15:09

kangshiyin