MCPcopy Create free account
hub / github.com/OpenPTrack/open_ptrack_v2 / UdUinversePDignoreInfinity

Function UdUinversePDignoreInfinity

bayes/src/UdU.cpp:793–818  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

791}
792
793SymMatrix::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
820SymMatrix::value_type UdUinversePD (SymMatrix& M)
821/* Inverse of Positive Definite matrix

Callers 1

predictMethod · 0.85

Calls 5

UdUfactor_variant1Function · 0.85
diagFunction · 0.85
UdUinverseFunction · 0.85
UdUrecompose_transposeFunction · 0.85

Tested by

no test coverage detected