diff --git a/include/armadillo_bits/op_expmat_meat.hpp b/include/armadillo_bits/op_expmat_meat.hpp index d50d43d0..61c448d9 100644 --- a/include/armadillo_bits/op_expmat_meat.hpp +++ b/include/armadillo_bits/op_expmat_meat.hpp @@ -195,25 +195,9 @@ op_expmat_sym::apply_direct(Mat& out, const Base::yes) + if((arma_config::debug) && (is_cx::yes) && (sympd_helper::check_diag_imag(X) == false)) { - arma_extra_debug_print("op_expmat_sym: checking imaginary components of diagonal elements"); - - const T tol = T(10000) * std::numeric_limits::epsilon(); // allow some leeway - - const eT* colmem = X.memptr(); - - for(uword i=0; i tol) { return false; } - - colmem += N; - } + arma_debug_warn_level(1, "inv_sympd(): imaginary components on diagonal are non-zero"); } if(is_op_diagmat::value || X.is_diagmat()) @@ -224,6 +208,8 @@ op_expmat_sym::apply_direct(Mat& out, const Base& out, const Base::yes) + if((arma_config::debug) && (is_cx::yes) && (sympd_helper::check_diag_imag(out) == false)) { - arma_extra_debug_print("op_inv_spd_full: checking imaginary components of diagonal elements"); - - const T tol = T(10000) * std::numeric_limits::epsilon(); // allow some leeway - - const eT* colmem = out.memptr(); - - for(uword i=0; i tol) { return false; } - - colmem += N; - } + arma_debug_warn_level(1, "inv_sympd(): imaginary components on diagonal are non-zero"); } if(is_op_diagmat::value || out.is_diagmat()) diff --git a/include/armadillo_bits/op_log_det_meat.hpp b/include/armadillo_bits/op_log_det_meat.hpp index 85245078..4f1411cd 100644 --- a/include/armadillo_bits/op_log_det_meat.hpp +++ b/include/armadillo_bits/op_log_det_meat.hpp @@ -195,25 +195,9 @@ op_log_det_sympd::apply_direct(typename T1::pod_type& out_val, const Base::yes) + if((arma_config::debug) && (is_cx::yes) && (sympd_helper::check_diag_imag(A) == false)) { - arma_extra_debug_print("op_log_det_sympd: checking imaginary components of diagonal elements"); - - const T tol = T(10000) * std::numeric_limits::epsilon(); // allow some leeway - - const eT* colmem = A.memptr(); - - for(uword i=0; i tol) { return false; } - - colmem += N; - } + arma_debug_warn_level(1, "log_det_sympd(): imaginary components on diagonal are non-zero"); } if(is_op_diagmat::value || A.is_diagmat()) @@ -224,6 +208,8 @@ op_log_det_sympd::apply_direct(typename T1::pod_type& out_val, const Base& out, const Base::yes) + if((arma_config::debug) && (is_cx::yes) && (sympd_helper::check_diag_imag(X) == false)) { - arma_extra_debug_print("op_logmat_sympd: checking imaginary components of diagonal elements"); - - const T tol = T(10000) * std::numeric_limits::epsilon(); // allow some leeway - - const eT* colmem = X.memptr(); - - const uword N = X.n_rows; - - for(uword i=0; i tol) { return false; } - - colmem += N; - } + arma_debug_warn_level(1, "logmat_sympd(): imaginary components on diagonal are non-zero"); } if(is_op_diagmat::value || X.is_diagmat()) diff --git a/include/armadillo_bits/op_sqrtmat_meat.hpp b/include/armadillo_bits/op_sqrtmat_meat.hpp index 94a08da6..b1bd65f2 100644 --- a/include/armadillo_bits/op_sqrtmat_meat.hpp +++ b/include/armadillo_bits/op_sqrtmat_meat.hpp @@ -482,25 +482,9 @@ op_sqrtmat_sympd::apply_direct(Mat& out, const Base::yes) + if((arma_config::debug) && (is_cx::yes) && (sympd_helper::check_diag_imag(X) == false)) { - arma_extra_debug_print("op_sqrtmat_sympd: checking imaginary components of diagonal elements"); - - const T tol = T(10000) * std::numeric_limits::epsilon(); // allow some leeway - - const eT* colmem = X.memptr(); - - const uword N = X.n_rows; - - for(uword i=0; i tol) { return false; } - - colmem += N; - } + arma_debug_warn_level(1, "sqrtmat_sympd(): imaginary components on the diagonal are non-zero"); } if(is_op_diagmat::value || X.is_diagmat()) diff --git a/include/armadillo_bits/sympd_helper.hpp b/include/armadillo_bits/sympd_helper.hpp index bf1d745c..f9c978b9 100644 --- a/include/armadillo_bits/sympd_helper.hpp +++ b/include/armadillo_bits/sympd_helper.hpp @@ -447,6 +447,38 @@ analyse_matrix(bool& is_approx_sym, bool& is_approx_sympd, const Mat& A) +template +inline +bool +check_diag_imag(const Mat& A) + { + arma_extra_debug_sigprint(); + + // NOTE: assuming matrix A is square-sized + + typedef typename get_pod_type::result T; + + const T tol = T(10000) * std::numeric_limits::epsilon(); // allow some leeway + + const eT* colmem = A.memptr(); + + const uword N = A.n_rows; + + for(uword i=0; i tol) { return false; } + + colmem += N; + } + + return true; + } + + + } // end of namespace sympd_helper