• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C++ nt2类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中nt2的典型用法代码示例。如果您正苦于以下问题:C++ nt2类的具体用法?C++ nt2怎么用?C++ nt2使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



在下文中一共展示了nt2类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: NT2_TEST_CASE_TPL

NT2_TEST_CASE_TPL ( seladd_real__2_0,  NT2_REAL_TYPES)
{
  using nt2::seladd;
  using nt2::tag::seladd_;
  using nt2::logical;

  typedef std::complex<T> cT;
  NT2_TEST_TYPE_IS( typename nt2::meta::call<seladd_(logical<T>, cT, cT)>::type
                  , cT
                  );

  // specific values tests
  NT2_TEST_EQUAL(seladd(nt2::False< logical<T> >(), cT(1), cT(0, 1)), cT(1));
  NT2_TEST_EQUAL(seladd(nt2::True< logical<T> >(),cT(1),cT(0, 1)), cT(1, 1));
  NT2_TEST_EQUAL(seladd(nt2::Inf<cT>(), cT(1),cT(0, 1)), cT(1, 1));
  NT2_TEST_EQUAL(seladd(nt2::Minf<cT>(), cT(1),cT(0, 1)),  cT(1, 1));
  NT2_TEST_EQUAL(seladd(nt2::Nan<cT>(), cT(1),cT(0, 1)) ,  cT(1, 1));
  NT2_TEST_EQUAL(seladd(nt2::Zero<cT>(), cT(1),cT(0, 1)),  cT(1));

  NT2_TEST_EQUAL(seladd(nt2::False< logical<T> >(), T(1), cT(0, 1)), cT(1));
  NT2_TEST_EQUAL(seladd(nt2::True< logical<T> >(),T(1),cT(0, 1)), cT(1, 1));
  NT2_TEST_EQUAL(seladd(nt2::Inf<cT>(), T(1),cT(0, 1)), cT(1, 1));
  NT2_TEST_EQUAL(seladd(nt2::Minf<cT>(), T(1),cT(0, 1)),  cT(1, 1));
  NT2_TEST_EQUAL(seladd(nt2::Nan<cT>(), T(1),cT(0, 1)) ,  cT(1, 1));
  NT2_TEST_EQUAL(seladd(nt2::Zero<cT>(), T(1),cT(0, 1)),  cT(1));

  NT2_TEST_EQUAL(seladd(nt2::False< logical<T> >(),cT(0, 1),  T(1)),  cT(0, 1));
  NT2_TEST_EQUAL(seladd(nt2::True< logical<T> >(), cT(0, 1),  T(1)),  cT(1, 1));
  NT2_TEST_EQUAL(seladd(nt2::Inf<cT>(),            cT(0, 1),  T(1)),  cT(1, 1));
  NT2_TEST_EQUAL(seladd(nt2::Minf<cT>(),           cT(0, 1),  T(1)),  cT(1, 1));
  NT2_TEST_EQUAL(seladd(nt2::Nan<cT>(),            cT(0, 1),  T(1)),  cT(1, 1));
  NT2_TEST_EQUAL(seladd(nt2::Zero<cT>(),           cT(0, 1),  T(1)),  cT(0, 1));

  NT2_TEST_EQUAL(seladd(nt2::Inf<T>(),             cT(0, 1),  T(1)),  cT(1, 1));
  NT2_TEST_EQUAL(seladd(nt2::Minf<T>(),            cT(0, 1),  T(1)),  cT(1, 1));
  NT2_TEST_EQUAL(seladd(nt2::Nan<T>(),             cT(0, 1),  T(1)),  cT(1, 1));
  NT2_TEST_EQUAL(seladd(nt2::Zero<T>(),            cT(0, 1),  T(1)),  cT(0, 1));


} // end of test for floating_
开发者ID:fpelliccioni,项目名称:nt2,代码行数:40,代码来源:seladd.cpp


示例2: NT2_TEST_EQUAL

  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<firstbitset_(vT)>::type r_t;
  typedef typename nt2::meta::call<firstbitset_(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(firstbitset(nt2::Inf<vT>())[0], 8388608u);
  NT2_TEST_EQUAL(firstbitset(nt2::Minf<vT>())[0], 8388608u);
  NT2_TEST_EQUAL(firstbitset(nt2::Nan<vT>())[0], nt2::One<sr_t>());
  NT2_TEST_EQUAL(firstbitset(nt2::Signmask<vT>())[0], nt2::One<sr_t>()+nt2::Valmax<sr_t>()/2);
  NT2_TEST_EQUAL(firstbitset(nt2::Zero<vT>())[0], nt2::Zero<sr_t>());
} // end of test for float

