static inline void kernel_log(const A0& a0, A0& dk, A0& hfsq, A0& s, A0& R, A0& f) { typedef typename meta::as_integer<A0, signed>::type int_type; typedef typename meta::scalar_of<A0>::type sA0; A0 x; int_type k; boost::fusion::tie(x, k) = fast_frexp(a0); const int_type x_lt_sqrthf = simd::native_cast<int_type>(gt(Sqrt_2o_2<A0>(), x)); k = k+x_lt_sqrthf; f = minusone(x+b_and(x, x_lt_sqrthf)); dk = tofloat(k); s = f/add(Two<A0>(),f); A0 z = sqr(s); A0 w = sqr(z); A0 t1= w*horner<NT2_HORNER_COEFF_T(sA0, 3, (0x3fc39a09d078c69fll, 0x3fcc71c51d8e78afll, 0x3fd999999997fa04ll) )> (w); A0 t2= z*horner<NT2_HORNER_COEFF_T(sA0, 4, (0x3fc2f112df3e5244ll, 0x3fc7466496cb03dell, 0x3fd2492494229359ll, 0x3fe5555555555593ll) )> (w); R = t2+t1; hfsq = mul(Half<A0>(), sqr(f)); }
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; }
static inline void kernel_log(const A0& a0, A0& dk, A0& hfsq, A0& s, A0& R, A0& f) { A0 x; int_type k(fast_frexp(a0, x)); const int_type x_lt_sqrthf = -isgt(Sqrt_2o_2<A0>(), x); k += x_lt_sqrthf; f = minusone(x+b_and(x, genmask<A0>(x_lt_sqrthf))); dk = tofloat(k); s = f/add(Two<A0>(),f); A0 z = sqr(s); A0 w = sqr(z); A0 t1= w*horner<NT2_HORNER_COEFF_T(A0, 3, (0x3fc39a09d078c69fll, 0x3fcc71c51d8e78afll, 0x3fd999999997fa04ll) )> (w); A0 t2= z*horner<NT2_HORNER_COEFF_T(A0, 4, (0x3fc2f112df3e5244ll, 0x3fc7466496cb03dell, 0x3fd2492494229359ll, 0x3fe5555555555593ll) )> (w); R = t2+t1; hfsq = mul(Half<A0>(), sqr(f)); }
static inline A0 kernel_atan(const A0& a0) { if (is_eqz(a0)) return Zero<A0>(); if (is_inf(a0)) return Pio_2<A0>(); A0 x = nt2::abs(a0); A0 y; if( x >single_constant<A0,0x401a827a>())//2.414213562373095 ) /* tan 3pi/8 */ { y = Pio_2<A0>(); x = -rec(x); } else if( x > single_constant<A0,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); return 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; }
int sted() { for(;;) { clear(); refresh(); wprintw(stdscr, "To add a character type press 1.\nTo view an character type press 4.\nTo save the enemy file press 7.\nTo save the enemy file under a different name press 8.\nTo edit enemies press 9\nTo delete a character type press 0.\n"); input [0] = bie(); if(input[0] == '1') addst(); if(input[0] == '4') viewst(); if(input[0] == '7') savest(filename); if(input[0] == '8') { stufffilename(); savest(filename); } if(input[0] == '9') break; if(input[0] == '.') plusone(3); if(input[0] == ',') minusone(3); if(input[0] == '/') checkone(3); if(input[0] == '0') clearst(); wprintw(stdscr, "Press any key to continue.\n"); bie(); } return 0; }
static inline A0 atan(const A0& a0) { // static const A0 tanpio8 = double_constant<double, 0x3fda827999fcef31ll>(); if (is_eqz(a0)) return a0; if (is_inf(a0)) return Pio_2<A0>()*sign(a0); A0 x = nt2::abs(a0); A0 y; A0 flag = (x > double_constant<double,0x4003504f333f9de6ll>()); if (flag) { y = Pio_2<A0>(); x = -rec(x); } else if ((x <= double_constant<double,0x3fe51eb851eb851fll>())) { y = Zero<A0>(); } else { y = Pio_4<A0>(); flag = Half<A0>(); x = minusone(x)/oneplus(x); } A0 z = sqr(x); z = z*horner< NT2_HORNER_COEFF_T(stype, 5, (0xbfec007fa1f72594ll, 0xc03028545b6b807all, 0xc052c08c36880273ll, 0xc05eb8bf2d05ba25ll, 0xc0503669fd28ec8ell) )>(z)/ horner< NT2_HORNER_COEFF_T(stype, 6, (0x3ff0000000000000ll, 0x4038dbc45b14603cll, 0x4064a0dd43b8fa25ll, 0x407b0e18d2e2be3bll, 0x407e563f13b049eall, 0x4068519efbbd62ecll) )>(z); z = madd(x, z, x); static const A0 morebits = double_constant<double,0x3c91a62633145c07ll>(); z += flag * morebits; y = y + z; if( is_ltz(a0) ) y = -y; return(y); }
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)); }
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); }
int itgred() { for(;;) { clear(); refresh(); wprintw(stdscr, "To add an item group press 1.\nTo view an item group press 4.\nTo save the enemy file press 7.\nTo save the enemy file under a different name press 8.\nTo edit items press 9\nTo delete an item group press 0.\n"); input [0] = bie(); if(input[0] == '1') additgr(); if(input[0] == '4') viewitgr(); if(input[0] == '7') saveen(filename); if(input[0] == '8') { stufffilename(); saveen(filename); } if(input[0] == '9') break; if(input[0] == '.') plusone(6); if(input[0] == ',') minusone(6); if(input[0] == '/') checkone(6); if(input[0] == '0') clearitgr(); wprintw(stdscr, "Press any key to continue.\n"); bie(); } if(input[0] == '9') ited(); return 0; }
int chared() { for(;;) { clear(); refresh(); wprintw(stdscr, "To add a character press 1.\nTo view a character press 4.\nTo save the enemy file press 7.\nTo save the enemy file under a different name press 8.\nTo edit equations press 9\nTo delete a character press 0.\n"); input [0] = bie(); if(input[0] == '1') addcha(); if(input[0] == '4') viewch(); if(input[0] == '7') saveen(filename); if(input[0] == '8') { stufffilename(); saveen(filename); } if(input[0] == '9') break; if(input[0] == '.') plusone(1); if(input[0] == ',') minusone(1); if(input[0] == '/') checkone(1); if(input[0] == '0') clearch(); wprintw(stdscr, "Press any key to continue.\n"); bie(); } if(input[0] == '9') eqed(); return 0; }
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)); }