Пример #1
0
 BOOST_FORCEINLINE typename Target::type
 operator()(Pos const& p, Size const&sz, Target const&) const
 {
   typedef typename Target::type                 type;
   typedef typename meta::as_index<type>::type i_t;
   return splat<type>( as_subscript(sz,enumerate<i_t>(p))[0] );
 }
Пример #2
0
    BOOST_FORCEINLINE typename Target::type
    operator()(Pos const&p , Size const& sz, Target const& ) const
    {
      typedef typename Target::type                                        type;
      typedef typename meta::as_index<type>::type                           i_t;
      typedef typename meta::
                       call<nt2::tag::enumerate_(Pos,meta::as_<i_t>)>::type p_t;
      typedef typename nt2::result_of::as_subscript<Size,p_t>::type         s_t;

      // Retrieve 2D position from the linear index
      s_t const pos = as_subscript(sz,nt2::enumerate<i_t>(p));

      // Return a diagonal of val_
      return nt2::if_else_zero(nt2::eq(pos[0],pos[1]), splat<type>(val_));
    }
Пример #3
0
    BOOST_FORCEINLINE
    result_type operator()(A0 const& a0, A1 ind, A2 dim) const
    {
      std::size_t along = dim-1;
      typename A0::extent_type ex1 = a0.extent();
      ex1[along] = 1;

      return boost::proto::make_expr< nt2::tag::line_
                                    , container::domain
                                    > ( boost::cref(a0)
                                      , along
                                      , as_index( a0.extent()
                                                , as_subscript(ex1, ind)
                                                )
                                      , nt2::linesstride(a0, dim)
                                      );
    }
Пример #4
0
    BOOST_FORCEINLINE typename Target::type
    operator()(Pos const& p, Size const& sz, Target const&) const
    {
      typedef typename Target::type                                         type;
      typedef typename meta::as_index<type>::type                            i_t;
      typedef typename meta::call<tag::enumerate_(Pos,meta::as_<i_t>)>::type p_t;
      typedef typename nt2::result_of::as_subscript<Size,p_t>::type          s_t;
      typedef typename s_t::value_type                                       v_t;

      // Retrieve 2D position from the linear index
      s_t const pos = as_subscript(sz,nt2::enumerate<i_t>(p));
      // Return a 1 where it belongs
      BOOST_AUTO_TPL(ii, nt2::splat<v_t>(i_));
      BOOST_AUTO_TPL(jj, nt2::splat<v_t>(j_));
      return nt2::if_else(nt2::logical_and(nt2::eq(pos[0],ii),
                                           nt2::eq(pos[1],jj)),
                          nt2::One<type>(), nt2::Zero<type>());
    }