示例#1
0
	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);
	    }
	}
示例#2
0
	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);
	    }
	}
示例#3
0
	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);
	}