Exemplo n.º 1
0
NT2_TEST_CASE_TPL ( ceil_real__1_0,  NT2_SIMD_REAL_TYPES)
{
  using nt2::ceil;
  using nt2::tag::ceil_;
  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<ceil_(vT)>::type r_t;
  typedef typename nt2::meta::call<ceil_(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(ceil(nt2::splat<vT>(-1.1))[0], sr_t(-1), 0);
  NT2_TEST_ULP_EQUAL(ceil(nt2::splat<vT>(1.1))[0], sr_t(2), 0);
  NT2_TEST_ULP_EQUAL(ceil(nt2::Inf<vT>())[0], nt2::Inf<T>(), 0);
  NT2_TEST_ULP_EQUAL(ceil(nt2::Minf<vT>())[0], nt2::Minf<T>(), 0);
  NT2_TEST_ULP_EQUAL(ceil(nt2::Mone<vT>())[0], nt2::Mone<T>(), 0);
  NT2_TEST_ULP_EQUAL(ceil(nt2::Nan<vT>())[0], nt2::Nan<T>(), 0);
  NT2_TEST_ULP_EQUAL(ceil(nt2::One<vT>())[0], nt2::One<T>(), 0);
  NT2_TEST_ULP_EQUAL(ceil(nt2::Zero<vT>())[0], nt2::Zero<T>(), 0);
} // end of test for real_
Exemplo n.º 2
0
NT2_TEST_CASE_TPL ( ceil_all_types,  NT2_SIMD_TYPES)
{
    using nt2::ceil;
    using nt2::tag::ceil_;
    using boost::simd::native;
    typedef NT2_SIMD_DEFAULT_EXTENSION  ext_t;
    typedef native<T,ext_t>                nT;

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

    // random verifications
    nt2::uint32_t NR  = NT2_NB_RANDOM_TEST;
    std::vector<T> in1(NR);
    nt2::roll(in1, 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] = ceil(in1[i]);
    NT2_COVER_ULP_EQUAL(ceil_, ((nT, in1)), ref, 0);
}
Exemplo n.º 3
0
Arquivo: ceil.cpp Projeto: faldah/nt2
NT2_TEST_CASE_TPL ( ceil_real__1_0,  NT2_SIMD_REAL_TYPES)
{
  using nt2::ceil;
  using nt2::tag::ceil_;
  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<ceil_(vT)>::type r_t;
  typedef typename nt2::meta::call<ceil_(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(-100), T(100));
    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 = ceil(a0);
        for(nt2::uint32_t i = 0; i< cardinal_of<n_t>::value; i++)
        {
          
          NT2_TEST_ULP_EQUAL( v[i],ssr_t(nt2::ceil (a0[i])), 2.5);
          ulp0 = nt2::max(ulpd,ulp0);
        }
      }
    std::cout << "max ulp found is: " << ulp0 << std::endl;
  }
} // end of test for floating_
Exemplo n.º 4
0
// Test behavior of arithmetic components using NT2_TEST_CASE
//////////////////////////////////////////////////////////////////////////////
NT2_TEST_CASE_TPL ( ceil_int,  (nt2::uint64_t)(nt2::int64_t) 
                          (nt2::uint32_t)(nt2::int32_t)  
                          (nt2::uint16_t)(nt2::int16_t)         
                          (nt2::uint8_t)(nt2::int8_t)
                  )
{
  using nt2::ceil;
  using nt2::functors::ceil_;

 NT2_TEST( (boost::is_same < typename nt2::meta::call<ceil_(T)>::type
             ,T
             >::value)
          );
   NT2_TEST_EQUAL(  ceil( T(42) ), 42 );
   NT2_TEST_EQUAL(  ceil( T(-42) ), T(-42) );

}

NT2_TEST_CASE_TPL ( real_ceil,  (double)(float)
                  )
{
  using nt2::ceil;
  using nt2::functors::ceil_;

 NT2_TEST( (boost::is_same < typename nt2::meta::call<ceil_(T)>::type
             ,T
             >::value)
          );
 NT2_TEST_EQUAL(  ceil( T(42.1) ), T(43) );
Exemplo n.º 5
0
NT2_TEST_CASE_TPL ( ceil_real__1_0,  BOOST_SIMD_REAL_TYPES)
{
  
  using nt2::ceil;
  using nt2::tag::ceil_;
  typedef typename boost::dispatch::meta::as_integer<T>::type iT;
  typedef typename boost::dispatch::meta::call<ceil_(T)>::type r_t;
  typedef typename nt2::meta::scalar_of<r_t>::type sr_t;
  typedef typename nt2::meta::scalar_of<r_t>::type ssr_t;
  typedef typename boost::dispatch::meta::upgrade<T>::type u_t;
  typedef T wished_r_t;
  typedef typename std::complex<T> cT;
  typedef typename nt2::meta::as_dry<T>::type dT;
  typedef typename nt2::meta::as_imaginary<T>::type ciT;



  // 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_EQUAL(ceil(cT(-1.1)), T(-1));
  NT2_TEST_EQUAL(ceil(cT(1.1)), T(2));
  NT2_TEST_EQUAL(ceil(nt2::Inf<cT>()), nt2::Inf<cT>());
  NT2_TEST_EQUAL(ceil(nt2::Minf<cT>()), nt2::Minf<cT>());
  NT2_TEST_EQUAL(ceil(nt2::Mone<cT>()), nt2::Mone<cT>());
  NT2_TEST_EQUAL(ceil(nt2::Nan<cT>()), nt2::Nan<cT>());
  NT2_TEST_EQUAL(ceil(nt2::One<cT>()), nt2::One<cT>());
  NT2_TEST_EQUAL(ceil(nt2::Zero<cT>()), nt2::Zero<cT>());
  NT2_TEST_EQUAL(ceil(dT(-1.1)), T(-1));
  NT2_TEST_EQUAL(ceil(dT(1.1)), T(2));
  NT2_TEST_EQUAL(ceil(dT(nt2::Inf<T>())), dT(nt2::Inf<T>()));
  NT2_TEST_EQUAL(ceil(dT(nt2::Minf<T>())), dT(nt2::Minf<T>()));
  NT2_TEST_EQUAL(ceil(dT(nt2::Mone<T>())), dT(nt2::Mone<T>()));
  NT2_TEST_EQUAL(ceil(dT(nt2::Nan<T>())), dT(nt2::Nan<T>()));
  NT2_TEST_EQUAL(ceil(dT(nt2::One<T>())), dT(nt2::One<T>()));
  NT2_TEST_EQUAL(ceil(dT(nt2::Zero<T>())), dT(nt2::Zero<T>()));
  NT2_TEST_EQUAL(ceil(ciT(-1.1)), ciT(-1));
  NT2_TEST_EQUAL(ceil(ciT(1.1)), ciT(2));
  NT2_TEST_EQUAL(ceil(nt2::Inf<ciT>()), nt2::Inf<ciT>());
  NT2_TEST_EQUAL(ceil(nt2::Minf<ciT>()), nt2::Minf<ciT>());
  NT2_TEST_EQUAL(ceil(nt2::Mone<ciT>()), nt2::Mone<ciT>());
  NT2_TEST_EQUAL(ceil(nt2::Nan<ciT>()), nt2::Nan<ciT>());
  NT2_TEST_EQUAL(ceil(nt2::One<ciT>()), nt2::One<ciT>());
  NT2_TEST_EQUAL(ceil(nt2::Zero<ciT>()), nt2::Zero<ciT>());
} // end of test for floating_