CNORXZ
Container with Native Operation Routines and Expressions
Loading...
Searching...
No Matches
reg.h
Go to the documentation of this file.
1// -*- C++ -*-
12#ifndef __cxz_reg_h__
13#define __cxz_reg_h__
14
15#include "base/base.h"
16
17namespace CNORXZ
18{
19
20 // no use of Arr = std::array here, since I want ensure that
21 // it has exactly a memory size of N
22 template <typename T, SizeT N>
24 {
25 T mD[N];
26 };
27
28 template <typename T>
30
31 template <typename T>
32 struct consecutive_base { typedef T type; };
33
34 template <typename T>
35 struct consecutive_size { static constexpr SizeT value = 0; };
36
37 template <typename T, SizeT N>
39
40 template <typename T, SizeT N>
41 struct consecutive_base<Consecutive<T,N>> { typedef T type; };
42
43 template <typename T, SizeT N>
44 struct consecutive_size<Consecutive<T,N>> { static constexpr SizeT value = N; };
45
46 /*======================================+
47 | consecutive generating functions |
48 +======================================*/
49
50 template <typename T, class EPosT, SizeT... Is>
51 inline decltype(auto) vregi(const T* d, const EPosT& pos, std::index_sequence<Is...> is);
52
53 template <typename T, class EPosT>
54 inline decltype(auto) vreg(const T* d, const EPosT& pos);
55
56 template <typename T, class EPosT>
57 inline decltype(auto) vreg(T* d, const EPosT& pos);
58
59 /*================+
60 | ConsecFunc |
61 +================*/
62
63 template <SizeT I, typename T>
64 constexpr decltype(auto) consecGet(const T& a);
65
66 template <SizeT I, typename T>
67 constexpr decltype(auto) consecGet(T& a);
68
69 template <SizeT I, class F, typename... Args>
70 constexpr decltype(auto) consecApply(const F& f, const Args&... args);
71
72 template <SizeT I, class F, typename Dst, typename... Args>
73 constexpr Dst& consecAssign(const F& f, Dst& dst, const Args&... args);
74
75 template <class F, typename... Args, SizeT... Is>
76 constexpr decltype(auto) consecFuncI(const F& f, const Args&... args,
77 std::index_sequence<Is...> is);
78
79 template <class F, typename Dst, typename... Args, SizeT... Is>
80 constexpr Dst& consecFuncAI(const F& f, Dst& dst, const Args&... args,
81 std::index_sequence<Is...> is);
82
83 template <SizeT N, class F, typename... Args>
84 constexpr decltype(auto) consecFunc(const F& f, const Args&... args);
85
86 template <SizeT N, class F, typename Dst, typename... Args>
87 constexpr Dst& consecFuncA(const F& f, Dst& dst, const Args&... args);
88
89 /*============================+
90 | basic operations: plus |
91 +============================*/
92
93 template <typename T, typename U, SizeT N>
94 struct PlusCC
95 {
96 static constexpr decltype(auto)
97 eval(const Consecutive<T,N>& a, const Consecutive<U,N>& b);
98
99 static constexpr decltype(auto)
101 };
102
103 template <typename T, typename X, SizeT N>
104 struct PlusCX
105 {
106 static constexpr decltype(auto)
107 eval(const Consecutive<T,N>& a, const X& b);
108
109 static constexpr decltype(auto)
110 aeval(Consecutive<T,N>& a, const X& b);
111
112 static constexpr decltype(auto)
113 eval(const X& a, const Consecutive<T,N>& b);
114 };
115
116 template <typename T, typename U, SizeT N>
117 constexpr decltype(auto) operator+(const Consecutive<T,N>& a, const Consecutive<U,N>& b)
118 { return PlusCC<T,U,N>::eval(a,b); }
119
120 template <typename T, typename U, SizeT N>
121 constexpr decltype(auto) operator+(const Consecutive<T,N>& a, const U& b)
122 { return PlusCX<T,U,N>::eval(a,b); }
123
124 template <typename T, typename U, SizeT N>
125 constexpr decltype(auto) operator+(const T& a, const Consecutive<U,N>& b)
126 { return PlusCX<U,T,N>::eval(a,b); }
127
128 template <typename T, typename U, SizeT N>
131
132 template <typename T, typename U, SizeT N>
134 { return PlusCX<T,U,N>::aeval(o,a); }
135
136 /*=============================+
137 | basic operations: minus |
138 +=============================*/
139
140 template <typename T, typename U, SizeT N>
141 struct MinusCC
142 {
143 static constexpr decltype(auto)
144 eval(const Consecutive<T,N>& a, const Consecutive<U,N>& b);
145
146 static constexpr decltype(auto)
148 };
149
150 template <typename T, typename X, SizeT N>
151 struct MinusCX
152 {
153 static constexpr decltype(auto)
154 eval(const Consecutive<T,N>& a, const X& b);
155
156 static constexpr decltype(auto)
157 aeval(Consecutive<T,N>& a, const X& b);
158
159 static constexpr decltype(auto)
160 eval(const X& a, const Consecutive<T,N>& b);
161 };
162
163 template <typename T, typename U, SizeT N>
164 constexpr decltype(auto) operator-(const Consecutive<T,N>& a, const Consecutive<U,N>& b)
165 { return MinusCC<T,U,N>::eval(a,b); }
166
167 template <typename T, typename U, SizeT N>
168 constexpr decltype(auto) operator-(const Consecutive<T,N>& a, const U& b)
169 { return MinusCX<T,U,N>::eval(a,b); }
170
171 template <typename T, typename U, SizeT N>
172 constexpr decltype(auto) operator-(const T& a, const Consecutive<U,N>& b)
173 { return MinusCX<U,T,N>::eval(a,b); }
174
175 template <typename T, typename U, SizeT N>
178
179 template <typename T, typename U, SizeT N>
181 { return MinusCX<T,U,N>::eval(o,a); }
182
183 /*=================================+
184 | basic operations: muliplies |
185 +=================================*/
186
187 template <typename T, typename U, SizeT N>
189 {
190 static constexpr decltype(auto)
191 eval(const Consecutive<T,N>& a, const Consecutive<U,N>& b);
192
193 static constexpr decltype(auto)
195 };
196
197 template <typename T, typename X, SizeT N>
199 {
200 static constexpr decltype(auto)
201 eval(const Consecutive<T,N>& a, const X& b);
202
203 static constexpr decltype(auto)
204 aeval(Consecutive<T,N>& a, const X& b);
205
206 static constexpr decltype(auto)
207 eval(const X& a, const Consecutive<T,N>& b);
208 };
209
210 template <typename T, typename U, SizeT N>
211 constexpr decltype(auto) operator*(const Consecutive<T,N>& a, const Consecutive<U,N>& b)
212 { return MultipliesCC<T,U,N>::eval(a,b); }
213
214 template <typename T, typename U, SizeT N>
215 constexpr decltype(auto) operator*(const Consecutive<T,N>& a, const U& b)
216 { return MultipliesCX<T,U,N>::eval(a,b); }
217
218 template <typename T, typename U, SizeT N>
219 constexpr decltype(auto) operator*(const T& a, const Consecutive<U,N>& b)
220 { return MultipliesCX<U,T,N>::eval(a,b); }
221
222 template <typename T, typename U, SizeT N>
225
226 template <typename T, typename U, SizeT N>
228 { return MultipliesCX<T,U,N>::eval(o,a); }
229
230 /*===============================+
231 | basic operations: divides |
232 +===============================*/
233
234 template <typename T, typename U, SizeT N>
236 {
237 static constexpr decltype(auto)
238 eval(const Consecutive<T,N>& a, const Consecutive<U,N>& b);
239
240 static constexpr decltype(auto)
242 };
243
244 template <typename T, typename X, SizeT N>
246 {
247 static constexpr decltype(auto)
248 eval(const Consecutive<T,N>& a, const X& b);
249
250 static constexpr decltype(auto)
251 aeval(Consecutive<T,N>& a, const X& b);
252
253 static constexpr decltype(auto)
254 eval(const X& a, const Consecutive<T,N>& b);
255 };
256
257 template <typename T, typename U, SizeT N>
258 constexpr decltype(auto) operator/(const Consecutive<T,N>& a, const Consecutive<U,N>& b)
259 { return DividesCC<T,U,N>::eval(a,b); }
260
261 template <typename T, typename U, SizeT N>
262 constexpr decltype(auto) operator/(const Consecutive<T,N>& a, const U& b)
263 { return DividesCX<T,U,N>::eval(a,b); }
264
265 template <typename T, typename U, SizeT N>
266 constexpr decltype(auto) operator/(const T& a, const Consecutive<U,N>& b)
267 { return DividesCX<U,T,N>::eval(a,b); }
268
269 template <typename T, typename U, SizeT N>
272
273 template <typename T, typename U, SizeT N>
275 { return DividesCX<T,U,N>::eval(o,a); }
276
277}
278
279#endif
basic headers
constexpr decltype(auto) consecGet(const T &a)
Definition reg.cc.h:56
constexpr decltype(auto) consecFuncI(const F &f, const Args &... args, std::index_sequence< Is... > is)
Definition reg.cc.h:95
uint64_t SizeT
Definition types.h:38
constexpr decltype(auto) consecApply(const F &f, const Args &... args)
Definition reg.cc.h:82
constexpr Consecutive< T, N > & operator+=(Consecutive< T, N > &o, const Consecutive< U, N > &a)
Definition reg.h:129
decltype(auto) vregi(const T *d, const EPosT &pos, std::index_sequence< Is... > is)
Definition reg.cc.h:21
constexpr Consecutive< T, N > & operator-=(Consecutive< T, N > &o, const Consecutive< U, N > &a)
Definition reg.h:176
constexpr Consecutive< T, N > & operator*=(Consecutive< T, N > &o, const Consecutive< U, N > &a)
Definition reg.h:223
Sptr< Range > rangeCast(const RangePtr r)
constexpr decltype(auto) consecFunc(const F &f, const Args &... args)
Definition reg.cc.h:112
constexpr Dst & consecFuncAI(const F &f, Dst &dst, const Args &... args, std::index_sequence< Is... > is)
Definition reg.cc.h:104
constexpr Dst & consecAssign(const F &f, Dst &dst, const Args &... args)
Definition reg.cc.h:88
decltype(auto) vreg(const T *d, const EPosT &pos)
Definition reg.cc.h:29
constexpr Dst & consecFuncA(const F &f, Dst &dst, const Args &... args)
Definition reg.cc.h:118
constexpr Consecutive< T, N > & operator/=(Consecutive< T, N > &o, const Consecutive< U, N > &a)
Definition reg.h:270
static constexpr decltype(auto) aeval(Consecutive< T, N > &a, const Consecutive< U, N > &b)
Definition reg.cc.h:250
static constexpr decltype(auto) eval(const Consecutive< T, N > &a, const Consecutive< U, N > &b)
Definition reg.cc.h:232
static constexpr decltype(auto) aeval(Consecutive< T, N > &a, const X &b)
Definition reg.cc.h:256
static constexpr decltype(auto) eval(const Consecutive< T, N > &a, const X &b)
Definition reg.cc.h:238
static constexpr decltype(auto) aeval(Consecutive< T, N > &a, const Consecutive< U, N > &b)
Definition reg.cc.h:182
static constexpr decltype(auto) eval(const Consecutive< T, N > &a, const Consecutive< U, N > &b)
Definition reg.cc.h:164
static constexpr decltype(auto) eval(const Consecutive< T, N > &a, const X &b)
Definition reg.cc.h:170
static constexpr decltype(auto) aeval(Consecutive< T, N > &a, const X &b)
Definition reg.cc.h:188
static constexpr decltype(auto) eval(const Consecutive< T, N > &a, const Consecutive< U, N > &b)
Definition reg.cc.h:198
static constexpr decltype(auto) aeval(Consecutive< T, N > &a, const Consecutive< U, N > &b)
Definition reg.cc.h:216
static constexpr decltype(auto) aeval(Consecutive< T, N > &a, const X &b)
Definition reg.cc.h:222
static constexpr decltype(auto) eval(const Consecutive< T, N > &a, const X &b)
Definition reg.cc.h:204
static constexpr decltype(auto) aeval(Consecutive< T, N > &a, const Consecutive< U, N > &b)
Definition reg.cc.h:136
static constexpr decltype(auto) eval(const Consecutive< T, N > &a, const Consecutive< U, N > &b)
Definition reg.cc.h:129
static constexpr decltype(auto) aeval(Consecutive< T, N > &a, const X &b)
Definition reg.cc.h:154
static constexpr decltype(auto) eval(const Consecutive< T, N > &a, const X &b)
Definition reg.cc.h:142
static constexpr SizeT value
Definition reg.h:35