当前位置: 首页>>代码示例>>C++>>正文


C++ ndarray::fbegin方法代码示例

本文整理汇总了C++中types::ndarray::fbegin方法的典型用法代码示例。如果您正苦于以下问题:C++ ndarray::fbegin方法的具体用法?C++ ndarray::fbegin怎么用?C++ ndarray::fbegin使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在types::ndarray的用法示例。


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

示例1: outer

 types::ndarray<decltype(std::declval<T0>() + std::declval<T1>()), 2>
 outer(types::ndarray<T0, N0> const& a, types::ndarray<T1, N1> const& b)
 {
     types::ndarray<decltype(std::declval<T0>() + std::declval<T1>()), 2> out(types::array<long, 2>{{a.flat_size(), b.flat_size()}}, __builtin__::None);
     auto iter = out.fbegin();
     for(auto iter_a = a.fbegin(), end_a = a.fend(); iter_a != end_a; ++iter_a) {
         auto val_a = *iter_a;
         iter = std::transform(b.fbegin(),  b.fend(), iter, [=](T1 val) { return val_a * val; });
     }
     return out;
 }
开发者ID:Pikalchemist,项目名称:pythran,代码行数:11,代码来源:outer.hpp

示例2: resize

types::ndarray<T,1> resize(types::ndarray<T,N> const& expr, int new_shape)
{
    types::ndarray<T,1> out(types::array<long, N> {{new_shape}}, __builtin__::None);
    auto n = expr.size();
    if(n < new_shape) {
        auto iter = std::copy(expr.fbegin(), expr.fend(), out.fbegin());
        for(size_t i = 1; i < new_shape / n; ++i)
            iter = std::copy(out.fbegin(), out.fbegin() + n, iter);
        std::copy(out.fbegin(), out.fbegin() + new_shape % n, iter);
    }
    else
        std::copy(expr.fbegin(), expr.fbegin() + new_shape, out.fbegin());
    return out;
}
开发者ID:baoboa,项目名称:pythran,代码行数:14,代码来源:resize.hpp

示例3: decltype

 types::ndarray<
 typename std::remove_cv<
 typename std::remove_reference<
 decltype(
         std::declval<T>()
         +
         std::declval<typename utils::nested_container_value_type<F>::type>())
 >::type
 >::type,
 1> append(types::ndarray<T,N> const& nto, F const& data) {
     typename types::numpy_expr_to_ndarray<F>::type ndata(data);
     long nsize = nto.size() + ndata.size();
     types::ndarray<
         typename std::remove_cv<
         typename std::remove_reference<
         decltype(
                 std::declval<T>()
                 +
                 std::declval<typename utils::nested_container_value_type<F>::type>())
         >::type
         >::type,
         1> out(types::make_tuple(nsize), __builtin__::None);
     size_t i=0;
     auto out_back = std::copy(nto.fbegin(), nto.fend(), out.fbegin());
     std::copy(ndata.fbegin(), ndata.fend(), out_back);
     return out;
 }
开发者ID:OnlySang,项目名称:pythran,代码行数:27,代码来源:append.hpp

示例4: put

 types::none_type put(types::ndarray<T, N> &expr, long int ind, T const &v)
 {
   if (ind >= expr.flat_size() || ind < 0)
     throw types::ValueError("indice out of bound");
   *(expr.fbegin() + ind) = v;
   return __builtin__::None;
 }
开发者ID:artas360,项目名称:pythran,代码行数:7,代码来源:put.hpp

示例5: roll

 types::ndarray<T,N> roll(types::ndarray<T,N> const& expr, long shift)
 {
     while(shift<0) shift+=expr.flat_size();
     shift %=expr.flat_size();
     types::ndarray<T,N> out(expr.shape(), __builtin__::None);
     std::copy(expr.fbegin(), expr.fend() - shift, std::copy(expr.fend() - shift, expr.fend(), out.fbegin()));
     return out;
 }
开发者ID:coyotte508,项目名称:pythran,代码行数:8,代码来源:roll.hpp

示例6: take

 typename types::numpy_expr_to_ndarray<F>::type take(types::ndarray<T,N> const & expr, F const& indices)
 {
     typename types::numpy_expr_to_ndarray<F>::type out = asarray(indices);
     auto expr_iter = expr.fbegin();
     for(auto out_iter = out.fbegin(), out_end = out.fend(); out_iter != out_end; ++out_iter)
         *out_iter = *(expr_iter + *out_iter);
     return out;
 }
