Example #1
0
 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));
 }
Example #2
0
      inline void kernel_log(const float& a0,
			     float& fe,
			     float& x,
			     float& x2,
			     float& y)
      {
        typedef float A0;
        typedef meta::as_integer<A0, signed>::type int_type;
        int_type e;
        boost::fusion::tie(x, e) = fast_frexp(a0);
        int_type x_lt_sqrthf = -(Const<float, 0x3f3504f3>() > x);
        e += x_lt_sqrthf;
        //     if (x_lt_sqrthf) x+= x;
        //     x += Const<float, 0xbf800000>();
        x += b_and(x, genmask<float>(x_lt_sqrthf))+Const<float,0xbf800000>();
        x2 = sqr(x);
        A0 y1 = fma(Const<float, 0x3d9021bb>() ,x2,Const<float, 0x3def251a>() );
        A0 y2 = fma(Const<float, 0xbdebd1b8>() ,x2,Const<float, 0xbdfe5d4f>() );
        y1 = fma(y1,x2,Const<float, 0x3e11e9bf>() );
        y2 = fma(y2,x2,Const<float, 0xbe2aae50>() );
        y1 = fma(y1,x2,Const<float, 0x3e4cceac>() );
        y2 = fma(y2,x2,Const<float, 0xbe7ffffc>() );
        y1 = fma(y1,x2,Const<float, 0x3eaaaaaa>() );
        y = fma(x,y2,y1)*x*x2;
        fe = tofloat(e);
      }
Example #3
0
 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));
 }
Example #4
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;
	  boost::fusion::tie(x, e) = fast_frexp(a0);
	  // 	std::cout << "x " << x << " e " << e << std::endl;
	  // 	bf::tie(x, e) = frexp(a0);
	  // 	std::cout << "x " << x << " e " << e << std::endl;
	  int_type x_lt_sqrthf = nt2::simd::native_cast<int_type>(gt(single_constant<A0, 0x3f3504f3>(),x));
	  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);
	}
Example #5
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;
	  typedef typename meta::strip<A0>::type stA0; 
	  int_type e;
	  boost::fusion::vector_tie(x, e) = fast_frexp(a0);
	  int_type x_lt_sqrthf = -(single_constant<stA0, 0x3f3504f3>() > x);
	  e += x_lt_sqrthf;
	  //     if (x_lt_sqrthf) x+= x;
	  //     x += single_constant<A0, 0xbf800000>();
	  x += b_and(x, x_lt_sqrthf)+single_constant<stA0,0xbf800000>();
	  x2 = sqr(x);
	  A0 y1 = madd(single_constant<stA0, 0x3d9021bb>() ,x2,single_constant<stA0, 0x3def251a>() );
	  A0 y2 = madd(single_constant<stA0, 0xbdebd1b8>() ,x2,single_constant<stA0, 0xbdfe5d4f>() );
	  y1 = madd(y1,x2,single_constant<stA0, 0x3e11e9bf>() );
	  y2 = madd(y2,x2,single_constant<stA0, 0xbe2aae50>() );
	  y1 = madd(y1,x2,single_constant<stA0, 0x3e4cceac>() );
	  y2 = madd(y2,x2,single_constant<stA0, 0xbe7ffffc>() );
	  y1 = madd(y1,x2,single_constant<stA0, 0x3eaaaaaa>() );
	  y = madd(x,y2,y1)*x*x2;
	  fe = tofloat(e);
	}
Example #6
0
  static inline void
  kernel_log(const A0& a0,A0& fe, A0& x,A0& x2, A0& y, const A0&)
  {
    int_type e;
    bf::tie(x, e) = fast_frexp(a0);
    int_type x_lt_sqrthf = -(Const<float,0x3f3504f3>() > x);
    e += x_lt_sqrthf;
    x += b_and(x, genmask<float>(x_lt_sqrthf))+Const<float,0xbf800000>();
    x2 = sqr(x);
    A0 y1 = fma(Const<float, 0x3d9021bb>() ,x2,Const<float, 0x3def251a>() );
    A0 y2 = fma(Const<float, 0xbdebd1b8>() ,x2,Const<float, 0xbdfe5d4f>() );
    y1 = fma(y1,x2,Const<float, 0x3e11e9bf>() );
    y2 = fma(y2,x2,Const<float, 0xbe2aae50>() );
    y1 = fma(y1,x2,Const<float, 0x3e4cceac>() );
    y2 = fma(y2,x2,Const<float, 0xbe7ffffc>() );
    y1 = fma(y1,x2,Const<float, 0x3eaaaaaa>() );
    y  = fma(x,y2,y1)*x*x2;
    fe = tofloat(e);
 }
Example #7
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);
 }