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_n acos(const A0_n a0_n) { const A0 a0 = { a0_n }; const A0 as = { asin( sqrt(Half<A0>() - Half<A0>()*a0) )}; A0 z1 = Two<A0>() * as; const A0 as1 = {asin(a0)}; A0 z2 = ((Pio_4<A0>() - as1)+double_constant<A0, 0x3c91a62633145c07ll>())+ Pio_4<A0>(); return if_nan_else( gt(abs(a0),One<A0>()), sel( gt(a0,Half<A0>()), z1, z2)); }
static inline A0 log2(const A0& a0) { A0 x, fe, x2, y; kernel_log(a0, fe, x, x2, y); y = madd(Mhalf<A0>(),x2, y); // multiply log of fraction by log2(e) A0 z = madd(x,single_constant<A0, 0x3ee2a8ed>(),mul(y,single_constant<A0, 0x3ee2a8ed>()));// 0.44269504088896340735992 A0 z1 = ((z+y)+x)+fe; A0 y1 = a0-rec(abs(a0)); // trick to reduce selection testing return seladd(is_inf(y1),if_nan_else(logical_or(is_ltz(a0), is_nan(a0)), z1),y1); }
static inline A0 log(const A0& a0) { A0 x, fe, x2, y; kernel_log(a0, fe, x, x2, y); y = madd(fe, single_constant<A0, 0xb95e8083>(), y); y = madd(Mhalf<A0>(), x2, y); A0 z = x + y; A0 y1 = a0-rec(abs(a0));// trick to reduce selection testing A0 y2 = madd(single_constant<A0, 0x3f318000>(), fe, z); y2 = if_nan_else(logical_or(is_ltz(a0), is_nan(a0)), y2); return seladd(is_inf(y1), y2, y1); }
static inline A0 log10(const A0& a0) { A0 x, fe, x2, y; kernel_log(a0, fe, x, x2, y); y = amul(y, -Half<A0>(), x2); // multiply log of fraction by log10(e) and base 2 exponent by log10(2) A0 z = mul(x+y, single_constant<A0, 0x3a37b152>());//7.00731903251827651129E-4f // log10(e)lo z = amul(z, y, single_constant<A0, 0x3ede0000>()); //4.3359375E-1f // log10(e)hi z = amul(z, x, single_constant<A0, 0x3ede0000>()); z = amul(z, fe, single_constant<A0, 0x39826a14>());//3.0078125E-1f // log10(2)hi z = amul(z, fe, single_constant<A0, 0x3e9a0000>());//2.48745663981195213739E-4f // log10(2)lo A0 y1 = a0-rec(abs(a0)); // trick to reduce selection testing perhaps bad TODO return seladd(is_inf(y1), if_nan_else(logical_or(is_ltz(a0), is_nan(a0)), z),y1); }
// compute exp(ax) static inline A0 expa(const A0& a0) { A0 hi, lo, x; A0 k = reduc_t::reduce(a0, hi, lo, x); A0 c = reduc_t::approx(x); bA0 ge = reduc_t::isgemaxlog(a0); bA0 le = reduc_t::isleminlog(a0); A0 z = nt2::if_zero_else(le, finalize_t::finalize(a0, x, c, k, hi, lo) ); #ifdef BOOST_SIMD_NO_INVALIDS return z; #else return if_nan_else(is_nan(a0), nt2::if_else(ge, nt2::Inf<A0>(), z)); #endif }