3

I have to invert a symmetric, positive definite matrix in order to execute an extended Kalman Filter. I know quite some matrix decompositon methods like Cholesky or QR, but the question is what is the most efficient way doing it for this specific class of matrices.

The implementation in C++ has to run on a pretty slow embedded processor. The most resource consuming part in the task is inverting this 8x8 matrix and whether the task is feasible depends on how efficient this inversion can be done.

If it is relevant: I know that the real part of two eigenvalues is always around 0.01 and two other eigenvalues are around 0.64. Also the eigenvalues don't change much over time. An example for the matrix is:

 0.0603    0.0166    0.0021   -0.0265    0.0118    0.0025    0.0010   -0.0071
 0.0166    0.0181    0.0053    0.0013    0.0040    0.0018    0.0015    0.0006
 0.0021    0.0053    0.0179    0.0160    0.0007    0.0017    0.0021    0.0046
-0.0265    0.0013    0.0160    0.0612   -0.0058    0.0023    0.0039    0.0145
 0.0118    0.0040    0.0007   -0.0058    0.7994    0.0550    0.0116   -0.0734
 0.0025    0.0018    0.0017    0.0023    0.0550    0.6686    0.0202    0.0103
 0.0010    0.0015    0.0021    0.0039    0.0116    0.0202    0.6683    0.0548
-0.0071    0.0006    0.0046    0.0145   -0.0734    0.0103    0.0548    0.8055
BThomas
  • 133

2 Answers2

1

If you know your matrix is of fixed dimension, you should unroll the Cholesky loop of your code to avoid branching. Furthermore, if you know it is positive definite, then you should avoid the checks to make sure the diagonal elements are positive. Finally, you want to use the square-root-free version ($LDL^T$ version). These techniques are all used by the CVXGEN embedded optimization code generator.

Victor Liu
  • 3,721
0

When you say resource consuming, is it memory or computation time? If it is memory consumption then storing the Cholesky decomposition (instead of the PD matrix) can reduce your memory consumption. Not to mention, the inverse of the matrix can be represented as the inverse of the decomposition (i.e. if $M$ is the matrix, then $M = QQ^{\top} \Rightarrow M^{-1} = Q^{\top-1}Q^{-1}$). Depending on how you plan to use the PD matrix later, storing it in decomposed form can even save on computation time.

TenaliRaman
  • 3,846
  • It's mainly computation time - the memory isn't too huge either, but the main problem is as stated the slow processor – BThomas Nov 25 '14 at 12:04