| 791 | } |
| 792 | |
| 793 | SymMatrix::value_type UdUinversePDignoreInfinity (SymMatrix& M) |
| 794 | /* Inverse of Positive Definite matrix |
| 795 | * The inverse is able to deal with infinities on the leading diagonal |
| 796 | * Input: |
| 797 | * M is a symmetric matrix |
| 798 | * Output: |
| 799 | * M inverse of M, only updated if return value >0 |
| 800 | * Return: |
| 801 | * reciprocal condition number, -1 if negative, 0 if semi-definite (including zero) |
| 802 | */ |
| 803 | { |
| 804 | // Abuse as a RowMatrix |
| 805 | RowMatrix& M_matrix = M.asRowMatrix(); // Must use variant1, variant2 cannot deal with infinity |
| 806 | SymMatrix::value_type orig_rcond = UdUfactor_variant1 (M_matrix, M_matrix.size1()); |
| 807 | // Ignore the normal rcond and recompute ingnoring infinites |
| 808 | SymMatrix::value_type rcond = rcond_ignore_infinity_internal (diag(M_matrix)); |
| 809 | assert (rcond == orig_rcond || orig_rcond == 0); (void)orig_rcond; |
| 810 | |
| 811 | // Only invert and recompose if PD |
| 812 | if (rcond > 0) { |
| 813 | bool singular = UdUinverse (M_matrix); |
| 814 | assert (!singular); (void)singular; |
| 815 | UdUrecompose_transpose (M_matrix); |
| 816 | } |
| 817 | return rcond; |
| 818 | } |
| 819 | |
| 820 | SymMatrix::value_type UdUinversePD (SymMatrix& M) |
| 821 | /* Inverse of Positive Definite matrix |
no test coverage detected