| 818 | } |
| 819 | |
| 820 | SymMatrix::value_type UdUinversePD (SymMatrix& M) |
| 821 | /* Inverse of Positive Definite matrix |
| 822 | * Input: |
| 823 | * M is a symmetric matrix |
| 824 | * Output: |
| 825 | * M inverse of M, only updated if return value >0 |
| 826 | * Return: |
| 827 | * reciprocal condition number, -1 if negative, 0 if semi-definite (including zero) |
| 828 | */ |
| 829 | { |
| 830 | // Abuse as a RowMatrix |
| 831 | RowMatrix& M_matrix = M.asRowMatrix(); |
| 832 | SymMatrix::value_type rcond = UdUfactor (M_matrix, M_matrix.size1()); |
| 833 | // Only invert and recompose if PD |
| 834 | if (rcond > 0) { |
| 835 | bool singular = UdUinverse (M_matrix); |
| 836 | assert (!singular); (void)singular; |
| 837 | UdUrecompose_transpose (M_matrix); |
| 838 | } |
| 839 | return rcond; |
| 840 | } |
| 841 | |
| 842 | SymMatrix::value_type UdUinversePD (SymMatrix& M, SymMatrix::value_type& detM) |
| 843 | /* As above but also computes determinant of original M if M is PSD |
no test coverage detected