コード例 #1
0
ファイル: csc.cpp プロジェクト: Mathieu-/nt2
//////////////////////////////////////////////////////////////////////////////
// Test behavior of arithmetic components using NT2_TEST_CASE
//////////////////////////////////////////////////////////////////////////////
NT2_TEST_CASE_TPL(csc, NT2_SIMD_REAL_CONVERTIBLE_TYPES )
{
 using nt2::csc;
 using nt2::functors::csc_;    
 using nt2::load; 
 using nt2::simd::native; 
 using nt2::meta::cardinal_of;

 typedef NT2_SIMD_DEFAULT_EXTENSION  ext_t;
 typedef native<T,ext_t>             n_t;
 typedef typename nt2::meta::call<csc_(n_t)>::type call_type;
 typedef typename nt2::meta::as_real<T>::type rT;
 typedef native<rT,ext_t>             rn_t;
 
   
 NT2_TEST( (boost::is_same<call_type, rn_t>::value) );  
 NT2_ALIGNED_TYPE(T) data[1*cardinal_of<n_t>::value];
 double z, m = 0; 
 for(int num = 0; num < 10; num++)
   {
     for(std::size_t i=0;i<1*cardinal_of<n_t>::value;++i){
       data[i] = nt2::random(0.0, 3.0*nt2::Pi<rT>()/8); // good value here for csc
     }
     n_t a0 = load<n_t>(&data[0],0);  
     rn_t v  = csc(a0);
     for(std::size_t j=0;j<cardinal_of<n_t>::value;++j)
       {
	 NT2_TEST_LESSER( z = nt2::ulpdist(v[j], csc(a0[j])), 1);
	 std::cout << a0[j] << "  "<< v[j] <<  "  " << csc(a0[j]) << std::endl;
	 if (z > m) m = z; 
       }
   } 
 std::cout << "ulp max = " << m << std::endl;
}
コード例 #2
0
ファイル: csc.cpp プロジェクト: msuchard/nt2
NT2_TEST_CASE_TPL ( csc_real__1_0,  NT2_SIMD_REAL_TYPES)
{
  using nt2::csc;
  using nt2::tag::csc_;
  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<csc_(vT)>::type r_t;
  typedef typename nt2::meta::call<csc_(T)>::type sr_t;
  typedef typename nt2::meta::scalar_of<r_t>::type ssr_t;
  double ulpd;
  ulpd=0.0;


  // specific values tests
  NT2_TEST_ULP_EQUAL(csc(-nt2::Pi<vT>()/nt2::splat<vT>(2))[0], nt2::Mone<sr_t>(), 0.5);
  NT2_TEST_ULP_EQUAL(csc(-nt2::Pi<vT>()/nt2::splat<vT>(4))[0], -nt2::Sqrt_2<sr_t>(), 0.5);
  NT2_TEST_ULP_EQUAL(csc(-nt2::Zero<vT>())[0], nt2::Minf<sr_t>(), 0.5);
  NT2_TEST_ULP_EQUAL(csc(nt2::Inf<vT>())[0], nt2::Nan<sr_t>(), 0.5);
  NT2_TEST_ULP_EQUAL(csc(nt2::Minf<vT>())[0], nt2::Nan<sr_t>(), 0.5);
  NT2_TEST_ULP_EQUAL(csc(nt2::Nan<vT>())[0], nt2::Nan<sr_t>(), 0.5);
  NT2_TEST_ULP_EQUAL(csc(nt2::Pi<vT>()/nt2::splat<vT>(2))[0], nt2::One<sr_t>(), 0.5);
  NT2_TEST_ULP_EQUAL(csc(nt2::Pi<vT>()/nt2::splat<vT>(4))[0], nt2::Sqrt_2<sr_t>(), 0.5);
  NT2_TEST_ULP_EQUAL(csc(nt2::Zero<vT>())[0], nt2::Inf<sr_t>(), 0.5);
} // end of test for floating_
コード例 #3
0
NT2_TEST_CASE_TPL ( csc_real__1_0,  NT2_REAL_TYPES)
{
  
  using nt2::csc;
  using nt2::tag::csc_;
  typedef typename nt2::meta::as_integer<T>::type iT;
  typedef typename nt2::meta::call<csc_(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; 
  double ulpd;
  ulpd=0.0;


  // specific values tests
  NT2_TEST_ULP_EQUAL(csc(-nt2::Pi<T>()/T(2)), nt2::Mone<r_t>(), 0.5);
  NT2_TEST_ULP_EQUAL(csc(-nt2::Pi<T>()/T(4)), -nt2::Sqrt_2<r_t>(), 0.5);
  NT2_TEST_ULP_EQUAL(csc(-nt2::Zero<T>()), nt2::Minf<r_t>(), 0.5);
  NT2_TEST_ULP_EQUAL(csc(nt2::Inf<T>()), nt2::Nan<r_t>(), 0.5);
  NT2_TEST_ULP_EQUAL(csc(nt2::Minf<T>()), nt2::Nan<r_t>(), 0.5);
  NT2_TEST_ULP_EQUAL(csc(nt2::Nan<T>()), nt2::Nan<r_t>(), 0.5);
  NT2_TEST_ULP_EQUAL(csc(nt2::Pi<T>()/T(2)), nt2::One<r_t>(), 0.5);
  NT2_TEST_ULP_EQUAL(csc(nt2::Pi<T>()/T(4)), nt2::Sqrt_2<r_t>(), 0.5);
  NT2_TEST_ULP_EQUAL(csc(nt2::Zero<T>()), nt2::Inf<r_t>(), 0.5);
} // end of test for floating_
コード例 #4
0
ファイル: csc.cpp プロジェクト: recampbell/nt2
NT2_TEST_CASE_TPL ( csc_signed_int__1_0,  NT2_INTEGRAL_SIGNED_TYPES)
{

  using nt2::csc;
  using nt2::tag::csc_;
  typedef typename nt2::meta::as_integer<T>::type iT;
  typedef typename nt2::meta::call<csc_(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(csc(nt2::Zero<T>()), nt2::Inf<r_t>(), 0.5);
} // end of test for signed_int_
コード例 #5
0
ファイル: csc.cpp プロジェクト: recampbell/nt2
NT2_TEST_CASE_TPL ( csc_uint_convert__1_0,  NT2_SIMD_UINT_CONVERT_TYPES)
{
  using nt2::csc;
  using nt2::tag::csc_;
  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<csc_(vT)>::type r_t;
  typedef typename nt2::meta::call<csc_(T)>::type sr_t;
  typedef typename nt2::meta::scalar_of<r_t>::type ssr_t;

  // specific values tests
  NT2_TEST_ULP_EQUAL(csc(nt2::Zero<vT>())[0], nt2::Inf<sr_t>(), 0.5);
} // end of test for uint_convert_
コード例 #6
0
ファイル: csc.cpp プロジェクト: pesterie/nt2
NT2_TEST_CASE_TPL ( csc_unsigned_int__1_0,  NT2_UNSIGNED_TYPES)
{
  
  using nt2::csc;
  using nt2::tag::csc_;
  typedef typename nt2::meta::as_integer<T>::type iT;
  typedef typename nt2::meta::call<csc_(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::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(csc(nt2::Zero<T>()), nt2::Nan<r_t>(), 0.5);
} // end of test for unsigned_int_
コード例 #7
0
NT2_TEST_CASE_TPL ( csc_int_convert__1_0,  NT2_SIMD_INT_CONVERT_TYPES)
{
  using nt2::csc;
  using nt2::tag::csc_;
  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<csc_(vT)>::type r_t;
  typedef typename nt2::meta::call<csc_(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(-60), T(60));
    double ulp0, ulpd ; ulpd=ulp0=0.0;
    for(nt2::uint32_t j = 0; j < NR;j+=cardinal_of<n_t>::value)
      {
        vT a0 = load<vT>(&tab_a0[0],j);
        r_t v = csc(a0);
        for(nt2::uint32_t i = 0; i< cardinal_of<n_t>::value; i++)
        {

          NT2_TEST_ULP_EQUAL( v[i],ssr_t(nt2::csc (a0[i])), 1.0);
          ulp0 = nt2::max(ulpd,ulp0);
        }
      }
    std::cout << "max ulp found is: " << ulp0 << std::endl;
  }
} // end of test for int_convert_
コード例 #8
0
ファイル: csc.cpp プロジェクト: francescog/nt2
  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<csc_(vT)>::type r_t;
  typedef typename nt2::meta::call<csc_(T)>::type sr_t;
  typedef typename nt2::meta::scalar_of<r_t>::type ssr_t;
  double ulpd;
  ulpd=0.0;


  // specific values tests
  NT2_TEST_ULP_EQUAL(csc(nt2::Zero<vT>())[0], nt2::Nan<sr_t>(), 0.5);
} // end of test for int_convert_

NT2_TEST_CASE_TPL ( csc_uint_convert__1_0,  (uint32_t)(uint64_t))
{
  using nt2::csc;
  using nt2::tag::csc_;
  using nt2::load; 
  using nt2::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;