simplifications

This commit is contained in:
conrad
2026-04-19 22:59:46 +10:00
parent b1f3a185bf
commit 59fbefc095
+15 -9
View File
@@ -87,6 +87,8 @@ op_rank::apply_diag(uword& out, Mat<eT>& A, typename get_pod_type<eT>::result to
typedef typename get_pod_type<eT>::result T;
out = uword(0);
const uword N = (std::min)(A.n_rows, A.n_cols);
podarray<T> diag_abs_vals(N);
@@ -98,7 +100,7 @@ op_rank::apply_diag(uword& out, Mat<eT>& A, typename get_pod_type<eT>::result to
const eT Aii = A.at(i,i);
const T abs_Aii = std::abs(Aii);
if(arma_isnan(Aii)) { out = uword(0); return false; }
if(arma_isnan(Aii)) { return false; }
diag_abs_vals[i] = abs_Aii;
@@ -108,7 +110,7 @@ op_rank::apply_diag(uword& out, Mat<eT>& A, typename get_pod_type<eT>::result to
// set tolerance to default if it hasn't been specified
if(tol == T(0)) { tol = (std::max)(A.n_rows, A.n_cols) * max_abs_Aii * std::numeric_limits<T>::epsilon(); }
if(arma_isnan(tol)) { out = uword(0); return false; }
if(arma_isnan(tol)) { return false; }
uword count = 0;
@@ -130,18 +132,20 @@ op_rank::apply_sym(uword& out, Mat<eT>& A, typename get_pod_type<eT>::result tol
typedef typename get_pod_type<eT>::result T;
if(A.is_square() == false) { out = uword(0); return false; }
out = uword(0);
if(A.is_square() == false) { return false; }
Col<T> v;
const bool status = auxlib::eig_sym(v, A);
if(status == false) { out = uword(0); return false; }
if(status == false) { return false; }
const uword v_n_elem = v.n_elem;
T* v_mem = v.memptr();
if(v_n_elem == 0) { out = uword(0); return true; }
if(v_n_elem == 0) { return true; }
T max_abs_v = T(0);
@@ -150,7 +154,7 @@ op_rank::apply_sym(uword& out, Mat<eT>& A, typename get_pod_type<eT>::result tol
// set tolerance to default if it hasn't been specified
if(tol == T(0)) { tol = (std::max)(A.n_rows, A.n_cols) * max_abs_v * std::numeric_limits<T>::epsilon(); }
if(arma_isnan(tol)) { out = uword(0); return false; }
if(arma_isnan(tol)) { return false; }
uword count = 0;
@@ -172,21 +176,23 @@ op_rank::apply_gen(uword& out, Mat<eT>& A, typename get_pod_type<eT>::result tol
typedef typename get_pod_type<eT>::result T;
out = uword(0);
Col<T> s;
const bool status = auxlib::svd_dc(s, A);
if(status == false) { out = uword(0); return false; }
if(status == false) { return false; }
const uword s_n_elem = s.n_elem;
const T* s_mem = s.memptr();
if(s_n_elem == 0) { out = uword(0); return true; }
if(s_n_elem == 0) { return true; }
// set tolerance to default if it hasn't been specified
if(tol == T(0)) { tol = (std::max)(A.n_rows, A.n_cols) * s_mem[0] * std::numeric_limits<T>::epsilon(); }
if(arma_isnan(tol)) { out = uword(0); return false; }
if(arma_isnan(tol)) { return false; }
uword count = 0;