forked from simbuerg/isl-cpp
-
Notifications
You must be signed in to change notification settings - Fork 0
/
PwQpolynomialFold.hpp
355 lines (313 loc) · 11.7 KB
/
PwQpolynomialFold.hpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
#ifndef ISL_CXX_PwQpolynomialFold_IMPL_H
#define ISL_CXX_PwQpolynomialFold_IMPL_H
#include "isl/PwQpolynomialFold.h"
#include "isl/Point.hpp"
#include "isl/PwQpolynomial.hpp"
#include "isl/QpolynomialFold.hpp"
#include "isl/Set.hpp"
#include "isl/Space.hpp"
#include "isl/Val.hpp"
#include "isl/Bool.h"
#include "isl/DimType.h"
#include "isl/Fold.h"
#include "isl/Format.h"
#include "isl/IslBase.h"
#include "isl/IslException.h"
#include "isl/Stat.h"
#include "isl/polynomial.h"
#include "isl/set.h"
#include <string>
#include <cassert>
namespace isl {
inline isl_pw_qpolynomial_fold *PwQpolynomialFold::GetCopy() const {
return isl_pw_qpolynomial_fold_copy((isl_pw_qpolynomial_fold *)This);
}
inline PwQpolynomialFold &PwQpolynomialFold::operator=(const PwQpolynomialFold &Other) {
isl_pw_qpolynomial_fold *New = Other.GetCopy();
ctx = Other.Context();
isl_pw_qpolynomial_fold_free((isl_pw_qpolynomial_fold *)This);
This = New;
return *this;
}
inline PwQpolynomialFold PwQpolynomialFold::fromPwQpolynomial(Fold type, const PwQpolynomial &pwqp) {
const Ctx &_ctx = pwqp.Context();
_ctx.lock();
isl_pw_qpolynomial_fold *That = isl_pw_qpolynomial_fold_from_pw_qpolynomial((enum isl_fold)type, (pwqp).GetCopy());
_ctx.unlock();
if (_ctx.hasError()) {
handleError("isl_pw_qpolynomial_fold_from_pw_qpolynomial returned a NULL pointer.");
}
return PwQpolynomialFold(_ctx, That);
}
inline PwQpolynomialFold PwQpolynomialFold::alloc(Fold type, const Set &set, const QpolynomialFold &fold) {
const Ctx &_ctx = fold.Context();
_ctx.lock();
isl_pw_qpolynomial_fold *That = isl_pw_qpolynomial_fold_alloc((enum isl_fold)type, (set).GetCopy(), (fold).GetCopy());
_ctx.unlock();
if (_ctx.hasError()) {
handleError("isl_pw_qpolynomial_fold_alloc returned a NULL pointer.");
}
return PwQpolynomialFold(_ctx, That);
}
inline PwQpolynomialFold PwQpolynomialFold::zero(const Space &dim, Fold type) {
const Ctx &_ctx = dim.Context();
_ctx.lock();
isl_pw_qpolynomial_fold *That = isl_pw_qpolynomial_fold_zero((dim).GetCopy(), (enum isl_fold)type);
_ctx.unlock();
if (_ctx.hasError()) {
handleError("isl_pw_qpolynomial_fold_zero returned a NULL pointer.");
}
return PwQpolynomialFold(_ctx, That);
}
inline PwQpolynomialFold::~PwQpolynomialFold() {
isl_pw_qpolynomial_fold_free((isl_pw_qpolynomial_fold *)This);
This = nullptr;
}
/// rief Release ownership of the wrapped object.
///
/// You are on your own now buddy.
/// The wrapper cannot be used anymore after calling Give()
///
///@return the wrapped isl object.
inline isl_pw_qpolynomial_fold *PwQpolynomialFold::Give() {
isl_pw_qpolynomial_fold *res = (isl_pw_qpolynomial_fold *)This;
This = nullptr;
return res;
}
/// \brief Unwrap the stored isl object.
/// \returns A the wrapped isl object.
inline isl_pw_qpolynomial_fold *PwQpolynomialFold::Get() const { return (isl_pw_qpolynomial_fold *)This;
}
inline PwQpolynomialFold PwQpolynomialFold::add(const PwQpolynomialFold &pwf2) const {
ctx.lock();
isl_pw_qpolynomial_fold * res = isl_pw_qpolynomial_fold_add((*this).GetCopy(), (pwf2).GetCopy());
ctx.unlock();
if (ctx.hasError()) {
handleError("isl_pw_qpolynomial_fold_add returned a NULL pointer.");
}
return PwQpolynomialFold(ctx, res);
}
inline PwQpolynomialFold PwQpolynomialFold::addDisjoint(const PwQpolynomialFold &pwf2) const {
ctx.lock();
isl_pw_qpolynomial_fold * res = isl_pw_qpolynomial_fold_add_disjoint((*this).GetCopy(), (pwf2).GetCopy());
ctx.unlock();
if (ctx.hasError()) {
handleError("isl_pw_qpolynomial_fold_add_disjoint returned a NULL pointer.");
}
return PwQpolynomialFold(ctx, res);
}
inline PwQpolynomialFold PwQpolynomialFold::bound(int * tight) const {
ctx.lock();
isl_pw_qpolynomial_fold * res = isl_pw_qpolynomial_fold_bound((*this).GetCopy(), tight);
ctx.unlock();
if (ctx.hasError()) {
handleError("isl_pw_qpolynomial_fold_bound returned a NULL pointer.");
}
return PwQpolynomialFold(ctx, res);
}
inline PwQpolynomialFold PwQpolynomialFold::coalesce() const {
ctx.lock();
isl_pw_qpolynomial_fold * res = isl_pw_qpolynomial_fold_coalesce((*this).GetCopy());
ctx.unlock();
if (ctx.hasError()) {
handleError("isl_pw_qpolynomial_fold_coalesce returned a NULL pointer.");
}
return PwQpolynomialFold(ctx, res);
}
inline unsigned int PwQpolynomialFold::dim(DimType type) const {
ctx.lock();
unsigned int res = isl_pw_qpolynomial_fold_dim((*this).Get(), (enum isl_dim_type)type);
ctx.unlock();
return res;
}
inline Set PwQpolynomialFold::domain() const {
ctx.lock();
isl_set * res = isl_pw_qpolynomial_fold_domain((*this).GetCopy());
ctx.unlock();
if (ctx.hasError()) {
handleError("isl_pw_qpolynomial_fold_domain returned a NULL pointer.");
}
return Set(ctx, res);
}
inline PwQpolynomialFold PwQpolynomialFold::dropDims(DimType type, unsigned int first, unsigned int n) const {
ctx.lock();
isl_pw_qpolynomial_fold * res = isl_pw_qpolynomial_fold_drop_dims((*this).GetCopy(), (enum isl_dim_type)type, first, n);
ctx.unlock();
if (ctx.hasError()) {
handleError("isl_pw_qpolynomial_fold_drop_dims returned a NULL pointer.");
}
return PwQpolynomialFold(ctx, res);
}
inline Val PwQpolynomialFold::eval(const Point &pnt) const {
ctx.lock();
isl_val * res = isl_pw_qpolynomial_fold_eval((*this).GetCopy(), (pnt).GetCopy());
ctx.unlock();
if (ctx.hasError()) {
handleError("isl_pw_qpolynomial_fold_eval returned a NULL pointer.");
}
return Val(ctx, res);
}
inline PwQpolynomialFold PwQpolynomialFold::fold(const PwQpolynomialFold &pwf2) const {
ctx.lock();
isl_pw_qpolynomial_fold * res = isl_pw_qpolynomial_fold_fold((*this).GetCopy(), (pwf2).GetCopy());
ctx.unlock();
if (ctx.hasError()) {
handleError("isl_pw_qpolynomial_fold_fold returned a NULL pointer.");
}
return PwQpolynomialFold(ctx, res);
}
inline Stat PwQpolynomialFold::foreachLiftedPiece(const std::function<isl_stat(isl_set *, isl_qpolynomial_fold *, void *)> && fn, void * user) const {
ctx.lock();
isl_stat res = isl_pw_qpolynomial_fold_foreach_lifted_piece((*this).Get(), get_fn_ptr<9>(fn), user);
ctx.unlock();
return (Stat)res;
}
inline Stat PwQpolynomialFold::foreachPiece(const std::function<isl_stat(isl_set *, isl_qpolynomial_fold *, void *)> && fn, void * user) const {
ctx.lock();
isl_stat res = isl_pw_qpolynomial_fold_foreach_piece((*this).Get(), get_fn_ptr<10>(fn), user);
ctx.unlock();
return (Stat)res;
}
inline Space PwQpolynomialFold::getDomainSpace() const {
ctx.lock();
isl_space * res = isl_pw_qpolynomial_fold_get_domain_space((*this).Get());
ctx.unlock();
if (ctx.hasError()) {
handleError("isl_pw_qpolynomial_fold_get_domain_space returned a NULL pointer.");
}
return Space(ctx, res);
}
inline Space PwQpolynomialFold::getSpace() const {
ctx.lock();
isl_space * res = isl_pw_qpolynomial_fold_get_space((*this).Get());
ctx.unlock();
if (ctx.hasError()) {
handleError("isl_pw_qpolynomial_fold_get_space returned a NULL pointer.");
}
return Space(ctx, res);
}
inline PwQpolynomialFold PwQpolynomialFold::gist(const Set &context) const {
ctx.lock();
isl_pw_qpolynomial_fold * res = isl_pw_qpolynomial_fold_gist((*this).GetCopy(), (context).GetCopy());
ctx.unlock();
if (ctx.hasError()) {
handleError("isl_pw_qpolynomial_fold_gist returned a NULL pointer.");
}
return PwQpolynomialFold(ctx, res);
}
inline PwQpolynomialFold PwQpolynomialFold::gistParams(const Set &context) const {
ctx.lock();
isl_pw_qpolynomial_fold * res = isl_pw_qpolynomial_fold_gist_params((*this).GetCopy(), (context).GetCopy());
ctx.unlock();
if (ctx.hasError()) {
handleError("isl_pw_qpolynomial_fold_gist_params returned a NULL pointer.");
}
return PwQpolynomialFold(ctx, res);
}
inline int PwQpolynomialFold::hasEqualSpace(const PwQpolynomialFold &pwf2) const {
ctx.lock();
int res = isl_pw_qpolynomial_fold_has_equal_space((*this).Get(), (pwf2).Get());
ctx.unlock();
return res;
}
inline PwQpolynomialFold PwQpolynomialFold::intersectDomain(const Set &set) const {
ctx.lock();
isl_pw_qpolynomial_fold * res = isl_pw_qpolynomial_fold_intersect_domain((*this).GetCopy(), (set).GetCopy());
ctx.unlock();
if (ctx.hasError()) {
handleError("isl_pw_qpolynomial_fold_intersect_domain returned a NULL pointer.");
}
return PwQpolynomialFold(ctx, res);
}
inline PwQpolynomialFold PwQpolynomialFold::intersectParams(const Set &set) const {
ctx.lock();
isl_pw_qpolynomial_fold * res = isl_pw_qpolynomial_fold_intersect_params((*this).GetCopy(), (set).GetCopy());
ctx.unlock();
if (ctx.hasError()) {
handleError("isl_pw_qpolynomial_fold_intersect_params returned a NULL pointer.");
}
return PwQpolynomialFold(ctx, res);
}
inline Bool PwQpolynomialFold::isZero() const {
ctx.lock();
isl_bool res = isl_pw_qpolynomial_fold_is_zero((*this).Get());
ctx.unlock();
return (Bool)res;
}
inline Val PwQpolynomialFold::max() const {
ctx.lock();
isl_val * res = isl_pw_qpolynomial_fold_max((*this).GetCopy());
ctx.unlock();
if (ctx.hasError()) {
handleError("isl_pw_qpolynomial_fold_max returned a NULL pointer.");
}
return Val(ctx, res);
}
inline Val PwQpolynomialFold::min() const {
ctx.lock();
isl_val * res = isl_pw_qpolynomial_fold_min((*this).GetCopy());
ctx.unlock();
if (ctx.hasError()) {
handleError("isl_pw_qpolynomial_fold_min returned a NULL pointer.");
}
return Val(ctx, res);
}
inline PwQpolynomialFold PwQpolynomialFold::moveDims(DimType dst_type, unsigned int dst_pos, DimType src_type, unsigned int src_pos, unsigned int n) const {
ctx.lock();
isl_pw_qpolynomial_fold * res = isl_pw_qpolynomial_fold_move_dims((*this).GetCopy(), (enum isl_dim_type)dst_type, dst_pos, (enum isl_dim_type)src_type, src_pos, n);
ctx.unlock();
if (ctx.hasError()) {
handleError("isl_pw_qpolynomial_fold_move_dims returned a NULL pointer.");
}
return PwQpolynomialFold(ctx, res);
}
inline Bool PwQpolynomialFold::plainIsEqual(const PwQpolynomialFold &pwf2) const {
ctx.lock();
isl_bool res = isl_pw_qpolynomial_fold_plain_is_equal((*this).Get(), (pwf2).Get());
ctx.unlock();
return (Bool)res;
}
inline PwQpolynomialFold PwQpolynomialFold::projectDomainOnParams() const {
ctx.lock();
isl_pw_qpolynomial_fold * res = isl_pw_qpolynomial_fold_project_domain_on_params((*this).GetCopy());
ctx.unlock();
if (ctx.hasError()) {
handleError("isl_pw_qpolynomial_fold_project_domain_on_params returned a NULL pointer.");
}
return PwQpolynomialFold(ctx, res);
}
inline PwQpolynomialFold PwQpolynomialFold::resetSpace(const Space &dim) const {
ctx.lock();
isl_pw_qpolynomial_fold * res = isl_pw_qpolynomial_fold_reset_space((*this).GetCopy(), (dim).GetCopy());
ctx.unlock();
if (ctx.hasError()) {
handleError("isl_pw_qpolynomial_fold_reset_space returned a NULL pointer.");
}
return PwQpolynomialFold(ctx, res);
}
inline PwQpolynomialFold PwQpolynomialFold::scaleVal(const Val &v) const {
ctx.lock();
isl_pw_qpolynomial_fold * res = isl_pw_qpolynomial_fold_scale_val((*this).GetCopy(), (v).GetCopy());
ctx.unlock();
if (ctx.hasError()) {
handleError("isl_pw_qpolynomial_fold_scale_val returned a NULL pointer.");
}
return PwQpolynomialFold(ctx, res);
}
inline PwQpolynomialFold PwQpolynomialFold::setDimName(DimType type, unsigned int pos, std::string s) const {
ctx.lock();
isl_pw_qpolynomial_fold * res = isl_pw_qpolynomial_fold_set_dim_name((*this).GetCopy(), (enum isl_dim_type)type, pos, s.c_str());
ctx.unlock();
if (ctx.hasError()) {
handleError("isl_pw_qpolynomial_fold_set_dim_name returned a NULL pointer.");
}
return PwQpolynomialFold(ctx, res);
}
inline size_t PwQpolynomialFold::size() const {
ctx.lock();
size_t res = isl_pw_qpolynomial_fold_size((*this).Get());
ctx.unlock();
return res;
}
} // namespace isl
#endif //ISL_CXX_PwQpolynomialFold_IMPL_H