CNORXZ
Container with Native Operation Routines and Expressions
Loading...
Searching...
No Matches
mrange.h
Go to the documentation of this file.
1// -*- C++ -*-
18#ifndef __cxz_mrange_h__
19#define __cxz_mrange_h__
20
21#include "base/base.h"
22#include "range_base.h"
23#include "index_base.h"
24#include "index_format.h"
25#include "index_pack.h"
26#include "xpr/xpr.h"
27
28namespace CNORXZ
29{
30
37 template <class FormatT, class... Indices>
38 class GMIndex : public IndexInterface<GMIndex<FormatT,Indices...>,
39 Tuple<typename Indices::MetaType...> >
40 {
41 public:
42
44 Tuple<typename Indices::MetaType...>> IB;
45 typedef Tuple<typename Indices::MetaType...> MetaType;
46 typedef MRange<typename Indices::RangeType...> RangeType;
47 static constexpr SizeT NI = sizeof...(Indices);
48
50
52 constexpr GMIndex() = default;
53
55 constexpr GMIndex(GMIndex&& i) = default;
56
58 constexpr GMIndex& operator=(GMIndex&& i) = default;
59
61 constexpr GMIndex(const GMIndex& i);
62
64 constexpr GMIndex& operator=(const GMIndex& i);
65
67 constexpr GMIndex(const SPack<Indices...>& pack);
68
70 constexpr GMIndex(const FormatT& format, const SPack<Indices...>& pack);
71
73 constexpr GMIndex(const Sptr<Indices>&... is);
74
76 constexpr GMIndex(const FormatT& format, const Sptr<Indices>&... is);
77
79 constexpr GMIndex(const RangePtr& range, SizeT lexpos = 0);
80
82 constexpr GMIndex(const RangePtr& range, const FormatT& format, SizeT lexpos = 0);
83
86
89
92
94 GMIndex operator+(Int n) const;
95
97 GMIndex operator-(Int n) const;
98
100 SizeT operator-(const GMIndex& i) const;
101
104
107
109 SizeT lex() const;
110
112 constexpr decltype(auto) pmax() const;
113
115 constexpr decltype(auto) lmax() const;
116
118 IndexId<0> id() const;
119
121 MetaType operator*() const;
122
124 constexpr SizeT dim() const;
125
127 Sptr<RangeType> range() const;
128
130 template <SizeT I>
131 decltype(auto) stepSize(const IndexId<I>& id) const;
132
134 String stringMeta() const;
135
137 MetaType meta() const;
138
140 GMIndex& at(const MetaType& metaPos);
141
144
146 auto deepFormat() const;
147
149 auto deepMax() const;
150
153
155 template <class Xpr, class F>
156 constexpr decltype(auto) ifor(const Xpr& xpr, F&& f) const;
157
159 bool formatIsTrivial() const;
160
162 decltype(auto) xpr(const Sptr<MIndex<Indices...>>& _this) const;
163
164 // replace sub-index instances; only use if you know what you are doing!
169
172
174 const SPack<Indices...>& pack() const;
175
177 const auto& format() const;
178
180 const auto& lexFormat() const;
181
183 GMIndex& setFormat(const FormatT& bs);
184
185 private:
186 template <SizeT... Is>
187 static constexpr decltype(auto) mkLexFormat(const SPack<Indices...>& ipack, Isq<Is...> is);
188
189 static constexpr decltype(auto) mkLMax(const SPack<Indices...>& ipack);
190
191 static constexpr decltype(auto) mkPMax(const SPack<Indices...>& ipack, const FormatT& format);
192
193 inline void mkPos();
194
195 template <SizeT... Is>
196 constexpr decltype(auto) mkIPack(Isq<Is...> is) const;
197
198 template <SizeT I>
199 inline void up();
200
201 template <SizeT I>
202 inline void down();
203
204 template <SizeT I, class Xpr, class F>
205 constexpr decltype(auto) mkIFor(const Xpr& xpr, F&& f) const;
206
207 Sptr<RangeType> mRange;
208 SPack<Indices...> mIPack;
209 typedef RemoveRef<decltype(mkLexFormat(mIPack,Isqr<1,NI>{}))> LexFormatT;
210 LexFormatT mLexFormat;
211 FormatT mFormat;
212 SizeT mLex;
213 typedef RemoveRef<decltype(mkLMax(mIPack))> LMaxT;
214 LMaxT mLMax;
215 typedef RemoveRef<decltype(mkPMax(mIPack,mFormat))> PMaxT;
216 PMaxT mPMax;
217 };
218
223 template <class FormatT, class... Indices>
226
231 template <class FormatT, class... Indices>
234
239 template <class FormatT, class... Indices>
241 { static constexpr SizeT value = sizeof...(Indices); };
242
247 template <class FormatT, class... Indices>
249 { static constexpr bool value = true; };
250
255 template <class FormatT, class... Indices>
257 { static constexpr bool value = true; };
258
263 template <class FormatT, class... Indices>
265 { static constexpr bool value = true; };
266
271 template <class... Indices>
273 {
274 static constexpr bool value = (index_expression_exists<Indices>::value and ...);
275 };
276
280 template <class... Indices>
281 constexpr decltype(auto) mindex(const Sptr<Indices>&... is);
282
286 template <class... Indices>
287 constexpr decltype(auto) mindex(const SPack<Indices...>& pack);
288
292 template <class... Indices>
293 constexpr decltype(auto) mindexPtr(const SPack<Indices...>& pack);
294
299 template <class FormatT, class... Indices>
300 constexpr decltype(auto) gmindexPtr(const FormatT& bs, const SPack<Indices...>& pack);
301
306 template <class I1, class FormatT, class... Indices>
307 decltype(auto) operator*(const Sptr<GMIndex<FormatT,Indices...>>& a, const Sptr<I1>& b);
308
313 template <class... Ranges>
315 {
316 public:
317
322
327 MRangeFactory(const Tuple<Sptr<Ranges>...>& rs, const RangePtr& ref);
328
329 private:
330 MRangeFactory() = default;
331 virtual void make() override final;
332
333 Tuple<Sptr<Ranges>...> mRs;
334 RangePtr mRef;
335 };
336
341 template <class... Ranges>
342 class MRange : public RangeInterface<MRange<Ranges...>>
343 {
344 public:
345 typedef RangeBase RB;
346 typedef MIndex<typename Ranges::IndexType...> IndexType;
347 typedef Tuple<typename Ranges::IndexType::MetaType...> MetaType;
348 static constexpr SizeT NR = sizeof...(Ranges);
349
351
352 virtual RangePtr sub(SizeT num) const override final;
360
363
368
373
374 protected:
375
378
381
386
391 private:
392
393 decltype(auto) mkA() const;
394 };
395
401
408 {
409 static Sptr<MRange<Ranges...>> func(const RangePtr& r);
410 };
411
412
413}
414
415#endif
basic headers
GMIndex & setFormat(const FormatT &bs)
Definition mrange.cc.h:608
bool formatIsTrivial() const
Definition mrange.cc.h:461
MetaType operator*() const
Definition mrange.cc.h:386
decltype(auto) xpr(const Sptr< MIndex< Indices... > > &_this) const
Definition mrange.cc.h:443
constexpr decltype(auto) pmax() const
Definition mrange.cc.h:368
SizeT lex() const
Definition mrange.cc.h:357
MetaType meta() const
Definition mrange.cc.h:426
constexpr decltype(auto) lmax() const
Definition mrange.cc.h:374
Tuple< typename Indices::MetaType... > MetaType
Definition mrange.h:45
IndexId< 0 > id() const
Definition mrange.cc.h:380
constexpr GMIndex(GMIndex &&i)=default
GMIndex & operator--()
Definition mrange.cc.h:297
constexpr GMIndex()=default
RangePtr prange(const GMIndex< FormatT, Indices... > &last) const
Definition mrange.cc.h:524
GMIndex & operator-=(Int n)
Definition mrange.cc.h:343
auto deepMax() const
Definition mrange.cc.h:544
GMIndex & reformat(const Vector< SizeT > &f, const Vector< SizeT > &s)
Definition mrange.cc.h:552
const SPack< Indices... > & pack() const
Definition mrange.cc.h:501
static constexpr SizeT NI
Definition mrange.h:47
GMIndex operator-(Int n) const
Definition mrange.cc.h:316
GMIndex operator+(Int n) const
Definition mrange.cc.h:309
IndexInterface< GMIndex< FormatT, Indices... >, Tuple< typename Indices::MetaType... > > IB
Definition mrange.h:44
auto deepFormat() const
Definition mrange.cc.h:537
constexpr SizeT dim() const
Definition mrange.cc.h:392
String stringMeta() const
Definition mrange.cc.h:413
GMIndex & at(const MetaType &metaPos)
Definition mrange.cc.h:433
GMIndex & operator++()
Definition mrange.cc.h:285
Sptr< RangeType > range() const
Definition mrange.cc.h:398
constexpr GMIndex & operator=(GMIndex &&i)=default
decltype(auto) stepSize(const IndexId< I > &id) const
Definition mrange.cc.h:405
GMIndex & operator()()
Definition mrange.cc.h:494
MRange< typename Indices::RangeType... > RangeType
Definition mrange.h:46
GMIndex & operator+=(Int n)
Definition mrange.cc.h:329
constexpr decltype(auto) ifor(const Xpr &xpr, F &&f) const
INDEX_RANDOM_ACCESS_ITERATOR_DEFS(MetaType)
const auto & lexFormat() const
Definition mrange.cc.h:518
const auto & format() const
Definition mrange.cc.h:507
RangeBase RB
Definition mrange.h:345
MIndex< typename Ranges::IndexType... > IndexType
Definition mrange.h:346
virtual RangePtr extend(const RangePtr &r) const override final
Definition mrange.cc.h:763
virtual String stringMeta(SizeT pos) const override final
Definition mrange.cc.h:726
virtual SizeT size() const override final
Definition mrange.cc.h:713
static constexpr SizeT NR
Definition mrange.h:348
virtual const TypeInfo & metaType() const override final
Definition mrange.cc.h:738
SizeT getMeta(const MetaType &metaPos) const
Definition mrange.cc.h:756
decltype(auto) space() const
Definition mrange.cc.h:744
Tuple< Sptr< Ranges >... > mRs
Definition mrange.h:387
virtual const TypeInfo & type() const override final
Definition mrange.cc.h:732
virtual Vector< Uuid > key() const override final
Definition mrange.cc.h:776
const MetaType get(SizeT pos) const
Definition mrange.cc.h:750
virtual SizeT dim() const override final
Definition mrange.cc.h:720
virtual MArray< RangePtr > sub() const override final
Definition mrange.cc.h:695
Arr< RangePtr, NR > mA
Definition mrange.h:388
Tuple< typename Ranges::IndexType::MetaType... > MetaType
Definition mrange.h:347
Index base declaration.
Index formats declaration.
Index pack declarations.
typename MkIsq< B, E >::type Isqr
Definition isq.h:45
constexpr decltype(auto) gmindexPtr(const FormatT &bs, const SPack< Indices... > &pack)
Definition mrange.cc.h:635
std::string String
Definition types.h:42
typename std::remove_reference< T >::type RemoveRef
Definition types.h:66
std::type_info TypeInfo
Definition types.h:71
uint64_t SizeT
Definition types.h:38
constexpr decltype(auto) mindex(const Sptr< Indices > &... is)
Definition mrange.cc.h:617
Sptr< RangeBase > RangePtr
Definition types.h:157
std::vector< T, Allocator< T > > Vector
Definition types.h:310
int32_t Int
Definition types.h:36
RangePtr mrange(const Sptr< Ranges > &... rs)
Definition mrange.cc.h:800
Sptr< Range > rangeCast(const RangePtr r)
std::tuple< T... > Tuple
Definition types.h:60
std::array< T, N > Arr
Definition types.h:45
std::index_sequence< Is... > Isq
Definition types.h:74
constexpr decltype(auto) mindexPtr(const SPack< Indices... > &pack)
Definition mrange.cc.h:629
std::shared_ptr< T > Sptr
Definition types.h:48
RangeBase declaration.
static constexpr bool value
static constexpr bool value
static constexpr SizeT value
static constexpr SizeT value
static constexpr bool value
static constexpr bool value
static constexpr bool value
Xpression main header.