NT2_TEST_CASE_TPL ( firstbitset_double_1_0,  (double))
{
  using nt2::firstbitset;
  using nt2::tag::firstbitset_;
  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;
开发者ID:pesterie,项目名称:nt2,代码行数:31,代码来源:firstbitset.cpp


示例3: NT2_TEST_CASE_TPL

NT2_TEST_CASE_TPL ( fast_sincosd_unsigned_int__1_0,  NT2_UNSIGNED_TYPES)
{
  
  using nt2::fast_sincosd;
  using nt2::tag::fast_sincosd_;
  typedef typename boost::result_of<nt2::meta::floating(T)>::type ftype;
  typedef typename nt2::meta::as_integer<T>::type iT;
  typedef typename nt2::meta::call<fast_sincosd_(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 boost::fusion::tuple<ftype,ftype> 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
  typedef typename nt2::meta::strip<typename boost::fusion::result_of::at_c<r_t,0>::type>::type r_t0;
  typedef typename nt2::meta::strip<typename boost::fusion::result_of::at_c<r_t,1>::type>::type r_t1;
  {
    r_t res = fast_sincosd(nt2::Zero<T>());
    NT2_TEST_TUPLE_ULP_EQUAL( boost::fusion::get<0>(res), nt2::Zero<r_t0>(), 0.75);
    NT2_TEST_TUPLE_ULP_EQUAL( boost::fusion::get<1>(res), nt2::One<r_t0>(), 0.75);
  }
  {
    r_t res = fast_sincosd(nt2::_45<T>());
    NT2_TEST_TUPLE_ULP_EQUAL( boost::fusion::get<0>(res), nt2::Sqrt_2o_2<r_t0>(), 0.75);
    NT2_TEST_TUPLE_ULP_EQUAL( boost::fusion::get<1>(res), nt2::Sqrt_2o_2<r_t0>(), 0.75);
  }

  // specific values tests
  typedef typename nt2::meta::strip<typename boost::fusion::result_of::at_c<r_t,0>::type>::type r_t0;
  typedef typename nt2::meta::strip<typename boost::fusion::result_of::at_c<r_t,1>::type>::type r_t1;
  {
    r_t res = fast_sincosd(nt2::Zero<T>());
    NT2_TEST_TUPLE_ULP_EQUAL( boost::fusion::get<0>(res), nt2::Zero<r_t0>(), 0.75);
    NT2_TEST_TUPLE_ULP_EQUAL( boost::fusion::get<1>(res), nt2::One<r_t0>(), 0.75);
  }
  {
    r_t res = fast_sincosd(nt2::_45<T>());
    NT2_TEST_TUPLE_ULP_EQUAL( boost::fusion::get<0>(res), nt2::Sqrt_2o_2<r_t0>(), 0.75);
    NT2_TEST_TUPLE_ULP_EQUAL( boost::fusion::get<1>(res), nt2::Sqrt_2o_2<r_t0>(), 0.75);
  }

  // specific values tests
  typedef typename nt2::meta::strip<typename boost::fusion::result_of::at_c<r_t,0>::type>::type r_t0;
  typedef typename nt2::meta::strip<typename boost::fusion::result_of::at_c<r_t,1>::type>::type r_t1;
  {
    r_t res = fast_sincosd(nt2::Zero<T>());
    NT2_TEST_TUPLE_ULP_EQUAL( boost::fusion::get<0>(res), nt2::Zero<r_t0>(), 0.75);
    NT2_TEST_TUPLE_ULP_EQUAL( boost::fusion::get<1>(res), nt2::One<r_t0>(), 0.75);
  }
  {
    r_t res = fast_sincosd(nt2::_45<T>());
    NT2_TEST_TUPLE_ULP_EQUAL( boost::fusion::get<0>(res), nt2::Sqrt_2o_2<r_t0>(), 0.75);
    NT2_TEST_TUPLE_ULP_EQUAL( boost::fusion::get<1>(res), nt2::Sqrt_2o_2<r_t0>(), 0.75);
  }

  // specific values tests
  typedef typename nt2::meta::strip<typename boost::fusion::result_of::at_c<r_t,0>::type>::type r_t0;
  typedef typename nt2::meta::strip<typename boost::fusion::result_of::at_c<r_t,1>::type>::type r_t1;
  {
    r_t res = fast_sincosd(nt2::Zero<T>());
    NT2_TEST_TUPLE_ULP_EQUAL( boost::fusion::get<0>(res), nt2::Zero<r_t0>(), 0.75);
    NT2_TEST_TUPLE_ULP_EQUAL( boost::fusion::get<1>(res), nt2::One<r_t0>(), 0.75);
  }
  {
    r_t res = fast_sincosd(nt2::_45<T>());
    NT2_TEST_TUPLE_ULP_EQUAL( boost::fusion::get<0>(res), nt2::Sqrt_2o_2<r_t0>(), 0.75);
    NT2_TEST_TUPLE_ULP_EQUAL( boost::fusion::get<1>(res), nt2::Sqrt_2o_2<r_t0>(), 0.75);
  }
} // end of test for unsigned_int_
开发者ID:pesterie,项目名称:nt2,代码行数:76,代码来源:fast_sincosd.cpp


示例4: NT2_TEST_CASE_TPL

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_
开发者ID:fpelliccioni,项目名称:nt2,代码行数:28,代码来源:cscpi.cpp


示例5: NT2_TEST_CASE_TPL

                    , (T)
                    );
}

