NT2_TEST_CASE_TPL ( cscpi_unsigned_int__1_0, NT2_UNSIGNED_TYPES) { using nt2::cscpi; using nt2::tag::cscpi_; typedef typename nt2::meta::as_integer<T>::type iT; typedef typename nt2::meta::call<cscpi_(T)>::type r_t; typedef typename nt2::meta::scalar_of<r_t>::type ssr_t; typedef typename nt2::meta::upgrade<T>::type u_t; typedef typename boost::dispatch::meta::as_floating<T>::type wished_r_t; // return type conformity test NT2_TEST( (boost::is_same < r_t, wished_r_t >::value) ); std::cout << std::endl; // specific values tests NT2_TEST_ULP_EQUAL(cscpi(nt2::One<T>()), nt2::Nan<r_t>(), 0.5); NT2_TEST_ULP_EQUAL(cscpi(nt2::Zero<T>()), nt2::Nan<r_t>(), 0.5); } // end of test for unsigned_int_
NT2_TEST_CASE_TPL ( cscpi_signed_int__1_0, NT2_INTEGRAL_SIGNED_TYPES) { using nt2::cscpi; using nt2::tag::cscpi_; typedef typename nt2::meta::as_integer<T>::type iT; typedef typename nt2::meta::call<cscpi_(T)>::type r_t; typedef typename nt2::meta::upgrade<T>::type u_t; typedef typename boost::result_of<nt2::meta::floating(T)>::type wished_r_t; // return type conformity test NT2_TEST( (boost::is_same < r_t, wished_r_t >::value) ); std::cout << std::endl; double ulpd; ulpd=0.0; // specific values tests NT2_TEST_ULP_EQUAL(cscpi(nt2::Mone<T>()), nt2::Nan<r_t>(), 0.5); NT2_TEST_ULP_EQUAL(cscpi(nt2::One<T>()), nt2::Nan<r_t>(), 0.5); NT2_TEST_ULP_EQUAL(cscpi(nt2::Zero<T>()), nt2::Nan<r_t>(), 0.5); } // end of test for signed_int_
NT2_TEST_CASE_TPL ( cscpi_real__1_0, NT2_SIMD_REAL_TYPES) { using nt2::cscpi; using nt2::tag::cscpi_; using nt2::load; using boost::simd::native; using nt2::meta::cardinal_of; typedef NT2_SIMD_DEFAULT_EXTENSION ext_t; typedef typename nt2::meta::upgrade<T>::type u_t; typedef native<T,ext_t> n_t; typedef n_t vT; typedef typename nt2::meta::as_integer<T>::type iT; typedef native<iT,ext_t> ivT; typedef typename nt2::meta::call<cscpi_(vT)>::type r_t; typedef typename nt2::meta::call<cscpi_(T)>::type sr_t; typedef typename nt2::meta::scalar_of<r_t>::type ssr_t; double ulpd; ulpd=0.0; // random verifications static const nt2::uint32_t NR = NT2_NB_RANDOM_TEST; { NT2_CREATE_BUF(tab_a0,T, NR, T(-40), T(40)); double ulp0, ulpd ; ulpd=ulp0=0.0; for(nt2::uint32_t j = 0; j < NR/cardinal_of<n_t>::value; j++) { vT a0 = load<vT>(&tab_a0[0],j); r_t v = cscpi(a0); for(nt2::uint32_t i = 0; i< cardinal_of<n_t>::value; i++) { nt2::uint32_t k = i+j*cardinal_of<n_t>::value; NT2_TEST_ULP_EQUAL( v[i],ssr_t(nt2::cscpi (tab_a0[k])), 10.0); ulp0 = nt2::max(ulpd,ulp0); } } std::cout << "max ulp found is: " << ulp0 << std::endl; } } // end of test for floating_
NT2_TEST_CASE_TPL ( cscpi_real__1_0, NT2_SIMD_REAL_TYPES) { using nt2::cscpi; using nt2::tag::cscpi_; using boost::simd::native; using nt2::meta::cardinal_of; typedef NT2_SIMD_DEFAULT_EXTENSION ext_t; typedef typename nt2::meta::upgrade<T>::type u_t; typedef native<T,ext_t> n_t; typedef n_t vT; typedef typename nt2::meta::as_integer<T>::type iT; typedef native<iT,ext_t> ivT; typedef typename nt2::meta::call<cscpi_(vT)>::type r_t; typedef typename nt2::meta::call<cscpi_(T)>::type sr_t; typedef typename nt2::meta::scalar_of<r_t>::type ssr_t; // specific values tests NT2_TEST_ULP_EQUAL(cscpi(-nt2::Quarter<vT>())[0], -nt2::Sqrt_2<sr_t>(), 0.5); NT2_TEST_ULP_EQUAL(cscpi(-nt2::Zero<vT>())[0], nt2::Minf<sr_t>(), 0.5); NT2_TEST_ULP_EQUAL(cscpi(nt2::Half<vT>())[0], nt2::One<sr_t>(), 0.5); NT2_TEST_ULP_EQUAL(cscpi(nt2::Inf<vT>())[0], nt2::Nan<sr_t>(), 0.5); NT2_TEST_ULP_EQUAL(cscpi(nt2::Mhalf<vT>())[0], nt2::Mone<sr_t>(), 0.5); NT2_TEST_ULP_EQUAL(cscpi(nt2::Minf<vT>())[0], nt2::Nan<sr_t>(), 0.5); NT2_TEST_ULP_EQUAL(cscpi(nt2::Mone<vT>())[0], nt2::Nan<sr_t>(), 0.5); NT2_TEST_ULP_EQUAL(cscpi(nt2::Nan<vT>())[0], nt2::Nan<sr_t>(), 0.5); NT2_TEST_ULP_EQUAL(cscpi(nt2::One<vT>())[0], nt2::Nan<sr_t>(), 0.5); NT2_TEST_ULP_EQUAL(cscpi(nt2::Quarter<vT>())[0], nt2::Sqrt_2<sr_t>(), 0.5); NT2_TEST_ULP_EQUAL(cscpi(nt2::Zero<vT>())[0], nt2::Inf<sr_t>(), 0.5); } // end of test for floating_
NT2_TEST_CASE_TPL ( cscpi_real__1_0, NT2_REAL_TYPES) { using nt2::cscpi; using nt2::tag::cscpi_; typedef typename nt2::meta::as_integer<T>::type iT; typedef typename nt2::meta::call<cscpi_(T)>::type r_t; typedef typename nt2::meta::scalar_of<r_t>::type ssr_t; typedef typename nt2::meta::upgrade<T>::type u_t; typedef typename boost::dispatch::meta::as_floating<T>::type wished_r_t; // return type conformity test NT2_TEST( (boost::is_same < r_t, wished_r_t >::value) ); std::cout << std::endl; // specific values tests NT2_TEST_ULP_EQUAL(cscpi(-nt2::Quarter<T>()), -nt2::Sqrt_2<r_t>(), 0.5); NT2_TEST_ULP_EQUAL(cscpi(-nt2::Zero<T>()), nt2::Minf<r_t>(), 0.5); NT2_TEST_ULP_EQUAL(cscpi(nt2::Half<T>()), nt2::One<r_t>(), 0.5); NT2_TEST_ULP_EQUAL(cscpi(nt2::Inf<T>()), nt2::Nan<r_t>(), 0.5); NT2_TEST_ULP_EQUAL(cscpi(nt2::Mhalf<T>()), nt2::Mone<r_t>(), 0.5); NT2_TEST_ULP_EQUAL(cscpi(nt2::Minf<T>()), nt2::Nan<r_t>(), 0.5); NT2_TEST_ULP_EQUAL(cscpi(nt2::Mone<T>()), nt2::Nan<r_t>(), 0.5); NT2_TEST_ULP_EQUAL(cscpi(nt2::Nan<T>()), nt2::Nan<r_t>(), 0.5); NT2_TEST_ULP_EQUAL(cscpi(nt2::One<T>()), nt2::Nan<r_t>(), 0.5); NT2_TEST_ULP_EQUAL(cscpi(nt2::Quarter<T>()), nt2::Sqrt_2<r_t>(), 0.5); NT2_TEST_ULP_EQUAL(cscpi(nt2::Zero<T>()), nt2::Inf<r_t>(), 0.5); } // end of test for floating_
NT2_TEST_CASE_TPL ( cscpi_real__1_0, NT2_REAL_TYPES) { using nt2::cscpi; using nt2::tag::cscpi_; typedef typename nt2::meta::as_integer<T>::type iT; typedef typename nt2::meta::call<cscpi_(T)>::type r_t; typedef typename nt2::meta::upgrade<T>::type u_t; typedef typename boost::result_of<nt2::meta::floating(T)>::type wished_r_t; // return type conformity test NT2_TEST( (boost::is_same < r_t, wished_r_t >::value) ); std::cout << std::endl; double ulpd; ulpd=0.0; // specific values tests NT2_TEST_ULP_EQUAL(cscpi(-nt2::Quarter<T>()), -nt2::Sqrt_2<r_t>(), 0.5); NT2_TEST_ULP_EQUAL(cscpi(-nt2::Zero<T>()), nt2::Minf<r_t>(), 0.5); NT2_TEST_ULP_EQUAL(cscpi(nt2::Half<T>()), nt2::One<r_t>(), 0.5); NT2_TEST_ULP_EQUAL(cscpi(nt2::Inf<T>()), nt2::Nan<r_t>(), 0.5); NT2_TEST_ULP_EQUAL(cscpi(nt2::Mhalf<T>()), nt2::Mone<r_t>(), 0.5); NT2_TEST_ULP_EQUAL(cscpi(nt2::Minf<T>()), nt2::Nan<r_t>(), 0.5); NT2_TEST_ULP_EQUAL(cscpi(nt2::Mone<T>()), nt2::Nan<r_t>(), 0.5); NT2_TEST_ULP_EQUAL(cscpi(nt2::Nan<T>()), nt2::Nan<r_t>(), 0.5); NT2_TEST_ULP_EQUAL(cscpi(nt2::One<T>()), nt2::Nan<r_t>(), 0.5); NT2_TEST_ULP_EQUAL(cscpi(nt2::Quarter<T>()), nt2::Sqrt_2<r_t>(), 0.5); NT2_TEST_ULP_EQUAL(cscpi(nt2::Zero<T>()), nt2::Inf<r_t>(), 0.5); // random verifications static const uint32_t NR = NT2_NB_RANDOM_TEST; { NT2_CREATE_BUF(tab_a0,T, NR, T(-40), T(40)); double ulp0, ulpd ; ulpd=ulp0=0.0; T a0; for (uint32_t j =0; j < NR; ++j ) { std::cout << "for param " << " a0 = "<< u_t(a0 = tab_a0[j]) << std::endl; NT2_TEST_ULP_EQUAL( nt2::cscpi(a0),1.0l/(::cephes_sinl(nt2::long_pi*a0)),10.0); ulp0=nt2::max(ulpd,ulp0); } std::cout << "max ulp found is: " << ulp0 << std::endl; } } // end of test for real_