本文整理汇总了C++中A1::extent方法的典型用法代码示例。如果您正苦于以下问题:C++ A1::extent方法的具体用法?C++ A1::extent怎么用?C++ A1::extent使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类A1
的用法示例。
在下文中一共展示了A1::extent方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: operator
result_type operator()(A0& yi, A1& inputs) const
{
yi.resize(inputs.extent());
const child0 & x = boost::proto::child_c<0>(inputs);
if (numel(x) <= 1)
BOOST_ASSERT_MSG(numel(x) > 1, "Interpolation requires at least two sample points in each dimension.");
else
{
BOOST_ASSERT_MSG(issorted(x, 'a'), "for 'nearest' interpolation x values must be sorted in ascending order");
const child1 & y = boost::proto::child_c<1>(inputs);
BOOST_ASSERT_MSG(numel(x) == numel(y), "The grid vectors do not define a grid of points that match the given values.");
const child2 & xi = boost::proto::child_c<2>(inputs);
bool extrap = false;
value_type extrapval = Nan<value_type>();
choices(inputs, extrap, extrapval, N1());
table<index_type> index = bsearch (x, xi);
table<value_type> dx = xi-x(index);
table<index_type> indexp1 = oneplus(index);
yi = y(nt2::if_else(lt(nt2::abs(xi-x(index)), nt2::abs(xi-x(indexp1))), index, indexp1));
value_type b = value_type(x(begin_));
value_type e = value_type(x(end_));
if (!extrap) yi = nt2::if_else(nt2::logical_or(boost::simd::is_nge(xi, b),
boost::simd::is_nle(xi, e)), extrapval, yi);
}
return yi;
}
示例2: if
BOOST_FORCEINLINE result_type
operator()(A0& a0, A1& a1) const
{
a0.resize(a1.extent());
input_type input = boost::proto::child_c<0>(a1);
extent_type ext = input.extent();
std::size_t dim = nt2::ndims(ext);
std::size_t red = reduction_dim(a1, boost::mpl::bool_<!(boost::proto::arity_of<A1>::value <= 1)>());
#if 0
if((red - 1 < ext.size() && ext[red-1] == 1) || ext.size() < red)
return nt2::run_assign(a0, input);
#endif
if(dim == 1 && red == 1)
{
nt2::run( a0, 0u
, nt2::fold( input
, typename nt2::make_functor<Neutral1, A0>::type()
, typename nt2::make_functor<O1, A0>::type()
, typename nt2::make_functor<T1, A0>::type()
)
);
}
else if(red == 1)
{
nt2::inner_fold( a0
, input
, typename nt2::make_functor<Neutral1, A0>::type()
, typename nt2::make_functor<O1, A0>::type()
, typename nt2::make_functor<T1, A0>::type()
);
}
#if 0
else if(red == ext.size())
{
nt2::outer_fold( a0
, input
, typename nt2::make_functor<Neutral1, A0>::type()
, typename nt2::make_functor<O1, A0>::type()
, typename nt2::make_functor<T1, A0>::type()
);
}
#endif
else
{
std::size_t inner = red-1 < ext.size() ? ext[red-1] : 1;
std::size_t lo = std::accumulate( ext.begin()
, ext.begin()+std::min(red-1, dim)
, std::size_t(1)
, std::multiplies<std::size_t>()
);
std::size_t hi = std::accumulate( ext.begin()+std::min(red, dim)
, ext.begin()+dim
, std::size_t(1)
, std::multiplies<std::size_t>()
);
nt2::partial_fold( reshape(a0, of_size(lo, hi))
, reshape(input, of_size(lo, inner, hi))
, typename nt2::make_functor<Neutral1, A0>::type()
, typename nt2::make_functor<O1, A0>::type()
, typename nt2::make_functor<T1, A0>::type()
);
}
return a0;
}