23 #ifndef NDARRAY_DETAIL_ViewBuilder_h_INCLUDED
24 #define NDARRAY_DETAIL_ViewBuilder_h_INCLUDED
31 #include <boost/fusion/include/push_back.hpp>
32 #include <boost/fusion/include/pop_back.hpp>
33 #include <boost/fusion/include/front.hpp>
34 #include <boost/fusion/include/back.hpp>
35 #include <boost/fusion/include/vector.hpp>
36 #include <boost/fusion/include/reverse_view.hpp>
37 #include <boost/fusion/include/mpl.hpp>
38 #include <boost/fusion/include/at.hpp>
39 #include <boost/fusion/include/at_c.hpp>
40 #include <boost/fusion/tuple.hpp>
41 #include <boost/mpl/count.hpp>
42 #include <boost/mpl/size.hpp>
43 #include <boost/mpl/fold.hpp>
52 template <
typename T,
int M,
int N>
64 template <
int M1,
int N1>
69 template <
int N,
int C,
int I>
71 typedef boost::mpl::int_<N>
ND;
72 typedef boost::mpl::int_<C>
RMC;
73 typedef boost::mpl::int_<I>
IDX;
74 typedef boost::mpl::int_<N-I>
N_I;
86 ((D::RMC::value < D::N_I::value) ? D::RMC::value : (D::N_I::value - 1)),
92 template <
typename T,
int M,
int N>
struct TransformCoreResult {
97 template <
typename T,
int M,
int N>
116 template <
typename D>
120 ((D::RMC::value < D::N_I::value) ? D::RMC::value : D::N_I::value),
126 template <
typename T,
int M,
int N>
struct TransformCoreResult {
131 template <
typename T,
int M,
int N>
148 template <
typename D>
158 template <
typename T,
int M,
int N>
struct TransformCoreResult {
163 template <
typename T,
int M,
int N>
176 template <
typename D>
180 ((D::RMC::value < (D::N_I::value - 1)) ? D::RMC::value : (D::N_I::value - 1)),
186 template <
typename T,
int M,
int N>
struct TransformCoreResult {
191 template <
typename T,
int M,
int N>
202 template <
typename T,
int M,
int N,
typename Index>
203 typename IndexTraits<Index>::template TransformCoreResult<T,M,N>::Type
210 template <
typename State,
typename Index>
217 template <
int N,
int C,
typename Seq_,
bool isColumnMajor = (C < 0)>
220 template <
int N,
int C,
typename Seq_>
225 typedef typename Dims::ND
ND;
226 typedef typename Dims::RMC
RMC;
230 template <
int N,
int C,
typename Seq_>
233 typedef typename boost::mpl::fold<
234 boost::fusion::reverse_view< typename boost::fusion::result_of::as_vector<Seq_>::type >,
238 typedef typename Dims::ND
ND;
239 typedef typename boost::mpl::negate<typename Dims::RMC>::type
RMC;
247 template <int N, typename Seq_, bool IsNormalized=(boost::mpl::template size<Seq_>::type::value==N)>
250 typedef typename boost::fusion::result_of::push_back<Seq_ const,index::Full>::type
Next;
254 static Output
apply(Seq_
const & input) {
261 template <
int N,
typename Seq_>
263 typedef typename boost::fusion::result_of::as_vector<Seq_>::type
Output;
264 static Output apply(Seq_
const & input) {
return boost::fusion::as_vector(input); }
271 template <
typename Array_,
typename InSeq>
297 std::pair<Element*,typename OutputCore::Ptr>
final =
process(normSeq, initial);
301 template <
int M,
int N>
302 static std::pair<Element*,typename OutputCore::Ptr>
307 static std::pair<Element*,typename OutputCore::Ptr>
309 return std::make_pair(t.
_data, boost::static_pointer_cast<OutputCore>(t.
_output));
318 template <
typename Array_,
typename Seq_>
319 typename ViewBuilder<Array_, Seq_>::OutputArray
328 #endif // !NDARRAY_DETAIL_ViewBuilder_h_INCLUDED
A proxy class for Array with deep assignment operators.
static Ptr create(Vector< int, M > const &shape, Vector< int, M > const &strides, Manager::Ptr const &manager=Manager::Ptr())
Create a Core::Ptr with the given shape, strides, and manager.
int getStride() const
Return the stride of the Nth dimension.
ViewTraits< InputND::value, InputRMC::value, NormSeq > OutputTraits
static CoreTransformer< T, M-1, N-1 > transformCore(ndarray::index::Full const &, CoreTransformer< T, M, N > &t)
Apply a full dimension index.
int getSize() const
Return the size of the Nth dimension.
boost::mpl::int_< I > IDX
boost::fusion::result_of::as_vector< Seq_ >::type Output
Dimensions< (D::ND::value-1),((D::RMC::value< (D::N_I::value-1))?D::RMC::value:(D::N_I::value-1)),(D::IDX::value+1) > Type
IndexTraits< Index >::template TransformCoreResult< T, M, N >::Type transformCore(Index const &index, CoreTransformer< T, M, N > &t)
boost::intrusive_ptr< Core > Ptr
intrusive_ptr to Core
Simple structure defining a contiguous range of indices.
boost::mpl::fold< Seq_, Dimensions< N, C, 0 >, AppendIndex >::type Dims
ViewNormalizer< InputND::value, InSeq > Normalizer
ViewNormalizer< N, Next >::Output Output
ExpressionTraits< Array_ > Traits
static Array_ construct(Element *data, CorePtr const &core)
boost::mpl::int_< C > RMC
Core< OutputND::value > OutputCore
Simple structure defining a noncontiguous range of indices.
boost::mpl::negate< typename Dims::RMC >::type RMC
static std::pair< Element *, typename OutputCore::Ptr > process(NormSeq const &seq, CoreTransformer< Element, M, N > t)
static Output apply(Seq_ const &input)
OutputTraits::ND OutputND
#define NDARRAY_ASSERT(ARG)
static std::pair< Element *, typename OutputCore::Ptr > process(NormSeq const &seq, CoreTransformer< Element, 0, 0 > t)
IndexTraits< Index >::template Append< State >::Type type
static CoreTransformer< T, M-1, N-1 > transformCore(ndarray::index::Range const &index, CoreTransformer< T, M, N > &t)
Apply a range index.
Empty structure marking a view of an entire dimension.
boost::mpl::bool_<(InputRMC::value< 0)> IsColumnMajor
static CoreTransformer< T, M-1, N > transformCore(ndarray::index::Scalar const &index, CoreTransformer< T, M, N > &t)
Apply a scalar dimension index.
static OutputArray apply(Array_ const &array, InSeq const &seq)
Structure marking a single element of a dimension.
static CorePtr const & getCore(Array_ const &array)
static Output apply(Seq_ const &input)
ViewNormalizer< InputND::value, InSeq >::Output NormSeq
OutputTraits::RMC OutputRMC
ArrayRef< Element, OutputND::value, OutputRMC::value > OutputArray
boost::fusion::result_of::push_back< Seq_ const, index::Full >::type Next
boost::mpl::fold< boost::fusion::reverse_view< typename boost::fusion::result_of::as_vector< Seq_ >::type >, Dimensions< N,-C, 0 >, AppendIndex >::type Dims
boost::mpl::int_< N-I > N_I
Public interface for arbitrary views into arrays.
ViewBuilder< Array_, Seq_ >::OutputArray buildView(Array_ const &array, Seq_ const &seq)
static CoreTransformer< T, M-1, N-1 > transformCore(ndarray::index::Slice const &index, CoreTransformer< T, M, N > &t)
Apply a slice index.
Dimensions< D::ND::value,((D::RMC::value< D::N_I::value)?D::RMC::value:(D::N_I::value-1)),(D::IDX::value+1) > Type