1 /* Implementation of the C interface: variables and non-inline functions.
2 Copyright (C) 2001-2010 Roberto Bagnara <bagnara@cs.unipr.it>
3 Copyright (C) 2010-2016 BUGSENG srl (http://bugseng.com)
4
5 This file is part of the Parma Polyhedra Library (PPL).
6
7 The PPL is free software; you can redistribute it and/or modify it
8 under the terms of the GNU General Public License as published by the
9 Free Software Foundation; either version 3 of the License, or (at your
10 option) any later version.
11
12 The PPL is distributed in the hope that it will be useful, but WITHOUT
13 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
14 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
15 for more details.
16
17 You should have received a copy of the GNU General Public License
18 along with this program; if not, write to the Free Software Foundation,
19 Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1307, USA.
20
21 For the most up-to-date information see the Parma Polyhedra Library
22 site: http://bugseng.com/products/ppl/ . */
23
24 /* Interface for Coefficient. */
25
26 #include "ppl_c_implementation_common_defs.hh"
27
28 namespace Parma_Polyhedra_Library {
29
30 namespace Interfaces {
31
32 namespace C {
33
34 error_handler_type user_error_handler = 0;
35
36 extern "C" const char*
c_variable_default_output_function(ppl_dimension_type var)37 c_variable_default_output_function(ppl_dimension_type var) {
38 #if PPL_SIZEOF_SIZE_T == PPL_SIZEOF_INT
39 # define FORMAT "%u"
40 # define CONVERSION (unsigned)
41 #elif PPL_SIZEOF_SIZE_T == PPL_SIZEOF_LONG
42 # define FORMAT "%lu"
43 # define CONVERSION (unsigned long)
44 #elif PPL_SIZEOF_SIZE_T == PPL_SIZEOF_LONG_LONG
45 # define FORMAT "%llu"
46 # define CONVERSION (unsigned long long)
47 #else
48 # error "Unsupported definition for `size_t'."
49 #endif
50 // On a 64-bits architecture, `var' will not be more than 2^64-1,
51 // (2^64-1)/26 is written with 18 decimal digits, plus one letter,
52 // plus one terminator makes 20.
53 #if defined(ULLONG_MAX) && ULLONG_MAX > 18446744073709551615ULL
54 # error "Please enlarge the buffer in the following line."
55 #endif
56 static char buffer[20];
57 buffer[0] = static_cast<char>('A' + var % 26);
58 if (ppl_dimension_type i = var / 26) {
59 int r = sprintf(buffer+1, FORMAT, CONVERSION i);
60 if (r < 0)
61 return 0;
62 else if (r >= 19) {
63 errno = ERANGE;
64 return 0;
65 }
66 }
67 else
68 buffer[1] = '\0';
69 return buffer;
70 }
71
72 // Holds a pointer to the C current output function.
73 ppl_io_variable_output_function_type* c_variable_output_function;
74
75 void
cxx_Variable_output_function(std::ostream & s,const Variable v)76 cxx_Variable_output_function(std::ostream& s, const Variable v) {
77 const char* b = c_variable_output_function(v.id());
78 if (b == 0)
79 // Something went wrong in the client's output function.
80 // Client code will know what to do: we do nothing.
81 return;
82 s << b;
83 }
84
85 extern "C" typedef const char*
86 c_variable_output_function_type(ppl_dimension_type var);
87
88 // Holds a pointer to the C++ saved output function.
89 Variable::output_function_type* saved_cxx_Variable_output_function;
90
91 void
notify_error(enum ppl_enum_error_code code,const char * description)92 notify_error(enum ppl_enum_error_code code, const char* description) {
93 if (user_error_handler != 0)
94 user_error_handler(code, description);
95 }
96
97 Parma_Polyhedra_Library::Watchdog* p_timeout_object = 0;
98
99 typedef
100 Parma_Polyhedra_Library::Threshold_Watcher
101 <Parma_Polyhedra_Library::Weightwatch_Traits> Weightwatch;
102
103 Weightwatch* p_deterministic_timeout_object = 0;
104
105 void
reset_timeout()106 reset_timeout() {
107 if (p_timeout_object != 0) {
108 delete p_timeout_object;
109 p_timeout_object = 0;
110 abandon_expensive_computations = 0;
111 }
112 }
113
114 void
reset_deterministic_timeout()115 reset_deterministic_timeout() {
116 if (p_deterministic_timeout_object != 0) {
117 delete p_deterministic_timeout_object;
118 p_deterministic_timeout_object = 0;
119 abandon_expensive_computations = 0;
120 }
121 }
122
123 } // namespace C
124
125 } // namespace Interfaces
126
127 } // namespace Parma_Polyhedra_Library
128
129 using namespace Parma_Polyhedra_Library;
130 using namespace Parma_Polyhedra_Library::Interfaces::C;
131
132 unsigned int PPL_POLY_CON_RELATION_IS_DISJOINT;
133 unsigned int PPL_POLY_CON_RELATION_STRICTLY_INTERSECTS;
134 unsigned int PPL_POLY_CON_RELATION_IS_INCLUDED;
135 unsigned int PPL_POLY_CON_RELATION_SATURATES;
136
137 unsigned int PPL_POLY_GEN_RELATION_SUBSUMES;
138
139 unsigned int PPL_COMPLEXITY_CLASS_POLYNOMIAL;
140 unsigned int PPL_COMPLEXITY_CLASS_SIMPLEX;
141 unsigned int PPL_COMPLEXITY_CLASS_ANY;
142
143 int PPL_MIP_PROBLEM_STATUS_UNFEASIBLE;
144 int PPL_MIP_PROBLEM_STATUS_UNBOUNDED;
145 int PPL_MIP_PROBLEM_STATUS_OPTIMIZED;
146
147 int PPL_MIP_PROBLEM_CONTROL_PARAMETER_NAME_PRICING;
148 int PPL_MIP_PROBLEM_CONTROL_PARAMETER_PRICING_STEEPEST_EDGE_FLOAT;
149 int PPL_MIP_PROBLEM_CONTROL_PARAMETER_PRICING_STEEPEST_EDGE_EXACT;
150 int PPL_MIP_PROBLEM_CONTROL_PARAMETER_PRICING_TEXTBOOK;
151
152 int PPL_PIP_PROBLEM_STATUS_UNFEASIBLE;
153 int PPL_PIP_PROBLEM_STATUS_OPTIMIZED;
154
155 int PPL_PIP_PROBLEM_CONTROL_PARAMETER_NAME_CUTTING_STRATEGY;
156 int PPL_PIP_PROBLEM_CONTROL_PARAMETER_CUTTING_STRATEGY_FIRST;
157 int PPL_PIP_PROBLEM_CONTROL_PARAMETER_CUTTING_STRATEGY_DEEPEST;
158 int PPL_PIP_PROBLEM_CONTROL_PARAMETER_CUTTING_STRATEGY_ALL;
159 int PPL_PIP_PROBLEM_CONTROL_PARAMETER_NAME_PIVOT_ROW_STRATEGY;
160 int PPL_PIP_PROBLEM_CONTROL_PARAMETER_PIVOT_ROW_STRATEGY_FIRST;
161 int PPL_PIP_PROBLEM_CONTROL_PARAMETER_PIVOT_ROW_STRATEGY_MAX_COLUMN;
162
163 int PPL_OPTIMIZATION_MODE_MINIMIZATION;
164 int PPL_OPTIMIZATION_MODE_MAXIMIZATION;
165
166 int
ppl_set_error_handler(error_handler_type h)167 ppl_set_error_handler(error_handler_type h) {
168 user_error_handler = h;
169 return 0;
170 }
171
172 int
ppl_initialize(void)173 ppl_initialize(void) try {
174 initialize();
175
176 PPL_POLY_CON_RELATION_IS_DISJOINT
177 = Poly_Con_Relation::is_disjoint().get_flags();
178 PPL_POLY_CON_RELATION_STRICTLY_INTERSECTS
179 = Poly_Con_Relation::strictly_intersects().get_flags();
180 PPL_POLY_CON_RELATION_IS_INCLUDED
181 = Poly_Con_Relation::is_included().get_flags();
182 PPL_POLY_CON_RELATION_SATURATES
183 = Poly_Con_Relation::saturates().get_flags();
184
185 PPL_POLY_GEN_RELATION_SUBSUMES
186 = Poly_Gen_Relation::subsumes().get_flags();
187
188 PPL_COMPLEXITY_CLASS_POLYNOMIAL = POLYNOMIAL_COMPLEXITY;
189 PPL_COMPLEXITY_CLASS_SIMPLEX = SIMPLEX_COMPLEXITY;
190 PPL_COMPLEXITY_CLASS_ANY = ANY_COMPLEXITY;
191
192 PPL_MIP_PROBLEM_STATUS_UNFEASIBLE = UNFEASIBLE_MIP_PROBLEM;
193 PPL_MIP_PROBLEM_STATUS_UNBOUNDED = UNBOUNDED_MIP_PROBLEM;
194 PPL_MIP_PROBLEM_STATUS_OPTIMIZED = OPTIMIZED_MIP_PROBLEM;
195
196 PPL_MIP_PROBLEM_CONTROL_PARAMETER_NAME_PRICING
197 = MIP_Problem::PRICING;
198 PPL_MIP_PROBLEM_CONTROL_PARAMETER_PRICING_STEEPEST_EDGE_FLOAT
199 = MIP_Problem::PRICING_STEEPEST_EDGE_FLOAT;
200 PPL_MIP_PROBLEM_CONTROL_PARAMETER_PRICING_STEEPEST_EDGE_EXACT
201 = MIP_Problem::PRICING_STEEPEST_EDGE_EXACT;
202 PPL_MIP_PROBLEM_CONTROL_PARAMETER_PRICING_TEXTBOOK
203 = MIP_Problem::PRICING_TEXTBOOK;
204
205 PPL_PIP_PROBLEM_STATUS_UNFEASIBLE = UNFEASIBLE_PIP_PROBLEM;
206 PPL_PIP_PROBLEM_STATUS_OPTIMIZED = OPTIMIZED_PIP_PROBLEM;
207
208 PPL_PIP_PROBLEM_CONTROL_PARAMETER_NAME_CUTTING_STRATEGY
209 = PIP_Problem::CUTTING_STRATEGY;
210 PPL_PIP_PROBLEM_CONTROL_PARAMETER_CUTTING_STRATEGY_FIRST
211 = PIP_Problem::CUTTING_STRATEGY_FIRST;
212 PPL_PIP_PROBLEM_CONTROL_PARAMETER_CUTTING_STRATEGY_DEEPEST
213 = PIP_Problem::CUTTING_STRATEGY_DEEPEST;
214 PPL_PIP_PROBLEM_CONTROL_PARAMETER_CUTTING_STRATEGY_ALL
215 = PIP_Problem::CUTTING_STRATEGY_ALL;
216 PPL_PIP_PROBLEM_CONTROL_PARAMETER_NAME_PIVOT_ROW_STRATEGY
217 = PIP_Problem::PIVOT_ROW_STRATEGY;
218 PPL_PIP_PROBLEM_CONTROL_PARAMETER_PIVOT_ROW_STRATEGY_FIRST
219 = PIP_Problem::PIVOT_ROW_STRATEGY_FIRST;
220 PPL_PIP_PROBLEM_CONTROL_PARAMETER_PIVOT_ROW_STRATEGY_MAX_COLUMN
221 = PIP_Problem::PIVOT_ROW_STRATEGY_MAX_COLUMN;
222
223 PPL_OPTIMIZATION_MODE_MINIMIZATION = MINIMIZATION;
224 PPL_OPTIMIZATION_MODE_MAXIMIZATION = MAXIMIZATION;
225
226 c_variable_output_function = c_variable_default_output_function;
227 saved_cxx_Variable_output_function = Variable::get_output_function();
228 Variable::set_output_function(cxx_Variable_output_function);
229
230 return 0;
231 }
232 CATCH_ALL
233
234 int
ppl_finalize(void)235 ppl_finalize(void) try {
236 Variable::set_output_function(saved_cxx_Variable_output_function);
237
238 finalize();
239 return 0;
240 }
241 CATCH_ALL
242
243 int
ppl_set_timeout(unsigned csecs)244 ppl_set_timeout(unsigned csecs) try {
245 // In case a timeout was already set.
246 reset_timeout();
247 static timeout_exception e;
248 using Parma_Polyhedra_Library::Watchdog;
249 p_timeout_object = new Watchdog(csecs, abandon_expensive_computations, e);
250 return 0;
251 }
252 CATCH_ALL
253
254 int
ppl_reset_timeout(void)255 ppl_reset_timeout(void) try {
256 reset_timeout();
257 return 0;
258 }
259 CATCH_ALL
260
261 int
ppl_set_deterministic_timeout(unsigned long unscaled_weight,unsigned scale)262 ppl_set_deterministic_timeout(unsigned long unscaled_weight,
263 unsigned scale) try {
264 // In case a deterministic timeout was already set.
265 reset_deterministic_timeout();
266 static timeout_exception e;
267 typedef Parma_Polyhedra_Library::Weightwatch_Traits Traits;
268 p_deterministic_timeout_object
269 = new Weightwatch(Traits::compute_delta(unscaled_weight, scale),
270 abandon_expensive_computations, e);
271 return 0;
272 }
273 CATCH_ALL
274
275 int
ppl_reset_deterministic_timeout(void)276 ppl_reset_deterministic_timeout(void) try {
277 reset_deterministic_timeout();
278 return 0;
279 }
280 CATCH_ALL
281
282 int
ppl_set_rounding_for_PPL(void)283 ppl_set_rounding_for_PPL(void) try {
284 set_rounding_for_PPL();
285 return 0;
286 }
287 CATCH_ALL
288
289 int
ppl_restore_pre_PPL_rounding(void)290 ppl_restore_pre_PPL_rounding(void) try {
291 restore_pre_PPL_rounding();
292 return 0;
293 }
294 CATCH_ALL
295
296 int
ppl_irrational_precision(unsigned * p)297 ppl_irrational_precision(unsigned* p) try {
298 *p = irrational_precision();
299 return 0;
300 }
301 CATCH_ALL
302
303 int
ppl_set_irrational_precision(unsigned p)304 ppl_set_irrational_precision(unsigned p) try {
305 set_irrational_precision(p);
306 return 0;
307 }
308 CATCH_ALL
309
310 int
ppl_version_major(void)311 ppl_version_major(void) try {
312 return static_cast<int>(version_major());
313 }
314 CATCH_ALL
315
316 int
ppl_version_minor(void)317 ppl_version_minor(void) try {
318 return static_cast<int>(version_minor());
319 }
320 CATCH_ALL
321
322 int
ppl_version_revision(void)323 ppl_version_revision(void) try {
324 return static_cast<int>(version_revision());
325 }
326 CATCH_ALL
327
328 int
ppl_version_beta(void)329 ppl_version_beta(void) try {
330 return static_cast<int>(version_beta());
331 }
332 CATCH_ALL
333
334 int
ppl_version(const char ** p)335 ppl_version(const char** p) try {
336 // Note: use explicit qualification to avoid clashes on, e.g.,
337 // Solaris 2.9, where `version' is the name of an enum defined in
338 // math.h.
339 *p = Parma_Polyhedra_Library::version();
340 return 0;
341 }
342 CATCH_ALL
343
344 int
ppl_banner(const char ** p)345 ppl_banner(const char** p) try {
346 *p = banner();
347 return 0;
348 }
349 CATCH_ALL
350
351 int
ppl_max_space_dimension(ppl_dimension_type * m)352 ppl_max_space_dimension(ppl_dimension_type* m) try {
353 *m = max_space_dimension();
354 return 0;
355 }
356 CATCH_ALL
357
358 int
ppl_not_a_dimension(ppl_dimension_type * m)359 ppl_not_a_dimension(ppl_dimension_type* m) try {
360 *m = not_a_dimension();
361 return 0;
362 }
363 CATCH_ALL
364
365 int
ppl_new_Coefficient(ppl_Coefficient_t * pc)366 ppl_new_Coefficient(ppl_Coefficient_t* pc) try {
367 *pc = to_nonconst(new Coefficient(0));
368 return 0;
369 }
370 CATCH_ALL
371
372 int
ppl_new_Coefficient_from_mpz_t(ppl_Coefficient_t * pc,mpz_t z)373 ppl_new_Coefficient_from_mpz_t(ppl_Coefficient_t* pc, mpz_t z) try {
374 *pc = to_nonconst(new Coefficient(reinterpret_mpz_class(z)));
375 return 0;
376 }
377 CATCH_ALL
378
379 int
ppl_new_Coefficient_from_Coefficient(ppl_Coefficient_t * pc,ppl_const_Coefficient_t c)380 ppl_new_Coefficient_from_Coefficient(ppl_Coefficient_t* pc,
381 ppl_const_Coefficient_t c) try {
382 const Coefficient& cc = *to_const(c);
383 *pc = to_nonconst(new Coefficient(cc));
384 return 0;
385 }
386 CATCH_ALL
387
388 int
ppl_Coefficient_to_mpz_t(ppl_const_Coefficient_t c,mpz_t z)389 ppl_Coefficient_to_mpz_t(ppl_const_Coefficient_t c, mpz_t z) try {
390 assign_r(reinterpret_mpz_class(z), *to_const(c), ROUND_NOT_NEEDED);
391 return 0;
392 }
393 CATCH_ALL
394
395 int
ppl_delete_Coefficient(ppl_const_Coefficient_t c)396 ppl_delete_Coefficient(ppl_const_Coefficient_t c) try {
397 delete to_const(c);
398 return 0;
399 }
400 CATCH_ALL
401
402 int
ppl_assign_Coefficient_from_mpz_t(ppl_Coefficient_t dst,mpz_t z)403 ppl_assign_Coefficient_from_mpz_t(ppl_Coefficient_t dst, mpz_t z) try {
404 Coefficient& ddst = *to_nonconst(dst);
405 ddst = reinterpret_mpz_class(z);
406 return 0;
407 }
408 CATCH_ALL
409
410 int
ppl_assign_Coefficient_from_Coefficient(ppl_Coefficient_t dst,ppl_const_Coefficient_t src)411 ppl_assign_Coefficient_from_Coefficient(ppl_Coefficient_t dst,
412 ppl_const_Coefficient_t src) try {
413 const Coefficient& ssrc = *to_const(src);
414 Coefficient& ddst = *to_nonconst(dst);
415 ddst = ssrc;
416 return 0;
417 }
418 CATCH_ALL
419
420 int
ppl_Coefficient_OK(ppl_const_Coefficient_t)421 ppl_Coefficient_OK(ppl_const_Coefficient_t /* c */) try {
422 return 1;
423 }
424 CATCH_ALL
425
426 int
ppl_Coefficient_is_bounded(void)427 ppl_Coefficient_is_bounded(void) try {
428 return std::numeric_limits<Coefficient>::is_bounded ? 1 : 0;
429 }
430 CATCH_ALL
431
432 int
ppl_Coefficient_min(mpz_t min)433 ppl_Coefficient_min(mpz_t min) try {
434 if (std::numeric_limits<Coefficient>::is_bounded) {
435 assign_r(reinterpret_mpz_class(min),
436 std::numeric_limits<Coefficient>::min(),
437 ROUND_NOT_NEEDED);
438 return 1;
439 }
440 else
441 return 0;
442 }
443 CATCH_ALL
444
445 int
ppl_Coefficient_max(mpz_t max)446 ppl_Coefficient_max(mpz_t max) try {
447 if (std::numeric_limits<Coefficient>::is_bounded) {
448 assign_r(reinterpret_mpz_class(max),
449 std::numeric_limits<Coefficient>::max(),
450 ROUND_NOT_NEEDED);
451 return 1;
452 }
453 else
454 return 0;
455 }
456 CATCH_ALL
457
458 /* Interface for Linear_Expression. */
459
460 int
ppl_new_Linear_Expression(ppl_Linear_Expression_t * ple)461 ppl_new_Linear_Expression(ppl_Linear_Expression_t* ple) try {
462 *ple = to_nonconst(new Linear_Expression());
463 return 0;
464 }
465 CATCH_ALL
466
467 int
ppl_new_Linear_Expression_with_dimension(ppl_Linear_Expression_t * ple,ppl_dimension_type d)468 ppl_new_Linear_Expression_with_dimension(ppl_Linear_Expression_t* ple,
469 ppl_dimension_type d) try {
470 *ple = to_nonconst(d == 0
471 ? new Linear_Expression(0)
472 : new Linear_Expression(0*Variable(d-1)));
473 return 0;
474 }
475 CATCH_ALL
476
477 int
ppl_new_Linear_Expression_from_Linear_Expression(ppl_Linear_Expression_t * ple,ppl_const_Linear_Expression_t le)478 ppl_new_Linear_Expression_from_Linear_Expression
479 (ppl_Linear_Expression_t* ple, ppl_const_Linear_Expression_t le) try {
480 const Linear_Expression& lle = *to_const(le);
481 *ple = to_nonconst(new Linear_Expression(lle));
482 return 0;
483 }
484 CATCH_ALL
485
486 int
ppl_delete_Linear_Expression(ppl_const_Linear_Expression_t le)487 ppl_delete_Linear_Expression(ppl_const_Linear_Expression_t le) try {
488 delete to_const(le);
489 return 0;
490 }
491 CATCH_ALL
492
493 int
ppl_assign_Linear_Expression_from_Linear_Expression(ppl_Linear_Expression_t dst,ppl_const_Linear_Expression_t src)494 ppl_assign_Linear_Expression_from_Linear_Expression
495 (ppl_Linear_Expression_t dst, ppl_const_Linear_Expression_t src) try {
496 const Linear_Expression& ssrc = *to_const(src);
497 Linear_Expression& ddst = *to_nonconst(dst);
498 ddst = ssrc;
499 return 0;
500 }
501 CATCH_ALL
502
503 int
ppl_Linear_Expression_add_to_coefficient(ppl_Linear_Expression_t le,ppl_dimension_type var,ppl_const_Coefficient_t n)504 ppl_Linear_Expression_add_to_coefficient(ppl_Linear_Expression_t le,
505 ppl_dimension_type var,
506 ppl_const_Coefficient_t n) try {
507 Linear_Expression& lle = *to_nonconst(le);
508 const Coefficient& nn = *to_const(n);
509 add_mul_assign(lle, nn, Variable(var));
510 return 0;
511 }
512 CATCH_ALL
513
514 int
ppl_Linear_Expression_add_to_inhomogeneous(ppl_Linear_Expression_t le,ppl_const_Coefficient_t n)515 ppl_Linear_Expression_add_to_inhomogeneous(ppl_Linear_Expression_t le,
516 ppl_const_Coefficient_t n) try {
517 Linear_Expression& lle = *to_nonconst(le);
518 const Coefficient& nn = *to_const(n);
519 lle += nn;
520 return 0;
521 }
522 CATCH_ALL
523
524 int
ppl_add_Linear_Expression_to_Linear_Expression(ppl_Linear_Expression_t dst,ppl_const_Linear_Expression_t src)525 ppl_add_Linear_Expression_to_Linear_Expression
526 (ppl_Linear_Expression_t dst, ppl_const_Linear_Expression_t src) try {
527 Linear_Expression& ddst = *to_nonconst(dst);
528 const Linear_Expression& ssrc = *to_const(src);
529 ddst += ssrc;
530 return 0;
531 }
532 CATCH_ALL
533
534 int
ppl_subtract_Linear_Expression_from_Linear_Expression(ppl_Linear_Expression_t dst,ppl_const_Linear_Expression_t src)535 ppl_subtract_Linear_Expression_from_Linear_Expression
536 (ppl_Linear_Expression_t dst, ppl_const_Linear_Expression_t src) try {
537 Linear_Expression& ddst = *to_nonconst(dst);
538 const Linear_Expression& ssrc = *to_const(src);
539 ddst -= ssrc;
540 return 0;
541 }
542 CATCH_ALL
543
544 int
ppl_multiply_Linear_Expression_by_Coefficient(ppl_Linear_Expression_t le,ppl_const_Coefficient_t n)545 ppl_multiply_Linear_Expression_by_Coefficient(ppl_Linear_Expression_t le,
546 ppl_const_Coefficient_t n) try {
547 Linear_Expression& lle = *to_nonconst(le);
548 const Coefficient& nn = *to_const(n);
549 lle *= nn;
550 return 0;
551 }
552 CATCH_ALL
553
554 int
ppl_Linear_Expression_space_dimension(ppl_const_Linear_Expression_t le,ppl_dimension_type * m)555 ppl_Linear_Expression_space_dimension(ppl_const_Linear_Expression_t le,
556 ppl_dimension_type* m) try {
557 *m = to_const(le)->space_dimension();
558 return 0;
559 }
560 CATCH_ALL
561
562 int
ppl_Linear_Expression_coefficient(ppl_const_Linear_Expression_t le,ppl_dimension_type var,ppl_Coefficient_t n)563 ppl_Linear_Expression_coefficient(ppl_const_Linear_Expression_t le,
564 ppl_dimension_type var,
565 ppl_Coefficient_t n) try {
566 const Linear_Expression& lle = *to_const(le);
567 Coefficient& nn = *to_nonconst(n);
568 nn = lle.coefficient(Variable(var));
569 return 0;
570 }
571 CATCH_ALL
572
573 int
ppl_Linear_Expression_inhomogeneous_term(ppl_const_Linear_Expression_t le,ppl_Coefficient_t n)574 ppl_Linear_Expression_inhomogeneous_term(ppl_const_Linear_Expression_t le,
575 ppl_Coefficient_t n) try {
576 const Linear_Expression& lle = *to_const(le);
577 Coefficient& nn = *to_nonconst(n);
578 nn = lle.inhomogeneous_term();
579 return 0;
580 }
581 CATCH_ALL
582
583 int
ppl_Linear_Expression_OK(ppl_const_Linear_Expression_t le)584 ppl_Linear_Expression_OK(ppl_const_Linear_Expression_t le) try {
585 return to_const(le)->OK() ? 1 : 0;
586 }
587 CATCH_ALL
588
589 int
ppl_Linear_Expression_is_zero(ppl_const_Linear_Expression_t le)590 ppl_Linear_Expression_is_zero(ppl_const_Linear_Expression_t le) try {
591 return to_const(le)->is_zero() ? 1 : 0;
592 }
593 CATCH_ALL
594
595 int
ppl_Linear_Expression_all_homogeneous_terms_are_zero(ppl_const_Linear_Expression_t le)596 ppl_Linear_Expression_all_homogeneous_terms_are_zero
597 (ppl_const_Linear_Expression_t le) try {
598 return to_const(le)->all_homogeneous_terms_are_zero() ? 1 : 0;
599 }
600 CATCH_ALL
601
602 /* Interface for Constraint. */
603
604 int
ppl_new_Constraint(ppl_Constraint_t * pc,ppl_const_Linear_Expression_t le,enum ppl_enum_Constraint_Type t)605 ppl_new_Constraint(ppl_Constraint_t* pc,
606 ppl_const_Linear_Expression_t le,
607 enum ppl_enum_Constraint_Type t) try {
608 Constraint* ppc;
609 const Linear_Expression& lle = *to_const(le);
610 switch (t) {
611 case PPL_CONSTRAINT_TYPE_EQUAL:
612 ppc = new Constraint(lle == 0);
613 break;
614 case PPL_CONSTRAINT_TYPE_GREATER_OR_EQUAL:
615 ppc = new Constraint(lle >= 0);
616 break;
617 case PPL_CONSTRAINT_TYPE_GREATER_THAN:
618 ppc = new Constraint(lle > 0);
619 break;
620 case PPL_CONSTRAINT_TYPE_LESS_OR_EQUAL:
621 ppc = new Constraint(lle <= 0);
622 break;
623 case PPL_CONSTRAINT_TYPE_LESS_THAN:
624 ppc = new Constraint(lle < 0);
625 break;
626 default:
627 throw std::invalid_argument("ppl_new_Constraint(pc, le, t): "
628 "t invalid");
629 }
630 *pc = to_nonconst(ppc);
631 return 0;
632 }
633 CATCH_ALL
634
635 int
ppl_new_Constraint_zero_dim_false(ppl_Constraint_t * pc)636 ppl_new_Constraint_zero_dim_false(ppl_Constraint_t* pc) try {
637 *pc = to_nonconst(new Constraint(Constraint::zero_dim_false()));
638 return 0;
639 }
640 CATCH_ALL
641
642 int
ppl_new_Constraint_zero_dim_positivity(ppl_Constraint_t * pc)643 ppl_new_Constraint_zero_dim_positivity(ppl_Constraint_t* pc) try {
644 *pc = to_nonconst(new Constraint(Constraint::zero_dim_positivity()));
645 return 0;
646 }
647 CATCH_ALL
648
649 int
ppl_new_Constraint_from_Constraint(ppl_Constraint_t * pc,ppl_const_Constraint_t c)650 ppl_new_Constraint_from_Constraint(ppl_Constraint_t* pc,
651 ppl_const_Constraint_t c) try {
652 const Constraint& cc = *to_const(c);
653 *pc = to_nonconst(new Constraint(cc));
654 return 0;
655 }
656 CATCH_ALL
657
658 int
ppl_delete_Constraint(ppl_const_Constraint_t le)659 ppl_delete_Constraint(ppl_const_Constraint_t le) try {
660 delete to_const(le);
661 return 0;
662 }
663 CATCH_ALL
664
665 int
ppl_assign_Constraint_from_Constraint(ppl_Constraint_t dst,ppl_const_Constraint_t src)666 ppl_assign_Constraint_from_Constraint(ppl_Constraint_t dst,
667 ppl_const_Constraint_t src) try {
668 const Constraint& ssrc = *to_const(src);
669 Constraint& ddst = *to_nonconst(dst);
670 ddst = ssrc;
671 return 0;
672 }
673 CATCH_ALL
674
675 int
ppl_Constraint_space_dimension(ppl_const_Constraint_t c,ppl_dimension_type * m)676 ppl_Constraint_space_dimension(ppl_const_Constraint_t c,
677 ppl_dimension_type* m) try {
678 *m = to_const(c)->space_dimension();
679 return 0;
680 }
681 CATCH_ALL
682
683 int
ppl_Constraint_type(ppl_const_Constraint_t c)684 ppl_Constraint_type(ppl_const_Constraint_t c) try {
685 switch (to_const(c)->type()) {
686 case Constraint::EQUALITY:
687 return PPL_CONSTRAINT_TYPE_EQUAL;
688 case Constraint::NONSTRICT_INEQUALITY:
689 return PPL_CONSTRAINT_TYPE_GREATER_OR_EQUAL;
690 case Constraint::STRICT_INEQUALITY:
691 return PPL_CONSTRAINT_TYPE_GREATER_THAN;
692 }
693 PPL_UNREACHABLE;
694 }
695 CATCH_ALL
696
697 int
ppl_Constraint_coefficient(ppl_const_Constraint_t c,ppl_dimension_type var,ppl_Coefficient_t n)698 ppl_Constraint_coefficient(ppl_const_Constraint_t c,
699 ppl_dimension_type var,
700 ppl_Coefficient_t n) try {
701 const Constraint& cc = *to_const(c);
702 Coefficient& nn = *to_nonconst(n);
703 nn = cc.coefficient(Variable(var));
704 return 0;
705 }
706 CATCH_ALL
707
708 int
ppl_Constraint_inhomogeneous_term(ppl_const_Constraint_t c,ppl_Coefficient_t n)709 ppl_Constraint_inhomogeneous_term(ppl_const_Constraint_t c,
710 ppl_Coefficient_t n) try {
711 const Constraint& cc = *to_const(c);
712 Coefficient& nn = *to_nonconst(n);
713 nn = cc.inhomogeneous_term();
714 return 0;
715 }
716 CATCH_ALL
717
718 int
ppl_Constraint_OK(ppl_const_Constraint_t c)719 ppl_Constraint_OK(ppl_const_Constraint_t c) try {
720 return to_const(c)->OK() ? 1 : 0;
721 }
722 CATCH_ALL
723
724 int
ppl_new_Linear_Expression_from_Constraint(ppl_Linear_Expression_t * ple,ppl_const_Constraint_t c)725 ppl_new_Linear_Expression_from_Constraint(ppl_Linear_Expression_t* ple,
726 ppl_const_Constraint_t c) try {
727 const Constraint& cc = *to_const(c);
728 *ple = to_nonconst(new Linear_Expression(cc.expression()));
729 return 0;
730 }
731 CATCH_ALL
732
733 /* Interface for Constraint_System. */
734
735 int
ppl_new_Constraint_System(ppl_Constraint_System_t * pcs)736 ppl_new_Constraint_System(ppl_Constraint_System_t* pcs) try {
737 *pcs = to_nonconst(new Constraint_System());
738 return 0;
739 }
740 CATCH_ALL
741
742 int
ppl_new_Constraint_System_zero_dim_empty(ppl_Constraint_System_t * pcs)743 ppl_new_Constraint_System_zero_dim_empty(ppl_Constraint_System_t* pcs) try {
744 *pcs = to_nonconst(new
745 Constraint_System(Constraint_System::zero_dim_empty()));
746 return 0;
747 }
748 CATCH_ALL
749
750
751 int
ppl_new_Constraint_System_from_Constraint(ppl_Constraint_System_t * pcs,ppl_const_Constraint_t c)752 ppl_new_Constraint_System_from_Constraint(ppl_Constraint_System_t* pcs,
753 ppl_const_Constraint_t c) try {
754 const Constraint& cc = *to_const(c);
755 *pcs = to_nonconst(new Constraint_System(cc));
756 return 0;
757 }
758 CATCH_ALL
759
760 int
ppl_new_Constraint_System_from_Constraint_System(ppl_Constraint_System_t * pcs,ppl_const_Constraint_System_t cs)761 ppl_new_Constraint_System_from_Constraint_System
762 (ppl_Constraint_System_t* pcs, ppl_const_Constraint_System_t cs) try {
763 const Constraint_System& ccs = *to_const(cs);
764 *pcs = to_nonconst(new Constraint_System(ccs));
765 return 0;
766 }
767 CATCH_ALL
768
769 int
ppl_delete_Constraint_System(ppl_const_Constraint_System_t cs)770 ppl_delete_Constraint_System(ppl_const_Constraint_System_t cs) try {
771 delete to_const(cs);
772 return 0;
773 }
774 CATCH_ALL
775
776 int
ppl_assign_Constraint_System_from_Constraint_System(ppl_Constraint_System_t dst,ppl_const_Constraint_System_t src)777 ppl_assign_Constraint_System_from_Constraint_System
778 (ppl_Constraint_System_t dst, ppl_const_Constraint_System_t src) try {
779 const Constraint_System& ssrc = *to_const(src);
780 Constraint_System& ddst = *to_nonconst(dst);
781 ddst = ssrc;
782 return 0;
783 }
784 CATCH_ALL
785
786 int
ppl_Constraint_System_space_dimension(ppl_const_Constraint_System_t cs,ppl_dimension_type * m)787 ppl_Constraint_System_space_dimension(ppl_const_Constraint_System_t cs,
788 ppl_dimension_type* m) try {
789 *m = to_const(cs)->space_dimension();
790 return 0;
791 }
792 CATCH_ALL
793
794 int
ppl_Constraint_System_empty(ppl_const_Constraint_System_t cs)795 ppl_Constraint_System_empty
796 (ppl_const_Constraint_System_t cs) try {
797 const Constraint_System& ccs = *to_const(cs);
798 return ccs.empty() ? 1 : 0;
799 }
800 CATCH_ALL
801
802 int
ppl_Constraint_System_has_strict_inequalities(ppl_const_Constraint_System_t cs)803 ppl_Constraint_System_has_strict_inequalities
804 (ppl_const_Constraint_System_t cs) try {
805 const Constraint_System& ccs = *to_const(cs);
806 return ccs.has_strict_inequalities() ? 1 : 0;
807 }
808 CATCH_ALL
809
810 int
ppl_Constraint_System_clear(ppl_Constraint_System_t cs)811 ppl_Constraint_System_clear(ppl_Constraint_System_t cs) try {
812 to_nonconst(cs)->clear();
813 return 0;
814 }
815 CATCH_ALL
816
817 int
ppl_Constraint_System_insert_Constraint(ppl_Constraint_System_t cs,ppl_const_Constraint_t c)818 ppl_Constraint_System_insert_Constraint(ppl_Constraint_System_t cs,
819 ppl_const_Constraint_t c) try {
820 const Constraint& cc = *to_const(c);
821 Constraint_System& ccs = *to_nonconst(cs);
822 ccs.insert(cc);
823 return 0;
824 }
825 CATCH_ALL
826
827 int
ppl_Constraint_System_OK(ppl_const_Constraint_System_t cs)828 ppl_Constraint_System_OK(ppl_const_Constraint_System_t cs) try {
829 return to_const(cs)->OK() ? 1 : 0;
830 }
831 CATCH_ALL
832
833 /* Interface for Constraint_System::const_iterator. */
834
835 int
ppl_new_Constraint_System_const_iterator(ppl_Constraint_System_const_iterator_t * pcit)836 ppl_new_Constraint_System_const_iterator
837 (ppl_Constraint_System_const_iterator_t* pcit) try {
838 *pcit = to_nonconst(new Constraint_System::const_iterator());
839 return 0;
840 }
841 CATCH_ALL
842
843 int
ppl_new_Constraint_System_const_iterator_from_Constraint_System_const_iterator(ppl_Constraint_System_const_iterator_t * pcit,ppl_const_Constraint_System_const_iterator_t cit)844 ppl_new_Constraint_System_const_iterator_from_Constraint_System_const_iterator
845 (ppl_Constraint_System_const_iterator_t* pcit,
846 ppl_const_Constraint_System_const_iterator_t cit) try {
847 *pcit = to_nonconst(new Constraint_System::const_iterator(*to_const(cit)));
848 return 0;
849 }
850 CATCH_ALL
851
852 int
ppl_delete_Constraint_System_const_iterator(ppl_const_Constraint_System_const_iterator_t cit)853 ppl_delete_Constraint_System_const_iterator
854 (ppl_const_Constraint_System_const_iterator_t cit)
855 try {
856 delete to_const(cit);
857 return 0;
858 }
859 CATCH_ALL
860
861 int
ppl_assign_Constraint_System_const_iterator_from_Constraint_System_const_iterator(ppl_Constraint_System_const_iterator_t dst,ppl_const_Constraint_System_const_iterator_t src)862 ppl_assign_Constraint_System_const_iterator_from_Constraint_System_const_iterator
863 (ppl_Constraint_System_const_iterator_t dst,
864 ppl_const_Constraint_System_const_iterator_t src) try {
865 const Constraint_System::const_iterator& ssrc = *to_const(src);
866 Constraint_System::const_iterator& ddst = *to_nonconst(dst);
867 ddst = ssrc;
868 return 0;
869 }
870 CATCH_ALL
871
872 int
ppl_Constraint_System_begin(ppl_const_Constraint_System_t cs,ppl_Constraint_System_const_iterator_t cit)873 ppl_Constraint_System_begin(ppl_const_Constraint_System_t cs,
874 ppl_Constraint_System_const_iterator_t cit) try {
875 const Constraint_System& ccs = *to_const(cs);
876 Constraint_System::const_iterator& ccit = *to_nonconst(cit);
877 ccit = ccs.begin();
878 return 0;
879 }
880 CATCH_ALL
881
882 int
ppl_Constraint_System_end(ppl_const_Constraint_System_t cs,ppl_Constraint_System_const_iterator_t cit)883 ppl_Constraint_System_end(ppl_const_Constraint_System_t cs,
884 ppl_Constraint_System_const_iterator_t cit) try {
885 const Constraint_System& ccs = *to_const(cs);
886 Constraint_System::const_iterator& ccit = *to_nonconst(cit);
887 ccit = ccs.end();
888 return 0;
889 }
890 CATCH_ALL
891
892 int
ppl_Constraint_System_const_iterator_dereference(ppl_const_Constraint_System_const_iterator_t cit,ppl_const_Constraint_t * pc)893 ppl_Constraint_System_const_iterator_dereference
894 (ppl_const_Constraint_System_const_iterator_t cit,
895 ppl_const_Constraint_t* pc) try {
896 const Constraint_System::const_iterator& ccit = *to_const(cit);
897 const Constraint& c = *ccit;
898 *pc = to_const(&c);
899 return 0;
900 }
901 CATCH_ALL
902
903 int
ppl_Constraint_System_const_iterator_increment(ppl_Constraint_System_const_iterator_t cit)904 ppl_Constraint_System_const_iterator_increment
905 (ppl_Constraint_System_const_iterator_t cit) try {
906 Constraint_System::const_iterator& ccit = *to_nonconst(cit);
907 ++ccit;
908 return 0;
909 }
910 CATCH_ALL
911
912 int
ppl_Constraint_System_const_iterator_equal_test(ppl_const_Constraint_System_const_iterator_t x,ppl_const_Constraint_System_const_iterator_t y)913 ppl_Constraint_System_const_iterator_equal_test
914 (ppl_const_Constraint_System_const_iterator_t x,
915 ppl_const_Constraint_System_const_iterator_t y) try {
916 const Constraint_System::const_iterator& xx = *to_const(x);
917 const Constraint_System::const_iterator& yy = *to_const(y);
918 return (xx == yy) ? 1 : 0;
919 }
920 CATCH_ALL
921
922 /* Interface for Generator. */
923
924 int
ppl_new_Generator(ppl_Generator_t * pg,ppl_const_Linear_Expression_t le,enum ppl_enum_Generator_Type t,ppl_const_Coefficient_t d)925 ppl_new_Generator(ppl_Generator_t* pg,
926 ppl_const_Linear_Expression_t le,
927 enum ppl_enum_Generator_Type t,
928 ppl_const_Coefficient_t d) try {
929 Generator* ppg;
930 const Linear_Expression& lle = *to_const(le);
931 const Coefficient& dd = *to_const(d);
932 switch (t) {
933 case PPL_GENERATOR_TYPE_POINT:
934 ppg = new Generator(Generator::point(lle, dd));
935 break;
936 case PPL_GENERATOR_TYPE_CLOSURE_POINT:
937 ppg = new Generator(Generator::closure_point(lle, dd));
938 break;
939 case PPL_GENERATOR_TYPE_RAY:
940 ppg = new Generator(Generator::ray(lle));
941 break;
942 case PPL_GENERATOR_TYPE_LINE:
943 ppg = new Generator(Generator::line(lle));
944 break;
945 default:
946 throw std::invalid_argument("ppl_new_Generator(pg, le, t, d): t invalid");
947 }
948 *pg = to_nonconst(ppg);
949 return 0;
950 }
951 CATCH_ALL
952
953 int
ppl_new_Generator_zero_dim_point(ppl_Generator_t * pg)954 ppl_new_Generator_zero_dim_point(ppl_Generator_t* pg) try {
955 *pg = to_nonconst(new Generator(Generator::zero_dim_point()));
956 return 0;
957 }
958 CATCH_ALL
959
960 int
ppl_new_Generator_zero_dim_closure_point(ppl_Generator_t * pg)961 ppl_new_Generator_zero_dim_closure_point(ppl_Generator_t* pg) try {
962 *pg = to_nonconst(new Generator(Generator::zero_dim_closure_point()));
963 return 0;
964 }
965 CATCH_ALL
966
967 int
ppl_new_Generator_from_Generator(ppl_Generator_t * pg,ppl_const_Generator_t g)968 ppl_new_Generator_from_Generator(ppl_Generator_t* pg,
969 ppl_const_Generator_t g) try {
970 const Generator& gg = *to_const(g);
971 *pg = to_nonconst(new Generator(gg));
972 return 0;
973 }
974 CATCH_ALL
975
976 int
ppl_delete_Generator(ppl_const_Generator_t le)977 ppl_delete_Generator(ppl_const_Generator_t le) try {
978 delete to_const(le);
979 return 0;
980 }
981 CATCH_ALL
982
983 int
ppl_assign_Generator_from_Generator(ppl_Generator_t dst,ppl_const_Generator_t src)984 ppl_assign_Generator_from_Generator(ppl_Generator_t dst,
985 ppl_const_Generator_t src) try {
986 const Generator& ssrc = *to_const(src);
987 Generator& ddst = *to_nonconst(dst);
988 ddst = ssrc;
989 return 0;
990 }
991 CATCH_ALL
992
993 int
ppl_Generator_space_dimension(ppl_const_Generator_t g,ppl_dimension_type * m)994 ppl_Generator_space_dimension(ppl_const_Generator_t g,
995 ppl_dimension_type* m) try {
996 *m = to_const(g)->space_dimension();
997 return 0;
998 }
999 CATCH_ALL
1000
1001 int
ppl_Generator_type(ppl_const_Generator_t g)1002 ppl_Generator_type(ppl_const_Generator_t g) try {
1003 switch (to_const(g)->type()) {
1004 case Generator::LINE:
1005 return PPL_GENERATOR_TYPE_LINE;
1006 case Generator::RAY:
1007 return PPL_GENERATOR_TYPE_RAY;
1008 case Generator::POINT:
1009 return PPL_GENERATOR_TYPE_POINT;
1010 case Generator::CLOSURE_POINT:
1011 return PPL_GENERATOR_TYPE_CLOSURE_POINT;
1012 }
1013 PPL_UNREACHABLE;
1014 }
1015 CATCH_ALL
1016
1017 int
ppl_Generator_coefficient(ppl_const_Generator_t g,ppl_dimension_type var,ppl_Coefficient_t n)1018 ppl_Generator_coefficient(ppl_const_Generator_t g,
1019 ppl_dimension_type var,
1020 ppl_Coefficient_t n) try {
1021 const Generator& gg = *to_const(g);
1022 Coefficient& nn = *to_nonconst(n);
1023 nn = gg.coefficient(Variable(var));
1024 return 0;
1025 }
1026 CATCH_ALL
1027
1028 int
ppl_Generator_divisor(ppl_const_Generator_t g,ppl_Coefficient_t n)1029 ppl_Generator_divisor(ppl_const_Generator_t g,
1030 ppl_Coefficient_t n) try {
1031 const Generator& gg = *to_const(g);
1032 Coefficient& nn = *to_nonconst(n);
1033 nn = gg.divisor();
1034 return 0;
1035 }
1036 CATCH_ALL
1037
1038 int
ppl_Generator_OK(ppl_const_Generator_t g)1039 ppl_Generator_OK(ppl_const_Generator_t g) try {
1040 return to_const(g)->OK() ? 1 : 0;
1041 }
1042 CATCH_ALL
1043
1044 int
ppl_new_Linear_Expression_from_Generator(ppl_Linear_Expression_t * ple,ppl_const_Generator_t g)1045 ppl_new_Linear_Expression_from_Generator(ppl_Linear_Expression_t* ple,
1046 ppl_const_Generator_t g) try {
1047 const Generator& gg = *to_const(g);
1048 *ple = to_nonconst(new Linear_Expression(gg.expression()));
1049 return 0;
1050 }
1051 CATCH_ALL
1052
1053 /* Interface for Generator_System. */
1054
1055 int
ppl_new_Generator_System(ppl_Generator_System_t * pgs)1056 ppl_new_Generator_System(ppl_Generator_System_t* pgs) try {
1057 *pgs = to_nonconst(new Generator_System());
1058 return 0;
1059 }
1060 CATCH_ALL
1061
1062 int
ppl_new_Generator_System_zero_dim_univ(ppl_Generator_System_t * pgs)1063 ppl_new_Generator_System_zero_dim_univ(ppl_Generator_System_t* pgs) try {
1064 *pgs = to_nonconst(new Generator_System(Generator_System::zero_dim_univ()));
1065 return 0;
1066 }
1067 CATCH_ALL
1068
1069 int
ppl_new_Generator_System_from_Generator(ppl_Generator_System_t * pgs,ppl_const_Generator_t g)1070 ppl_new_Generator_System_from_Generator(ppl_Generator_System_t* pgs,
1071 ppl_const_Generator_t g) try {
1072 const Generator& gg = *to_const(g);
1073 *pgs = to_nonconst(new Generator_System(gg));
1074 return 0;
1075 }
1076 CATCH_ALL
1077
1078 int
ppl_new_Generator_System_from_Generator_System(ppl_Generator_System_t * pgs,ppl_const_Generator_System_t gs)1079 ppl_new_Generator_System_from_Generator_System
1080 (ppl_Generator_System_t* pgs, ppl_const_Generator_System_t gs) try {
1081 const Generator_System& ggs = *to_const(gs);
1082 *pgs = to_nonconst(new Generator_System(ggs));
1083 return 0;
1084 }
1085 CATCH_ALL
1086
1087 int
ppl_delete_Generator_System(ppl_const_Generator_System_t gs)1088 ppl_delete_Generator_System(ppl_const_Generator_System_t gs) try {
1089 delete to_const(gs);
1090 return 0;
1091 }
1092 CATCH_ALL
1093
1094 int
ppl_assign_Generator_System_from_Generator_System(ppl_Generator_System_t dst,ppl_const_Generator_System_t src)1095 ppl_assign_Generator_System_from_Generator_System
1096 (ppl_Generator_System_t dst, ppl_const_Generator_System_t src) try {
1097 const Generator_System& ssrc = *to_const(src);
1098 Generator_System& ddst = *to_nonconst(dst);
1099 ddst = ssrc;
1100 return 0;
1101 }
1102 CATCH_ALL
1103
1104 int
ppl_Generator_System_space_dimension(ppl_const_Generator_System_t gs,ppl_dimension_type * m)1105 ppl_Generator_System_space_dimension(ppl_const_Generator_System_t gs,
1106 ppl_dimension_type* m) try {
1107 *m = to_const(gs)->space_dimension();
1108 return 0;
1109 }
1110 CATCH_ALL
1111
1112 int
ppl_Generator_System_empty(ppl_const_Generator_System_t gs)1113 ppl_Generator_System_empty
1114 (ppl_const_Generator_System_t gs) try {
1115 const Generator_System& cgs = *to_const(gs);
1116 return cgs.empty() ? 1 : 0;
1117 }
1118 CATCH_ALL
1119
1120 int
ppl_Generator_System_clear(ppl_Generator_System_t gs)1121 ppl_Generator_System_clear(ppl_Generator_System_t gs) try {
1122 to_nonconst(gs)->clear();
1123 return 0;
1124 }
1125 CATCH_ALL
1126
1127 int
ppl_Generator_System_insert_Generator(ppl_Generator_System_t gs,ppl_const_Generator_t g)1128 ppl_Generator_System_insert_Generator(ppl_Generator_System_t gs,
1129 ppl_const_Generator_t g) try {
1130 const Generator& gg = *to_const(g);
1131 Generator_System& ggs = *to_nonconst(gs);
1132 ggs.insert(gg);
1133 return 0;
1134 }
1135 CATCH_ALL
1136
1137 int
ppl_Generator_System_OK(ppl_const_Generator_System_t gs)1138 ppl_Generator_System_OK(ppl_const_Generator_System_t gs) try {
1139 return to_const(gs)->OK() ? 1 : 0;
1140 }
1141 CATCH_ALL
1142
1143 /* Interface for Generator_System::const_iterator. */
1144
1145 int
ppl_new_Generator_System_const_iterator(ppl_Generator_System_const_iterator_t * pgit)1146 ppl_new_Generator_System_const_iterator
1147 (ppl_Generator_System_const_iterator_t* pgit) try {
1148 *pgit = to_nonconst(new Generator_System::const_iterator());
1149 return 0;
1150 }
1151 CATCH_ALL
1152
1153 int
ppl_new_Generator_System_const_iterator_from_Generator_System_const_iterator(ppl_Generator_System_const_iterator_t * pgit,ppl_const_Generator_System_const_iterator_t git)1154 ppl_new_Generator_System_const_iterator_from_Generator_System_const_iterator
1155 (ppl_Generator_System_const_iterator_t* pgit,
1156 ppl_const_Generator_System_const_iterator_t git) try {
1157 *pgit = to_nonconst(new Generator_System::const_iterator(*to_const(git)));
1158 return 0;
1159 }
1160 CATCH_ALL
1161
1162 int
ppl_delete_Generator_System_const_iterator(ppl_const_Generator_System_const_iterator_t git)1163 ppl_delete_Generator_System_const_iterator
1164 (ppl_const_Generator_System_const_iterator_t git) try {
1165 delete to_const(git);
1166 return 0;
1167 }
1168 CATCH_ALL
1169
1170 int
ppl_assign_Generator_System_const_iterator_from_Generator_System_const_iterator(ppl_Generator_System_const_iterator_t dst,ppl_const_Generator_System_const_iterator_t src)1171 ppl_assign_Generator_System_const_iterator_from_Generator_System_const_iterator
1172 (ppl_Generator_System_const_iterator_t dst,
1173 ppl_const_Generator_System_const_iterator_t src) try {
1174 const Generator_System::const_iterator& ssrc = *to_const(src);
1175 Generator_System::const_iterator& ddst = *to_nonconst(dst);
1176 ddst = ssrc;
1177 return 0;
1178 }
1179 CATCH_ALL
1180
1181 int
ppl_Generator_System_begin(ppl_const_Generator_System_t gs,ppl_Generator_System_const_iterator_t git)1182 ppl_Generator_System_begin(ppl_const_Generator_System_t gs,
1183 ppl_Generator_System_const_iterator_t git) try {
1184 const Generator_System& ggs = *to_const(gs);
1185 Generator_System::const_iterator& ggit = *to_nonconst(git);
1186 ggit = ggs.begin();
1187 return 0;
1188 }
1189 CATCH_ALL
1190
1191 int
ppl_Generator_System_end(ppl_const_Generator_System_t gs,ppl_Generator_System_const_iterator_t git)1192 ppl_Generator_System_end(ppl_const_Generator_System_t gs,
1193 ppl_Generator_System_const_iterator_t git) try {
1194 const Generator_System& ggs = *to_const(gs);
1195 Generator_System::const_iterator& ggit = *to_nonconst(git);
1196 ggit = ggs.end();
1197 return 0;
1198 }
1199 CATCH_ALL
1200
1201 int
ppl_Generator_System_const_iterator_dereference(ppl_const_Generator_System_const_iterator_t git,ppl_const_Generator_t * pg)1202 ppl_Generator_System_const_iterator_dereference
1203 (ppl_const_Generator_System_const_iterator_t git,
1204 ppl_const_Generator_t* pg) try {
1205 const Generator_System::const_iterator& ggit = *to_const(git);
1206 const Generator& c = *ggit;
1207 *pg = to_const(&c);
1208 return 0;
1209 }
1210 CATCH_ALL
1211
1212 int
ppl_Generator_System_const_iterator_increment(ppl_Generator_System_const_iterator_t git)1213 ppl_Generator_System_const_iterator_increment
1214 (ppl_Generator_System_const_iterator_t git) try {
1215 Generator_System::const_iterator& ggit = *to_nonconst(git);
1216 ++ggit;
1217 return 0;
1218 }
1219 CATCH_ALL
1220
1221 int
ppl_Generator_System_const_iterator_equal_test(ppl_const_Generator_System_const_iterator_t x,ppl_const_Generator_System_const_iterator_t y)1222 ppl_Generator_System_const_iterator_equal_test
1223 (ppl_const_Generator_System_const_iterator_t x,
1224 ppl_const_Generator_System_const_iterator_t y) try {
1225 const Generator_System::const_iterator& xx = *to_const(x);
1226 const Generator_System::const_iterator& yy = *to_const(y);
1227 return (xx == yy) ? 1 : 0;
1228 }
1229 CATCH_ALL
1230
1231 /* Interface for Congruence. */
1232
1233 int
ppl_new_Congruence(ppl_Congruence_t * pc,ppl_const_Linear_Expression_t le,ppl_const_Coefficient_t m)1234 ppl_new_Congruence(ppl_Congruence_t* pc,
1235 ppl_const_Linear_Expression_t le,
1236 ppl_const_Coefficient_t m) try {
1237 Congruence* ppc;
1238 const Linear_Expression& lle = *to_const(le);
1239 const Coefficient& mm = *to_const(m);
1240 ppc = new Congruence((lle %= 0) / mm);
1241 *pc = to_nonconst(ppc);
1242 return 0;
1243 }
1244 CATCH_ALL
1245
1246 int
ppl_new_Congruence_zero_dim_false(ppl_Congruence_t * pc)1247 ppl_new_Congruence_zero_dim_false(ppl_Congruence_t* pc) try {
1248 *pc = to_nonconst(new Congruence(Congruence::zero_dim_false()));
1249 return 0;
1250 }
1251 CATCH_ALL
1252
1253 int
ppl_new_Congruence_zero_dim_integrality(ppl_Congruence_t * pc)1254 ppl_new_Congruence_zero_dim_integrality(ppl_Congruence_t* pc) try {
1255 *pc = to_nonconst(new Congruence(Congruence::zero_dim_integrality()));
1256 return 0;
1257 }
1258 CATCH_ALL
1259
1260 int
ppl_new_Congruence_from_Congruence(ppl_Congruence_t * pc,ppl_const_Congruence_t c)1261 ppl_new_Congruence_from_Congruence(ppl_Congruence_t* pc,
1262 ppl_const_Congruence_t c) try {
1263 const Congruence& cc = *to_const(c);
1264 *pc = to_nonconst(new Congruence(cc));
1265 return 0;
1266 }
1267 CATCH_ALL
1268
1269 int
ppl_delete_Congruence(ppl_const_Congruence_t le)1270 ppl_delete_Congruence(ppl_const_Congruence_t le) try {
1271 delete to_const(le);
1272 return 0;
1273 }
1274 CATCH_ALL
1275
1276 int
ppl_assign_Congruence_from_Congruence(ppl_Congruence_t dst,ppl_const_Congruence_t src)1277 ppl_assign_Congruence_from_Congruence(ppl_Congruence_t dst,
1278 ppl_const_Congruence_t src) try {
1279 const Congruence& ssrc = *to_const(src);
1280 Congruence& ddst = *to_nonconst(dst);
1281 ddst = ssrc;
1282 return 0;
1283 }
1284 CATCH_ALL
1285
1286 int
ppl_Congruence_space_dimension(ppl_const_Congruence_t c,ppl_dimension_type * m)1287 ppl_Congruence_space_dimension(ppl_const_Congruence_t c,
1288 ppl_dimension_type* m) try {
1289 *m = to_const(c)->space_dimension();
1290 return 0;
1291 }
1292 CATCH_ALL
1293
1294 int
ppl_Congruence_coefficient(ppl_const_Congruence_t c,ppl_dimension_type var,ppl_Coefficient_t n)1295 ppl_Congruence_coefficient(ppl_const_Congruence_t c,
1296 ppl_dimension_type var,
1297 ppl_Coefficient_t n) try {
1298 const Congruence& cc = *to_const(c);
1299 Coefficient& nn = *to_nonconst(n);
1300 nn = cc.coefficient(Variable(var));
1301 return 0;
1302 }
1303 CATCH_ALL
1304
1305 int
ppl_Congruence_inhomogeneous_term(ppl_const_Congruence_t c,ppl_Coefficient_t n)1306 ppl_Congruence_inhomogeneous_term(ppl_const_Congruence_t c,
1307 ppl_Coefficient_t n) try {
1308 const Congruence& cc = *to_const(c);
1309 Coefficient& nn = *to_nonconst(n);
1310 nn = cc.inhomogeneous_term();
1311 return 0;
1312 }
1313 CATCH_ALL
1314
1315 int
ppl_Congruence_modulus(ppl_const_Congruence_t c,ppl_Coefficient_t m)1316 ppl_Congruence_modulus(ppl_const_Congruence_t c,
1317 ppl_Coefficient_t m) try {
1318 const Congruence& cc = *to_const(c);
1319 Coefficient& mm = *to_nonconst(m);
1320 mm = cc.modulus();
1321 return 0;
1322 }
1323 CATCH_ALL
1324
1325 int
ppl_Congruence_OK(ppl_const_Congruence_t c)1326 ppl_Congruence_OK(ppl_const_Congruence_t c) try {
1327 return to_const(c)->OK() ? 1 : 0;
1328 }
1329 CATCH_ALL
1330
1331 int
ppl_new_Linear_Expression_from_Congruence(ppl_Linear_Expression_t * ple,ppl_const_Congruence_t c)1332 ppl_new_Linear_Expression_from_Congruence(ppl_Linear_Expression_t* ple,
1333 ppl_const_Congruence_t c) try {
1334 const Congruence& cc = *to_const(c);
1335 *ple = to_nonconst(new Linear_Expression(cc.expression()));
1336 return 0;
1337 }
1338 CATCH_ALL
1339
1340 /* Interface for Congruence_System. */
1341
1342 int
ppl_new_Congruence_System(ppl_Congruence_System_t * pcs)1343 ppl_new_Congruence_System(ppl_Congruence_System_t* pcs) try {
1344 *pcs = to_nonconst(new Congruence_System());
1345 return 0;
1346 }
1347 CATCH_ALL
1348
1349 int
ppl_new_Congruence_System_zero_dim_empty(ppl_Congruence_System_t * pcs)1350 ppl_new_Congruence_System_zero_dim_empty(ppl_Congruence_System_t* pcs) try {
1351 *pcs = to_nonconst(new
1352 Congruence_System(Congruence_System::zero_dim_empty()));
1353 return 0;
1354 }
1355 CATCH_ALL
1356
1357
1358 int
ppl_new_Congruence_System_from_Congruence(ppl_Congruence_System_t * pcs,ppl_const_Congruence_t c)1359 ppl_new_Congruence_System_from_Congruence(ppl_Congruence_System_t* pcs,
1360 ppl_const_Congruence_t c) try {
1361 const Congruence& cc = *to_const(c);
1362 *pcs = to_nonconst(new Congruence_System(cc));
1363 return 0;
1364 }
1365 CATCH_ALL
1366
1367 int
ppl_new_Congruence_System_from_Congruence_System(ppl_Congruence_System_t * pcs,ppl_const_Congruence_System_t cs)1368 ppl_new_Congruence_System_from_Congruence_System
1369 (ppl_Congruence_System_t* pcs, ppl_const_Congruence_System_t cs) try {
1370 const Congruence_System& ccs = *to_const(cs);
1371 *pcs = to_nonconst(new Congruence_System(ccs));
1372 return 0;
1373 }
1374 CATCH_ALL
1375
1376 int
ppl_delete_Congruence_System(ppl_const_Congruence_System_t cs)1377 ppl_delete_Congruence_System(ppl_const_Congruence_System_t cs) try {
1378 delete to_const(cs);
1379 return 0;
1380 }
1381 CATCH_ALL
1382
1383 int
ppl_assign_Congruence_System_from_Congruence_System(ppl_Congruence_System_t dst,ppl_const_Congruence_System_t src)1384 ppl_assign_Congruence_System_from_Congruence_System
1385 (ppl_Congruence_System_t dst, ppl_const_Congruence_System_t src) try {
1386 const Congruence_System& ssrc = *to_const(src);
1387 Congruence_System& ddst = *to_nonconst(dst);
1388 ddst = ssrc;
1389 return 0;
1390 }
1391 CATCH_ALL
1392
1393 int
ppl_Congruence_System_space_dimension(ppl_const_Congruence_System_t cs,ppl_dimension_type * m)1394 ppl_Congruence_System_space_dimension(ppl_const_Congruence_System_t cs,
1395 ppl_dimension_type* m) try {
1396 *m = to_const(cs)->space_dimension();
1397 return 0;
1398 }
1399 CATCH_ALL
1400
1401 int
ppl_Congruence_System_empty(ppl_const_Congruence_System_t cs)1402 ppl_Congruence_System_empty
1403 (ppl_const_Congruence_System_t cs) try {
1404 const Congruence_System& ccs = *to_const(cs);
1405 return ccs.empty() ? 1 : 0;
1406 }
1407 CATCH_ALL
1408
1409 int
ppl_Congruence_System_clear(ppl_Congruence_System_t cs)1410 ppl_Congruence_System_clear(ppl_Congruence_System_t cs) try {
1411 to_nonconst(cs)->clear();
1412 return 0;
1413 }
1414 CATCH_ALL
1415
1416 int
ppl_Congruence_System_insert_Congruence(ppl_Congruence_System_t cs,ppl_const_Congruence_t c)1417 ppl_Congruence_System_insert_Congruence(ppl_Congruence_System_t cs,
1418 ppl_const_Congruence_t c) try {
1419 const Congruence& cc = *to_const(c);
1420 Congruence_System& ccs = *to_nonconst(cs);
1421 ccs.insert(cc);
1422 return 0;
1423 }
1424 CATCH_ALL
1425
1426 int
ppl_Congruence_System_OK(ppl_const_Congruence_System_t cs)1427 ppl_Congruence_System_OK(ppl_const_Congruence_System_t cs) try {
1428 return to_const(cs)->OK() ? 1 : 0;
1429 }
1430 CATCH_ALL
1431
1432 /* Interface for Congruence_System::const_iterator. */
1433
1434 int
ppl_new_Congruence_System_const_iterator(ppl_Congruence_System_const_iterator_t * pcit)1435 ppl_new_Congruence_System_const_iterator
1436 (ppl_Congruence_System_const_iterator_t* pcit) try {
1437 *pcit = to_nonconst(new Congruence_System::const_iterator());
1438 return 0;
1439 }
1440 CATCH_ALL
1441
1442 int
ppl_new_Congruence_System_const_iterator_from_Congruence_System_const_iterator(ppl_Congruence_System_const_iterator_t * pcit,ppl_const_Congruence_System_const_iterator_t cit)1443 ppl_new_Congruence_System_const_iterator_from_Congruence_System_const_iterator
1444 (ppl_Congruence_System_const_iterator_t* pcit,
1445 ppl_const_Congruence_System_const_iterator_t cit) try {
1446 *pcit = to_nonconst(new Congruence_System::const_iterator(*to_const(cit)));
1447 return 0;
1448 }
1449 CATCH_ALL
1450
1451 int
ppl_delete_Congruence_System_const_iterator(ppl_const_Congruence_System_const_iterator_t cit)1452 ppl_delete_Congruence_System_const_iterator
1453 (ppl_const_Congruence_System_const_iterator_t cit)
1454 try {
1455 delete to_const(cit);
1456 return 0;
1457 }
1458 CATCH_ALL
1459
1460 int
ppl_assign_Congruence_System_const_iterator_from_Congruence_System_const_iterator(ppl_Congruence_System_const_iterator_t dst,ppl_const_Congruence_System_const_iterator_t src)1461 ppl_assign_Congruence_System_const_iterator_from_Congruence_System_const_iterator
1462 (ppl_Congruence_System_const_iterator_t dst,
1463 ppl_const_Congruence_System_const_iterator_t src) try {
1464 const Congruence_System::const_iterator& ssrc = *to_const(src);
1465 Congruence_System::const_iterator& ddst = *to_nonconst(dst);
1466 ddst = ssrc;
1467 return 0;
1468 }
1469 CATCH_ALL
1470
1471 int
ppl_Congruence_System_begin(ppl_const_Congruence_System_t cs,ppl_Congruence_System_const_iterator_t cit)1472 ppl_Congruence_System_begin(ppl_const_Congruence_System_t cs,
1473 ppl_Congruence_System_const_iterator_t cit) try {
1474 const Congruence_System& ccs = *to_const(cs);
1475 Congruence_System::const_iterator& ccit = *to_nonconst(cit);
1476 ccit = ccs.begin();
1477 return 0;
1478 }
1479 CATCH_ALL
1480
1481 int
ppl_Congruence_System_end(ppl_const_Congruence_System_t cs,ppl_Congruence_System_const_iterator_t cit)1482 ppl_Congruence_System_end(ppl_const_Congruence_System_t cs,
1483 ppl_Congruence_System_const_iterator_t cit) try {
1484 const Congruence_System& ccs = *to_const(cs);
1485 Congruence_System::const_iterator& ccit = *to_nonconst(cit);
1486 ccit = ccs.end();
1487 return 0;
1488 }
1489 CATCH_ALL
1490
1491 int
ppl_Congruence_System_const_iterator_dereference(ppl_const_Congruence_System_const_iterator_t cit,ppl_const_Congruence_t * pc)1492 ppl_Congruence_System_const_iterator_dereference
1493 (ppl_const_Congruence_System_const_iterator_t cit,
1494 ppl_const_Congruence_t* pc) try {
1495 const Congruence_System::const_iterator& ccit = *to_const(cit);
1496 const Congruence& c = *ccit;
1497 *pc = to_const(&c);
1498 return 0;
1499 }
1500 CATCH_ALL
1501
1502 int
ppl_Congruence_System_const_iterator_increment(ppl_Congruence_System_const_iterator_t cit)1503 ppl_Congruence_System_const_iterator_increment
1504 (ppl_Congruence_System_const_iterator_t cit) try {
1505 Congruence_System::const_iterator& ccit = *to_nonconst(cit);
1506 ++ccit;
1507 return 0;
1508 }
1509 CATCH_ALL
1510
1511 int
ppl_Congruence_System_const_iterator_equal_test(ppl_const_Congruence_System_const_iterator_t x,ppl_const_Congruence_System_const_iterator_t y)1512 ppl_Congruence_System_const_iterator_equal_test
1513 (ppl_const_Congruence_System_const_iterator_t x,
1514 ppl_const_Congruence_System_const_iterator_t y) try {
1515 const Congruence_System::const_iterator& xx = *to_const(x);
1516 const Congruence_System::const_iterator& yy = *to_const(y);
1517 return (xx == yy) ? 1 : 0;
1518 }
1519 CATCH_ALL
1520
1521 /* Interface for Grid_Generator. */
1522
1523 int
ppl_new_Grid_Generator(ppl_Grid_Generator_t * pg,ppl_const_Linear_Expression_t le,enum ppl_enum_Grid_Generator_Type t,ppl_const_Coefficient_t d)1524 ppl_new_Grid_Generator(ppl_Grid_Generator_t* pg,
1525 ppl_const_Linear_Expression_t le,
1526 enum ppl_enum_Grid_Generator_Type t,
1527 ppl_const_Coefficient_t d) try {
1528 Grid_Generator* ppg;
1529 const Linear_Expression& lle = *to_const(le);
1530 const Coefficient& dd = *to_const(d);
1531 switch (t) {
1532 case PPL_GRID_GENERATOR_TYPE_LINE:
1533 ppg = new Grid_Generator(Grid_Generator::grid_line(lle));
1534 break;
1535 case PPL_GRID_GENERATOR_TYPE_PARAMETER:
1536 ppg = new Grid_Generator(Grid_Generator::parameter(lle));
1537 break;
1538 case PPL_GRID_GENERATOR_TYPE_POINT:
1539 ppg = new Grid_Generator(Grid_Generator::grid_point(lle, dd));
1540 break;
1541 default:
1542 throw std::invalid_argument("ppl_new_Grid_Generator(pg, le, t, d): "
1543 "t invalid");
1544 }
1545 *pg = to_nonconst(ppg);
1546 return 0;
1547 }
1548 CATCH_ALL
1549
1550 int
ppl_new_Grid_Generator_zero_dim_point(ppl_Grid_Generator_t * pg)1551 ppl_new_Grid_Generator_zero_dim_point(ppl_Grid_Generator_t* pg) try {
1552 *pg = to_nonconst(new Grid_Generator(Grid_Generator::zero_dim_point()));
1553 return 0;
1554 }
1555 CATCH_ALL
1556
1557 int
ppl_new_Grid_Generator_from_Grid_Generator(ppl_Grid_Generator_t * pg,ppl_const_Grid_Generator_t g)1558 ppl_new_Grid_Generator_from_Grid_Generator(ppl_Grid_Generator_t* pg,
1559 ppl_const_Grid_Generator_t g) try {
1560 const Grid_Generator& gg = *to_const(g);
1561 *pg = to_nonconst(new Grid_Generator(gg));
1562 return 0;
1563 }
1564 CATCH_ALL
1565
1566 int
ppl_delete_Grid_Generator(ppl_const_Grid_Generator_t le)1567 ppl_delete_Grid_Generator(ppl_const_Grid_Generator_t le) try {
1568 delete to_const(le);
1569 return 0;
1570 }
1571 CATCH_ALL
1572
1573 int
ppl_assign_Grid_Generator_from_Grid_Generator(ppl_Grid_Generator_t dst,ppl_const_Grid_Generator_t src)1574 ppl_assign_Grid_Generator_from_Grid_Generator
1575 (ppl_Grid_Generator_t dst,
1576 ppl_const_Grid_Generator_t src) try {
1577 const Grid_Generator& ssrc = *to_const(src);
1578 Grid_Generator& ddst = *to_nonconst(dst);
1579 ddst = ssrc;
1580 return 0;
1581 }
1582 CATCH_ALL
1583
1584 int
ppl_Grid_Generator_space_dimension(ppl_const_Grid_Generator_t g,ppl_dimension_type * m)1585 ppl_Grid_Generator_space_dimension(ppl_const_Grid_Generator_t g,
1586 ppl_dimension_type* m) try {
1587 *m = to_const(g)->space_dimension();
1588 return 0;
1589 }
1590 CATCH_ALL
1591
1592 int
ppl_Grid_Generator_type(ppl_const_Grid_Generator_t g)1593 ppl_Grid_Generator_type(ppl_const_Grid_Generator_t g) try {
1594 switch (to_const(g)->type()) {
1595 case Grid_Generator::LINE:
1596 return PPL_GRID_GENERATOR_TYPE_LINE;
1597 case Grid_Generator::PARAMETER:
1598 return PPL_GRID_GENERATOR_TYPE_PARAMETER;
1599 case Grid_Generator::POINT:
1600 return PPL_GRID_GENERATOR_TYPE_POINT;
1601 }
1602 PPL_UNREACHABLE;
1603 }
1604 CATCH_ALL
1605
1606 int
ppl_Grid_Generator_coefficient(ppl_const_Grid_Generator_t g,ppl_dimension_type var,ppl_Coefficient_t n)1607 ppl_Grid_Generator_coefficient(ppl_const_Grid_Generator_t g,
1608 ppl_dimension_type var,
1609 ppl_Coefficient_t n) try {
1610 const Grid_Generator& gg = *to_const(g);
1611 Coefficient& nn = *to_nonconst(n);
1612 nn = gg.coefficient(Variable(var));
1613 return 0;
1614 }
1615 CATCH_ALL
1616
1617 int
ppl_Grid_Generator_divisor(ppl_const_Grid_Generator_t g,ppl_Coefficient_t n)1618 ppl_Grid_Generator_divisor(ppl_const_Grid_Generator_t g,
1619 ppl_Coefficient_t n) try {
1620 const Grid_Generator& gg = *to_const(g);
1621 Coefficient& nn = *to_nonconst(n);
1622 nn = gg.divisor();
1623 return 0;
1624 }
1625 CATCH_ALL
1626
1627 int
ppl_Grid_Generator_OK(ppl_const_Grid_Generator_t g)1628 ppl_Grid_Generator_OK(ppl_const_Grid_Generator_t g) try {
1629 return to_const(g)->OK() ? 1 : 0;
1630 }
1631 CATCH_ALL
1632
1633 // FIXME: to be restored soon.
1634 // int
1635 // ppl_new_Linear_Expression_from_Grid_Generator
1636 // (ppl_Linear_Expression_t* ple,
1637 // ppl_const_Grid_Generator_t g) try {
1638 // const Grid_Generator& gg = *to_const(g);
1639 // *ple = to_nonconst(new Linear_Expression(gg));
1640 // return 0;
1641 // }
1642 // CATCH_ALL
1643
1644 /* Interface for Grid_Generator_System. */
1645
1646 int
ppl_new_Grid_Generator_System(ppl_Grid_Generator_System_t * pgs)1647 ppl_new_Grid_Generator_System(ppl_Grid_Generator_System_t* pgs) try {
1648 *pgs = to_nonconst(new Grid_Generator_System());
1649 return 0;
1650 }
1651 CATCH_ALL
1652
1653 int
ppl_new_Grid_Generator_System_zero_dim_univ(ppl_Grid_Generator_System_t * pgs)1654 ppl_new_Grid_Generator_System_zero_dim_univ
1655 (ppl_Grid_Generator_System_t* pgs) try {
1656 *pgs = to_nonconst
1657 (new Grid_Generator_System(Grid_Generator_System::zero_dim_univ()));
1658 return 0;
1659 }
1660 CATCH_ALL
1661
1662 int
ppl_new_Grid_Generator_System_from_Grid_Generator(ppl_Grid_Generator_System_t * pgs,ppl_const_Grid_Generator_t g)1663 ppl_new_Grid_Generator_System_from_Grid_Generator
1664 (ppl_Grid_Generator_System_t* pgs, ppl_const_Grid_Generator_t g) try {
1665 const Grid_Generator& gg = *to_const(g);
1666 *pgs = to_nonconst(new Grid_Generator_System(gg));
1667 return 0;
1668 }
1669 CATCH_ALL
1670
1671 int
ppl_new_Grid_Generator_System_from_Grid_Generator_System(ppl_Grid_Generator_System_t * pgs,ppl_const_Grid_Generator_System_t gs)1672 ppl_new_Grid_Generator_System_from_Grid_Generator_System
1673 (ppl_Grid_Generator_System_t* pgs, ppl_const_Grid_Generator_System_t gs) try {
1674 const Grid_Generator_System& ggs = *to_const(gs);
1675 *pgs = to_nonconst(new Grid_Generator_System(ggs));
1676 return 0;
1677 }
1678 CATCH_ALL
1679
1680 int
ppl_delete_Grid_Generator_System(ppl_const_Grid_Generator_System_t gs)1681 ppl_delete_Grid_Generator_System(ppl_const_Grid_Generator_System_t gs) try {
1682 delete to_const(gs);
1683 return 0;
1684 }
1685 CATCH_ALL
1686
1687 int
ppl_assign_Grid_Generator_System_from_Grid_Generator_System(ppl_Grid_Generator_System_t dst,ppl_const_Grid_Generator_System_t src)1688 ppl_assign_Grid_Generator_System_from_Grid_Generator_System
1689 (ppl_Grid_Generator_System_t dst, ppl_const_Grid_Generator_System_t src) try {
1690 const Grid_Generator_System& ssrc = *to_const(src);
1691 Grid_Generator_System& ddst = *to_nonconst(dst);
1692 ddst = ssrc;
1693 return 0;
1694 }
1695 CATCH_ALL
1696
1697 int
ppl_Grid_Generator_System_space_dimension(ppl_const_Grid_Generator_System_t gs,ppl_dimension_type * m)1698 ppl_Grid_Generator_System_space_dimension(ppl_const_Grid_Generator_System_t gs,
1699 ppl_dimension_type* m) try {
1700 *m = to_const(gs)->space_dimension();
1701 return 0;
1702 }
1703 CATCH_ALL
1704
1705 int
ppl_Grid_Generator_System_empty(ppl_const_Grid_Generator_System_t gs)1706 ppl_Grid_Generator_System_empty
1707 (ppl_const_Grid_Generator_System_t gs) try {
1708 const Grid_Generator_System& cgs = *to_const(gs);
1709 return cgs.empty() ? 1 : 0;
1710 }
1711 CATCH_ALL
1712
1713 int
ppl_Grid_Generator_System_clear(ppl_Grid_Generator_System_t gs)1714 ppl_Grid_Generator_System_clear(ppl_Grid_Generator_System_t gs) try {
1715 to_nonconst(gs)->clear();
1716 return 0;
1717 }
1718 CATCH_ALL
1719
1720 int
ppl_Grid_Generator_System_insert_Grid_Generator(ppl_Grid_Generator_System_t gs,ppl_const_Grid_Generator_t g)1721 ppl_Grid_Generator_System_insert_Grid_Generator
1722 (ppl_Grid_Generator_System_t gs,
1723 ppl_const_Grid_Generator_t g) try {
1724 const Grid_Generator& gg = *to_const(g);
1725 Grid_Generator_System& ggs = *to_nonconst(gs);
1726 ggs.insert(gg);
1727 return 0;
1728 }
1729 CATCH_ALL
1730
1731 int
ppl_Grid_Generator_System_OK(ppl_const_Grid_Generator_System_t gs)1732 ppl_Grid_Generator_System_OK(ppl_const_Grid_Generator_System_t gs) try {
1733 return to_const(gs)->OK() ? 1 : 0;
1734 }
1735 CATCH_ALL
1736
1737 /* Interface for Grid_Generator_System::const_iterator. */
1738
1739 int
ppl_new_Grid_Generator_System_const_iterator(ppl_Grid_Generator_System_const_iterator_t * pgit)1740 ppl_new_Grid_Generator_System_const_iterator
1741 (ppl_Grid_Generator_System_const_iterator_t* pgit) try {
1742 *pgit = to_nonconst(new Grid_Generator_System::const_iterator());
1743 return 0;
1744 }
1745 CATCH_ALL
1746
1747 int
ppl_new_Grid_Generator_System_const_iterator_from_Grid_Generator_System_const_iterator(ppl_Grid_Generator_System_const_iterator_t * pgit,ppl_const_Grid_Generator_System_const_iterator_t git)1748 ppl_new_Grid_Generator_System_const_iterator_from_Grid_Generator_System_const_iterator
1749 (ppl_Grid_Generator_System_const_iterator_t* pgit,
1750 ppl_const_Grid_Generator_System_const_iterator_t git) try {
1751 *pgit = to_nonconst
1752 (new Grid_Generator_System::const_iterator(*to_const(git)));
1753 return 0;
1754 }
1755 CATCH_ALL
1756
1757 int
ppl_delete_Grid_Generator_System_const_iterator(ppl_const_Grid_Generator_System_const_iterator_t git)1758 ppl_delete_Grid_Generator_System_const_iterator
1759 (ppl_const_Grid_Generator_System_const_iterator_t git) try {
1760 delete to_const(git);
1761 return 0;
1762 }
1763 CATCH_ALL
1764
1765 int
ppl_assign_Grid_Generator_System_const_iterator_from_Grid_Generator_System_const_iterator(ppl_Grid_Generator_System_const_iterator_t dst,ppl_const_Grid_Generator_System_const_iterator_t src)1766 ppl_assign_Grid_Generator_System_const_iterator_from_Grid_Generator_System_const_iterator
1767 (ppl_Grid_Generator_System_const_iterator_t dst,
1768 ppl_const_Grid_Generator_System_const_iterator_t src) try {
1769 const Grid_Generator_System::const_iterator& ssrc = *to_const(src);
1770 Grid_Generator_System::const_iterator& ddst = *to_nonconst(dst);
1771 ddst = ssrc;
1772 return 0;
1773 }
1774 CATCH_ALL
1775
1776 int
ppl_Grid_Generator_System_begin(ppl_const_Grid_Generator_System_t gs,ppl_Grid_Generator_System_const_iterator_t git)1777 ppl_Grid_Generator_System_begin
1778 (ppl_const_Grid_Generator_System_t gs,
1779 ppl_Grid_Generator_System_const_iterator_t git) try {
1780 const Grid_Generator_System& ggs = *to_const(gs);
1781 Grid_Generator_System::const_iterator& ggit = *to_nonconst(git);
1782 ggit = ggs.begin();
1783 return 0;
1784 }
1785 CATCH_ALL
1786
1787 int
ppl_Grid_Generator_System_end(ppl_const_Grid_Generator_System_t gs,ppl_Grid_Generator_System_const_iterator_t git)1788 ppl_Grid_Generator_System_end
1789 (ppl_const_Grid_Generator_System_t gs,
1790 ppl_Grid_Generator_System_const_iterator_t git) try {
1791 const Grid_Generator_System& ggs = *to_const(gs);
1792 Grid_Generator_System::const_iterator& ggit = *to_nonconst(git);
1793 ggit = ggs.end();
1794 return 0;
1795 }
1796 CATCH_ALL
1797
1798 int
ppl_Grid_Generator_System_const_iterator_dereference(ppl_const_Grid_Generator_System_const_iterator_t git,ppl_const_Grid_Generator_t * pg)1799 ppl_Grid_Generator_System_const_iterator_dereference
1800 (ppl_const_Grid_Generator_System_const_iterator_t git,
1801 ppl_const_Grid_Generator_t* pg) try {
1802 const Grid_Generator_System::const_iterator& ggit = *to_const(git);
1803 const Grid_Generator& g = *ggit;
1804 *pg = to_const(&g);
1805 return 0;
1806 }
1807 CATCH_ALL
1808
1809 int
ppl_Grid_Generator_System_const_iterator_increment(ppl_Grid_Generator_System_const_iterator_t git)1810 ppl_Grid_Generator_System_const_iterator_increment
1811 (ppl_Grid_Generator_System_const_iterator_t git) try {
1812 Grid_Generator_System::const_iterator& ggit = *to_nonconst(git);
1813 ++ggit;
1814 return 0;
1815 }
1816 CATCH_ALL
1817
1818 int
ppl_Grid_Generator_System_const_iterator_equal_test(ppl_const_Grid_Generator_System_const_iterator_t x,ppl_const_Grid_Generator_System_const_iterator_t y)1819 ppl_Grid_Generator_System_const_iterator_equal_test
1820 (ppl_const_Grid_Generator_System_const_iterator_t x,
1821 ppl_const_Grid_Generator_System_const_iterator_t y) try {
1822 const Grid_Generator_System::const_iterator& xx = *to_const(x);
1823 const Grid_Generator_System::const_iterator& yy = *to_const(y);
1824 return (xx == yy) ? 1 : 0;
1825 }
1826 CATCH_ALL
1827
1828 int
ppl_new_MIP_Problem_from_space_dimension(ppl_MIP_Problem_t * pmip,ppl_dimension_type d)1829 ppl_new_MIP_Problem_from_space_dimension(ppl_MIP_Problem_t* pmip,
1830 ppl_dimension_type d) try {
1831 *pmip = to_nonconst(new MIP_Problem(d));
1832 return 0;
1833 }
1834 CATCH_ALL
1835
1836 int
ppl_new_MIP_Problem(ppl_MIP_Problem_t * pmip,ppl_dimension_type d,ppl_const_Constraint_System_t cs,ppl_const_Linear_Expression_t le,int m)1837 ppl_new_MIP_Problem(ppl_MIP_Problem_t* pmip,
1838 ppl_dimension_type d,
1839 ppl_const_Constraint_System_t cs,
1840 ppl_const_Linear_Expression_t le, int m) try {
1841 const Constraint_System& ccs = *to_const(cs);
1842 const Linear_Expression& lle = *to_const(le);
1843 Optimization_Mode mm = (m == PPL_OPTIMIZATION_MODE_MINIMIZATION)
1844 ? MINIMIZATION : MAXIMIZATION;
1845 *pmip = to_nonconst(new MIP_Problem(d, ccs, lle, mm));
1846 return 0;
1847 }
1848 CATCH_ALL
1849
1850 int
ppl_new_MIP_Problem_from_MIP_Problem(ppl_MIP_Problem_t * pmip,ppl_const_MIP_Problem_t mip)1851 ppl_new_MIP_Problem_from_MIP_Problem(ppl_MIP_Problem_t* pmip,
1852 ppl_const_MIP_Problem_t mip) try {
1853 const MIP_Problem& mmip = *to_const(mip);
1854 *pmip = to_nonconst(new MIP_Problem(mmip));
1855 return 0;
1856 }
1857 CATCH_ALL
1858
1859 int
ppl_delete_MIP_Problem(ppl_const_MIP_Problem_t mip)1860 ppl_delete_MIP_Problem(ppl_const_MIP_Problem_t mip) try {
1861 delete to_const(mip);
1862 return 0;
1863 }
1864 CATCH_ALL
1865
1866 int
ppl_assign_MIP_Problem_from_MIP_Problem(ppl_MIP_Problem_t dst,ppl_const_MIP_Problem_t src)1867 ppl_assign_MIP_Problem_from_MIP_Problem(ppl_MIP_Problem_t dst,
1868 ppl_const_MIP_Problem_t src) try {
1869 const MIP_Problem& ssrc = *to_const(src);
1870 MIP_Problem& ddst = *to_nonconst(dst);
1871 ddst = ssrc;
1872 return 0;
1873 }
1874 CATCH_ALL
1875
1876 int
ppl_MIP_Problem_space_dimension(ppl_const_MIP_Problem_t mip,ppl_dimension_type * m)1877 ppl_MIP_Problem_space_dimension(ppl_const_MIP_Problem_t mip,
1878 ppl_dimension_type* m) try {
1879 *m = to_const(mip)->space_dimension();
1880 return 0;
1881 }
1882 CATCH_ALL
1883
1884 int
ppl_MIP_Problem_number_of_integer_space_dimensions(ppl_const_MIP_Problem_t mip,ppl_dimension_type * m)1885 ppl_MIP_Problem_number_of_integer_space_dimensions(ppl_const_MIP_Problem_t mip,
1886 ppl_dimension_type* m) try {
1887 const MIP_Problem& mmip = *to_const(mip);
1888 *m = mmip.integer_space_dimensions().size();
1889 return 0;
1890 }
1891 CATCH_ALL
1892
1893 int
ppl_MIP_Problem_integer_space_dimensions(ppl_const_MIP_Problem_t mip,ppl_dimension_type ds[])1894 ppl_MIP_Problem_integer_space_dimensions(ppl_const_MIP_Problem_t mip,
1895 ppl_dimension_type ds[]) try {
1896 const Variables_Set& vars = to_const(mip)->integer_space_dimensions();
1897 ppl_dimension_type* ds_i = ds;
1898 for (Variables_Set::const_iterator v_iter = vars.begin(),
1899 v_end = vars.end(); v_iter != v_end; ++v_iter, ++ds_i)
1900 *ds_i = *v_iter;
1901 return 0;
1902 }
1903 CATCH_ALL
1904
1905 int
ppl_MIP_Problem_number_of_constraints(ppl_const_MIP_Problem_t mip,ppl_dimension_type * m)1906 ppl_MIP_Problem_number_of_constraints(ppl_const_MIP_Problem_t mip,
1907 ppl_dimension_type* m) try {
1908 const MIP_Problem& mmip = *to_const(mip);
1909 *m = static_cast<ppl_dimension_type>(mmip.constraints_end() - mmip.constraints_begin());
1910 return 0;
1911 }
1912 CATCH_ALL
1913
1914 int
ppl_MIP_Problem_constraint_at_index(ppl_const_MIP_Problem_t mip,ppl_dimension_type i,ppl_const_Constraint_t * pc)1915 ppl_MIP_Problem_constraint_at_index(ppl_const_MIP_Problem_t mip,
1916 ppl_dimension_type i,
1917 ppl_const_Constraint_t* pc) try {
1918 #ifndef NDEBUG
1919 ppl_dimension_type num_constraints;
1920 ppl_MIP_Problem_number_of_constraints(mip, &num_constraints);
1921 assert(i < num_constraints);
1922 #endif
1923 const MIP_Problem& mmip = *to_const(mip);
1924 const Constraint& c = *(mmip.constraints_begin() + i);
1925 *pc = to_const(&c);
1926 return 0;
1927 }
1928 CATCH_ALL
1929
1930 int
ppl_MIP_Problem_objective_function(ppl_const_MIP_Problem_t mip,ppl_const_Linear_Expression_t * ple)1931 ppl_MIP_Problem_objective_function(ppl_const_MIP_Problem_t mip,
1932 ppl_const_Linear_Expression_t* ple) try {
1933 const Linear_Expression& le = to_const(mip)->objective_function();
1934 *ple = to_const(&le);
1935 return 0;
1936 }
1937 CATCH_ALL
1938
1939 int
ppl_MIP_Problem_optimization_mode(ppl_const_MIP_Problem_t mip)1940 ppl_MIP_Problem_optimization_mode(ppl_const_MIP_Problem_t mip) try {
1941 return to_const(mip)->optimization_mode();
1942 }
1943 CATCH_ALL
1944
1945 int
ppl_MIP_Problem_clear(ppl_MIP_Problem_t mip)1946 ppl_MIP_Problem_clear(ppl_MIP_Problem_t mip) try {
1947 to_nonconst(mip)->clear();
1948 return 0;
1949 }
1950 CATCH_ALL
1951
1952 int
ppl_MIP_Problem_add_space_dimensions_and_embed(ppl_MIP_Problem_t mip,ppl_dimension_type d)1953 ppl_MIP_Problem_add_space_dimensions_and_embed(ppl_MIP_Problem_t mip,
1954 ppl_dimension_type d) try {
1955 MIP_Problem& mmip = *to_nonconst(mip);
1956 mmip.add_space_dimensions_and_embed(d);
1957 return 0;
1958 }
1959 CATCH_ALL
1960
1961 int
ppl_MIP_Problem_add_to_integer_space_dimensions(ppl_MIP_Problem_t mip,ppl_dimension_type ds[],size_t n)1962 ppl_MIP_Problem_add_to_integer_space_dimensions(ppl_MIP_Problem_t mip,
1963 ppl_dimension_type ds[],
1964 size_t n) try {
1965 MIP_Problem& mmip = *to_nonconst(mip);
1966 Variables_Set vars;
1967 for (ppl_dimension_type i = n; i-- > 0; )
1968 vars.insert(ds[i]);
1969 mmip.add_to_integer_space_dimensions(vars);
1970 return 0;
1971 }
1972 CATCH_ALL
1973
1974 int
ppl_MIP_Problem_add_constraint(ppl_MIP_Problem_t mip,ppl_const_Constraint_t c)1975 ppl_MIP_Problem_add_constraint(ppl_MIP_Problem_t mip,
1976 ppl_const_Constraint_t c) try {
1977 const Constraint& cc = *to_const(c);
1978 MIP_Problem& mmip = *to_nonconst(mip);
1979 mmip.add_constraint(cc);
1980 return 0;
1981 }
1982 CATCH_ALL
1983
1984 int
ppl_MIP_Problem_add_constraints(ppl_MIP_Problem_t mip,ppl_const_Constraint_System_t cs)1985 ppl_MIP_Problem_add_constraints(ppl_MIP_Problem_t mip,
1986 ppl_const_Constraint_System_t cs) try {
1987 const Constraint_System& ccs = *to_const(cs);
1988 MIP_Problem& mmip = *to_nonconst(mip);
1989 mmip.add_constraints(ccs);
1990 return 0;
1991 }
1992 CATCH_ALL
1993
1994 int
ppl_MIP_Problem_set_objective_function(ppl_MIP_Problem_t mip,ppl_const_Linear_Expression_t le)1995 ppl_MIP_Problem_set_objective_function(ppl_MIP_Problem_t mip,
1996 ppl_const_Linear_Expression_t le) try {
1997 const Linear_Expression& lle = *to_const(le);
1998 MIP_Problem& mmip = *to_nonconst(mip);
1999 mmip.set_objective_function(lle);
2000 return 0;
2001 }
2002 CATCH_ALL
2003
2004 int
ppl_MIP_Problem_set_optimization_mode(ppl_MIP_Problem_t mip,int mode)2005 ppl_MIP_Problem_set_optimization_mode(ppl_MIP_Problem_t mip, int mode) try {
2006 MIP_Problem& mmip = *to_nonconst(mip);
2007 Optimization_Mode m = (mode == PPL_OPTIMIZATION_MODE_MINIMIZATION)
2008 ? MINIMIZATION : MAXIMIZATION;
2009 mmip.set_optimization_mode(m);
2010 return 0;
2011 }
2012 CATCH_ALL
2013
2014 int
ppl_MIP_Problem_is_satisfiable(ppl_const_MIP_Problem_t mip)2015 ppl_MIP_Problem_is_satisfiable(ppl_const_MIP_Problem_t mip) try {
2016 return to_const(mip)->is_satisfiable() ? 1 : 0;
2017 }
2018 CATCH_ALL
2019
2020 int
ppl_MIP_Problem_solve(ppl_const_MIP_Problem_t mip)2021 ppl_MIP_Problem_solve(ppl_const_MIP_Problem_t mip) try {
2022 return to_const(mip)->solve();
2023 }
2024 CATCH_ALL
2025
2026 int
ppl_MIP_Problem_evaluate_objective_function(ppl_const_MIP_Problem_t mip,ppl_const_Generator_t g,ppl_Coefficient_t num,ppl_Coefficient_t den)2027 ppl_MIP_Problem_evaluate_objective_function(ppl_const_MIP_Problem_t mip,
2028 ppl_const_Generator_t g,
2029 ppl_Coefficient_t num,
2030 ppl_Coefficient_t den) try {
2031 const MIP_Problem& mmip = *to_const(mip);
2032 const Generator& gg = *to_const(g);
2033 Coefficient& nnum = *to_nonconst(num);
2034 Coefficient& dden = *to_nonconst(den);
2035 mmip.evaluate_objective_function(gg, nnum, dden);
2036 return 0;
2037 }
2038 CATCH_ALL
2039
2040 int
ppl_MIP_Problem_feasible_point(ppl_const_MIP_Problem_t mip,ppl_const_Generator_t * pg)2041 ppl_MIP_Problem_feasible_point(ppl_const_MIP_Problem_t mip,
2042 ppl_const_Generator_t* pg) try {
2043 const Generator& g = to_const(mip)->feasible_point();
2044 *pg = to_const(&g);
2045 return 0;
2046 }
2047 CATCH_ALL
2048
2049 int
ppl_MIP_Problem_optimizing_point(ppl_const_MIP_Problem_t mip,ppl_const_Generator_t * pg)2050 ppl_MIP_Problem_optimizing_point(ppl_const_MIP_Problem_t mip,
2051 ppl_const_Generator_t* pg) try {
2052 const Generator& g = to_const(mip)->optimizing_point();
2053 *pg = to_const(&g);
2054 return 0;
2055 }
2056 CATCH_ALL
2057
2058 int
ppl_MIP_Problem_optimal_value(ppl_const_MIP_Problem_t mip,ppl_Coefficient_t num,ppl_Coefficient_t den)2059 ppl_MIP_Problem_optimal_value(ppl_const_MIP_Problem_t mip,
2060 ppl_Coefficient_t num,
2061 ppl_Coefficient_t den) try {
2062 Coefficient& nnum = *to_nonconst(num);
2063 Coefficient& dden = *to_nonconst(den);
2064 to_const(mip)->optimal_value(nnum, dden);
2065 return 0;
2066 }
2067 CATCH_ALL
2068
2069 int
ppl_MIP_Problem_get_control_parameter(ppl_const_MIP_Problem_t mip,int name)2070 ppl_MIP_Problem_get_control_parameter(ppl_const_MIP_Problem_t mip,
2071 int name) try {
2072 MIP_Problem::Control_Parameter_Name n
2073 = static_cast<MIP_Problem::Control_Parameter_Name>(name);
2074 return to_const(mip)->get_control_parameter(n);
2075 }
2076 CATCH_ALL
2077
2078 int
ppl_MIP_Problem_set_control_parameter(ppl_MIP_Problem_t mip,int value)2079 ppl_MIP_Problem_set_control_parameter(ppl_MIP_Problem_t mip,
2080 int value) try {
2081 MIP_Problem::Control_Parameter_Value v
2082 = static_cast<MIP_Problem::Control_Parameter_Value>(value);
2083 to_nonconst(mip)->set_control_parameter(v);
2084 return 0;
2085 }
2086 CATCH_ALL
2087
2088 int
ppl_MIP_Problem_OK(ppl_const_MIP_Problem_t mip)2089 ppl_MIP_Problem_OK(ppl_const_MIP_Problem_t mip) try {
2090 return to_const(mip)->OK() ? 1 : 0;
2091 }
2092 CATCH_ALL
2093
2094 int
ppl_MIP_Problem_total_memory_in_bytes(ppl_const_MIP_Problem_t mip,size_t * sz)2095 ppl_MIP_Problem_total_memory_in_bytes(ppl_const_MIP_Problem_t mip,
2096 size_t* sz) try {
2097 *sz = to_const(mip)->total_memory_in_bytes();
2098 return 0;
2099 }
2100 CATCH_ALL
2101
2102 int
ppl_MIP_Problem_external_memory_in_bytes(ppl_const_MIP_Problem_t mip,size_t * sz)2103 ppl_MIP_Problem_external_memory_in_bytes(ppl_const_MIP_Problem_t mip,
2104 size_t* sz) try {
2105 *sz = to_const(mip)->external_memory_in_bytes();
2106 return 0;
2107 }
2108 CATCH_ALL
2109
2110 int
ppl_new_PIP_Problem_from_space_dimension(ppl_PIP_Problem_t * ppip,ppl_dimension_type d)2111 ppl_new_PIP_Problem_from_space_dimension(ppl_PIP_Problem_t* ppip,
2112 ppl_dimension_type d) try {
2113 *ppip = to_nonconst(new PIP_Problem(d));
2114 return 0;
2115 }
2116 CATCH_ALL
2117
2118 int
ppl_new_PIP_Problem_from_PIP_Problem(ppl_PIP_Problem_t * dpip,ppl_const_PIP_Problem_t pip)2119 ppl_new_PIP_Problem_from_PIP_Problem(ppl_PIP_Problem_t* dpip,
2120 ppl_const_PIP_Problem_t pip) try {
2121 const PIP_Problem& spip = *to_const(pip);
2122 *dpip = to_nonconst(new PIP_Problem(spip));
2123 return 0;
2124 }
2125 CATCH_ALL
2126
2127 int
ppl_new_PIP_Problem_from_constraints(ppl_PIP_Problem_t * ppip,ppl_dimension_type d,ppl_Constraint_System_const_iterator_t first,ppl_Constraint_System_const_iterator_t last,size_t n,ppl_dimension_type ds[])2128 ppl_new_PIP_Problem_from_constraints
2129 (ppl_PIP_Problem_t* ppip,
2130 ppl_dimension_type d,
2131 ppl_Constraint_System_const_iterator_t first,
2132 ppl_Constraint_System_const_iterator_t last,
2133 size_t n,
2134 ppl_dimension_type ds[]) try {
2135 Variables_Set p_vars;
2136 for (ppl_dimension_type i = n; i-- > 0; )
2137 p_vars.insert(ds[i]);
2138 *ppip = to_nonconst(new PIP_Problem(d, *to_const(first),
2139 *to_const(last), p_vars));
2140 return 0;
2141 }
2142 CATCH_ALL
2143
2144 int
ppl_assign_PIP_Problem_from_PIP_Problem(ppl_PIP_Problem_t dst,ppl_const_PIP_Problem_t src)2145 ppl_assign_PIP_Problem_from_PIP_Problem(ppl_PIP_Problem_t dst,
2146 ppl_const_PIP_Problem_t src) try {
2147 const PIP_Problem& ssrc = *to_const(src);
2148 PIP_Problem& ddst = *to_nonconst(dst);
2149 ddst = ssrc;
2150 return 0;
2151 }
2152 CATCH_ALL
2153
2154 int
ppl_delete_PIP_Problem(ppl_const_PIP_Problem_t pip)2155 ppl_delete_PIP_Problem(ppl_const_PIP_Problem_t pip) try {
2156 delete to_const(pip);
2157 return 0;
2158 }
2159 CATCH_ALL
2160
2161 int
ppl_PIP_Problem_space_dimension(ppl_const_PIP_Problem_t pip,ppl_dimension_type * m)2162 ppl_PIP_Problem_space_dimension(ppl_const_PIP_Problem_t pip,
2163 ppl_dimension_type* m) try {
2164 *m = to_const(pip)->space_dimension();
2165 return 0;
2166 }
2167 CATCH_ALL
2168
2169 int
ppl_PIP_Problem_number_of_parameter_space_dimensions(ppl_const_PIP_Problem_t pip,ppl_dimension_type * m)2170 ppl_PIP_Problem_number_of_parameter_space_dimensions
2171 (ppl_const_PIP_Problem_t pip, ppl_dimension_type* m) try {
2172 const PIP_Problem& ppip = *to_const(pip);
2173 *m = ppip.parameter_space_dimensions().size();
2174 return 0;
2175 }
2176 CATCH_ALL
2177
2178 int
ppl_PIP_Problem_parameter_space_dimensions(ppl_const_PIP_Problem_t pip,ppl_dimension_type ds[])2179 ppl_PIP_Problem_parameter_space_dimensions(ppl_const_PIP_Problem_t pip,
2180 ppl_dimension_type ds[]) try {
2181 const Variables_Set& vars = to_const(pip)->parameter_space_dimensions();
2182 ppl_dimension_type* ds_i = ds;
2183 for (Variables_Set::const_iterator v_iter = vars.begin(),
2184 v_end = vars.end(); v_iter != v_end; ++v_iter, ++ds_i)
2185 *ds_i = *v_iter;
2186 return 0;
2187 }
2188 CATCH_ALL
2189
2190 int
ppl_PIP_Problem_number_of_constraints(ppl_const_PIP_Problem_t pip,ppl_dimension_type * m)2191 ppl_PIP_Problem_number_of_constraints(ppl_const_PIP_Problem_t pip,
2192 ppl_dimension_type* m) try {
2193 const PIP_Problem& ppip = *to_const(pip);
2194 *m = static_cast<ppl_dimension_type>(ppip.constraints_end() - ppip.constraints_begin());
2195 return 0;
2196 }
2197 CATCH_ALL
2198
2199 int
ppl_PIP_Problem_constraint_at_index(ppl_const_PIP_Problem_t pip,ppl_dimension_type i,ppl_const_Constraint_t * pc)2200 ppl_PIP_Problem_constraint_at_index(ppl_const_PIP_Problem_t pip,
2201 ppl_dimension_type i,
2202 ppl_const_Constraint_t* pc) try {
2203 #ifndef NDEBUG
2204 ppl_dimension_type num_constraints;
2205 ppl_PIP_Problem_number_of_constraints(pip, &num_constraints);
2206 assert(i < num_constraints);
2207 #endif
2208 const PIP_Problem& ppip = *to_const(pip);
2209 const Constraint& c = *(ppip.constraints_begin() + i);
2210 *pc = to_const(&c);
2211 return 0;
2212 }
2213 CATCH_ALL
2214 int
ppl_PIP_Problem_clear(ppl_PIP_Problem_t pip)2215 ppl_PIP_Problem_clear(ppl_PIP_Problem_t pip) try {
2216 to_nonconst(pip)->clear();
2217 return 0;
2218 }
2219 CATCH_ALL
2220 int
ppl_PIP_Problem_add_space_dimensions_and_embed(ppl_PIP_Problem_t pip,ppl_dimension_type pip_vars,ppl_dimension_type pip_params)2221 ppl_PIP_Problem_add_space_dimensions_and_embed(ppl_PIP_Problem_t pip,
2222 ppl_dimension_type pip_vars,
2223 ppl_dimension_type pip_params)
2224 try {
2225 PIP_Problem& spip = *to_nonconst(pip);
2226 spip.add_space_dimensions_and_embed(pip_vars,pip_params);
2227 return 0;
2228 }
2229 CATCH_ALL
2230 int
ppl_PIP_Problem_add_to_parameter_space_dimensions(ppl_PIP_Problem_t pip,ppl_dimension_type ds[],size_t n)2231 ppl_PIP_Problem_add_to_parameter_space_dimensions(ppl_PIP_Problem_t pip,
2232 ppl_dimension_type ds[],
2233 size_t n) try {
2234 PIP_Problem& ppip = *to_nonconst(pip);
2235 Variables_Set vars;
2236 for (ppl_dimension_type i = n; i-- > 0; )
2237 vars.insert(ds[i]);
2238 ppip.add_to_parameter_space_dimensions(vars);
2239 return 0;
2240 }
2241 CATCH_ALL
2242 int
ppl_PIP_Problem_add_constraint(ppl_PIP_Problem_t pip,ppl_const_Constraint_t c)2243 ppl_PIP_Problem_add_constraint(ppl_PIP_Problem_t pip,
2244 ppl_const_Constraint_t c) try {
2245 const Constraint& cc = *to_const(c);
2246 PIP_Problem& ppip = *to_nonconst(pip);
2247 ppip.add_constraint(cc);
2248 return 0;
2249 }
2250 CATCH_ALL
2251
2252 int
ppl_PIP_Problem_add_constraints(ppl_PIP_Problem_t pip,ppl_const_Constraint_System_t cs)2253 ppl_PIP_Problem_add_constraints(ppl_PIP_Problem_t pip,
2254 ppl_const_Constraint_System_t cs) try {
2255 const Constraint_System& ccs = *to_const(cs);
2256 PIP_Problem& ppip = *to_nonconst(pip);
2257 ppip.add_constraints(ccs);
2258 return 0;
2259 }
2260 CATCH_ALL
2261 int
ppl_PIP_Problem_is_satisfiable(ppl_const_PIP_Problem_t pip)2262 ppl_PIP_Problem_is_satisfiable(ppl_const_PIP_Problem_t pip) try {
2263 return to_const(pip)->is_satisfiable() ? 1 : 0;
2264 }
2265 CATCH_ALL
2266 int
ppl_PIP_Problem_solve(ppl_const_PIP_Problem_t pip)2267 ppl_PIP_Problem_solve(ppl_const_PIP_Problem_t pip) try {
2268 return to_const(pip)->solve();
2269 }
2270 CATCH_ALL
2271
2272 int
ppl_PIP_Problem_solution(ppl_const_PIP_Problem_t pip,ppl_const_PIP_Tree_Node_t * ppip_tree)2273 ppl_PIP_Problem_solution(ppl_const_PIP_Problem_t pip,
2274 ppl_const_PIP_Tree_Node_t* ppip_tree) try {
2275 *ppip_tree = to_const(to_const(pip)->solution());
2276 return 0;
2277 }
2278 CATCH_ALL
2279
2280 int
ppl_PIP_Problem_optimizing_solution(ppl_const_PIP_Problem_t pip,ppl_const_PIP_Tree_Node_t * ppip_tree)2281 ppl_PIP_Problem_optimizing_solution(ppl_const_PIP_Problem_t pip,
2282 ppl_const_PIP_Tree_Node_t* ppip_tree) try {
2283 *ppip_tree = to_const(to_const(pip)->optimizing_solution());
2284 return 0;
2285 }
2286 CATCH_ALL
2287
2288 int
ppl_PIP_Problem_OK(ppl_const_PIP_Problem_t pip)2289 ppl_PIP_Problem_OK(ppl_const_PIP_Problem_t pip) try {
2290 return to_const(pip)->OK() ? 1 : 0;
2291 }
2292 CATCH_ALL
2293
2294 int
ppl_PIP_Problem_get_control_parameter(ppl_const_PIP_Problem_t pip,int name)2295 ppl_PIP_Problem_get_control_parameter(ppl_const_PIP_Problem_t pip,
2296 int name) try {
2297 PIP_Problem::Control_Parameter_Name n
2298 = static_cast<PIP_Problem::Control_Parameter_Name>(name);
2299 return to_const(pip)->get_control_parameter(n);
2300 }
2301 CATCH_ALL
2302
2303 int
ppl_PIP_Problem_set_control_parameter(ppl_PIP_Problem_t pip,int value)2304 ppl_PIP_Problem_set_control_parameter(ppl_PIP_Problem_t pip,
2305 int value) try {
2306 PIP_Problem::Control_Parameter_Value v
2307 = static_cast<PIP_Problem::Control_Parameter_Value>(value);
2308 to_nonconst(pip)->set_control_parameter(v);
2309 return 0;
2310 }
2311 CATCH_ALL
2312
2313 int
ppl_PIP_Problem_get_big_parameter_dimension(ppl_const_PIP_Problem_t pip,ppl_dimension_type * pd)2314 ppl_PIP_Problem_get_big_parameter_dimension(ppl_const_PIP_Problem_t pip,
2315 ppl_dimension_type* pd) try {
2316 *pd = to_const(pip)->get_big_parameter_dimension();
2317 return 0;
2318 }
2319 CATCH_ALL
2320
2321 int
ppl_PIP_Problem_set_big_parameter_dimension(ppl_PIP_Problem_t pip,ppl_dimension_type d)2322 ppl_PIP_Problem_set_big_parameter_dimension(ppl_PIP_Problem_t pip,
2323 ppl_dimension_type d) try {
2324 to_nonconst(pip)->set_big_parameter_dimension(d);
2325 return 0;
2326 }
2327 CATCH_ALL
2328
2329 int
ppl_PIP_Problem_total_memory_in_bytes(ppl_const_PIP_Problem_t pip,size_t * sz)2330 ppl_PIP_Problem_total_memory_in_bytes(ppl_const_PIP_Problem_t pip,
2331 size_t* sz) try {
2332 *sz = to_const(pip)->total_memory_in_bytes();
2333 return 0;
2334 }
2335 CATCH_ALL
2336
2337 int
ppl_PIP_Problem_external_memory_in_bytes(ppl_const_PIP_Problem_t pip,size_t * sz)2338 ppl_PIP_Problem_external_memory_in_bytes(ppl_const_PIP_Problem_t pip,
2339 size_t* sz) try {
2340 *sz = to_const(pip)->external_memory_in_bytes();
2341 return 0;
2342 }
2343 CATCH_ALL
2344
2345 int
ppl_PIP_Tree_Node_as_solution(ppl_const_PIP_Tree_Node_t spip_tree,ppl_const_PIP_Solution_Node_t * dpip_tree)2346 ppl_PIP_Tree_Node_as_solution(ppl_const_PIP_Tree_Node_t spip_tree,
2347 ppl_const_PIP_Solution_Node_t* dpip_tree) try {
2348 *dpip_tree = to_const(to_const(spip_tree)->as_solution());
2349 return 0;
2350 }
2351 CATCH_ALL
2352
2353 int
ppl_PIP_Tree_Node_as_decision(ppl_const_PIP_Tree_Node_t spip_tree,ppl_const_PIP_Decision_Node_t * dpip_tree)2354 ppl_PIP_Tree_Node_as_decision(ppl_const_PIP_Tree_Node_t spip_tree,
2355 ppl_const_PIP_Decision_Node_t* dpip_tree) try {
2356 *dpip_tree = to_const(to_const(spip_tree)->as_decision());
2357 return 0;
2358 }
2359 CATCH_ALL
2360
2361 int
ppl_PIP_Tree_Node_get_constraints(ppl_const_PIP_Tree_Node_t pip_tree,ppl_const_Constraint_System_t * pcs)2362 ppl_PIP_Tree_Node_get_constraints(ppl_const_PIP_Tree_Node_t pip_tree,
2363 ppl_const_Constraint_System_t* pcs) try {
2364 const PIP_Tree_Node& spip_tree = *to_const(pip_tree);
2365 const Constraint_System& cs = spip_tree.constraints();
2366 *pcs = to_const(&cs);
2367 return 0;
2368 }
2369 CATCH_ALL
2370
2371 int
ppl_PIP_Tree_Node_OK(ppl_const_PIP_Tree_Node_t pip_tree)2372 ppl_PIP_Tree_Node_OK(ppl_const_PIP_Tree_Node_t pip_tree) try {
2373 return to_const(pip_tree)->OK() ? 1 : 0;
2374 }
2375 CATCH_ALL
2376
2377 int
ppl_PIP_Tree_Node_number_of_artificials(ppl_const_PIP_Tree_Node_t pip_tree,ppl_dimension_type * m)2378 ppl_PIP_Tree_Node_number_of_artificials(ppl_const_PIP_Tree_Node_t pip_tree,
2379 ppl_dimension_type* m) try {
2380 const PIP_Tree_Node& node = *to_const(pip_tree);
2381 *m = node.art_parameter_count();
2382 return 0;
2383 }
2384 CATCH_ALL
2385
2386 int
ppl_PIP_Tree_Node_begin(ppl_const_PIP_Tree_Node_t pip_tree,ppl_Artificial_Parameter_Sequence_const_iterator_t pit)2387 ppl_PIP_Tree_Node_begin
2388 (ppl_const_PIP_Tree_Node_t pip_tree,
2389 ppl_Artificial_Parameter_Sequence_const_iterator_t pit) try {
2390 PIP_Tree_Node::Artificial_Parameter_Sequence::const_iterator& spit
2391 = *to_nonconst(pit);
2392 spit = to_const(pip_tree)->art_parameter_begin();
2393 return 0;
2394 }
2395 CATCH_ALL
2396
2397 int
ppl_PIP_Tree_Node_end(ppl_const_PIP_Tree_Node_t pip_tree,ppl_Artificial_Parameter_Sequence_const_iterator_t pit)2398 ppl_PIP_Tree_Node_end
2399 (ppl_const_PIP_Tree_Node_t pip_tree,
2400 ppl_Artificial_Parameter_Sequence_const_iterator_t pit) try {
2401 PIP_Tree_Node::Artificial_Parameter_Sequence::const_iterator& spit
2402 = *to_nonconst(pit);
2403 spit = to_const(pip_tree)->art_parameter_end();
2404 return 0;
2405 }
2406 CATCH_ALL
2407
2408 int
ppl_PIP_Solution_Node_get_parametric_values(ppl_const_PIP_Solution_Node_t pip_sol,ppl_dimension_type var,ppl_const_Linear_Expression_t * le)2409 ppl_PIP_Solution_Node_get_parametric_values
2410 (ppl_const_PIP_Solution_Node_t pip_sol,
2411 ppl_dimension_type var,
2412 ppl_const_Linear_Expression_t* le) try {
2413 const PIP_Solution_Node& spip_sol = *to_const(pip_sol);
2414 const Linear_Expression& lle = spip_sol.parametric_values(Variable(var));
2415 *le = to_const(&lle);
2416 return 0;
2417 }
2418 CATCH_ALL
2419
2420 int
ppl_PIP_Solution_Node_OK(ppl_const_PIP_Solution_Node_t pip_sol)2421 ppl_PIP_Solution_Node_OK(ppl_const_PIP_Solution_Node_t pip_sol) try {
2422 return to_const(pip_sol)->OK() ? 1 : 0;
2423 }
2424 CATCH_ALL
2425
2426 int
ppl_PIP_Decision_Node_OK(ppl_const_PIP_Decision_Node_t pip_dec)2427 ppl_PIP_Decision_Node_OK(ppl_const_PIP_Decision_Node_t pip_dec) try {
2428 return to_const(pip_dec)->OK() ? 1 : 0;
2429 }
2430 CATCH_ALL
2431
2432 int
ppl_PIP_Decision_Node_get_child_node(ppl_const_PIP_Decision_Node_t pip_dec,int b,ppl_const_PIP_Tree_Node_t * pip_tree)2433 ppl_PIP_Decision_Node_get_child_node(ppl_const_PIP_Decision_Node_t pip_dec,
2434 int b,
2435 ppl_const_PIP_Tree_Node_t* pip_tree) try {
2436 *pip_tree = to_const(to_const(pip_dec)->child_node(b != 0));
2437 return 0;
2438 }
2439 CATCH_ALL
2440
2441 int
ppl_Artificial_Parameter_get_Linear_Expression(ppl_const_Artificial_Parameter_t ap,ppl_Linear_Expression_t le)2442 ppl_Artificial_Parameter_get_Linear_Expression
2443 (ppl_const_Artificial_Parameter_t ap,
2444 ppl_Linear_Expression_t le) try {
2445 const Artificial_Parameter& sap = *to_const(ap);
2446 Linear_Expression& lle = *to_nonconst(le);
2447 lle = sap;
2448 return 0;
2449 }
2450 CATCH_ALL
2451
2452 int
ppl_Artificial_Parameter_coefficient(ppl_const_Artificial_Parameter_t ap,ppl_dimension_type var,ppl_Coefficient_t n)2453 ppl_Artificial_Parameter_coefficient(ppl_const_Artificial_Parameter_t ap,
2454 ppl_dimension_type var,
2455 ppl_Coefficient_t n) try {
2456 const Artificial_Parameter& sap = *to_const(ap);
2457 Coefficient& nn = *to_nonconst(n);
2458 nn = sap.coefficient(Variable(var));
2459 return 0;
2460 }
2461 CATCH_ALL
2462
2463 int
ppl_Artificial_Parameter_inhomogeneous_term(ppl_const_Artificial_Parameter_t ap,ppl_Coefficient_t n)2464 ppl_Artificial_Parameter_inhomogeneous_term
2465 (ppl_const_Artificial_Parameter_t ap, ppl_Coefficient_t n) try {
2466 const Artificial_Parameter& sap = *to_const(ap);
2467 Coefficient& nn = *to_nonconst(n);
2468 nn = sap.inhomogeneous_term();
2469 return 0;
2470 }
2471 CATCH_ALL
2472
2473
2474 int
ppl_Artificial_Parameter_denominator(ppl_const_Artificial_Parameter_t ap,ppl_Coefficient_t n)2475 ppl_Artificial_Parameter_denominator(ppl_const_Artificial_Parameter_t ap,
2476 ppl_Coefficient_t n) try {
2477 const Artificial_Parameter& sap = *to_const(ap);
2478 Coefficient& nn = *to_nonconst(n);
2479 nn = sap.denominator();
2480 return 0;
2481 }
2482 CATCH_ALL
2483
2484
2485 /* Interface for Artificial_Parameter_Sequence::const_iterator. */
2486
2487 int
ppl_new_Artificial_Parameter_Sequence_const_iterator(ppl_Artificial_Parameter_Sequence_const_iterator_t * papit)2488 ppl_new_Artificial_Parameter_Sequence_const_iterator
2489 (ppl_Artificial_Parameter_Sequence_const_iterator_t* papit) try {
2490 *papit = to_nonconst(new Artificial_Parameter_Sequence::const_iterator());
2491 return 0;
2492 }
2493 CATCH_ALL
2494
2495 int
ppl_new_Artificial_Parameter_Sequence_const_iterator_from_Artificial_Parameter_Sequence_const_iterator(ppl_Artificial_Parameter_Sequence_const_iterator_t * papit,ppl_const_Artificial_Parameter_Sequence_const_iterator_t apit)2496 ppl_new_Artificial_Parameter_Sequence_const_iterator_from_Artificial_Parameter_Sequence_const_iterator
2497 (ppl_Artificial_Parameter_Sequence_const_iterator_t* papit,
2498 ppl_const_Artificial_Parameter_Sequence_const_iterator_t apit) try {
2499 *papit = to_nonconst(new Artificial_Parameter_Sequence::const_iterator(*to_const(apit)));
2500 return 0;
2501 }
2502 CATCH_ALL
2503
2504 int
ppl_delete_Artificial_Parameter_Sequence_const_iterator(ppl_const_Artificial_Parameter_Sequence_const_iterator_t apit)2505 ppl_delete_Artificial_Parameter_Sequence_const_iterator
2506 (ppl_const_Artificial_Parameter_Sequence_const_iterator_t apit)
2507 try {
2508 delete to_const(apit);
2509 return 0;
2510 }
2511 CATCH_ALL
2512
2513 int
ppl_assign_Artificial_Parameter_Sequence_const_iterator_from_Artificial_Parameter_Sequence_const_iterator(ppl_Artificial_Parameter_Sequence_const_iterator_t dst,ppl_const_Artificial_Parameter_Sequence_const_iterator_t src)2514 ppl_assign_Artificial_Parameter_Sequence_const_iterator_from_Artificial_Parameter_Sequence_const_iterator
2515 (ppl_Artificial_Parameter_Sequence_const_iterator_t dst,
2516 ppl_const_Artificial_Parameter_Sequence_const_iterator_t src) try {
2517 const Artificial_Parameter_Sequence::const_iterator& ssrc = *to_const(src);
2518 Artificial_Parameter_Sequence::const_iterator& ddst = *to_nonconst(dst);
2519 ddst = ssrc;
2520 return 0;
2521 }
2522 CATCH_ALL
2523
2524 int
ppl_Artificial_Parameter_Sequence_const_iterator_dereference(ppl_const_Artificial_Parameter_Sequence_const_iterator_t apit,ppl_const_Artificial_Parameter_t * pap)2525 ppl_Artificial_Parameter_Sequence_const_iterator_dereference
2526 (ppl_const_Artificial_Parameter_Sequence_const_iterator_t apit,
2527 ppl_const_Artificial_Parameter_t* pap) try {
2528 const Artificial_Parameter_Sequence::const_iterator& papit = *to_const(apit);
2529 const Artificial_Parameter& ap = *papit;
2530 *pap = to_const(&ap);
2531 return 0;
2532 }
2533 CATCH_ALL
2534
2535 int
ppl_Artificial_Parameter_Sequence_const_iterator_increment(ppl_Artificial_Parameter_Sequence_const_iterator_t apit)2536 ppl_Artificial_Parameter_Sequence_const_iterator_increment
2537 (ppl_Artificial_Parameter_Sequence_const_iterator_t apit) try {
2538 Artificial_Parameter_Sequence::const_iterator& papit = *to_nonconst(apit);
2539 ++papit;
2540 return 0;
2541 }
2542 CATCH_ALL
2543
2544 int
ppl_Artificial_Parameter_Sequence_const_iterator_equal_test(ppl_const_Artificial_Parameter_Sequence_const_iterator_t x,ppl_const_Artificial_Parameter_Sequence_const_iterator_t y)2545 ppl_Artificial_Parameter_Sequence_const_iterator_equal_test
2546 (ppl_const_Artificial_Parameter_Sequence_const_iterator_t x,
2547 ppl_const_Artificial_Parameter_Sequence_const_iterator_t y) try {
2548 const Artificial_Parameter_Sequence::const_iterator& xx = *to_const(x);
2549 const Artificial_Parameter_Sequence::const_iterator& yy = *to_const(y);
2550 return (xx == yy) ? 1 : 0;
2551 }
2552 CATCH_ALL
2553
2554 int
ppl_io_print_variable(ppl_dimension_type var)2555 ppl_io_print_variable(ppl_dimension_type var) try {
2556 const char* b = c_variable_output_function(var);
2557 if (b == 0 || puts(b) < 0)
2558 return PPL_STDIO_ERROR;
2559 return 0;
2560 }
2561 CATCH_ALL
2562
2563 int
ppl_io_fprint_variable(FILE * stream,ppl_dimension_type var)2564 ppl_io_fprint_variable(FILE* stream, ppl_dimension_type var) try {
2565 const char* b = c_variable_output_function(var);
2566 if (b == 0 || fputs(b, stream) < 0)
2567 return PPL_STDIO_ERROR;
2568 return 0;
2569 }
2570 CATCH_ALL
2571
2572 int
ppl_io_asprint_variable(char ** strp,ppl_dimension_type var)2573 ppl_io_asprint_variable(char** strp, ppl_dimension_type var) try {
2574 const char* b = c_variable_output_function(var);
2575 if (b == 0)
2576 return PPL_STDIO_ERROR;
2577 *strp = strdup(b);
2578 if (*strp == 0)
2579 return PPL_ERROR_OUT_OF_MEMORY;
2580 return 0;
2581 }
2582 CATCH_ALL
2583
2584 /* No ascii dump for Coefficient. */
DEFINE_PRINT_FUNCTIONS(Coefficient)2585 DEFINE_PRINT_FUNCTIONS(Coefficient)
2586
2587 DEFINE_OUTPUT_FUNCTIONS(Linear_Expression)
2588
2589 DEFINE_OUTPUT_FUNCTIONS(Constraint)
2590
2591 DEFINE_OUTPUT_FUNCTIONS(Constraint_System)
2592
2593 DEFINE_OUTPUT_FUNCTIONS(Generator)
2594
2595 DEFINE_OUTPUT_FUNCTIONS(Generator_System)
2596
2597 DEFINE_OUTPUT_FUNCTIONS(Congruence)
2598
2599 DEFINE_OUTPUT_FUNCTIONS(Congruence_System)
2600
2601 DEFINE_OUTPUT_FUNCTIONS(Grid_Generator)
2602
2603 DEFINE_OUTPUT_FUNCTIONS(Grid_Generator_System)
2604
2605 DEFINE_OUTPUT_FUNCTIONS(MIP_Problem)
2606
2607 DEFINE_OUTPUT_FUNCTIONS(PIP_Problem)
2608
2609 DEFINE_OUTPUT_FUNCTIONS(PIP_Tree_Node)
2610
2611 DEFINE_OUTPUT_FUNCTIONS(PIP_Decision_Node)
2612
2613 DEFINE_OUTPUT_FUNCTIONS(PIP_Solution_Node)
2614
2615 DEFINE_OUTPUT_FUNCTIONS(Artificial_Parameter)
2616
2617 char*
2618 ppl_io_wrap_string(const char* src,
2619 unsigned indent_depth,
2620 unsigned preferred_first_line_length,
2621 unsigned preferred_line_length) {
2622 using namespace IO_Operators;
2623 return strdup(wrap_string(src, indent_depth,
2624 preferred_first_line_length,
2625 preferred_line_length).c_str());
2626 }
2627
2628 int
ppl_io_set_variable_output_function(ppl_io_variable_output_function_type * p)2629 ppl_io_set_variable_output_function(ppl_io_variable_output_function_type* p)
2630 try {
2631 c_variable_output_function = p;
2632 return 0;
2633 }
2634 CATCH_ALL
2635
2636 int
ppl_io_get_variable_output_function(ppl_io_variable_output_function_type ** pp)2637 ppl_io_get_variable_output_function(ppl_io_variable_output_function_type** pp)
2638 try {
2639 *pp = c_variable_output_function;
2640 return 0;
2641 }
2642 CATCH_ALL
2643