CNORXZ
Container with Native Operation Routines and Expressions
Loading...
Searching...
No Matches
srange.h
Go to the documentation of this file.
1// -*- C++ -*-
12#ifndef __cxz_srange_h__
13#define __cxz_srange_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{
27 template <typename MetaT, SizeT S>
28 class SIndex : public IndexInterface<SIndex<MetaT,S>,MetaT>
29 {
30 public:
33 typedef MetaT MetaType;
34
42 SIndex(const RangePtr& range, SizeT pos = 0);
43
46
49
52
54 SIndex operator+(Int n) const;
55
57 SIndex operator-(Int n) const;
58
60 SizeT operator-(const SIndex& i) const;
61
64
67
69 SizeT lex() const;
70
72 SPos<S> pmax() const;
73
75 SPos<S> lmax() const;
76
78 IndexId<0> id() const;
79
81 const MetaT& operator*() const;
82
84 SizeT dim() const; // = 1
85
87 Sptr<RangeType> range() const;
88
90 template <SizeT I>
91 UPos stepSize(const IndexId<I>& id) const;
92
94 String stringMeta() const;
95
97 const MetaT& meta() const;
98
100 SIndex& at(const MetaT& metaPos);
101
104
106 SizeT deepFormat() const;
107
109 SizeT deepMax() const;
110
112 SIndex& reformat(const Vector<SizeT>& f, const Vector<SizeT>& s);
113
115 decltype(auto) xpr(const Sptr<SIndex<MetaType,S>>& _this) const;
116
118 template <class Xpr, class F>
119 decltype(auto) ifor(const Xpr& xpr, F&& f) const;
120
122 bool formatIsTrivial() const;
123
124 private:
125 Sptr<RangeType> mRangePtr;
126 const MetaT* mMetaPtr;
127 };
128
133 template <typename MetaT, SizeT S, class I1>
134 decltype(auto) operator*(const Sptr<SIndex<MetaT,S>>& a, const Sptr<I1>& b);
135
141 template <typename MetaT, SizeT S>
143 {
144 public:
145
150
155
160 SRangeFactory(const Arr<MetaT,S>& space, const RangePtr& ref);
161
167
168 private:
169 SRangeFactory() = default;
170 virtual void make() override final;
171
172 Arr<MetaT,S> mSpace;
173 RangePtr mRef;
174 };
175
184 {
185 public:
186 typedef RangeBase RB;
189
191
192 virtual SizeT size() const override final;
194 virtual String stringMeta(SizeT pos) const override final;
198
202 const MetaT& get(SizeT pos) const;
203
207 const MetaT* get() const;
208
212 SizeT getMeta(const MetaT& metaPos) const;
213
214 private:
215
216 SRange() = default;
218 SRange(const Arr<MetaT,S>& space);
219 SRange(Arr<MetaT,S>&& space);
220
221 Arr<MetaT,S> mSpace;
222
224
226 };
227
240
245 template <typename MetaT, SizeT S>
247 {
248 static constexpr bool value = true;
249 };
250}
251
252#endif
basic headers
INDEX_RANDOM_ACCESS_ITERATOR_DEFS(MetaType)
SIndex operator-(Int n) const
Definition srange.cc.h:62
SIndex & operator=(SizeT lexpos)
Definition srange.cc.h:35
String stringMeta() const
Definition srange.cc.h:137
bool formatIsTrivial() const
Definition srange.cc.h:203
SizeT deepFormat() const
Definition srange.cc.h:174
RangePtr prange(const SIndex< MetaType, S > &last) const
Definition srange.cc.h:162
UPos stepSize(const IndexId< I > &id) const
Definition srange.cc.h:131
SPos< S > pmax() const
Definition srange.cc.h:94
SIndex & operator+=(Int n)
Definition srange.cc.h:74
SizeT deepMax() const
Definition srange.cc.h:180
SIndex & reformat(const Vector< SizeT > &f, const Vector< SizeT > &s)
Definition srange.cc.h:186
decltype(auto) xpr(const Sptr< SIndex< MetaType, S > > &_this) const
Definition srange.cc.h:156
SRange< MetaT, S > RangeType
Definition srange.h:32
Sptr< RangeType > range() const
Definition srange.cc.h:124
SIndex operator+(Int n) const
Definition srange.cc.h:56
SizeT dim() const
Definition srange.cc.h:118
DEFAULT_MEMBERS(SIndex)
MetaT MetaType
Definition srange.h:33
SIndex & operator--()
Definition srange.cc.h:49
IndexInterface< SIndex< MetaT, S >, MetaT > IB
Definition srange.h:31
const MetaT & operator*() const
Definition srange.cc.h:112
SPos< S > lmax() const
Definition srange.cc.h:100
decltype(auto) ifor(const Xpr &xpr, F &&f) const
Definition srange.cc.h:197
SizeT lex() const
Definition srange.cc.h:88
SIndex & operator++()
Definition srange.cc.h:42
SIndex & operator-=(Int n)
Definition srange.cc.h:81
SIndex(const RangePtr &range, SizeT pos=0)
Definition srange.cc.h:25
IndexId< 0 > id() const
Definition srange.cc.h:106
const MetaT & meta() const
Definition srange.cc.h:143
SIndex & at(const MetaT &metaPos)
Definition srange.cc.h:149
SRangeFactory(const Arr< MetaT, S > &space, const RangePtr &ref)
SRangeFactory(Arr< MetaT, S > &&space, const RangePtr &ref)
SRangeFactory(const Arr< MetaT, S > &space)
SRangeFactory(Arr< MetaT, S > &&space)
RangeBase RB
Definition srange.h:186
MetaT MetaType
Definition srange.h:188
SIndex< MetaT, S > IndexType
Definition srange.h:187
Index base declaration.
#define SERIALIZATION_FUNCTIONS_NOPUB
Definition macros.h:132
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)
std::array< T, N > Arr
Definition types.h:45
std::shared_ptr< T > Sptr
Definition types.h:48
RangeBase declaration.
static Sptr< SRange< MetaT, S > > func(const RangePtr &r)
Xpression main header.