开发者ID:OnlySang,项目名称:pythran,代码行数:8,代码来源:take.hpp

示例7: place

 types::none_type place(types::ndarray<T, N> &expr,
                        types::ndarray<Tp, Np> const &mask, F const &values)
 {
   auto first = expr.fend();
   auto viter = values.begin(), vend = values.end();
   auto miter = mask.fbegin();
   for (auto iter = expr.fbegin(), end = expr.fend(); iter != end;
        ++iter, ++miter) {
     if (*miter) {
       if (first == expr.fend())
         first = iter;
       if (viter != vend) {
         *iter = *viter;
         ++viter;
       } else
         *iter = *first;
     }
   }
   return __builtin__::None;
 }
开发者ID:LuisBL,项目名称:pythran,代码行数:20,代码来源:place.hpp

示例8: repeat

 types::ndarray<T, 1> repeat(types::ndarray<T, N> const &expr, int repeats)
 {
   types::ndarray<T, 1> out(
       types::array<long, 1>{{expr.flat_size() * repeats}},
       __builtin__::None);
   auto out_iter = out.fbegin();
   for (auto iter = expr.fbegin(), end = expr.fend(); iter != end; ++iter)
     for (int i = 0; i < repeats; ++i)
       *out_iter++ = *iter;
   return out;
 }
开发者ID:artas360,项目名称:pythran,代码行数:11,代码来源:repeat.hpp

示例9: putmask

 types::none_type putmask(types::ndarray<T, pS> &expr, E const &mask,
                          F const &values)
 {
   auto amask = asarray(mask);
   auto avalues = asarray(values);
   auto iexpr = expr.fbegin();
   auto n = avalues.flat_size();
   for (long i = 0; i < expr.flat_size(); ++i)
     if (*(amask.fbegin() + i))
       *(iexpr + i) = *(avalues.fbegin() + i % n);
   return __builtin__::None;
 }
开发者ID:serge-sans-paille,项目名称:pythran,代码行数:12,代码来源:putmask.hpp

示例10: ValueError

 typename std::enable_if<types::is_numexpr_arg<F>::value,
                         types::none_type>::type
 put(types::ndarray<T, N> &expr, F const &ind, E const &v)
 {
   auto vind = asarray(ind);
   auto vv = asarray(v);
   for (long i = 0; i < ind.flat_size(); ++i) {
     auto val = *(vind.fbegin() + i);
     if (val >= expr.flat_size() || val < 0)
       throw types::ValueError("indice out of bound");
     *(expr.fbegin() + val) = *(vv.fbegin() + i % vv.flat_size());
   }
   return __builtin__::None;
 }
开发者ID:artas360,项目名称:pythran,代码行数:14,代码来源:put.hpp

示例11: argsort

 types::ndarray<long, N> argsort(types::ndarray<T,N> const& a) {
     size_t last_axis = a.shape[N-1];
     size_t n = a.flat_size();
     types::ndarray<long, N> indices(a.shape, __builtin__::None);
     for(long j=0, * iter_indices = indices.buffer, *end_indices = indices.buffer + n;
             iter_indices != end_indices;
             iter_indices += last_axis, j+=last_axis)
     {
         // fill with the original indices
         std::iota(iter_indices, iter_indices + last_axis, 0L);
         // sort the index using the value from a
         std::sort(iter_indices, iter_indices + last_axis,
                 [&a,j](long i1, long i2) {return *(a.fbegin() + j + i1) < *(a.fbegin() + j + i2);});
     }
     return indices;
 }
开发者ID:Pikalchemist,项目名称:pythran,代码行数:16,代码来源:argsort.hpp

示例12: item

 T item(types::ndarray<T, N> const& expr, long i)
 {
     if(i<0) i += expr.size();
     return *(expr.fbegin() + i);
 }
开发者ID:OnlySang,项目名称:pythran,代码行数:5,代码来源:item.hpp

示例13: fill

 types::none_type fill(types::ndarray<T, N> &e, F f)
 {
   std::fill(e.fbegin(), e.fend(), f);
   return __builtin__::None;
 }
开发者ID:LuisBL,项目名称:pythran,代码行数:5,代码来源:fill.hpp


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