void SliceSampler::find_limits(){ if(unimodal){ while(phi > pstar) doubling(true); while(plo > pstar) doubling(false); }else{ while(phi > pstar || plo > pstar){ double tmp = runif_mt(rng(), -1,1); doubling(tmp>0);}}}
void SliceSampler::find_limits() { if (unimodal_) { // If the posterior is unimodal then expand each endpoint until it // is out of the slice. while (logphi_ > log_p_slice_) doubling(true); while (logplo_ > log_p_slice_) doubling(false); } else { // If the posterior is not known to be unimodal, then randomly // pick an endpoint and double it until both ends are out of the // slice. This will sometimes result in unnecessary doubling, // but this algorithm has the right stationary distribution // (Neal 2003). while (logphi_ > log_p_slice_ || logplo_ > log_p_slice_) { double tmp = runif_mt(rng(), -1, 1); doubling(tmp > 0); } } }
bool_t add(divisor& x, const divisor& a, const divisor& b) // This subroutine wraps other functions that does the actual // divisor arithmetic. It checks the validity of input divisors // so that other subroutines it calls do not need to do so. { bool_t OK = TRUE; /* Reduce overhead of checking with NDEBUG flag */ assert(OK = OK && a.is_valid_divisor() && b.is_valid_divisor()); if (deg(a.get_upoly()) == genus && deg(b.get_upoly()) == genus) { if (a == - b) { x.set_unit(); OK = TRUE; return OK; } if (a != b && IsOne(GCD(a.get_upoly(), b.get_upoly()))) { // Addition OK = OK && add_diff(x, a, b); return OK; } else if (a == b && IsOne(GCD(a.get_curve().get_h() + 2*a.get_vpoly(), a.get_upoly())) ) { // Doubling // Exclude the case when one point of the divisor is equal to // its opposite OK = OK && doubling(x, a); return OK; } } // Call add_cantor() to handle other cases OK = OK && add_cantor(x, a, b); return OK; }