Example #1
0
 static inline A0_n kernel_atan(const A0_n a0_n)
 {
   typedef typename meta::scalar_of<A0>::type sA0;
   const A0 tan3pio8  = double_constant<A0, 0x4003504f333f9de6ll>();
   const A0 tanpio8 = double_constant<A0, 0x3fda827999fcef31ll>();
   const A0 a0 = {a0_n};
   const A0 x =  nt2::abs(a0);
   const bA0 flag1 = lt(x,  tan3pio8);             
   const bA0 flag2 = logical_and(ge(x, tanpio8), flag1); 
   A0 yy = if_zero_else(flag1, Pio_2<A0>());
   yy = select(flag2, Pio_4<A0>(), yy);
   A0 xx = select(flag1, x, -rec(x));
   xx = select(flag2, minusone(x)/oneplus(x),xx);
   A0 z = sqr(xx);
   z = z*horner< NT2_HORNER_COEFF_T(sA0, 5,
                                (0xbfec007fa1f72594ll,
                                 0xc03028545b6b807all,
                                 0xc052c08c36880273ll,
                                 0xc05eb8bf2d05ba25ll,
                                 0xc0503669fd28ec8ell)
                                )>(z)/
       horner< NT2_HORNER_COEFF_T(sA0, 6,
                                (0x3ff0000000000000ll,
                                 0x4038dbc45b14603cll,
                                 0x4064a0dd43b8fa25ll,
                                 0x407b0e18d2e2be3bll,
                                 0x407e563f13b049eall,
                                 0x4068519efbbd62ecll)
                                )>(z);
   z = fma(xx, z, xx);
   const A0 morebits = double_constant<A0, 0x3c91a62633145c07ll>();
   z = seladd(flag2, z, mul(Half<A0>(), morebits));
   z = z+if_zero_else(flag1, morebits);
   return yy + z;
 }
Example #2
0
        static inline A0_n kernel_atan(const A0_n a0_n)
        {
          const A0 a0 = {a0_n};
          const A0 x = nt2::abs(a0);

          //here x is positive
          const bA0 flag1 = lt(x, single_constant<A0, 0x401a827a>()); //tan3pio8);
          const bA0 flag2 = logical_and(ge(x, single_constant<A0, 0x3ed413cd>()), flag1);
          A0 yy =  if_zero_else(flag1, Pio_2<A0>());
          yy =  select(flag2, Pio_4<A0>(), yy);
          A0 xx =   select(flag1, x, -rec(x));
          xx =  select(flag2, (minusone(x)/oneplus(x)),xx);
          const A0 z = sqr(xx);
          A0 z1 = madd(z,  single_constant<A0, 0x3da4f0d1>(),single_constant<A0, 0xbe0e1b85>());
          const A0 z2 = madd(z,  single_constant<A0, 0x3e4c925f>(),single_constant<A0, 0xbeaaaa2a>());
          z1 = madd(z1, sqr(z), z2);
          return  add(yy, madd(xx, mul( z1, z), xx));
        }
