static inline A0 sina(const A0& a0) { static const sint_type de = sizeof(sint_type)*8-1; if (is_invalid(a0)) return Nan<A0>(); A0 x = nt2::abs(a0); if (redu_t::replacement_needed(x)) { return redu_t::sin_replacement(a0); } else { A0 xr = Nan<A0>(), xc; int_type n = redu_t::reduce(x, xr, xc); int_type swap_bit = n&One<int_type>(); A0 sign_bit = b_xor(bitofsign(a0), shli(n&Two<int_type>(), de-1)); A0 z = sqr(xr); if (is_eqz(swap_bit)) { z = eval_t::sin_eval(z, xr, xc); } else { z = eval_t::cos_eval(z, xr, xc); } return b_xor(z,sign_bit); } }
static inline A0 sincosa(const A0& a0, A0& c, const regular&) { A0 s; if (is_invalid(a0)) { c = Nan<A0>(); return c; } const A0 x = nt2::abs(a0); static const sint_type de = sizeof(sint_type)*8-1; A0 xr, xc; const int_type n = redu_t::reduce(x, xr, xc); const int_type swap_bit = n&One<int_type>(); const A0 z = sqr(xr); const int_type cos_sign_bit = shli(b_xor(swap_bit, (n&Two<int_type>())>>1), de); const A0 sin_sign_bit = b_xor(bitofsign(a0), shli(n&Two<int_type>(), de-1)); if (is_nez(swap_bit)) { c = eval_t::sin_eval(z, xr, xc); s = eval_t::cos_eval(z, xr, xc); } else { c = eval_t::cos_eval(z, xr, xc); s = eval_t::sin_eval(z, xr, xc); } c = b_xor(c,cos_sign_bit); return b_xor(s,sin_sign_bit); }
static inline void sincosa(const A0& a0, A0& s, A0& c) { if (is_invalid(a0)) { s = c = Nan<A0>(); return; } A0 x = nt2::abs(a0); if (redu_t::replacement_needed(x)) { redu_t::sincos_replacement(a0, s, c); } else { static const sint_type de = sizeof(sint_type)*8-1; A0 xr, xc; int_type n = redu_t::reduce(x, xr, xc); int_type swap_bit = n&One<int_type>(); A0 z = sqr(xr); int_type cos_sign_bit = shli(b_xor(swap_bit, (n&Two<int_type>())>>1), de); A0 sin_sign_bit = b_xor(bitofsign(a0), shli(n&Two<int_type>(), de-1)); if (is_nez(swap_bit)) { c = eval_t::sin_eval(z, xr, xc); s = eval_t::cos_eval(z, xr, xc); } else { c = eval_t::cos_eval(z, xr, xc); s = eval_t::sin_eval(z, xr, xc); } c = b_xor(c,cos_sign_bit); s = b_xor(s,sin_sign_bit); } }
static inline A0 cosa(const A0& a0) { static const sint_type de = sizeof(sint_type)*8-1; // size in bits of the scalar types minus one if (is_invalid(a0)) return Nan<A0>(); //Nan or Inf input A0 x = nt2::abs(a0); if (redu_t::replacement_needed(x)) { return redu_t::cos_replacement(a0); } else { A0 xr = Nan<A0>(), xc; int_type n = redu_t::reduce(x, xr, xc); int_type swap_bit = n&One<int_type>(); int_type sign_bit = shli(b_xor(swap_bit, (n&2)>>1), de); A0 z = sqr(xr); if (is_nez(swap_bit)) { z = eval_t::sin_eval(z, xr, xc); } else { z = eval_t::cos_eval(z, xr, xc); } return b_xor(z,sign_bit); } }
static inline A0_n asin(const A0_n a0_n) { const A0 a0 = { a0_n }; A0 sign, x; x = nt2::abs(a0); sign = bitofsign(a0); const bA0 x_smaller_1e_4 = lt(x, single_constant<A0, 0x38d1b717>()); //1.0e-4f; const bA0 x_larger_05 = gt(x, Half<A0>()); const bA0 x_else = logical_or(x_smaller_1e_4, x_larger_05); A0 a = if_else_zero(x_smaller_1e_4, x); const A0 b = if_else_zero(x_larger_05, Half<A0>()*oneminus(x)); A0 z = b_or(b_or(if_zero_else(x_else, sqr(x)), a), b); x = if_zero_else(x_else, x); a = if_else_zero(x_larger_05, sqrt(z)); x = b_or(a, x); A0 z1 = madd(z, single_constant<A0, 0x3d2cb352>(), single_constant<A0, 0x3cc617e3>()); z1 = madd(z1, z, single_constant<A0, 0x3d3a3ec7>()); z1 = madd(z1, z, single_constant<A0, 0x3d9980f6>()); z1 = madd(z1, z, single_constant<A0, 0x3e2aaae4>()); z1 = madd(z1, z*x, x); z = select(x_smaller_1e_4, z, z1); z1 = z+z; z1 = Pio_2<A0>()-z1; z = select(x_larger_05, z1, z); return b_xor(z, sign); }
static inline A0 asin(const A0& a0) { A0 sign, x; // bf::tie(sign, x) = sign_and_abs(a0); x = abs(a0); sign = bitofsign(a0); A0 x_smaller_1e_4 = lt(x, single_constant<A0, 0x38d1b717>()); //1.0e-4f; A0 x_larger_05 = gt(x, Half<A0>()); A0 x_else = b_or(x_smaller_1e_4, x_larger_05); A0 a = b_and(x, x_smaller_1e_4); A0 b = b_and(Half<A0>()*oneminus(x), x_larger_05); A0 z = b_or(b_or(b_notand(x_else, sqr(x)), a), b); x = b_notand(x_else, x); a = b_and(sqrt(z), x_larger_05); x = b_or(a, x); A0 z1 = madd(z, single_constant<A0, 0x3d2cb352>(), single_constant<A0, 0x3cc617e3>()); z1 = madd(z1, z, single_constant<A0, 0x3d3a3ec7>()); z1 = madd(z1, z, single_constant<A0, 0x3d9980f6>()); z1 = madd(z1, z, single_constant<A0, 0x3e2aaae4>()); z1 = madd(z1, z*x, x); z = select(x_smaller_1e_4, z, z1); z1 = z+z; z1 = Pio_2<A0>()-z1; z = select(x_larger_05, z1, z); return b_xor(z, sign); }
static inline A0 asin(const A0& a0) { A0 sign, x, z; // bf::tie(sign, x) = sign_and_abs(a0); x = nt2::abs(a0); sign = bitofsign(a0); if ((x < single_constant<A0,0x38d1b717>())) return a0; if ((x > One<A0>())) return Nan<A0>(); bool bx_larger_05 = (x > Half<A0>()); if (bx_larger_05) { z = Half<A0>()*oneminus(x); x = sqrt(z); } else { z = sqr(x); } A0 z1 = madd(z, single_constant<A0,0x3d2cb352>(), single_constant<A0,0x3cc617e3>()); z1 = madd(z1, z, single_constant<A0,0x3d3a3ec7>()); z1 = madd(z1, z, single_constant<A0,0x3d9980f6>()); z1 = madd(z1, z, single_constant<A0,0x3e2aaae4>()); z1 = madd(z1, z*x, x); if(bx_larger_05) { z1 = z1+z1; z1 = Pio_2<A0>()-z1; } return b_xor(z1, sign); }
static inline A0_n asin(const A0_n a0_n) { const A0 a0 = { a0_n }; typedef typename meta::scalar_of<A0>::type sA0; A0 x = nt2::abs(a0); const A0 pio4 = Pio_4<A0>(); const bA0 small= lt(x, Sqrteps<A0>()); const A0 morebits = double_constant<A0, 0xbc91a62633145c07ll>(); const A0 ct1 = double_constant<A0, 0x3fe4000000000000ll>(); A0 zz1 = oneminus(x); const A0 vp = zz1*horner< NT2_HORNER_COEFF_T(sA0, 5, (0x3f684fc3988e9f08ll, 0xbfe2079259f9290fll, 0x401bdff5baf33e6all, 0xc03991aaac01ab68ll, 0x403c896240f3081dll) )>(zz1)/ horner< NT2_HORNER_COEFF_T(sA0, 5, (0x3ff0000000000000ll, 0xc035f2a2b6bf5d8cll, 0x40626219af6a7f42ll, 0xc077fe08959063eell, 0x40756709b0b644bell) )>(zz1); zz1 = sqrt(zz1+zz1); A0 z = pio4-zz1; zz1 = fma(zz1, vp, morebits); z = z-zz1; zz1 = z+pio4; A0 zz2 = sqr(a0); z = zz2*horner< NT2_HORNER_COEFF_T(sA0, 6, (0x3f716b9b0bd48ad3ll, 0xbfe34341333e5c16ll, 0x4015c74b178a2dd9ll, 0xc0304331de27907bll, 0x40339007da779259ll, 0xc020656c06ceafd5ll) )>(zz2)/ horner< NT2_HORNER_COEFF_T(sA0, 6, (0x3ff0000000000000ll, 0xc02d7b590b5e0eabll, 0x40519fc025fe9054ll, 0xc06265bb6d3576d7ll, 0x4061705684ffbf9dll, 0xc04898220a3607acll) )>(zz2); zz2 = x*z+x; return if_nan_else( gt(x, One<A0>()) , b_xor ( select( small , x , select( gt(x, ct1) , zz1 , zz2 ) ) , bitofsign(a0) ) ); }
static inline A0 cota(const A0& a0, const regular&) { if (nt2::is_invalid(a0)||redu_t::cot_invalid(a0)) return Nan<A0>(); const A0 x = nt2::abs(a0); const A0 bos = bitofsign(a0); if (!a0) return b_or(Inf<A0>(), bos); A0 xr = Nan<A0>(), xc; const int_type n = redu_t::reduce(x, xr, xc); const A0 y = eval_t::cot_eval(xr, xc, 1-((n&1)<<1)); return b_xor(y, bos); }
static inline A0 tana(const A0& a0, const regular&) { if (is_invalid(a0)||redu_t::tan_invalid(a0)) return Nan<A0>(); if (is_eqz(a0)) return a0; const A0 x = nt2::abs(a0); A0 xr = Nan<A0>(), xc, y; const int_type n = redu_t::reduce(x, xr, xc); y = eval_t::tan_eval(xr, xc, 1-((n&1)<<1)); // 1 -- n even //-1 -- n odd return b_xor(y, bitofsign(a0)); }
static inline A0 asin(const A0& a0) { A0 x = nt2::abs(a0); if ((x > One<A0>())) return Nan<A0>(); if ((x < Sqrteps<A0>())) return a0; A0 zz; if((x > double_constant<double,0x3fe4000000000000ll> ())) //0.625; { zz = oneminus(x); const A0 vp = zz*horner< NT2_HORNER_COEFF_T(stype, 5, (0x3f684fc3988e9f08ll, 0xbfe2079259f9290fll, 0x401bdff5baf33e6all, 0xc03991aaac01ab68ll, 0x403c896240f3081dll) )>(zz)/ horner< NT2_HORNER_COEFF_T(stype, 5, (0x3ff0000000000000ll, 0xc035f2a2b6bf5d8cll, 0x40626219af6a7f42ll, 0xc077fe08959063eell, 0x40756709b0b644bell) )>(zz); zz = sqrt(zz+zz); A0 z = Pio_4<A0>()-zz; zz = madd(zz, vp, double_constant<double,0xbc91a62633145c07ll>()); z = z-zz; zz = z+Pio_4<A0>(); } else { zz = sqr(x); A0 z = zz*horner< NT2_HORNER_COEFF_T(stype, 6, (0x3f716b9b0bd48ad3ll, 0xbfe34341333e5c16ll, 0x4015c74b178a2dd9ll, 0xc0304331de27907bll, 0x40339007da779259ll, 0xc020656c06ceafd5ll) )>(zz)/ horner< NT2_HORNER_COEFF_T(stype, 6, (0x3ff0000000000000ll, 0xc02d7b590b5e0eabll, 0x40519fc025fe9054ll, 0xc06265bb6d3576d7ll, 0x4061705684ffbf9dll, 0xc04898220a3607acll) )>(zz); zz = x*z+x; } return b_xor(bitofsign(a0), zz); }
void emit(int tt, unsigned int tval) { if(tt == UNKNOWN) error("Unknown token"); else if(tt == DONE) error("Unexpected end of expression"); else if(tt == NONE) error("No token in expression"); else if(tt == EOS) error("End of string in expression"); else if(tt == NUM) push(tt, tval); else if(tt == STRING) { if(tval <= 0) error("Unrecognized expression"); else push(tt, tval); } else { /* apply operator */ switch(tt) { case 1: l_orr(); break; case 2: l_and(); break; case 3: b_orr(); break; case 4: b_xor(); break; case 5: b_and(); break; case 6: l_equ(); break; case 7: l_neq(); break; case 8: l_leq(); break; case 9: l_geq(); break; case 10: l_ltt(); break; case 11: l_gtt(); break; case 12: lshift(); break; case 13: l_rshift(); break; case 14: rshift(); break; case 15: plus(); break; case 16: minus(); break; case 17: multiply(); break; case 18: divide(); break; case 19: modulo(); break; case 20: l_not(); break; case 21: b_not(); break; case 22: unaryminus(); break; case 23: unaryplus(); break; default: error("Unknown operator"); } } }
static inline A0 sina(const A0& a0, const regular&) { static const sint_type de = static_cast<sint_type>(sizeof(sint_type)*8-1); if (is_invalid(a0)) return Nan<A0>(); const A0 x = nt2::abs(a0); A0 xr = nt2::Nan<A0>(); const int_type n = redu_t::reduce(x, xr); const int_type swap_bit = n&nt2::One<int_type>(); const A0 sign_bit = nt2::bitwise_xor(nt2::bitofsign(a0), nt2::shli(n&nt2::Two<int_type>(), de-1)); A0 z = nt2::sqr(xr); if (swap_bit) z = eval_t::cos_eval(z); else z = eval_t::sin_eval(z, xr); return b_xor(z,sign_bit); }
static inline A0 cosa(const A0& a0, const regular&) { static const sint_type de = static_cast<sint_type>(sizeof(sint_type)*8-1); // size in bits of the scalar types minus one if (nt2::is_invalid(a0)) return nt2::Nan<A0>(); //Nan or Inf input const A0 x = nt2::abs(a0); A0 xr = nt2::Nan<A0>(); const int_type n = redu_t::reduce(x, xr); const int_type swap_bit = n&nt2::One<int_type>(); const int_type sign_bit = shli(nt2::bitwise_xor(swap_bit, (n&2)>>1), de); A0 z = nt2::sqr(xr); if (swap_bit) z = eval_t::sin_eval(z, xr); else z = eval_t::cos_eval(z); return b_xor(z,sign_bit); }
static inline A0 cota(const A0& a0) { if (nt2::is_invalid(a0)||redu_t::cot_invalid(a0)) return Nan<A0>(); A0 x = nt2::abs(a0); if (redu_t::replacement_needed(x)) { return redu_t::cot_replacement(a0); } else { const A0 bos = bitofsign(a0); if (!a0) return b_or(Inf<A0>(), bos); A0 xr = Nan<A0>(), xc, y; int_type n = redu_t::reduce(x, xr, xc); y = eval_t::cot_eval(xr, xc, 1-((n&1)<<1)); return b_xor(y, bos); } }
static inline A0 atan(const A0& a0) { A0 x, sign; x = nt2::abs(a0); sign = bitofsign(a0); // bf::tie(sign, x) = sign_and_abs(a0); const A0 flag1 = lt(x, single_constant<A0, 0x401a827a>()); //tan3pio8); const A0 flag2 = b_and(ge(x, single_constant<A0, 0x3ed413cd>()), flag1); A0 yy = b_notand(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>()); A0 z2 = madd(z, single_constant<A0, 0x3e4c925f>(),single_constant<A0, 0xbeaaaa2a>()); z1 = madd(z1, sqr(z), z2); yy = add(yy, madd(xx, mul( z1, z), xx)); return b_xor(yy, sign); }
static inline A0 tana(const A0& a0) { if (is_invalid(a0)||redu_t::tan_invalid(a0)) return Nan<A0>(); if (is_eqz(a0)) return a0; A0 x = nt2::abs(a0); if (redu_t::replacement_needed(x)) { return redu_t::tan_replacement(a0); } else { A0 xr = Nan<A0>(), xc, y; int_type n = redu_t::reduce(x, xr, xc); y = eval_t::tan_eval(xr, xc, 1-((n&1)<<1)); // 1 -- n even //-1 -- n odd return b_xor(y, bitofsign(a0)); } }
void SeniorVMHandle::b_add_b(long _register1,long _register2) { d_push_imm(0); pop(T_TMP_REGISTER3); b_and(_register1,_register2); pop(T_INVALID); b_xor(_register1,_register2); pop(T_INVALID); pop(T_TMP_R8_1H); b_push_imm(1<<7); pop(T_TMP_R8_1L); pop(T_TMP_R8_2H); b_and(T_TMP_R8_2H,T_TMP_R8_1L); pop(T_INVALID); pop(T_TMP_R8_3L); d_shr(T_TMP_REGISTER3,7); pop(T_INVALID); pop(T_TMP_REGISTER3); d_or(T_TMP_REGISTER3,T_TMP_EFLAG); pop(T_INVALID); pop(T_TMP_EFLAG); d_push_imm(0); pop(T_TMP_REGISTER3); b_push_imm(1<<3); pop(T_TMP_R8_3H); b_and(T_TMP_R8_3H,T_TMP_R8_2H); pop(T_INVALID); pop(T_TMP_R8_2L); b_shl(T_TMP_R8_2L,1); pop(T_INVALID); pop(T_TMP_R8_3L); d_or(T_TMP_REGISTER3,T_TMP_EFLAG); pop(T_INVALID); pop(T_TMP_EFLAG); b_shl(T_TMP_R8_2H,1); pop(T_INVALID); pop(T_TMP_R8_2H); }
static inline A0 atan(const A0& a0) { if (is_eqz(a0)) return a0; if (is_inf(a0)) return Pio_2<A0>()*sign(a0); A0 y; A0 x = nt2::abs(a0); A0 sgn = bitofsign(a0); if( x >single_constant<float,0x401a827a>())//2.414213562373095 ) /* tan 3pi/8 */ { y = Pio_2<A0>(); x = -rec(x); } else if( x > single_constant<float,0x3ed413cd>()) //0.4142135623730950f ) /* tan pi/8 */ { y = Pio_4<A0>(); x = minusone(x)/oneplus(x); } else y = 0.0; A0 z = sqr(x); A0 z1 = madd(z, single_constant<A0,0x3da4f0d1>(),single_constant<A0,0xbe0e1b85>()); A0 z2 = madd(z, single_constant<A0,0x3e4c925f>(),single_constant<A0,0xbeaaaa2a>()); z1 = madd(z1, sqr(z), z2); y = add(y, madd(x, mul( z1, z), x)); // y += // ((( 8.05374449538e-2 * z // - 1.38776856032E-1) * z // + 1.99777106478E-1) * z // - 3.33329491539E-1) * z * x // + x; return b_xor(sgn, y ); }
static inline A0 atan(const A0& a0) { typedef typename meta::scalar_of<A0>::type sA0; static const A0 tan3pio8 = double_constant<A0, 0x4003504f333f9de6ll>(); static const A0 Twothird = double_constant<A0, 0x3fe51eb851eb851fll>(); static const A0 tanpio8 = double_constant<A0, 0x3fda827999fcef31ll>(); A0 x = abs(a0); const A0 flag1 = lt(x, double_constant<A0, 0x4003504f333f9de6ll>()); //tan3pio8 const A0 flag2 = b_and(ge(x, double_constant<A0, 0x3fda827999fcef31ll>()), flag1); //tanpio8 A0 yy = b_notand(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); // static const A0 morebits = double_constant<A0, 0x3c91a62633145c07ll>(); z = seladd(flag2, z, mul(Half<A0>(), double_constant<A0, 0x3c91a62633145c07ll>())); z = z+b_notand(flag1, double_constant<A0, 0x3c91a62633145c07ll>()); yy = yy + z; return b_xor(yy, bitofsign(a0)); }
namespace nt2 { namespace ext { template<class Dummy> struct call<tag::average_(tag::simd_<tag::arithmetic_, tag::sse_>, tag::simd_<tag::arithmetic_, tag::sse_>), tag::cpu_, Dummy> : callable { template<class Sig> struct result; template<class This,class A0> struct result<This(A0,A0)> : meta::strip<A0>{};// NT2_FUNCTOR_CALL(2) { return b_and(a0, a1)+shrai(b_xor(a0, a1),1); } }; } } ///////////////////////////////////////////////////////////////////////////// // Implementation when type A0 is uint16_t ///////////////////////////////////////////////////////////////////////////// NT2_REGISTER_DISPATCH(tag::average_, tag::cpu_, (A0), ((simd_<uint16_<A0>,tag::sse_>)) ((simd_<uint16_<A0>,tag::sse_>)) ); namespace nt2 { namespace ext {
static inline A0_n atan(const A0_n a0_n) { const A0 a0 = {a0_n}; const A0 x = {kernel_atan(a0)}; return b_xor(x, bitofsign(a0)); }
void cover_sc_bit() { sc_bit bdef; sc_bit bf(false); sc_bit bt(true); sc_bit b0(0); sc_bit b1(1); try { sc_bit foo(2); } catch (sc_report) { cout << "Caught exception for sc_bit(2)\n"; } sc_bit bc0('0'); sc_bit bc1('1'); try { sc_bit foo('2'); } catch (sc_report) { cout << "Caught exception for sc_bit('2')\n"; } sc_bit blc0(sc_logic('0')); sc_bit blc1(sc_logic('1')); sc_bit blcx(sc_logic('X')); sc_bit bcop(bt); cout << bdef << bf << bt << b0 << b1 << bc0 << bc1 << blc0 << blc1 << blcx << bcop << endl; sc_bit b; b = bt; sc_assert(b); b = 0; sc_assert(!b); b = true; sc_assert(b.to_bool()); b = '0'; sc_assert(!b.to_bool()); b = sc_logic('1'); sc_assert(b.to_char() == '1'); b = bf; sc_assert(~b); b |= bt; sc_assert(b); b &= bf; sc_assert(!b); b |= 1; sc_assert(b); b &= 0; sc_assert(!b); b |= '1'; sc_assert(b); b &= '0'; sc_assert(!b); b |= true; sc_assert(b); b &= false; sc_assert(!b); b ^= bt; sc_assert(b); b ^= 1; sc_assert(!b); b ^= '1'; sc_assert(b); b ^= true; sc_assert(!b); sc_assert(b == bf); sc_assert(b == 0); sc_assert(b == '0'); sc_assert(b == false); b = 1; sc_assert(b == bt); sc_assert(b == 1); sc_assert(b == '1'); sc_assert(b == true); sc_assert(1 == b); sc_assert('1' == b); sc_assert(true == b); sc_assert(equal(b, bt)); sc_assert(equal(b, 1)); sc_assert(equal(b, '1')); sc_assert(equal(b, true)); sc_assert(equal(1, b)); sc_assert(equal('1', b)); sc_assert(equal(true, b)); b = 0; sc_assert(b != bt); sc_assert(b != 1); sc_assert(b != '1'); sc_assert(b != true); sc_assert(1 != b); sc_assert('1' != b); sc_assert(true != b); sc_assert(not_equal(b, bt)); sc_assert(not_equal(b, 1)); sc_assert(not_equal(b, '1')); sc_assert(not_equal(b, true)); sc_assert(not_equal(1, b)); sc_assert(not_equal('1', b)); sc_assert(not_equal(true, b)); // the following assertion is incorrect, because the b_not() method // is destructive, i.e., it implements something like b ~= void. /// sc_assert(b == b_not(b.b_not())); b.b_not(); sc_assert(b); sc_bit bx; b_not(bx, b0); sc_assert(bx); b_not(bx, b1); sc_assert(!bx); cout << (b0|b0) << (b0|b1) << (b1|b0) << (b1|b1) << endl; cout << (b0&b0) << (b0&b1) << (b1&b0) << (b1&b1) << endl; cout << (b0^b0) << (b0^b1) << (b1^b0) << (b1^b1) << endl; cout << (b0|0) << (b0|1) << (b1|0) << (b1|1) << endl; cout << (b0&0) << (b0&1) << (b1&0) << (b1&1) << endl; cout << (b0^0) << (b0^1) << (b1^0) << (b1^1) << endl; cout << (b0|'0') << (b0|'1') << (b1|'0') << (b1|'1') << endl; cout << (b0&'0') << (b0&'1') << (b1&'0') << (b1&'1') << endl; cout << (b0^'0') << (b0^'1') << (b1^'0') << (b1^'1') << endl; cout << (b0|true) << (b0|false) << (b1|true) << (b1|false) << endl; cout << (b0&true) << (b0&false) << (b1&true) << (b1&false) << endl; cout << (b0^true) << (b0^false) << (b1^true) << (b1^false) << endl; cout << (0|b0) << (0|b1) << (1|b0) << (1|b1) << endl; cout << (0&b0) << (0&b1) << (1&b0) << (1&b1) << endl; cout << (0^b0) << (0^b1) << (1^b0) << (1^b1) << endl; cout << ('0'|b0) << ('0'|b1) << ('1'|b0) << ('1'|b1) << endl; cout << ('0'&b0) << ('0'&b1) << ('1'&b0) << ('1'&b1) << endl; cout << ('0'^b0) << ('0'^b1) << ('1'^b0) << ('1'^b1) << endl; cout << (false|b0) << (false|b1) << (true|b0) << (true|b1) << endl; cout << (false&b0) << (false&b1) << (true&b0) << (true&b1) << endl; cout << (false^b0) << (false^b1) << (true^b0) << (true^b1) << endl; cout << b_or(b0,b0) << b_or(b0,b1) << b_or(b1,b0) << b_or(b1,b1) << endl; cout << b_and(b0,b0) << b_and(b0,b1) << b_and(b1,b0) << b_and(b1,b1) << endl; cout << b_xor(b0,b0) << b_xor(b0,b1) << b_xor(b1,b0) << b_xor(b1,b1) << endl; cout << b_or(b0,0) << b_or(b0,1) << b_or(b1,0) << b_or(b1,1) << endl; cout << b_and(b0,0) << b_and(b0,1) << b_and(b1,0) << b_and(b1,1) << endl; cout << b_xor(b0,0) << b_xor(b0,1) << b_xor(b1,0) << b_xor(b1,1) << endl; cout << b_or(b0,'0') << b_or(b0,'1') << b_or(b1,'0') << b_or(b1,'1') << endl; cout << b_and(b0,'0') << b_and(b0,'1') << b_and(b1,'0') << b_and(b1,'1') << endl; cout << b_xor(b0,'0') << b_xor(b0,'1') << b_xor(b1,'0') << b_xor(b1,'1') << endl; cout << b_or(b0,false) << b_or(b0,true) << b_or(b1,false) << b_or(b1,true) << endl; cout << b_and(b0,false) << b_and(b0,true) << b_and(b1,false) << b_and(b1,true) << endl; cout << b_xor(b0,false) << b_xor(b0,true) << b_xor(b1,false) << b_xor(b1,true) << endl; cout << b_or(0,b0) << b_or(0,b1) << b_or(1,b0) << b_or(1,b1) << endl; cout << b_and(0,b0) << b_and(0,b1) << b_and(1,b0) << b_and(1,b1) << endl; cout << b_xor(0,b0) << b_xor(0,b1) << b_xor(1,b0) << b_xor(1,b1) << endl; cout << b_or('0',b0) << b_or('0',b1) << b_or('1',b0) << b_or('1',b1) << endl; cout << b_and('0',b0) << b_and('0',b1) << b_and('1',b0) << b_and('1',b1) << endl; cout << b_xor('0',b0) << b_xor('0',b1) << b_xor('1',b0) << b_xor('1',b1) << endl; cout << b_or(false,b0) << b_or(false,b1) << b_or(true,b0) << b_or(true,b1) << endl; cout << b_and(false,b0) << b_and(false,b1) << b_and(true,b0) << b_and(true,b1) << endl; cout << b_xor(false,b0) << b_xor(false,b1) << b_xor(true,b0) << b_xor(true,b1) << endl; b_or(b, b0, b1); sc_assert(b); b_and(b, b0, b1); sc_assert(!b); b_xor(b, b0, b1); sc_assert(b); }
// Overloads implementation //////////////////////////////////////////////////////////////////////////////// NT2_REGISTER_DISPATCH ( tag::complement_, tag::cpu_, (A0)(X) , ((simd_<arithmetic_<A0>,X>)) ); namespace nt2 { namespace ext { ////////////////////////////////////////////////////////////////////////////// // Implement ~ using xor ////////////////////////////////////////////////////////////////////////////// template<class X, class Dummy> struct call< tag::complement_( tag::simd_<tag::arithmetic_,X> ) , tag::cpu_, Dummy > : callable { template<class Sig> struct result; template<class This,class A0> struct result<This(A0)> : meta::strip<A0> {}; NT2_FUNCTOR_CALL(1) { A0 that = { b_xor(True<A0>(), a0) }; return that; } }; } } #endif
static inline A0 atan(const A0& a0) { A0 x = kernel_atan(a0); return b_xor(x, bitofsign(a0)); }