detect failure

This commit is contained in:
conrad
2021-03-31 14:23:25 +10:00
parent 57973528c1
commit 175a0bcbd7
+5 -5
View File
@@ -89,21 +89,21 @@ log_det
eT x = A[0];
T sign = (is_cx<eT>::no) ? ( (access::tmp_real(x) < T(0)) ? -1 : +1 ) : +1;
eT val = (is_cx<eT>::no) ? std::log( (access::tmp_real(x) < T(0)) ? x*T(-1) : x ) : std::log(x);
T sign = (is_cx<eT>::no) ? ( (access::tmp_real(x) < T(0)) ? T(-1) : T(1) ) : T(1);
eT val = (is_cx<eT>::no) ? std::log( (access::tmp_real(x) < T(0)) ? x*T(-1) : x ) : std::log(x);
for(uword i=1; i<N; ++i)
{
x = A[i];
sign *= (is_cx<eT>::no) ? ( (access::tmp_real(x) < T(0)) ? -1 : +1 ) : +1;
val += (is_cx<eT>::no) ? std::log( (access::tmp_real(x) < T(0)) ? x*T(-1) : x ) : std::log(x);
sign *= (is_cx<eT>::no) ? ( (access::tmp_real(x) < T(0)) ? T(-1) : T(1) ) : T(1);
val += (is_cx<eT>::no) ? std::log( (access::tmp_real(x) < T(0)) ? x*T(-1) : x ) : std::log(x);
}
out_val = val;
out_sign = sign;
return true; // TODO: detect failure
return arma_isnan(out_val);
}