--- src/T_Model/General_Methods.hpp.orig 2022-07-18 22:59:27.000000000 +0700 +++ src/T_Model/General_Methods.hpp 2023-09-16 05:03:59.000000000 +0700 @@ -281,8 +281,8 @@ } double ss = arma::sum(inter_zigs.row(i)); - - if(isnan(ss)){ + + if(std::isnan(ss)){ inter_zigs.row(i) = zi_gs.row(i); ss = arma::sum(inter_zigs.row(i)); } @@ -355,8 +355,8 @@ } double ss = arma::sum(inter_zigs.row(i)); - - if(isnan(ss)){ + + if(std::isnan(ss)){ inter_zigs.row(i) = zi_gs.row(i); ss = arma::sum(inter_zigs.row(i)); } @@ -443,8 +443,8 @@ } double ss = arma::sum(inter_zigs.row(i)); - - if(isnan(ss)){ + + if(std::isnan(ss)){ inter_zigs.row(i) = zi_gs.row(i); ss = arma::sum(inter_zigs.row(i)); } @@ -563,14 +563,11 @@ try { double vgs_g = vgs_solve(eta_g,vgs[0], 0.1); if(!std::isnan(vgs_g) && !comparison_t(vgs_g,0)){ - for(int g = 0; g < G; g++){ vgs[g] = vgs_g; } - } - } catch(const std::exception& e) { }; - + } catch(const std::exception& e) { }; } @@ -607,7 +604,7 @@ else { logliks.push_back(calculate_log_liklihood()); - //checking aitkens convergence criterion + // checking aitkens convergence criterion int last_index = logliks.size()-1; double l_p1 = logliks[last_index]; double l_t = logliks[last_index-1]; @@ -622,7 +619,7 @@ #pragma once void T_Mixture_Model::z_ig_init_random(void) { - + // arma::mat inter_zigs = arma::mat(n,G,arma::fill::zeros); // for(int i = 0; i < n; i++){ @@ -634,22 +631,19 @@ // inter_row_sum += inter_zigs.at(i,g); // } // // check for stupid nans - + // for(int g = 0; g < G; g++){ - + // double numer_g = inter_row_sum - inter_zigs(i,g); // double denom_g = inter_zigs(i,g); // inter_zigs(i,g) = 1.0/(1 + numer_g/denom_g); - // if(isnan(inter_zigs(i,g))){ + // if(std::isnan(inter_zigs(i,g))){ // inter_zigs.row(i) = inter_zigs.row(i-1); // break; // } - - // } - + // } // } - // zi_gs = inter_zigs; } --- src/gpcm_arma.hpp.orig 2022-07-18 22:59:27.000000000 +0700 +++ src/gpcm_arma.hpp 2023-09-16 05:07:07.000000000 +0700 @@ -656,8 +656,8 @@ } double ss = arma::sum(inter_zigs.row(i)); - - if(isnan(ss)){ + + if(std::isnan(ss)){ inter_zigs.row(i) = zi_gs.row(i); ss = arma::sum(inter_zigs.row(i)); } @@ -732,8 +732,8 @@ } double ss = arma::sum(inter_zigs.row(i)); - - if(isnan(ss)){ + + if(std::isnan(ss)){ inter_zigs.row(i) = zi_gs.row(i); ss = arma::sum(inter_zigs.row(i)); } @@ -819,8 +819,8 @@ } double ss = arma::sum(inter_zigs.row(i)); - - if(isnan(ss)){ + + if(std::isnan(ss)){ inter_zigs.row(i) = zi_gs.row(i); ss = arma::sum(inter_zigs.row(i)); } --- src/ghpcm_arma.hpp.orig 2022-09-20 22:04:13.000000000 +0700 +++ src/ghpcm_arma.hpp 2023-09-16 04:55:37.000000000 +0700 @@ -189,10 +189,10 @@ } } } - + m->set_E_step(stochastic_check); - if(isnan(in_l_tol)){ + if(std::isnan(in_l_tol)){ m->tol_l = 1e-6; } else{ --- src/stpcm_arma.hpp.orig 2022-09-20 22:04:13.000000000 +0700 +++ src/stpcm_arma.hpp 2023-09-16 05:01:47.000000000 +0700 @@ -203,7 +203,7 @@ } // in all other cases use a standard sampler. - if(isnan(in_l_tol)){ + if(std::isnan(in_l_tol)){ m->tol_l = 1e-6; } else{ --- src/tpcm_arma.hpp.orig 2022-07-18 22:59:27.000000000 +0700 +++ src/tpcm_arma.hpp 2023-09-16 05:01:05.000000000 +0700 @@ -122,7 +122,7 @@ m->set_E_step(stochastic_check); m->set_m_step_vgs(constrained_check); - if(isnan(in_l_tol)){ + if(std::isnan(in_l_tol)){ m->tol_l = 1e-6; } else{ --- src/vgpcm_arma.hpp.orig 2022-09-20 22:04:13.000000000 +0700 +++ src/vgpcm_arma.hpp 2023-09-16 04:58:53.000000000 +0700 @@ -193,7 +193,7 @@ m->set_E_step(stochastic_check); m->set_latent_step(latent_step); - if(isnan(in_l_tol)){ + if(std::isnan(in_l_tol)){ m->tol_l = 1e-6; } else{ --- src/GH_Model/GH_Mixture_Model.h.orig 2022-09-20 22:04:13.000000000 +0700 +++ src/GH_Model/GH_Mixture_Model.h 2023-09-16 05:07:50.000000000 +0700 @@ -496,7 +496,7 @@ int last_index = logliks.size(); double l_p1 = logliks[last_index-1]; double l_t = logliks[last_index-2]; - if( isnan(l_p1) || isinf(l_p1) ){ + if( std::isnan(l_p1) || std::isinf(l_p1) ){ infinite_loglik_except e; throw e; } @@ -506,7 +506,7 @@ } double l_m1 = logliks[last_index-3]; double a_t = (l_p1 - l_t)/(l_t - l_m1); - if(isnan(a_t) || isinf(a_t)){ + if(std::isnan(a_t) || std::isinf(a_t)){ a_t = 0.0; } double l_Inf = l_t + (l_p1 - l_t)/(1.0-a_t); @@ -610,7 +610,7 @@ // loggy("nu" space nu space "rho" space rho space "delta" space delta space "bess_input" space bess_input space "leading_terms" space leading_terms space "middle terms" space middle_terms space "third term" space third_term space "bessel_term" space bessel_term space "result" space result); - if(isnan(result) || isinf(result)){ + if(std::isnan(result) || std::isinf(result)){ // loggy("result: " << result << " leading_terms: " << leading_terms << " middle_terms: " << middle_terms << " third_term: " << third_term << " bessel_term: " << bessel_term ); // loggy("delta: " << delta << " omega_g " << omega_g << " rho " << rho); @@ -811,8 +811,8 @@ } double ss = arma::sum(inter_zigs.row(i)); - - if(isnan(ss)){ + + if(std::isnan(ss)){ inter_zigs.row(i) = zi_gs.row(i); ss = arma::sum(inter_zigs.row(i)); } @@ -904,8 +904,8 @@ } double ss = arma::sum(inter_zigs.row(i)); - - if(isnan(ss)){ + + if(std::isnan(ss)){ inter_zigs.row(i) = zi_gs.row(i); ss = arma::sum(inter_zigs.row(i)); } @@ -982,8 +982,8 @@ } double ss = arma::sum(inter_zigs.row(i)); - - if(isnan(ss)){ + + if(std::isnan(ss)){ inter_zigs.row(i) = zi_gs.row(i); ss = arma::sum(inter_zigs.row(i)); } --- src/ST_Model/ST_Mixture_Model.h.orig 2022-09-20 22:04:13.000000000 +0700 +++ src/ST_Model/ST_Mixture_Model.h 2023-09-16 04:58:15.000000000 +0700 @@ -490,7 +490,7 @@ double l_p1 = logliks[last_index-1]; double l_t = logliks[last_index-2]; - if( isnan(l_p1) || isinf(l_p1) ){ + if( std::isnan(l_p1) || std::isinf(l_p1) ){ infinite_loglik_except e; throw e; } @@ -529,8 +529,8 @@ double c_loglik = calculate_log_liklihood(); bool conv_check = false; // loggy("loglik: " << c_loglik); - if( isnan(c_loglik) || isinf(c_loglik) ){ - + if( std::isnan(c_loglik) || std::isinf(c_loglik) ){ + if(logliks.size() < 10){ infinite_loglik_except e; throw e; @@ -564,7 +564,7 @@ c_loglik = calculate_log_liklihood(); - if(isnan(c_loglik) || isinf(c_loglik)){ + if(std::isnan(c_loglik) || std::isinf(c_loglik)){ zi_gs = prev_zi_gs; abar_gs = prev_abar_gs; bbar_gs = prev_bbar_gs; @@ -667,12 +667,12 @@ double third_term = (nu/2.0)*( log(delta + v_g) - log(rho)); double bessel_term = LG_k_bessel(nu,bess_input); - if( isnan(bessel_term)){ + if( std::isnan(bessel_term)){ bessel_term = log(1e-10); } double result = leading_terms + middle_terms +third_term + bessel_term; - + return(result); } @@ -861,8 +861,8 @@ } double ss = arma::sum(inter_zigs.row(i)); - - if(isnan(ss)){ + + if(std::isnan(ss)){ inter_zigs.row(i) = zi_gs.row(i); ss = arma::sum(inter_zigs.row(i)); } @@ -958,8 +958,8 @@ } double ss = arma::sum(inter_zigs.row(i)); - - if(isnan(ss)){ + + if(std::isnan(ss)){ inter_zigs.row(i) = zi_gs.row(i); ss = arma::sum(inter_zigs.row(i)); } @@ -1037,8 +1037,8 @@ } double ss = arma::sum(inter_zigs.row(i)); - - if(isnan(ss)){ + + if(std::isnan(ss)){ inter_zigs.row(i) = zi_gs.row(i); ss = arma::sum(inter_zigs.row(i)); } @@ -1542,15 +1542,13 @@ const double eta_g = bbar_gs[g] - cbar_gs[g] - 1; try { double gam_g = st_gamma_solve(eta_g,vs[g], 2*eps); - if(!isnan(gam_g) && !comparison_st(gam_g,20.0)){ + if(!std::isnan(gam_g) && !comparison_st(gam_g,20.0)){ vs[g] = gam_g; } } catch(const std::exception& e){ - Rcpp::Rcout << "error has occured with gamma solver." << std::endl; - }; - + Rcpp::Rcout << "error has occured with gamma solver." << std::endl; + }; } - } --- src/VG_Model/VG_Mixture_Model.h.orig 2022-09-20 22:04:13.000000000 +0700 +++ src/VG_Model/VG_Mixture_Model.h 2023-09-16 05:00:24.000000000 +0700 @@ -491,7 +491,7 @@ double l_p1 = logliks[last_index-1]; double l_t = logliks[last_index-2]; - if( isnan(l_p1) || isinf(l_p1) ){ + if( std::isnan(l_p1) || std::isinf(l_p1) ){ infinite_loglik_except e; throw e; } @@ -532,7 +532,7 @@ double c_loglik = calculate_log_liklihood(); // loggy("loglik: " << c_loglik); - if( isnan(c_loglik) || isinf(c_loglik) ){ + if( std::isnan(c_loglik) || std::isinf(c_loglik) ){ if(logliks.size() < 10){ infinite_loglik_except e; @@ -567,7 +567,7 @@ c_loglik = calculate_log_liklihood(); - if(isnan(c_loglik) || isinf(c_loglik)){ + if(std::isnan(c_loglik) || std::isinf(c_loglik)){ zi_gs = prev_zi_gs; abar_gs = prev_abar_gs; bbar_gs = prev_bbar_gs; @@ -669,7 +669,7 @@ double third_term = (nu/2.0)*( log(delta) - log( rho + 2*gam_g)); double bessel_term = LG_k_bessel(nu, bess_input); - if( isnan(bessel_term)){ + if( std::isnan(bessel_term)){ bessel_term = log(1e-10); } @@ -862,8 +862,8 @@ } double ss = arma::sum(inter_zigs.row(i)); - - if(isnan(ss)){ + + if(std::isnan(ss)){ inter_zigs.row(i) = zi_gs.row(i); ss = arma::sum(inter_zigs.row(i)); } @@ -956,8 +956,8 @@ } double ss = arma::sum(inter_zigs.row(i)); - - if(isnan(ss)){ + + if(std::isnan(ss)){ inter_zigs.row(i) = zi_gs.row(i); ss = arma::sum(inter_zigs.row(i)); } @@ -1035,8 +1035,8 @@ } double ss = arma::sum(inter_zigs.row(i)); - - if(isnan(ss)){ + + if(std::isnan(ss)){ inter_zigs.row(i) = zi_gs.row(i); ss = arma::sum(inter_zigs.row(i)); } @@ -1360,16 +1360,13 @@ const double eta_g = abar_gs[g] - cbar_gs[g] - 1; try { double gam_g = vg_gamma_solve(eta_g,gammas[g], 1e-7); - if(!isnan(gam_g) && !comparison_vg(gam_g,10.0)){ + if(!std::isnan(gam_g) && !comparison_vg(gam_g,10.0)){ gammas[g] = gam_g; } } catch(const std::exception& e){ - Rcpp::Rcout << "error has occured with gamma solver." << std::endl; - }; - - + Rcpp::Rcout << "error has occured with gamma solver." << std::endl; + }; } - }