1212#include " print_mutex.h"
1313#include " rng_utils.h"
1414#include " sampler_output.h"
15+ #include " explog_switch.h"
1516#include < string>
1617
1718using namespace Rcpp ;
@@ -125,7 +126,7 @@ void impute_missing_bgmcompare(
125126 for (int category = 1 ; category <= num_categories (variable, group); category++) {
126127 exponent = group_main_effects (category - 1 );
127128 exponent += category * rest_score;
128- cumsum += std::exp (exponent);
129+ cumsum += MY_EXP (exponent);
129130 category_response_probabilities[category] = cumsum;
130131 }
131132 } else {
@@ -137,7 +138,7 @@ void impute_missing_bgmcompare(
137138 (category - baseline_category[variable]) *
138139 (category - baseline_category[variable]);
139140 exponent += category * rest_score;
140- cumsum += std::exp (exponent);
141+ cumsum += MY_EXP (exponent);
141142 category_response_probabilities[category] = cumsum;
142143 }
143144 }
@@ -985,7 +986,7 @@ void tune_proposal_sd_bgmcompare(
985986 SamplerResult result = rwm_sampler (current, prop_sd, log_post, rng);
986987 current = result.state [0 ];
987988 prop_sd = update_proposal_sd_with_robbins_monro (
988- prop_sd, std::log (result.accept_prob ), rm_weight, target_accept
989+ prop_sd, MY_LOG (result.accept_prob ), rm_weight, target_accept
989990 );
990991 }
991992 }
@@ -1013,7 +1014,7 @@ void tune_proposal_sd_bgmcompare(
10131014 SamplerResult result = rwm_sampler (current, prop_sd, log_post, rng);
10141015 current = result.state [0 ];
10151016 prop_sd = update_proposal_sd_with_robbins_monro (
1016- prop_sd, std::log (result.accept_prob ), rm_weight, target_accept
1017+ prop_sd, MY_LOG (result.accept_prob ), rm_weight, target_accept
10171018 );
10181019 }
10191020 }
@@ -1046,7 +1047,7 @@ void tune_proposal_sd_bgmcompare(
10461047 SamplerResult result = rwm_sampler (current, prop_sd, log_post, rng);
10471048 current = result.state [0 ];
10481049 prop_sd = update_proposal_sd_with_robbins_monro (
1049- prop_sd, std::log (result.accept_prob ), rm_weight, target_accept
1050+ prop_sd, MY_LOG (result.accept_prob ), rm_weight, target_accept
10501051 );
10511052 }
10521053 }
@@ -1165,11 +1166,11 @@ void update_indicator_differences_metropolis_bgmcompare (
11651166 // Add prior inclusion probability contribution
11661167 double inc_prob = inclusion_probability_difference (var, var);
11671168 if (proposed_ind == 1 ) {
1168- log_accept += std::log (inc_prob);
1169- log_accept -= std::log (1 - inc_prob);
1169+ log_accept += MY_LOG (inc_prob);
1170+ log_accept -= MY_LOG (1 - inc_prob);
11701171 } else {
1171- log_accept -= std::log (inc_prob);
1172- log_accept += std::log (1 - inc_prob);
1172+ log_accept -= MY_LOG (inc_prob);
1173+ log_accept += MY_LOG (1 - inc_prob);
11731174 }
11741175
11751176 // Add parameter prior contribution
@@ -1201,7 +1202,7 @@ void update_indicator_differences_metropolis_bgmcompare (
12011202
12021203 // Perform Metropolis-Hastings step
12031204 double U = runif (rng);
1204- if (std::log (U) < log_accept) {
1205+ if (MY_LOG (U) < log_accept) {
12051206 inclusion_indicator (var, var) = proposed_ind;
12061207 main_effects.rows (start, stop).cols (1 , num_groups - 1 ) =
12071208 proposed_main_effects.rows (start, stop).cols (1 , num_groups - 1 );
@@ -1243,11 +1244,11 @@ void update_indicator_differences_metropolis_bgmcompare (
12431244 // Add prior inclusion probability contribution
12441245 double inc_prob = inclusion_probability_difference (var1, var2);
12451246 if (proposed_ind == 1 ) {
1246- log_accept += std::log (inc_prob);
1247- log_accept -= std::log (1 - inc_prob);
1247+ log_accept += MY_LOG (inc_prob);
1248+ log_accept -= MY_LOG (1 - inc_prob);
12481249 } else {
1249- log_accept -= std::log (inc_prob);
1250- log_accept += std::log (1 - inc_prob);
1250+ log_accept -= MY_LOG (inc_prob);
1251+ log_accept += MY_LOG (1 - inc_prob);
12511252 }
12521253
12531254 // Add parameter prior contribution
@@ -1280,7 +1281,7 @@ void update_indicator_differences_metropolis_bgmcompare (
12801281
12811282 // Metropolis-Hastings acceptance step
12821283 double U = runif (rng);
1283- if (std::log (U) < log_accept) {
1284+ if (MY_LOG (U) < log_accept) {
12841285 // Update inclusion inclusion_indicator
12851286 inclusion_indicator (var1, var2) = proposed_ind;
12861287 inclusion_indicator (var2, var1) = proposed_ind;
0 commit comments