CNORXZ
Container with Native Operation Routines and Expressions
Loading...
Searching...
No Matches
yrange.h
Go to the documentation of this file.
1// -*- C++ -*-
12#ifndef __cxz_yrange_h__
13#define __cxz_yrange_h__
14
15#include "base/base.h"
16#include "range_base.h"
17#include "index_base.h"
18#include "xindex.h"
19#include "xpr/xpr.h"
20#include "index_format.h"
21#include "index_pack.h"
22#include "prange.h"
23
24namespace CNORXZ
25{
33 class YIndex : public IndexInterface<YIndex,Vector<DType>>
34 {
35 public:
39
41
43 YIndex() = default;
44
46 YIndex(YIndex&& i) = default;
47
49 YIndex& operator=(YIndex&& i) = default;
50
54 YIndex(const YIndex& i);
55
59 YIndex& operator=(const YIndex& i);
60
65
70 YIndex(const YFormat& bs, const Vector<XIndexPtr>& is);
71
76 YIndex(const RangePtr& range, SizeT lexpos = 0);
77
83 YIndex(const RangePtr& range, const YFormat& bs, SizeT lexpos = 0);
84
87
90
93
95 YIndex operator+(Int n) const;
96
98 YIndex operator-(Int n) const;
99
101 SizeT operator-(const YIndex& i) const;
102
105
108
110 SizeT lex() const;
111
113 UPos pmax() const;
114
116 UPos lmax() const;
117
119 IndexId<0> id() const;
120
122 Vector<DType> operator*() const;
123
125 SizeT dim() const;
126
128 Sptr<YRange> range() const;
129
131 UPos stepSize(const IndexId<0> id) const;
132
134 String stringMeta() const;
135
137 Vector<DType> meta() const;
138
140 YIndex& at(const Vector<DType>& meta);
141
143 RangePtr prange(const YIndex& last) const;
144
147
149 Vector<SizeT> deepMax() const;
150
152 YIndex& reformat(const Vector<SizeT>& f, const Vector<SizeT>& s);
153
155 DXpr<None> ifor(const DXpr<None>& xpr, NoF&& f) const;
156
158 bool formatIsTrivial() const;
159
165
168
172 const DPack& pack() const;
173
177 const YFormat& format() const;
178
182 const YFormat& lexFormat() const;
183
187 YIndex& setFormat(const YFormat& bs);
188
194
195 private:
196 inline Vector<SizeT> mkFormat() const;
197 inline Vector<SizeT> mkLexFormat() const;
198 inline Vector<RangePtr> mkRangeVec(const Vector<XIndexPtr>& is) const;
199 inline void mkPos();
200 inline DPack mkIndices() const;
201 inline void up(SizeT i);
202 inline void down(SizeT i);
203 inline decltype(auto) mkIFor(SizeT i, const DXpr<None>& xpr, NoF&& f) const;
204
205 inline SizeT mkPMax() const;
206 inline SizeT mkLMax() const;
207
208 Sptr<YRange> mRange;
209 DPack mIs;
210 YFormat mFormat; // dim() elements only!
211 YFormat mLexFormat; // dim() elements only!
212 SizeT mLex = 0;
213 UPos mPMax = 0;
214 UPos mLMax = 0;
215 };
216
221 template <>
223 { static constexpr bool value = true; };
224
229 template <>
231 { static constexpr bool value = true; };
232
237 YIndex yindex(const DPack& pack);
238
244
250
256
263
268 {
269 public:
270
275
280
286
292
293 private:
294 YRangeFactory() = default;
295 virtual void make() override final;
296
297 Vector<RangePtr> mRVec;
298 RangePtr mRef;
299
300 };
301
309 class YRange : public RangeInterface<YRange>
310 {
311 public:
312 typedef RangeBase RB;
314
316
317 virtual RangePtr sub(SizeT i) const override final;
325
326 private:
327
328 YRange() = default;
332
333 Vector<RangePtr> mRVec;
334
336
337 SERIALIZATION_FUNCTIONS_NOPUB;
338 };
339
345
350 template <>
352 {
353 static Sptr<YRange> func(const RangePtr& r);
354 };
355
356
357}
358
359#endif
basic headers
Vector< DType > MetaType
Definition yrange.h:38
YIndex operator-(Int n) const
Definition yrange.cc:253
YRange RangeType
Definition yrange.h:37
Vector< SizeT > deepMax() const
Definition yrange.cc:410
YIndex operator+(Int n) const
Definition yrange.cc:247
const YFormat & format() const
Definition yrange.cc:491
RangePtr prange(const YIndex &last) const
Definition yrange.cc:380
const YFormat & lexFormat() const
Definition yrange.cc:496
YIndex & operator=(YIndex &&i)=default
const DPack & pack() const
Definition yrange.cc:375
bool formatIsTrivial() const
Definition yrange.cc:473
YIndex & at(const Vector< DType > &meta)
Definition yrange.cc:345
UPos stepSize(const IndexId< 0 > id) const
Definition yrange.cc:315
YIndex(YIndex &&i)=default
Vector< DType > operator*() const
Definition yrange.cc:300
UPos pmax() const
Definition yrange.cc:285
YIndex & operator()()
Definition yrange.cc:369
DXpr< None > ifor(const DXpr< None > &xpr, NoF &&f) const
Definition yrange.cc:357
YIndex & operator-=(Int n)
Definition yrange.cc:272
SizeT lex() const
Definition yrange.cc:280
YIndex & operator--()
Definition yrange.cc:236
YIndex & setSub(SizeT ind, SizeT lex)
Definition yrange.cc:507
String stringMeta() const
Definition yrange.cc:325
UPos lmax() const
Definition yrange.cc:290
INDEX_RANDOM_ACCESS_ITERATOR_DEFS(MetaType)
YIndex & operator+=(Int n)
Definition yrange.cc:264
YIndex()=default
Sptr< YRange > range() const
Definition yrange.cc:310
YIndex & operator++()
Definition yrange.cc:225
Vector< DType > meta() const
Definition yrange.cc:337
IndexId< 0 > id() const
Definition yrange.cc:295
IndexInterface< YIndex, Vector< DType > > IB
Definition yrange.h:36
Vector< SizeT > deepFormat() const
Definition yrange.cc:391
YIndex & setFormat(const YFormat &bs)
Definition yrange.cc:501
SizeT dim() const
Definition yrange.cc:305
YIndex & reformat(const Vector< SizeT > &f, const Vector< SizeT > &s)
Definition yrange.cc:427
virtual MArray< RangePtr > sub() const override final
Definition yrange.cc:582
friend YRangeFactory
Definition yrange.h:315
virtual const TypeInfo & type() const override final
Definition yrange.cc:624
virtual RangePtr extend(const RangePtr &r) const override final
Definition yrange.cc:634
virtual SizeT size() const override final
Definition yrange.cc:590
YIndex IndexType
Definition yrange.h:313
virtual SizeT dim() const override final
Definition yrange.cc:599
virtual String stringMeta(SizeT pos) const override final
Definition yrange.cc:604
virtual const TypeInfo & metaType() const override final
Definition yrange.cc:629
RangeBase RB
Definition yrange.h:312
Index base declaration.
Index formats declaration.
Index pack declarations.
std::string String
Definition types.h:42
std::type_info TypeInfo
Definition types.h:71
uint64_t SizeT
Definition types.h:38
RangePtr yrange(const Vector< RangePtr > &rs)
Definition yrange.cc:666
Sptr< RangeBase > RangePtr
Definition types.h:157
Sptr< YIndex > yindexPtr(const DPack &is)
Definition yrange.cc:534
std::vector< T, Allocator< T > > Vector
Definition types.h:310
int32_t Int
Definition types.h:36
decltype(auto) xpr(const Sptr< I > &i)
Sptr< Range > rangeCast(const RangePtr r)
YIndex yindex(const DPack &pack)
Definition yrange.cc:524
std::shared_ptr< T > Sptr
Definition types.h:48
PRange, PRangeFactory and PIndex declaration.
RangeBase declaration.
static constexpr bool value
static constexpr bool value
XIndexBase and XIndex template declaration.
Xpression main header.