| 1109 | */ |
| 1110 | template<typename typ, typename basetyp> |
| 1111 | static inline void |
| 1112 | slogdet_single_element(fortran_int m, |
| 1113 | typ* src, |
| 1114 | fortran_int* pivots, |
| 1115 | typ *sign, |
| 1116 | basetyp *logdet) |
| 1117 | { |
| 1118 | using 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 | |
| 1144 | template<typename typ, typename basetyp> |
| 1145 | static void |
no test coverage detected