NT2_TEST_CASE_TPL( ind2sub, (double)(float)(int) )
{
  using nt2::table;
  using nt2::ind2sub;
  using nt2::of_size;
  using nt2::tie;
  using nt2::cons;
  using nt2::ones;

  table<T> inds,x,y,z,w;

  table<T> rx = cons(T(1),T(2),T(1),T(2),T(1),T(2),T(1),T(2));
  table<T> ry = cons(T(1),T(1),T(2),T(2),T(3),T(3),T(4),T(4));
  table<T> rz = cons(T(1),T(1),T(1),T(1),T(2),T(2),T(2),T(2));

  inds = cons(T(1),T(2),T(3),T(4),T(5),T(6),T(7),T(8));

  x = ind2sub(of_size(2,2,2), inds);
  NT2_TEST_EQUAL(x, inds);
  NT2_TEST_EQUAL(x.extent(), inds.extent());

  nt2::tie(x,y) = ind2sub(of_size(2,4), inds);
  NT2_TEST_EQUAL(x, rx);
  NT2_TEST_EQUAL(x.extent(), inds.extent());
  NT2_TEST_EQUAL(y, ry);
  NT2_TEST_EQUAL(y.extent(), inds.extent());
开发者ID:JanVogelgesang,项目名称:nt2,代码行数:30,代码来源:ind2sub.cpp


示例6: NT2_TEST_CASE_TPL

NT2_TEST_CASE_TPL ( iround_real__1_0,  NT2_REAL_TYPES)
{
    using nt2::iround;
    using nt2::tag::iround_;
    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;
    typedef typename nt2::meta::call<iround_(vT)>::type r_t;
    typedef typename nt2::meta::call<iround_(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(iround(nt2::splat<vT>(1.4))[0], 1, 0);
    NT2_TEST_ULP_EQUAL(iround(nt2::splat<vT>(1.5))[0], 2, 0);
    NT2_TEST_ULP_EQUAL(iround(nt2::splat<vT>(1.6))[0], 2, 0);
    NT2_TEST_ULP_EQUAL(iround(nt2::splat<vT>(2.5))[0], 2, 0);
    NT2_TEST_ULP_EQUAL(iround(nt2::Half<vT>())[0], nt2::Zero<sr_t>(), 0);
    NT2_TEST_ULP_EQUAL(iround(nt2::Inf<vT>())[0], nt2::Inf<sr_t>(), 0);
    NT2_TEST_ULP_EQUAL(iround(nt2::Mhalf<vT>())[0], nt2::Zero<sr_t>(), 0);
    NT2_TEST_ULP_EQUAL(iround(nt2::Minf<vT>())[0], nt2::Minf<sr_t>(), 0);
    NT2_TEST_ULP_EQUAL(iround(nt2::Mone<vT>())[0], nt2::Mone<sr_t>(), 0);
    NT2_TEST_ULP_EQUAL(iround(nt2::Nan<vT>())[0], nt2::Zero<sr_t>(), 0);
    NT2_TEST_ULP_EQUAL(iround(nt2::One<vT>())[0], nt2::One<sr_t>(), 0);
    NT2_TEST_ULP_EQUAL(iround(nt2::Zero<vT>())[0], nt2::Zero<sr_t>(), 0);
} // end of test for real_
开发者ID:francescog,项目名称:nt2,代码行数:34,代码来源:iround.cpp


示例7: NT2_TEST_CASE_TPL

NT2_TEST_CASE_TPL ( lcm_real__2_0,  NT2_REAL_TYPES)
{
  
  using nt2::lcm;
  using nt2::tag::lcm_;
  typedef typename nt2::meta::as_integer<T>::type iT;
  typedef typename nt2::meta::call<lcm_(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::result_of<nt2::meta::arithmetic(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(lcm(T(120),T(80)), T(240), 0);
  NT2_TEST_ULP_EQUAL(lcm(T(3),T(15)), T(15), 0);
  NT2_TEST_ULP_EQUAL(lcm(T(3),T(5)), T(15), 0);
  NT2_TEST_ULP_EQUAL(lcm(T(6),T(15)), T(30), 0);
  NT2_TEST_ULP_EQUAL(lcm(nt2::Inf<T>(), nt2::Inf<T>()), nt2::Nan<T>(), 0);
  NT2_TEST_ULP_EQUAL(lcm(nt2::Inf<T>(),T(5)), nt2::Nan<T>(), 0);
  NT2_TEST_ULP_EQUAL(lcm(nt2::Minf<T>(), nt2::Minf<T>()), nt2::Nan<T>(), 0);
  NT2_TEST_ULP_EQUAL(lcm(nt2::Mone<T>(), nt2::Mone<T>()), nt2::One<T>(), 0);
  NT2_TEST_ULP_EQUAL(lcm(nt2::Nan<T>(), nt2::Nan<T>()), nt2::Nan<T>(), 0);
  NT2_TEST_ULP_EQUAL(lcm(nt2::One<T>(), nt2::One<T>()), nt2::One<T>(), 0);
  NT2_TEST_ULP_EQUAL(lcm(nt2::Zero<T>(), nt2::Zero<T>()), nt2::Nan<T>(), 0);
} // end of test for floating_
开发者ID:ethanrublee,项目名称:nt2,代码行数:32,代码来源:lcm.cpp


示例8: NT2_TEST_CASE_TPL

NT2_TEST_CASE_TPL ( is_negative_real__1_0,  NT2_REAL_TYPES)
{

  using nt2::is_negative;
  using nt2::tag::is_negative_;
  typedef typename nt2::meta::as_integer<T>::type iT;
  typedef typename nt2::meta::call<is_negative_(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 nt2::meta::as_logical<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_EQUAL(is_negative((-nt2::Zero<T>())), nt2::True<r_t>());
  NT2_TEST_EQUAL(is_negative(nt2::Half<T>()), nt2::False<r_t>());
  NT2_TEST_EQUAL(is_negative(nt2::Inf<T>()), nt2::False<r_t>());
  NT2_TEST_EQUAL(is_negative(nt2::Minf<T>()), nt2::True<r_t>());
  NT2_TEST_EQUAL(is_negative(nt2::Mone<T>()), nt2::True<r_t>());
  NT2_TEST_EQUAL(is_negative(nt2::Mzero<T>()), nt2::True<r_t>());
  NT2_TEST_EQUAL(is_negative(nt2::Nan<T>()), nt2::True<r_t>());
  NT2_TEST_EQUAL(is_negative(nt2::One<T>()), nt2::False<r_t>());
  NT2_TEST_EQUAL(is_negative(nt2::Quarter<T>()), nt2::False<r_t>());
  NT2_TEST_EQUAL(is_negative(nt2::Two<T>()), nt2::False<r_t>());
  NT2_TEST_EQUAL(is_negative(nt2::Zero<T>()), nt2::False<r_t>());
} // end of test for floating_
开发者ID:fpelliccioni,项目名称:nt2,代码行数:29,代码来源:is_negative.cpp


示例9: NT2_TEST_CASE_TPL

NT2_TEST_CASE_TPL( cumtrapz_mat, NT2_REAL_TYPES )
{
  using nt2::table;
  using nt2::of_size;
  using nt2::cumtrapz;
  using nt2::reshape;
  using nt2::trans;
  using nt2::cons;
  using nt2::_;
  using nt2::_2D;
  using nt2::meta::as_;
  table<T> y = reshape(_(T(1), T(15)), 3, 5); // test fails if y is _2D
  table<T, _2D> r1= trans(reshape(cons(
                                    T(0  ),  T(0  ),  T(0  ), T(0   ),T( 0  ),
                                    T(1.5),  T(4.5),  T(7.5), T(10.5),T( 13.5),
                                    T(4.0),  T(10.),  T(16.0),T(22.0),T( 28.0)
                                    ), 5, 3));

  table<T, _2D> r2= trans(reshape(cons(
                                    T(0),  T(2.5), T( 8.0), T(16.5), T(28.0),
                                    T(0),  T(3.5), T(10.0), T(19.5), T(32.0),
                                    T(0),  T(4.5), T(12.0), T(22.5), T(36.0)
                                    ), 5, 3));
  table<T, _2D> r3 =  nt2::zeros(3, 5, as_<T>());

  table<T, _2D> v1 =  cumtrapz(y, 1);
  NT2_TEST_EQUAL(v1, r1);
  table<T, _2D> v2 =  cumtrapz(y, 2);
  NT2_TEST_EQUAL(v2, r2);
  table<T, _2D> v3 =  cumtrapz(y, 3);
  NT2_TEST_EQUAL(v3, r3);
}
开发者ID:JanVogelgesang,项目名称:nt2,代码行数:32,代码来源:cumtrapz.cpp


示例10: NT2_TEST_CASE_TPL

NT2_TEST_CASE_TPL ( oneplus_real__1_0,  BOOST_SIMD_REAL_TYPES)
{
  
  using nt2::oneplus;
  using nt2::tag::oneplus_;
  typedef typename boost::dispatch::meta::as_integer<T>::type iT;
  typedef typename boost::dispatch::meta::call<oneplus_(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 typename boost::common_type<T>::type wished_r_t;
  typedef typename std::complex<T> cT;
  typedef typename nt2::meta::as_imaginary<T>::type ciT;
  typedef typename nt2::meta::as_dry<T>::type dT;


  // 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(oneplus(cT(nt2::Inf<T>(), nt2::Inf<T>() ))  , cT(nt2::Inf<cT>(),nt2::Inf<T>()));
  NT2_TEST_EQUAL(oneplus(cT(nt2::Minf<T>(),nt2::Minf<T>()))  , cT(nt2::Minf<cT>(),nt2::Minf<T>()));
  NT2_TEST_EQUAL(oneplus(cT(nt2::Mone<T>(),nt2::Mone<T>()))  , cT(nt2::Zero<cT>(),nt2::Mone<T>()));
  NT2_TEST_EQUAL(oneplus(cT(nt2::Nan<T>() ,nt2::Nan<T>() ))  , cT(nt2::Nan<cT>(),nt2::Nan<T>()));
  NT2_TEST_EQUAL(oneplus(cT(nt2::One<T>() ,nt2::One<T>() ))  , cT(nt2::Two<cT>(),nt2::One<T>()));
  NT2_TEST_EQUAL(oneplus(cT(nt2::Zero<T>(),nt2::Zero<T>()))  , cT(nt2::One<cT>(),nt2::Zero<T>()));
  NT2_TEST_EQUAL(oneplus(nt2::Inf<cT>()),  nt2::Inf<cT>());
  NT2_TEST_EQUAL(oneplus(nt2::Minf<cT>()), nt2::Minf<cT>());
  NT2_TEST_EQUAL(oneplus(nt2::Mone<cT>()), nt2::Zero<cT>());
  NT2_TEST_EQUAL(oneplus(nt2::Nan<cT>()),  nt2::Nan<cT>());
  NT2_TEST_EQUAL(oneplus(nt2::One<cT>()),  nt2::Two<cT>());
  NT2_TEST_EQUAL(oneplus(nt2::Zero<cT>()), nt2::One<cT>());
} // end of test for floating_
开发者ID:KWMalik,项目名称:nt2,代码行数:37,代码来源:oneplus.cpp


示例11: NT2_TEST_CASE_TPL

NT2_TEST_CASE_TPL(norm, NT2_REAL_TYPES)
{
  typedef typename nt2::meta::as_complex<T>::type  cT;
  using nt2::norm;
  using nt2::tag::norm_;
  nt2::table<cT> n = nt2::ones(10, 1, nt2::meta::as_<cT>());
  NT2_TEST_ULP_EQUAL(norm(n, 1), nt2::Ten<T>(), 0);
  NT2_TEST_ULP_EQUAL(norm(n, 2), nt2::sqrt(nt2::Ten<T>()), 0);
  NT2_TEST_ULP_EQUAL(norm(n)   , nt2::sqrt(nt2::Ten<T>()), 0);
  NT2_TEST_ULP_EQUAL(norm(n, 3), nt2::pow(nt2::Ten<T>(), 1/T(3)), 0);
  NT2_TEST_ULP_EQUAL(norm(n, nt2::Inf<T>()), nt2::One<T>(), 0);
  NT2_TEST_ULP_EQUAL(norm(n, nt2::Minf<T>()), nt2::One<T>(), 0);

  nt2::table<cT> a = nt2::ones(10, 10, nt2::meta::as_<cT>());
  NT2_TEST_ULP_EQUAL(norm(a, 1), nt2::Ten<T>(), 0);
  NT2_TEST_ULP_EQUAL(norm(a, 2), norm(a), 0);
  NT2_TEST_ULP_EQUAL(norm(a, nt2::Inf<T>()), nt2::Ten<T>(), 0);
  NT2_TEST_ULP_EQUAL(norm(a, 'I'), nt2::Ten<T>(), 0);
  NT2_TEST_ULP_EQUAL(norm(a, '1'), nt2::Ten<T>(), 0);
  NT2_TEST_ULP_EQUAL(norm(a, 'f'), nt2::Ten<T>(), 0);
  NT2_TEST_ULP_EQUAL(norm(a, "fro"), nt2::Ten<T>(), 0);

  NT2_TEST_ULP_EQUAL(norm(a+a, 1), 2*nt2::Ten<T>(), 0);
  NT2_TEST_ULP_EQUAL(norm(a+a, 2), norm(a+a), 0);
  NT2_TEST_ULP_EQUAL(norm(a+a, nt2::Inf<T>()), 2*nt2::Ten<T>(), 0);
  NT2_TEST_ULP_EQUAL(norm(a+a, 'I'), 2*nt2::Ten<T>(), 0);
  NT2_TEST_ULP_EQUAL(norm(a+a, '1'), 2*nt2::Ten<T>(), 0);
  NT2_TEST_ULP_EQUAL(norm(a+a, 'f'), 2*nt2::Ten<T>(), 0);
  NT2_TEST_ULP_EQUAL(norm(a+a, "fro"), 2*nt2::Ten<T>(), 0);

}
开发者ID:atyuwen,项目名称:nt2,代码行数:31,代码来源:norm.cpp


示例12: NT2_TEST_CASE_TPL

NT2_TEST_CASE_TPL ( round_real__1_0,  NT2_REAL_TYPES)
{

  using nt2::round;
  using nt2::tag::round_;
  typedef typename nt2::meta::call<round_(T)>::type r_t;
  typedef T wished_r_t;

  // return type conformity test
  NT2_TEST_TYPE_IS( r_t, wished_r_t );

  // specific values tests
  NT2_TEST_ULP_EQUAL(round(T(1.4)), r_t(1), 0);
  NT2_TEST_ULP_EQUAL(round(T(1.5)), r_t(2), 0);
  NT2_TEST_ULP_EQUAL(round(T(1.6)), r_t(2), 0);
  NT2_TEST_ULP_EQUAL(round(T(2.5)), r_t(3), 0);
  NT2_TEST_ULP_EQUAL(round(nt2::Half<T>()), nt2::One<r_t>(), 0);
  NT2_TEST_ULP_EQUAL(round(nt2::Inf<T>()), nt2::Inf<r_t>(), 0);
  NT2_TEST_ULP_EQUAL(round(nt2::Mhalf<T>()), nt2::Mone<r_t>(), 0);
  NT2_TEST_ULP_EQUAL(round(nt2::Minf<T>()), nt2::Minf<r_t>(), 0);
  NT2_TEST_ULP_EQUAL(round(nt2::Mone<T>()), nt2::Mone<r_t>(), 0);
  NT2_TEST_ULP_EQUAL(round(nt2::Nan<T>()), nt2::Nan<r_t>(), 0);
  NT2_TEST_ULP_EQUAL(round(nt2::One<T>()), nt2::One<r_t>(), 0);
  NT2_TEST_ULP_EQUAL(round(nt2::Zero<T>()), nt2::Zero<r_t>(), 0);
} // end of test for floating_
开发者ID:JanVogelgesang,项目名称:nt2,代码行数:25,代码来源:round.cpp


示例13: NT2_TEST_CASE_TPL

#include <nt2/sdk/functor/meta/call.hpp>
#include <nt2/sdk/meta/as_unsigned.hpp>
#include <boost/type_traits/is_same.hpp>
#include <nt2/toolbox/arithmetic/include/dist.hpp>
#include <nt2/sdk/unit/tests.hpp>
#include <nt2/sdk/unit/module.hpp>

//////////////////////////////////////////////////////////////////////////////
// Test behavior of arithmetic components using NT2_TEST_CASE
//////////////////////////////////////////////////////////////////////////////


NT2_TEST_CASE_TPL ( dist,  (double)(nt2::uint64_t)(nt2::int64_t) 
                          (float)(nt2::uint32_t)(nt2::int32_t)  
                          (nt2::uint16_t)(nt2::int16_t)         
                          (nt2::uint8_t)(nt2::int8_t)
                  )
{
  using nt2::dist;
  using nt2::functors::dist_;

  NT2_TEST( (boost::is_same < typename nt2::meta::call<dist_(T, T)>::type
	     , typename boost::result_of<nt2::meta::arithmetic(T, T)>::type
              >::value)
           );
  NT2_TEST_EQUAL(  dist( T(42), T(12)), T(30) );
  NT2_TEST_EQUAL(  dist( T(12), T(42) ), T(30) );

}
          
开发者ID:Mathieu-,项目名称:nt2,代码行数:29,代码来源:dist.cpp


示例14: NT2_TEST_CASE_TPL

NT2_TEST_CASE_TPL ( round_real__1_0,  NT2_REAL_TYPES)
{

    using nt2::round;
    using nt2::tag::round_;
    typedef typename nt2::meta::as_integer<T>::type iT;
    typedef typename nt2::meta::call<round_(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_ULP_EQUAL(round(T(1.4)), 1, 0);
    NT2_TEST_ULP_EQUAL(round(T(1.5)), 2, 0);
    NT2_TEST_ULP_EQUAL(round(T(1.6)), 2, 0);
    NT2_TEST_ULP_EQUAL(round(T(2.5)), 2, 0);
    NT2_TEST_ULP_EQUAL(round(nt2::Half<T>()), nt2::Zero<r_t>(), 0);
    NT2_TEST_ULP_EQUAL(round(nt2::Inf<T>()), nt2::Inf<r_t>(), 0);
    NT2_TEST_ULP_EQUAL(round(nt2::Mhalf<T>()), nt2::Zero<r_t>(), 0);
    NT2_TEST_ULP_EQUAL(round(nt2::Minf<T>()), nt2::Minf<r_t>(), 0);
    NT2_TEST_ULP_EQUAL(round(nt2::Mone<T>()), nt2::Mone<r_t>(), 0);
    NT2_TEST_ULP_EQUAL(round(nt2::Nan<T>()), nt2::Nan<r_t>(), 0);
    NT2_TEST_ULP_EQUAL(round(nt2::One<T>()), nt2::One<r_t>(), 0);
    NT2_TEST_ULP_EQUAL(round(nt2::Zero<T>()), nt2::Zero<r_t>(), 0);
} // end of test for floating_
开发者ID:pyrtsa,项目名称:nt2,代码行数:33,代码来源:round.cpp


示例15: NT2_TEST_CASE_TPL

#include <nt2/sdk/functor/meta/call.hpp>
#include <boost/type_traits/is_same.hpp>
#include <nt2/toolbox/arithmetic/include/rem.hpp>
#include <nt2/sdk/unit/tests.hpp>
#include <nt2/sdk/unit/module.hpp>

//////////////////////////////////////////////////////////////////////////////
// Test behavior of arithmetic components using NT2_TEST_CASE
//////////////////////////////////////////////////////////////////////////////


NT2_TEST_CASE_TPL ( rem,  (double)(nt2::uint64_t)(nt2::int64_t) 
                          (float)(nt2::uint32_t)(nt2::int32_t)  
                          (nt2::uint16_t)(nt2::int16_t)         
                          (nt2::uint8_t)(nt2::int8_t)
                  )
{
  using nt2::rem;
  using nt2::functors::rem_;

  NT2_TEST( (boost::is_same < typename nt2::meta::call<rem_(T, T)>::type
              , typename boost::result_of<nt2::meta::arithmetic(T, T)>::type
              >::value)
           );
  NT2_TEST_EQUAL(  rem( T(4), T(3)), 1 );
  NT2_TEST_EQUAL(  rem( T(5), T(3)), 2);
  NT2_TEST_EQUAL(  rem( T(6), T(3)), 0 );

}
          
开发者ID:Mathieu-,项目名称:nt2,代码行数:29,代码来源:rem.cpp


示例16: NT2_TEST_CASE_TPL

// Test behavior of bitwise components using NT2_TEST_CASE
//////////////////////////////////////////////////////////////////////////////
NT2_TEST_CASE_TPL ( rol,  (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::rol;
  using nt2::functors::rol_;

  NT2_TEST( (boost::is_same < typename nt2::meta::call<rol_(T, int)>::type
	     , T
              >::value)
           );
  NT2_TEST_EQUAL(  rol( T(1), 1), T(2) );
  NT2_TEST_EQUAL(  rol( ~T(0), 1), ~T(0) );
}
NT2_TEST_CASE_TPL ( real_rol,  (double)(float)
                  )
{
  using nt2::rol;
  using nt2::functors::rol_;

  NT2_TEST( (boost::is_same < typename nt2::meta::call<rol_(T, int)>::type
	     , T
              >::value)
           );

}
开发者ID:Mathieu-,项目名称:nt2,代码行数:30,代码来源:rol.cpp


示例17: NT2_TEST_ULP_EQUAL

  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;
开发者ID:francescog,项目名称:nt2,代码行数:31,代码来源:csc.cpp


示例18: NT2_TEST_CASE_TPL

NT2_TEST_CASE_TPL ( fast_cotd_real__1_0,  NT2_REAL_TYPES)
{
  
  using nt2::fast_cotd;
  using nt2::tag::fast_cotd_;
  typedef typename nt2::meta::as_integer<T>::type iT;
  typedef typename nt2::meta::call<fast_cotd_(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(fast_cotd(-nt2::Zero<T>()), -nt2::Inf<r_t>(), 1.0);
  NT2_TEST_ULP_EQUAL(fast_cotd(-nt2::_180<T>()), nt2::Nan<r_t>(), 1.0);
  NT2_TEST_ULP_EQUAL(fast_cotd(-nt2::_45<T>()), nt2::Mone<r_t>(), 4.0);
  NT2_TEST_ULP_EQUAL(fast_cotd(-nt2::_90<T>()), nt2::Nan<r_t>(), 1.0);
  NT2_TEST_ULP_EQUAL(fast_cotd(nt2::Inf<T>()), nt2::Nan<r_t>(), 1.0);
  NT2_TEST_ULP_EQUAL(fast_cotd(nt2::Minf<T>()), nt2::Nan<r_t>(), 1.0);
  NT2_TEST_ULP_EQUAL(fast_cotd(nt2::Nan<T>()), nt2::Nan<r_t>(), 1.0);
  NT2_TEST_ULP_EQUAL(fast_cotd(nt2::Zero<T>()), nt2::Inf<r_t>(), 1.0);
  NT2_TEST_ULP_EQUAL(fast_cotd(nt2::_180<T>()), nt2::Nan<r_t>(), 1.0);
  NT2_TEST_ULP_EQUAL(fast_cotd(nt2::_45<T>()), nt2::One<r_t>(), 4.0);
  NT2_TEST_ULP_EQUAL(fast_cotd(nt2::_90<T>()), nt2::Nan<r_t>(), 1.0);
} // end of test for real_
开发者ID:pesterie,项目名称:nt2,代码行数:32,代码来源:fast_cotd.cpp


示例19: NT2_TEST

  typedef typename nt2::meta::as_integer<T>::type iT;
  typedef typename nt2::meta::call<ffs_(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 nt2::meta::as_integer<T, unsigned>::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_EQUAL(ffs(nt2::Inf<T>()), 24u);
  NT2_TEST_EQUAL(ffs(nt2::Minf<T>()), 24u);
  NT2_TEST_EQUAL(ffs(nt2::Nan<T>()), nt2::One<r_t>());
  NT2_TEST_EQUAL(ffs(nt2::Signmask<T>()), sizeof(T)*8);
  NT2_TEST_EQUAL(ffs(nt2::Zero<T>()), nt2::Zero<r_t>());
} // end of test for float

NT2_TEST_CASE_TPL ( ffs_double_1_0,  (double))
{
  
  using nt2::ffs;
  using nt2::tag::ffs_;
  typedef typename nt2::meta::as_integer<T>::type iT;
  typedef typename nt2::meta::call<ffs_(T)>::type r_t;
  typedef typename nt2::meta::scalar_of<r_t>::type ssr_t;
  typedef typename nt2::meta::upgrade<T>::type u_t;
开发者ID:KWMalik,项目名称:nt2,代码行数:31,代码来源:ffs.cpp


示例20: NT2_TEST_CASE_TPL

NT2_TEST_CASE_TPL(sinhcosh, NT2_SIMD_REAL_TYPES)
{
  using nt2::sinhcosh;
  using nt2::tag::sinhcosh_;
  using boost::simd::native;
  typedef native<T,BOOST_SIMD_DEFAULT_EXTENSION>            vT;
  vT a[] = {nt2::Zero<vT>(), nt2::Half<vT>(), nt2::One<vT>(), nt2::splat<vT>(-5), nt2::splat<vT>(5)};
  size_t N =  sizeof(a)/sizeof(vT);
  NT2_TEST_TYPE_IS( (typename boost::dispatch::meta::call<sinhcosh_(vT)>::type)
                  , (std::pair<vT,vT>)
                  );

  {
    vT s, c;
    for(size_t i=0; i < N; ++i)
    {
      sinhcosh(a[i], s, c);
      NT2_TEST_ULP_EQUAL(s, nt2::sinh(a[i]), 1);
      NT2_TEST_ULP_EQUAL(c, nt2::cosh(a[i]), 1);
    }
  }

  {
    vT s, c;
    for(size_t i=0; i < N; ++i)
    {
      s = sinhcosh(a[i], c);
      NT2_TEST_ULP_EQUAL(s, nt2::sinh(a[i]), 1);
      NT2_TEST_ULP_EQUAL(c, nt2::cosh(a[i]), 1);
    }
  }

  {
    vT s, c;
    for(size_t i=0; i < N; ++i)
    {
      boost::fusion::vector_tie(s, c) = sinhcosh(a[i]);
      NT2_TEST_ULP_EQUAL(s, nt2::sinh(a[i]), 1);
      NT2_TEST_ULP_EQUAL(c, nt2::cosh(a[i]), 1);
    }
  }

  {
    for(size_t i=0; i < N; ++i)
    {
      std::pair<vT,vT> p = sinhcosh(a[i]);
      NT2_TEST_ULP_EQUAL(p.first,  nt2::sinh(a[i]), 1);
      NT2_TEST_ULP_EQUAL(p.second, nt2::cosh(a[i]), 1);
    }
  }

#ifndef BOOST_SIMD_NO_INVALIDS
  vT b[] = {nt2::splat<vT>(10), nt2::Inf<vT>(), nt2::Minf<vT>(), nt2::Nan<vT>()};
  N =  sizeof(b)/sizeof(vT);
  {
    vT s, c;
    for(size_t i=0; i < N; ++i)
    {
      sinhcosh(b[i], s, c);
      NT2_TEST_ULP_EQUAL(s, nt2::sinh(b[i]), 1);
      NT2_TEST_ULP_EQUAL(c, nt2::cosh(b[i]), 1);
    }
  }

  {
    vT s, c;
    for(size_t i=0; i < N; ++i)
    {
      s = sinhcosh(b[i], c);
      NT2_TEST_ULP_EQUAL(s, nt2::sinh(b[i]), 1);
      NT2_TEST_ULP_EQUAL(c, nt2::cosh(b[i]), 1);
    }
  }

  {
    vT s, c;
    for(size_t i=0; i < N; ++i)
    {
      boost::fusion::vector_tie(s, c) = sinhcosh(b[i]);
      NT2_TEST_ULP_EQUAL(s, nt2::sinh(b[i]), 1);
      NT2_TEST_ULP_EQUAL(c, nt2::cosh(b[i]), 1);
    }
  }

  {
    for(size_t i=0; i < N; ++i)
    {
      std::pair<vT,vT> p = sinhcosh(b[i]);
      NT2_TEST_ULP_EQUAL(p.first,  nt2::sinh(b[i]), 1);
      NT2_TEST_ULP_EQUAL(p.second, nt2::cosh(b[i]), 1);
    }
  }
#endif


}
开发者ID:ndoss,项目名称:nt2,代码行数:96,代码来源:sinhcosh.cpp



注:本文中的nt2类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ nuiEvent类代码示例发布时间:2022-05-31
下一篇:
C++ ns_sql类代码示例发布时间:2022-05-31
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap