CNORXZ
Container with Native Operation Routines and Expressions
Loading...
Searching...
No Matches
prange.h
Go to the documentation of this file.
1// -*- C++ -*-
12#ifndef __cxz_prange_h__
13#define __cxz_prange_h__
14
15#include "base/base.h"
16#include "ranges/index_base.h"
17#include "ranges/range_base.h"
18#include "xpr/xpr.h"
19
20namespace CNORXZ
21{
26 template <class IndexT>
27 class PIndex : public IndexInterface<PIndex<IndexT>,typename IndexT::MetaType>
28 {
29 public:
30
31 typedef IndexInterface<PIndex<IndexT>,typename IndexT::MetaType> IB;
33 typedef typename IndexT::MetaType MetaType;
34
39 PIndex(const RangePtr& range, SizeT pos = 0);
40
43
46
49
51 PIndex operator+(Int n) const;
52
54 PIndex operator-(Int n) const;
55
57 SizeT operator-(const PIndex& i) const;
58
61
64
66 SizeT lex() const;
67
69 UPos pmax() const;
70
72 UPos lmax() const;
73
75 IndexId<0> id() const;
76
78 decltype(auto) operator*() const;
79
81 SizeT dim() const;
82
84 Sptr<RangeType> range() const;
85
87 template <SizeT I>
88 UPos stepSize(const IndexId<I>& id) const;
89
91 String stringMeta() const;
92
94 decltype(auto) meta() const;
95
97 PIndex& at(const MetaType& metaPos);
98
100 RangePtr prange(const PIndex<IndexT>& last) const;
101
103 decltype(auto) deepFormat() const;
104
106 decltype(auto) deepMax() const;
107
109 PIndex& reformat(const Vector<SizeT>& f, const Vector<SizeT>& s);
110
112 template <class Xpr, class F>
113 decltype(auto) ifor(const Xpr& xpr, F&& f) const;
114
116 bool formatIsTrivial() const;
117
119 decltype(auto) xpr(const Sptr<PIndex<IndexT>>& _this) const;
120
125
128
132 const Sptr<IndexT>& orig() const;
133
134 private:
135 Sptr<RangeType> mRangePtr;
136 Sptr<IndexT> mOrig;
137
138 void mkPos();
139 };
140
145 template <class I, class I1>
146 decltype(auto) operator*(const Sptr<PIndex<I>>& a, const Sptr<I1>& b);
147
151 template <class RangeT>
153 {
154 public:
155
160 PRangeFactory(const Sptr<RangeT>& range, const Vector<SizeT>& _parts);
161
166 PRangeFactory(const RangePtr& range, const Vector<SizeT>& _parts);
167
168 private:
169 PRangeFactory() = default;
170 virtual void make() override final;
171
172 Sptr<RangeT> mRange;
173 Vector<SizeT> mParts;
174 };
175
183 template <class RangeT>
184 class PRange : public RangeInterface<PRange<RangeT>>
185 {
186 public:
187 typedef RangeBase RB;
189 typedef typename RangeT::MetaType MetaType;
190
192
193 virtual SizeT size() const override final;
199
204
209
215
216 private:
217
218 PRange() = delete;
221
223
224 Sptr<RangeT> mRange;
225 Vector<SizeT> mParts;
226 };
227
235
236} // namespace CNORXZ
237
238#endif
basic headers
const Sptr< IndexT > & orig() const
Definition prange.cc.h:241
PIndex & operator-=(Int n)
Definition prange.cc.h:86
RangePtr prange(const PIndex< IndexT > &last) const
Definition prange.cc.h:148
SizeT lex() const
Definition prange.cc.h:94
UPos stepSize(const IndexId< I > &id) const
Definition prange.cc.h:137
decltype(auto) xpr(const Sptr< PIndex< IndexT > > &_this) const
Definition prange.cc.h:206
IndexInterface< PIndex< IndexT >, typename IndexT::MetaType > IB
Definition prange.h:31
UPos pmax() const
Definition prange.cc.h:100
SizeT dim() const
Definition prange.cc.h:124
PIndex operator-(Int n) const
Definition prange.cc.h:72
PIndex & operator--()
Definition prange.cc.h:52
String stringMeta() const
Definition prange.cc.h:186
UPos lmax() const
Definition prange.cc.h:106
decltype(auto) ifor(const Xpr &xpr, F &&f) const
Definition prange.cc.h:213
PIndex & operator=(SizeT lexpos)
Definition prange.cc.h:36
PIndex & reformat(const Vector< SizeT > &f, const Vector< SizeT > &s)
Definition prange.cc.h:176
PIndex & operator+=(Int n)
Definition prange.cc.h:78
decltype(auto) deepMax() const
Definition prange.cc.h:170
decltype(auto) meta() const
Definition prange.cc.h:192
PIndex operator+(Int n) const
Definition prange.cc.h:60
IndexT::MetaType MetaType
Definition prange.h:33
PIndex & operator()()
Definition prange.cc.h:226
PRange< typename IndexT::RangeType > RangeType
Definition prange.h:32
PIndex & operator++()
Definition prange.cc.h:44
bool formatIsTrivial() const
Definition prange.cc.h:220
PIndex & at(const MetaType &metaPos)
Definition prange.cc.h:198
IndexId< 0 > id() const
Definition prange.cc.h:112
decltype(auto) deepFormat() const
Definition prange.cc.h:164
PIndex(const RangePtr &range, SizeT pos=0)
Definition prange.cc.h:25
Sptr< RangeType > range() const
Definition prange.cc.h:130
RangeBase RB
Definition prange.h:187
RangePtr derive() const
Definition prange.cc.h:366
const Vector< SizeT > & parts() const
Definition prange.cc.h:360
PIndex< typename RangeT::IndexType > IndexType
Definition prange.h:188
virtual SizeT size() const override final
Definition prange.cc.h:306
virtual const TypeInfo & type() const override final
Definition prange.cc.h:324
virtual RangePtr extend(const RangePtr &r) const override final
Definition prange.cc.h:336
RangeT::MetaType MetaType
Definition prange.h:189
virtual SizeT dim() const override final
Definition prange.cc.h:312
virtual const TypeInfo & metaType() const override final
Definition prange.cc.h:330
virtual String stringMeta(SizeT pos) const override final
Definition prange.cc.h:318
Sptr< RangeT > orig() const
Definition prange.cc.h:354
Index base declaration.
std::string String
Definition types.h:42
std::type_info TypeInfo
Definition types.h:71
uint64_t SizeT
Definition types.h:38
Sptr< RangeBase > RangePtr
Definition types.h:157
std::vector< T, Allocator< T > > Vector
Definition types.h:310
int32_t Int
Definition types.h:36
Sptr< Range > rangeCast(const RangePtr r)
RangePtr prange(const Sptr< RangeT > &range, const Vector< SizeT > &parts)
Definition prange.cc.h:401
std::shared_ptr< T > Sptr
Definition types.h:48
RangeBase declaration.
Xpression main header.