Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
36b0cd37ec | ||
|
|
59fbefc095 | ||
|
|
b1f3a185bf | ||
|
|
adcbf1380a | ||
|
|
733533f089 | ||
|
|
ae6f216a82 | ||
|
|
417bb37042 | ||
|
|
95cad27904 | ||
|
|
3e66e7b1f0 |
@@ -352,7 +352,7 @@ Base<elem_type,derived>::is_symmetric(const typename get_pod_type<elem_type>::re
|
||||
|
||||
if(tol == T(0)) { return (*this).is_symmetric(); }
|
||||
|
||||
arma_conform_check( ((tol >= T(0)) == false), "is_symmetric(): parameter 'tol' must be >= 0" );
|
||||
arma_conform_check( ((tol >= T(0)) == false), "is_symmetric(): parameter 'tol' must be > 0" );
|
||||
|
||||
const quasi_unwrap<derived> U( (*this).get_ref() );
|
||||
|
||||
@@ -365,8 +365,12 @@ Base<elem_type,derived>::is_symmetric(const typename get_pod_type<elem_type>::re
|
||||
|
||||
if(norm_A == T(0)) { return true; }
|
||||
|
||||
if(arma_isnan(norm_A)) { return false; }
|
||||
|
||||
const T norm_A_Ast = as_scalar( arma::max(sum(abs(A - A.st()), 1), 0) );
|
||||
|
||||
if(arma_isnan(norm_A_Ast)) { return false; }
|
||||
|
||||
return ( (norm_A_Ast / norm_A) <= tol );
|
||||
}
|
||||
|
||||
@@ -435,7 +439,7 @@ Base<elem_type,derived>::is_hermitian(const typename get_pod_type<elem_type>::re
|
||||
|
||||
if(tol == T(0)) { return (*this).is_hermitian(); }
|
||||
|
||||
arma_conform_check( ((tol >= T(0)) == false), "is_hermitian(): parameter 'tol' must be >= 0" );
|
||||
arma_conform_check( ((tol >= T(0)) == false), "is_hermitian(): parameter 'tol' must be > 0" );
|
||||
|
||||
const quasi_unwrap<derived> U( (*this).get_ref() );
|
||||
|
||||
@@ -448,8 +452,12 @@ Base<elem_type,derived>::is_hermitian(const typename get_pod_type<elem_type>::re
|
||||
|
||||
if(norm_A == T(0)) { return true; }
|
||||
|
||||
if(arma_isnan(norm_A)) { return false; }
|
||||
|
||||
const T norm_A_At = as_scalar( arma::max(sum(abs(A - A.t()), 1), 0) );
|
||||
|
||||
if(arma_isnan(norm_A_At)) { return false; }
|
||||
|
||||
return ( (norm_A_At / norm_A) <= tol );
|
||||
}
|
||||
|
||||
@@ -927,6 +935,8 @@ Base_extra_yes<elem_type,derived>::is_sympd() const
|
||||
// default value for tol
|
||||
const T tol = T(100) * std::numeric_limits<T>::epsilon() * norm(X, "fro");
|
||||
|
||||
if(arma_isnan(tol)) { return false; }
|
||||
|
||||
if(X.is_hermitian(tol) == false) { return false; }
|
||||
|
||||
if(X.is_empty()) { return false; }
|
||||
@@ -947,7 +957,7 @@ Base_extra_yes<elem_type,derived>::is_sympd(typename get_pod_type<elem_type>::re
|
||||
|
||||
typedef typename get_pod_type<elem_type>::result T;
|
||||
|
||||
arma_conform_check( ((tol >= T(0)) == false), "is_sympd(): parameter 'tol' must be >= 0" );
|
||||
arma_conform_check( ((tol >= T(0)) == false), "is_sympd(): parameter 'tol' must be > 0" );
|
||||
|
||||
Mat<elem_type> X = static_cast<const derived&>(*this);
|
||||
|
||||
|
||||
@@ -3565,7 +3565,7 @@ SpMat<eT>::is_symmetric(const typename get_pod_type<elem_type>::result tol) cons
|
||||
|
||||
if(tol == T(0)) { return (*this).is_symmetric(); }
|
||||
|
||||
arma_conform_check( ((tol >= T(0)) == false), "is_symmetric(): parameter 'tol' must be >= 0" );
|
||||
arma_conform_check( ((tol >= T(0)) == false), "is_symmetric(): parameter 'tol' must be > 0" );
|
||||
|
||||
const SpMat<eT>& A = (*this);
|
||||
|
||||
@@ -3575,8 +3575,12 @@ SpMat<eT>::is_symmetric(const typename get_pod_type<elem_type>::result tol) cons
|
||||
|
||||
if(norm_A == T(0)) { return true; }
|
||||
|
||||
if(arma_isnan(norm_A)) { return false; }
|
||||
|
||||
const T norm_A_Ast = as_scalar( arma::max(sum(abs(A - A.st()), 1), 0) );
|
||||
|
||||
if(arma_isnan(norm_A_Ast)) { return false; }
|
||||
|
||||
return ( (norm_A_Ast / norm_A) <= tol );
|
||||
}
|
||||
|
||||
@@ -3611,7 +3615,7 @@ SpMat<eT>::is_hermitian(const typename get_pod_type<elem_type>::result tol) cons
|
||||
|
||||
if(tol == T(0)) { return (*this).is_hermitian(); }
|
||||
|
||||
arma_conform_check( ((tol >= T(0)) == false), "is_hermitian(): parameter 'tol' must be >= 0" );
|
||||
arma_conform_check( ((tol >= T(0)) == false), "is_hermitian(): parameter 'tol' must be > 0" );
|
||||
|
||||
const SpMat<eT>& A = (*this);
|
||||
|
||||
@@ -3621,8 +3625,12 @@ SpMat<eT>::is_hermitian(const typename get_pod_type<elem_type>::result tol) cons
|
||||
|
||||
if(norm_A == T(0)) { return true; }
|
||||
|
||||
if(arma_isnan(norm_A)) { return false; }
|
||||
|
||||
const T norm_A_At = as_scalar( arma::max(sum(abs(A - A.t()), 1), 0) );
|
||||
|
||||
if(arma_isnan(norm_A_At)) { return false; }
|
||||
|
||||
return ( (norm_A_At / norm_A) <= tol );
|
||||
}
|
||||
|
||||
|
||||
@@ -23,7 +23,7 @@
|
||||
|
||||
#define ARMA_VERSION_MAJOR 15
|
||||
#define ARMA_VERSION_MINOR 2
|
||||
#define ARMA_VERSION_PATCH 5
|
||||
#define ARMA_VERSION_PATCH 6
|
||||
#define ARMA_VERSION_NAME "Medium Roast Deluxe"
|
||||
|
||||
|
||||
|
||||
@@ -87,6 +87,8 @@ op_orth::apply_direct(Mat<typename T1::elem_type>& out, const Base<typename T1::
|
||||
// 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)) { return false; }
|
||||
|
||||
uword count = 0;
|
||||
|
||||
for(uword i=0; i < s_n_elem; ++i) { count += (s_mem[i] > tol) ? uword(1) : uword(0); }
|
||||
@@ -174,6 +176,8 @@ op_null::apply_direct(Mat<typename T1::elem_type>& out, const Base<typename T1::
|
||||
// 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)) { return false; }
|
||||
|
||||
uword count = 0;
|
||||
|
||||
for(uword i=0; i < s_n_elem; ++i) { count += (s_mem[i] > tol) ? uword(1) : uword(0); }
|
||||
|
||||
@@ -176,6 +176,8 @@ op_pinv::apply_diag(Mat<eT>& out, const Mat<eT>& A, typename get_pod_type<eT>::r
|
||||
|
||||
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)) { return false; }
|
||||
|
||||
for(uword i=0; i<N; ++i)
|
||||
{
|
||||
if(diag_abs_vals[i] >= tol)
|
||||
@@ -236,6 +238,8 @@ op_pinv::apply_sym(Mat<eT>& out, const Mat<eT>& A, typename get_pod_type<eT>::re
|
||||
// set tolerance to default if it hasn't been specified
|
||||
if(tol == T(0)) { tol = (std::max)(A.n_rows, A.n_cols) * abs_eigval[0] * std::numeric_limits<T>::epsilon(); }
|
||||
|
||||
if(arma_isnan(tol)) { return false; }
|
||||
|
||||
uword count = 0;
|
||||
|
||||
for(uword i=0; i < abs_eigval.n_elem; ++i) { count += (abs_eigval[i] >= tol) ? uword(1) : uword(0); }
|
||||
@@ -310,6 +314,8 @@ op_pinv::apply_gen(Mat<eT>& out, Mat<eT>& A, typename get_pod_type<eT>::result t
|
||||
// set tolerance to default if it hasn't been specified
|
||||
if( (tol == T(0)) && (s.n_elem > 0) ) { tol = (std::max)(n_rows, n_cols) * s[0] * std::numeric_limits<T>::epsilon(); }
|
||||
|
||||
if(arma_isnan(tol)) { return false; }
|
||||
|
||||
uword count = 0;
|
||||
|
||||
for(uword i=0; i < s.n_elem; ++i) { count += (s[i] >= tol) ? uword(1) : uword(0); }
|
||||
|
||||
@@ -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,6 +110,8 @@ 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)) { return false; }
|
||||
|
||||
uword count = 0;
|
||||
|
||||
for(uword i=0; i<N; ++i) { count += (diag_abs_vals[i] > tol) ? uword(1) : uword(0); }
|
||||
@@ -128,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);
|
||||
|
||||
@@ -148,6 +154,8 @@ 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)) { return false; }
|
||||
|
||||
uword count = 0;
|
||||
|
||||
for(uword i=0; i < v_n_elem; ++i) { count += (v_mem[i] > tol) ? uword(1) : uword(0); }
|
||||
@@ -168,20 +176,24 @@ 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)) { return false; }
|
||||
|
||||
uword count = 0;
|
||||
|
||||
for(uword i=0; i < s_n_elem; ++i) { count += (s_mem[i] > tol) ? uword(1) : uword(0); }
|
||||
|
||||
@@ -214,6 +214,8 @@ sp_auxlib::eigs_sym_newarp(Col<eT>& eigval, Mat<eT>& eigvec, const SpMat<eT>& X,
|
||||
if(ncv < (n_eigvals + 1)) { ncv = (n_eigvals + 1); }
|
||||
if(ncv > n ) { ncv = n; }
|
||||
|
||||
if(arma_isnan(opts.tol)) { return false; }
|
||||
|
||||
eT tol = (std::max)(eT(opts.tol), std::numeric_limits<eT>::epsilon());
|
||||
|
||||
uword maxiter = uword(opts.maxiter);
|
||||
@@ -347,6 +349,8 @@ sp_auxlib::eigs_sym_newarp(Col<eT>& eigval, Mat<eT>& eigvec, const SpMat<eT>& X,
|
||||
if(ncv < (n_eigvals + 1)) { ncv = (n_eigvals + 1); }
|
||||
if(ncv > n ) { ncv = n; }
|
||||
|
||||
if(arma_isnan(opts.tol)) { return false; }
|
||||
|
||||
eT tol = (std::max)(eT(opts.tol), std::numeric_limits<eT>::epsilon());
|
||||
|
||||
uword maxiter = uword(opts.maxiter);
|
||||
@@ -667,6 +671,8 @@ sp_auxlib::eigs_gen_newarp(Col< std::complex<T> >& eigval, Mat< std::complex<T>
|
||||
if(ncv < (n_eigvals + 3)) { ncv = (n_eigvals + 3); }
|
||||
if(ncv > n ) { ncv = n; }
|
||||
|
||||
if(arma_isnan(opts.tol)) { return false; }
|
||||
|
||||
T tol = (std::max)(T(opts.tol), std::numeric_limits<T>::epsilon());
|
||||
|
||||
uword maxiter = uword(opts.maxiter);
|
||||
|
||||
@@ -4812,7 +4812,6 @@ subview_row<eT>::is_zero(const typename get_pod_type<eT>::result tol) const
|
||||
const T val_real = access::tmp_real(val);
|
||||
const T val_imag = access::tmp_imag(val);
|
||||
|
||||
// convoluted formulation to handle NaNs
|
||||
if( (eop_aux::arma_abs(val_real) <= tol) == false ) { return false; }
|
||||
if( (eop_aux::arma_abs(val_imag) <= tol) == false ) { return false; }
|
||||
}
|
||||
@@ -4835,7 +4834,6 @@ subview_row<eT>::is_zero(const typename get_pod_type<eT>::result tol) const
|
||||
{
|
||||
const eT val = (*mem_ptr); mem_ptr += local_m_n_rows;
|
||||
|
||||
// convoluted formulation to handle NaNs
|
||||
if( (eop_aux::arma_abs(val) <= tol) == false ) { return false; }
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user