Example #1
0
 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);
 }
Example #2
0
 static inline void kernel_log(const A0& a0,
                               A0& fe,
                               A0& x,
                               A0& x2,
                               A0& y)
 {
   typedef typename meta::as_integer<A0, signed>::type int_type;
   int_type e;
   x = fast_frexp(a0, e);
   int_type x_lt_sqrthf = if_else_zero(gt(single_constant<A0, 0x3f3504f3>(),x), Mone<int_type>());
   e = e+x_lt_sqrthf;
   x = x+b_and(x, x_lt_sqrthf)+single_constant<A0, 0xbf800000>();
   x2 = sqr(x);
   A0 y1 = madd(single_constant<A0, 0x3d9021bb>() ,x2,single_constant<A0, 0x3def251a>() );
   A0 y2 = madd(single_constant<A0, 0xbdebd1b8>() ,x2,single_constant<A0, 0xbdfe5d4f>() );
   y1 = madd(y1,x2,single_constant<A0, 0x3e11e9bf>() );
   y2 = madd(y2,x2,single_constant<A0, 0xbe2aae50>() );
   y1 = madd(y1,x2,single_constant<A0, 0x3e4cceac>() );
   y2 = madd(y2,x2,single_constant<A0, 0xbe7ffffc>() );
   y1 = madd(y1,x2,single_constant<A0, 0x3eaaaaaa>() );
   y = madd(x,y2,y1)*x*x2;
   fe = tofloat(e);
 }