Example #3
0
void Parser::executeAction(int production) try {
    if (d_token__ != _UNDETERMINED_)
        pushToken__(d_token__); // save an already available token

    // $insert defaultactionreturn
    // save default non-nested block $$
    if (int size = s_productionInfo[production].d_size)
        d_val__ = d_vsp__[1 - size];

    switch (production) {
        // $insert actioncases

        case 1:
#line 43 "parser.yy"
        {
            d_val__.get<Tag__::basic>() = d_vsp__[0].data<Tag__::basic>();
            res = d_val__.get<Tag__::basic>();
        } break;

        case 2:
#line 51 "parser.yy"
        {
            d_val__.get<Tag__::basic>() = add(d_vsp__[-2].data<Tag__::basic>(),
                                              d_vsp__[0].data<Tag__::basic>());
        } break;

        case 3:
#line 54 "parser.yy"
        {
            d_val__.get<Tag__::basic>() = sub(d_vsp__[-2].data<Tag__::basic>(),
                                              d_vsp__[0].data<Tag__::basic>());
        } break;

        case 4:
#line 57 "parser.yy"
        {
            d_val__.get<Tag__::basic>() = mul(d_vsp__[-2].data<Tag__::basic>(),
                                              d_vsp__[0].data<Tag__::basic>());
        } break;

        case 5:
#line 60 "parser.yy"
        {
            d_val__.get<Tag__::basic>() = div(d_vsp__[-2].data<Tag__::basic>(),
                                              d_vsp__[0].data<Tag__::basic>());
        } break;

        case 6:
#line 63 "parser.yy"
        {
            auto tup = parse_implicit_mul(d_vsp__[-2].data<Tag__::string>());
            if (neq(*std::get<1>(tup), *one)) {
                d_val__.get<Tag__::basic>() = mul(
                    std::get<0>(tup),
                    pow(std::get<1>(tup), d_vsp__[0].data<Tag__::basic>()));
            } else {
                d_val__.get<Tag__::basic>()
                    = pow(std::get<0>(tup), d_vsp__[0].data<Tag__::basic>());
            }
        } break;

        case 7:
#line 73 "parser.yy"
        {
            d_val__.get<Tag__::basic>() = pow(d_vsp__[-2].data<Tag__::basic>(),
                                              d_vsp__[0].data<Tag__::basic>());
        } break;

        case 8:
#line 76 "parser.yy"
        {
            d_val__.get<Tag__::basic>() = rcp_static_cast<const Basic>(
                Lt(d_vsp__[-2].data<Tag__::basic>(),
                   d_vsp__[0].data<Tag__::basic>()));
        } break;

        case 9:
#line 79 "parser.yy"
        {
            d_val__.get<Tag__::basic>() = rcp_static_cast<const Basic>(
                Gt(d_vsp__[-2].data<Tag__::basic>(),
                   d_vsp__[0].data<Tag__::basic>()));
        } break;

        case 10:
#line 82 "parser.yy"
        {
            d_val__.get<Tag__::basic>() = rcp_static_cast<const Basic>(
                Le(d_vsp__[-2].data<Tag__::basic>(),
                   d_vsp__[0].data<Tag__::basic>()));
        } break;

        case 11:
#line 85 "parser.yy"
        {
            d_val__.get<Tag__::basic>() = rcp_static_cast<const Basic>(
                Ge(d_vsp__[-2].data<Tag__::basic>(),
                   d_vsp__[0].data<Tag__::basic>()));
        } break;

        case 12:
#line 88 "parser.yy"
        {
            d_val__.get<Tag__::basic>() = rcp_static_cast<const Basic>(
                Eq(d_vsp__[-2].data<Tag__::basic>(),
                   d_vsp__[0].data<Tag__::basic>()));
        } break;

        case 13:
#line 91 "parser.yy"
        {
            set_boolean s;
            s.insert(rcp_static_cast<const Boolean>(
                d_vsp__[-2].data<Tag__::basic>()));
            s.insert(rcp_static_cast<const Boolean>(
                d_vsp__[0].data<Tag__::basic>()));
            d_val__.get<Tag__::basic>()
                = rcp_static_cast<const Basic>(logical_or(s));
        } break;

        case 14:
#line 99 "parser.yy"
        {
            set_boolean s;
            s.insert(rcp_static_cast<const Boolean>(
                d_vsp__[-2].data<Tag__::basic>()));
            s.insert(rcp_static_cast<const Boolean>(
                d_vsp__[0].data<Tag__::basic>()));
            d_val__.get<Tag__::basic>()
                = rcp_static_cast<const Basic>(logical_and(s));
        } break;

        case 15:
#line 107 "parser.yy"
        {
            vec_boolean s;
            s.push_back(rcp_static_cast<const Boolean>(
                d_vsp__[-2].data<Tag__::basic>()));
            s.push_back(rcp_static_cast<const Boolean>(
                d_vsp__[0].data<Tag__::basic>()));
            d_val__.get<Tag__::basic>()
                = rcp_static_cast<const Basic>(logical_xor(s));
        } break;

        case 16:
#line 115 "parser.yy"
        {
            d_val__.get<Tag__::basic>() = d_vsp__[-1].data<Tag__::basic>();
        } break;

        case 17:
#line 118 "parser.yy"
        {
            d_val__.get<Tag__::basic>() = neg(d_vsp__[0].data<Tag__::basic>());
        } break;

        case 18:
#line 121 "parser.yy"
        {
            d_val__.get<Tag__::basic>() = rcp_static_cast<const Basic>(
                logical_not(rcp_static_cast<const Boolean>(
                    d_vsp__[0].data<Tag__::basic>())));
        } break;

        case 19:
#line 124 "parser.yy"
        {
            d_val__.get<Tag__::basic>()
                = rcp_static_cast<const Basic>(d_vsp__[0].data<Tag__::basic>());
        } break;

        case 20:
#line 129 "parser.yy"
        {
            d_val__.get<Tag__::basic>()
                = parse_identifier(d_vsp__[0].data<Tag__::string>());
        } break;

        case 21:
#line 134 "parser.yy"
        {
            auto tup = parse_implicit_mul(d_vsp__[0].data<Tag__::string>());
            d_val__.get<Tag__::basic>()
                = mul(std::get<0>(tup), std::get<1>(tup));
        } break;

        case 22:
#line 140 "parser.yy"
        {
            d_val__.get<Tag__::basic>()
                = parse_numeric(d_vsp__[0].data<Tag__::string>());
        } break;

        case 23:
#line 145 "parser.yy"
        {
            d_val__.get<Tag__::basic>() = d_vsp__[0].data<Tag__::basic>();
        } break;

        case 24:
#line 152 "parser.yy"
        {
            d_val__.get<Tag__::basic>()
                = functionify(d_vsp__[-3].data<Tag__::string>(),
                              d_vsp__[-1].data<Tag__::basic_vec>());
        } break;

        case 25:
#line 160 "parser.yy"
        {
            d_val__.get<Tag__::basic_vec>()
                = d_vsp__[-2].data<Tag__::basic_vec>();
            d_val__.get<Tag__::basic_vec>().push_back(
                d_vsp__[0].data<Tag__::basic>());
        } break;

        case 26:
#line 166 "parser.yy"
        {
            d_val__.get<Tag__::basic_vec>()
                = vec_basic(1, d_vsp__[0].data<Tag__::basic>());
        } break;
    }
} catch (std::exception const &exc) {
    exceptionHandler__(exc);
}
Example #4
0
File: main.cpp Project: CCJY/coliru
 S operator ()(const LExpr & l, const RExpr & r) const
 {
   const S & temp = evaluate(l);
   return temp? logical_and(temp, evaluate(r)) : temp;
 }
Example #5
0
bool logical_nand(unsigned short array_size, bool* boolean_list) {
  return NOT logical_and(array_size, boolean_list);
}