コード例 #1
0
ファイル: divround.cpp プロジェクト: fpelliccioni/nt2
NT2_TEST_CASE_TPL ( divround_unsigned_int__2_0,  NT2_UNSIGNED_TYPES)
{

  using nt2::divround;
  using nt2::tag::divround_;
  typedef typename nt2::meta::as_integer<T>::type iT;
  typedef typename nt2::meta::call<divround_(T,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::common_type<T,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(divround(nt2::Five<T>(),nt2::Three<T>()), nt2::Two<r_t>(), 0);
  NT2_TEST_ULP_EQUAL(divround(nt2::Four<T>(),nt2::Three<T>()), nt2::One<r_t>(), 0);
  NT2_TEST_ULP_EQUAL(divround(nt2::Four<T>(),nt2::Zero<T>()), nt2::Valmax<r_t>(), 0);
  NT2_TEST_ULP_EQUAL(divround(nt2::One<T>(), nt2::One<T>()), nt2::One<r_t>(), 0);
} // end of test for unsigned_int_
コード例 #2
0
ファイル: divround.cpp プロジェクト: fpelliccioni/nt2
NT2_TEST_CASE_TPL ( divround_real__2_0,  NT2_SIMD_REAL_TYPES)
{
  using nt2::divround;
  using nt2::tag::divround_;
  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<divround_(vT,vT)>::type r_t;
  typedef typename nt2::meta::call<divround_(T,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(divround(nt2::Five<vT>(),nt2::Three<vT>())[0], nt2::Two<sr_t>(), 0);
  NT2_TEST_ULP_EQUAL(divround(nt2::Four<vT>(),nt2::Three<vT>())[0], nt2::One<sr_t>(), 0);
  NT2_TEST_ULP_EQUAL(divround(nt2::Four<vT>(),nt2::Zero<vT>())[0], nt2::Inf<sr_t>(), 0);
  NT2_TEST_ULP_EQUAL(divround(nt2::Inf<vT>(), nt2::Inf<vT>())[0], nt2::Nan<sr_t>(), 0);
  NT2_TEST_ULP_EQUAL(divround(nt2::Minf<vT>(), nt2::Minf<vT>())[0], nt2::Nan<sr_t>(), 0);
  NT2_TEST_ULP_EQUAL(divround(nt2::Mone<vT>(), nt2::Mone<vT>())[0], nt2::One<sr_t>(), 0);
  NT2_TEST_ULP_EQUAL(divround(nt2::Nan<vT>(), nt2::Nan<vT>())[0], nt2::Nan<sr_t>(), 0);
  NT2_TEST_ULP_EQUAL(divround(nt2::One<vT>(), nt2::One<vT>())[0], nt2::One<sr_t>(), 0);
} // end of test for floating_
コード例 #3
0
ファイル: divround.cpp プロジェクト: JanVogelgesang/nt2
NT2_TEST_CASE_TPL ( divround_all_types,  NT2_SIMD_TYPES)
{
  using nt2::divround;
  using nt2::tag::divround_;
  using boost::simd::native;
  typedef NT2_SIMD_DEFAULT_EXTENSION  ext_t;
  typedef native<T,ext_t>                nT;

  typedef typename nt2::meta::call<divround_(T, T)>::type r_t;

  // random verifications
  nt2::uint32_t NR  = NT2_NB_RANDOM_TEST;
  std::vector<T> in1(NR), in2(NR);
  nt2::roll(in1, nt2::Valmin<T>()/2, nt2::Valmax<T>()/2);
  nt2::roll(in2, nt2::Valmin<T>()/2, nt2::Valmax<T>()/2);

  std::vector<r_t> ref(NR);
  for(nt2::uint32_t i=0; i < NR ; ++i) ref[i] = divround(in1[i], in2[i]);
  NT2_COVER_ULP_EQUAL(divround_, ((nT, in1))((nT, in2)), ref, 0);

}
コード例 #4
0
ファイル: divround.cpp プロジェクト: pesterie/nt2
NT2_TEST_CASE_TPL ( divround_real__2_0,  NT2_SIMD_REAL_TYPES)
{
  using nt2::divround;
  using nt2::tag::divround_;
  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<divround_(vT,vT)>::type r_t;
  typedef typename nt2::meta::call<divround_(T,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(-10), T(10));
    NT2_CREATE_BUF(tab_a1,T, NR, T(-10), T(10));
    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);
        vT a1 = load<vT>(&tab_a1[0],j);
        r_t v = divround(a0,a1);
        for(int i = 0; i< cardinal_of<n_t>::value; i++)
        {
          int k = i+j*cardinal_of<n_t>::value;
          NT2_TEST_ULP_EQUAL( v[i],ssr_t(nt2::divround (tab_a0[k],tab_a1[k])), 2.5);
          ulp0 = nt2::max(ulpd,ulp0);
        }
      }
    std::cout << "max ulp found is: " << ulp0 << std::endl;
  }
} // end of test for real_