MCPcopy Create free account
hub / github.com/numpy/numpy / slogdet_single_element

Function slogdet_single_element

numpy/linalg/umath_linalg.cpp:1111–1142  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1109 */
1110template<typename typ, typename basetyp>
1111static inline void
1112slogdet_single_element(fortran_int m,
1113 typ* src,
1114 fortran_int* pivots,
1115 typ *sign,
1116 basetyp *logdet)
1117{
1118using ftyp = fortran_type_t<typ>;
1119 fortran_int info = 0;
1120 fortran_int lda = fortran_int_max(m, 1);
1121 int i;
1122 /* note: done in place */
1123 getrf(&m, &m, (ftyp*)src, &lda, pivots, &info);
1124
1125 if (info == 0) {
1126 int change_sign = 0;
1127 /* note: fortran uses 1 based indexing */
1128 for (i = 0; i < m; i++)
1129 {
1130 change_sign += (pivots[i] != (i+1));
1131 }
1132
1133 *sign = (change_sign % 2)?numeric_limits<typ>::minus_one:numeric_limits<typ>::one;
1134 slogdet_from_factored_diagonal(src, m, sign, logdet);
1135 } else {
1136 /*
1137 if getrf fails, use 0 as sign and -inf as logdet
1138 */
1139 *sign = numeric_limits<typ>::zero;
1140 *logdet = numeric_limits<basetyp>::ninf;
1141 }
1142}
1143
1144template<typename typ, typename basetyp>
1145static void

Callers 2

slogdetFunction · 0.85
detFunction · 0.85

Calls 3

fortran_int_maxFunction · 0.85
getrfFunction · 0.85

Tested by

no test coverage detected