示例#1
0
 BOOST_FORCEINLINE static void conf_bounds(const A0& a0, A1& a1,
                                           const value_type& alpha )
 {
   typedef nt2::memory::container<tag::table_, value_type, nt2::_2D>  semantic;
   NT2_AS_TERMINAL_IN(semantic, pcov, boost::proto::child_c<3>(a0));
   const In0& p  = boost::proto::child_c<0>(a0);
   const In1& mu = boost::proto::child_c<1>(a0);
   const In2& sigma = boost::proto::child_c<2>(a0);
   auto logx0 = -Sqrt_2<A0>()*erfcinv( nt2::Two<A0>()*p);
   auto xvar =   fma(fma(pcov(2,2), logx0, Two<value_type>()*pcov(1,2)), logx0, pcov(1,1));
   BOOST_ASSERT_MSG(nt2::globalall(nt2::is_nltz(xvar)), "Covariance matrix must be positive");
   value_type normz = -nt2::norminv(alpha*nt2::Half<value_type>());
   auto halfwidth = normz*nt2::sqrt(xvar);
   boost::proto::child_c<0>(a1) = exp(fma(sigma, logx0, mu));
   auto coef = exp(-halfwidth);
   boost::proto::child_c<1>(a1) = boost::proto::child_c<0>(a1)*coef;
   boost::proto::child_c<2>(a1) = boost::proto::child_c<0>(a1)/coef;
 }
示例#2
0
FastDMSamplingBase::value_t FastDMSamplingNormExp::rand(rngeng_t& rngeng)
{
    std::uniform_real_distribution<double> unif_dist;
    while (true) {
        const value_t P = F1inf_ * unif_dist(rngeng);
        if (P <= CF1st_) {
            // short-time series
            const value_t erfcinvP = erfcinv(P / Cf1s_);
            const value_t t = 1 / (2 * a_ * erfcinvP * erfcinvP);
            if (acceptt(t, exp(- 0.5/(a_ * t) - sqrtamu_ + 
                               mu2_ * t / 2) * unif_dist(rngeng),
                        0.5 / t)) 
                return t;
        } else {
            // long-time series
            const value_t t = -log1p(- (P - CF1st_) / Cf1l_ - F1lt_) / fourmu2pi_;
            const value_t pi2t8 = PI * PI * t / 8;
            if (acceptt(t, exp(-pi2t8) * unif_dist(rngeng), pi2t8)) return t;
        }
    }
}
__device__ void double_precision_math_functions() {
    int iX;
    double fX, fY;

    acos(1.0);
    acosh(1.0);
    asin(0.0);
    asinh(0.0);
    atan(0.0);
    atan2(0.0, 1.0);
    atanh(0.0);
    cbrt(0.0);
    ceil(0.0);
    copysign(1.0, -2.0);
    cos(0.0);
    cosh(0.0);
    cospi(0.0);
    cyl_bessel_i0(0.0);
    cyl_bessel_i1(0.0);
    erf(0.0);
    erfc(0.0);
    erfcinv(2.0);
    erfcx(0.0);
    erfinv(1.0);
    exp(0.0);
    exp10(0.0);
    exp2(0.0);
    expm1(0.0);
    fabs(1.0);
    fdim(1.0, 0.0);
    floor(0.0);
    fma(1.0, 2.0, 3.0);
    fmax(0.0, 0.0);
    fmin(0.0, 0.0);
    fmod(0.0, 1.0);
    frexp(0.0, &iX);
    hypot(1.0, 0.0);
    ilogb(1.0);
    isfinite(0.0);
    isinf(0.0);
    isnan(0.0);
    j0(0.0);
    j1(0.0);
    jn(-1.0, 1.0);
    ldexp(0.0, 0);
    lgamma(1.0);
    llrint(0.0);
    llround(0.0);
    log(1.0);
    log10(1.0);
    log1p(-1.0);
    log2(1.0);
    logb(1.0);
    lrint(0.0);
    lround(0.0);
    modf(0.0, &fX);
    nan("1");
    nearbyint(0.0);
    nextafter(0.0, 0.0);
    fX = 1.0;
    norm(1, &fX);
    norm3d(1.0, 0.0, 0.0);
    norm4d(1.0, 0.0, 0.0, 0.0);
    normcdf(0.0);
    normcdfinv(1.0);
    pow(1.0, 0.0);
    rcbrt(1.0);
    remainder(2.0, 1.0);
    remquo(1.0, 2.0, &iX);
    rhypot(0.0, 1.0);
    rint(1.0);
    fX = 1.0;
    rnorm(1, &fX);
    rnorm3d(0.0, 0.0, 1.0);
    rnorm4d(0.0, 0.0, 0.0, 1.0);
    round(0.0);
    rsqrt(1.0);
    scalbln(0.0, 1);
    scalbn(0.0, 1);
    signbit(1.0);
    sin(0.0);
    sincos(0.0, &fX, &fY);
    sincospi(0.0, &fX, &fY);
    sinh(0.0);
    sinpi(0.0);
    sqrt(0.0);
    tan(0.0);
    tanh(0.0);
    tgamma(2.0);
    trunc(0.0);
    y0(1.0);
    y1(1.0);
    yn(1, 1.0);
}