예제 #1
0
NT2_TEST_CASE_TPL ( complement_integer__1_0,  NT2_INTEGRAL_TYPES)
{

  using nt2::complement;
  using nt2::tag::complement_;
  typedef typename nt2::meta::as_integer<T>::type iT;
  typedef typename nt2::meta::call<complement_(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 T 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_EQUAL(complement(nt2::Mone<T>()), nt2::Zero<r_t>());
  NT2_TEST_EQUAL(complement(nt2::One<T>()), nt2::shli(nt2::Mone<r_t>(),1));
  NT2_TEST_EQUAL(complement(nt2::Three<T>()), nt2::shli(nt2::Mone<r_t>(),2));
  NT2_TEST_EQUAL(complement(nt2::Zero<T>()), nt2::Mone<r_t>());
} // end of test for integer_
예제 #2
0
NT2_TEST_CASE_TPL ( complement_integer__1_0,  NT2_SIMD_INTEGRAL_TYPES)
{
  using nt2::complement;
  using nt2::tag::complement_;
  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<complement_(vT)>::type r_t;
  typedef typename nt2::meta::call<complement_(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_EQUAL(complement(nt2::Mone<vT>())[0], nt2::Zero<sr_t>());
  NT2_TEST_EQUAL(complement(nt2::One<vT>())[0], nt2::shli(nt2::Mone<sr_t>(),1));
  NT2_TEST_EQUAL(complement(nt2::Three<vT>())[0], nt2::shli(nt2::Mone<sr_t>(),2));
  NT2_TEST_EQUAL(complement(nt2::Zero<vT>())[0], nt2::Mone<sr_t>());
} // end of test for integer_
예제 #3
0
NT2_TEST_CASE_TPL ( complement_integer__1_0,  NT2_SIMD_INTEGRAL_TYPES)
{
  using nt2::complement;
  using nt2::tag::complement_;
  using nt2::aligned_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<complement_(vT)>::type r_t;
  typedef typename nt2::meta::call<complement_(T)>::type sr_t;
  typedef typename nt2::meta::scalar_of<r_t>::type ssr_t;

  // random verifications
  static const nt2::uint32_t NR = NT2_NB_RANDOM_TEST;
  {
    NT2_CREATE_BUF(tab_a0,T, NR, nt2::Valmin<T>()/2, nt2::Valmax<T>()/2);
    for(nt2::uint32_t j = 0; j < NR;j+=cardinal_of<n_t>::value)
      {
        vT a0 = aligned_load<vT>(&tab_a0[0],j);
        r_t v = complement(a0);
        for(nt2::uint32_t i = 0; i< cardinal_of<n_t>::value; i++)
        {

          NT2_TEST_EQUAL( v[i],ssr_t(nt2::complement (a0[i])));
        }
      }

  }
} // end of test for integer_
예제 #4
0
파일: complement.cpp 프로젝트: atyuwen/nt2
NT2_TEST_CASE_TPL ( complement_real__1_0,  NT2_SIMD_REAL_TYPES)
{
  using nt2::complement;
  using nt2::tag::complement_;
  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<complement_(vT)>::type r_t;
  typedef typename nt2::meta::call<complement_(T)>::type sr_t;
  typedef typename nt2::meta::scalar_of<r_t>::type ssr_t;



  // specific values tests
  NT2_TEST_EQUAL(complement(nt2::Nan<vT>())[0], nt2::Zero<sr_t>());
  NT2_TEST_EQUAL(complement(nt2::Zero<vT>())[0], nt2::Nan<sr_t>());
} // end of test for floating_