本文整理汇总了C++中nt2::compare_less方法的典型用法代码示例。如果您正苦于以下问题:C++ nt2::compare_less方法的具体用法?C++ nt2::compare_less怎么用?C++ nt2::compare_less使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类nt2
的用法示例。
在下文中一共展示了nt2::compare_less方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: NT2_TEST_CASE_TPL
NT2_TEST_CASE_TPL ( compare_less_real__2_0, NT2_REAL_TYPES)
{
using nt2::compare_less;
using nt2::tag::compare_less_;
typedef typename nt2::meta::as_integer<T>::type iT;
typedef typename nt2::meta::call<compare_less_(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 nt2::logical<T> 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(compare_less(nt2::Inf<T>(), nt2::Inf<T>()), ssr_t(false));
NT2_TEST_EQUAL(compare_less(nt2::Minf<T>(), nt2::Minf<T>()), ssr_t(false));
NT2_TEST_EQUAL(compare_less(nt2::Nan<T>(), nt2::Nan<T>()), ssr_t(false));
NT2_TEST_EQUAL(compare_less(nt2::One<T>(),nt2::Zero<T>()), ssr_t(false));
NT2_TEST_EQUAL(compare_less(nt2::Zero<T>(), nt2::Zero<T>()), ssr_t(false));
} // end of test for floating_
示例2: NT2_TEST_CASE_TPL
NT2_TEST_CASE_TPL ( compare_less_real__2_0, NT2_REAL_TYPES)
{
using nt2::compare_less;
using nt2::tag::compare_less_;
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<compare_less_(vT,vT)>::type r_t;
typedef typename nt2::meta::call<compare_less_(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, nt2::Valmin<T>()/2, nt2::Valmax<T>()/2);
// NT2_CREATE_BUF(tab_a1,T, NR, nt2::Valmin<T>()/2, nt2::Valmax<T>()/2);
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(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 = compare_less(a0,a1);
std::cout << a0 << " " << a1 << std::endl;
bool zz = std::lexicographical_compare(a0.begin(), a0.end(), a1.begin(), a1.end());
std::cout << "std::lexicographical_compare(a0.begin(), a0.end(), a1.begin(), a1.end()) " << std::lexicographical_compare(a0.begin(), a0.end(), a1.begin(), a1.end())<< std::endl;
std::cout <<"compare_less(a0,a1)" << compare_less(a0,a1) << std::endl;
// bool z = false;
// for(int i = 0; i< cardinal_of<n_t>::value; ++i)
// {
// if (a0[i]<a1[i]) {z=true;break;}
// else if (a0[i]> a1[i]){z=false; break;}
// }
// NT2_TEST_EQUAL( v,z);
NT2_TEST_EQUAL( v,zz);
}
}
} // end of test for real_
示例3: NT2_TEST_CASE_TPL
NT2_TEST_CASE_TPL ( compare_less_signed_int__2_0, NT2_SIMD_INTEGRAL_SIGNED_TYPES)
{
using nt2::compare_less;
using nt2::tag::compare_less_;
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<compare_less_(vT,vT)>::type r_t;
typedef typename nt2::meta::call<compare_less_(T,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);
NT2_CREATE_BUF(tab_a1,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);
vT a1 = aligned_load<vT>(&tab_a1[0],j);
r_t v = compare_less(a0,a1);
bool z = false;
for(nt2::uint32_t i = 0; i< cardinal_of<n_t>::value; ++i)
{
if (a0[i]<a1[i]) {z=true;break;}
else if (a0[i]>a1[i]){z=false; break;}
}
NT2_TEST_EQUAL( v,sr_t(z));
}
}
} // end of test for signed_int_