|
PPL C Language Interface
0.12.1
|
00001 /* Implementation of the C interface: variables and non-inline functions. 00002 Copyright (C) 2001-2010 Roberto Bagnara <bagnara@cs.unipr.it> 00003 Copyright (C) 2010-2012 BUGSENG srl (http://bugseng.com) 00004 00005 This file is part of the Parma Polyhedra Library (PPL). 00006 00007 The PPL is free software; you can redistribute it and/or modify it 00008 under the terms of the GNU General Public License as published by the 00009 Free Software Foundation; either version 3 of the License, or (at your 00010 option) any later version. 00011 00012 The PPL is distributed in the hope that it will be useful, but WITHOUT 00013 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 00014 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 00015 for more details. 00016 00017 You should have received a copy of the GNU General Public License 00018 along with this program; if not, write to the Free Software Foundation, 00019 Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1307, USA. 00020 00021 For the most up-to-date information see the Parma Polyhedra Library 00022 site: http://bugseng.com/products/ppl/ . */ 00023 00024 /* Interface for Coefficient. */ 00025 00026 #include "ppl_c_implementation_common.defs.hh" 00027 00028 namespace Parma_Polyhedra_Library { 00029 00030 namespace Interfaces { 00031 00032 namespace C { 00033 00034 error_handler_type user_error_handler = 0; 00035 00036 extern "C" const char* 00037 c_variable_default_output_function(ppl_dimension_type var) { 00038 #if PPL_SIZEOF_SIZE_T == PPL_SIZEOF_INT 00039 # define FORMAT "%u" 00040 # define CONVERSION (unsigned) 00041 #elif PPL_SIZEOF_SIZE_T == PPL_SIZEOF_LONG 00042 # define FORMAT "%lu" 00043 # define CONVERSION (unsigned long) 00044 #elif PPL_SIZEOF_SIZE_T == PPL_SIZEOF_LONG_LONG 00045 # define FORMAT "%llu" 00046 # define CONVERSION (unsigned long long) 00047 #else 00048 # error "Unsupported definition for `size_t'." 00049 #endif 00050 // On a 64-bits architecture, `var' will not be more than 2^64-1, 00051 // (2^64-1)/26 is written with 18 decimal digits, plus one letter, 00052 // plus one terminator makes 20. 00053 #if defined(ULLONG_MAX) && ULLONG_MAX > 18446744073709551615ULL 00054 # error "Please enlarge the buffer in the following line." 00055 #endif 00056 static char buffer[20]; 00057 buffer[0] = static_cast<char>('A' + var % 26); 00058 if (ppl_dimension_type i = var / 26) { 00059 int r = sprintf(buffer+1, FORMAT, CONVERSION i); 00060 if (r < 0) 00061 return 0; 00062 else if (r >= 19) { 00063 errno = ERANGE; 00064 return 0; 00065 } 00066 } 00067 else 00068 buffer[1] = '\0'; 00069 return buffer; 00070 } 00071 00072 // Holds a pointer to the C current output function. 00073 ppl_io_variable_output_function_type* c_variable_output_function; 00074 00075 void 00076 cxx_Variable_output_function(std::ostream& s, const Variable v) { 00077 const char* b = c_variable_output_function(v.id()); 00078 if (b == 0) 00079 // Something went wrong in the client's output function. 00080 // Client code will know what to do: we do nothing. 00081 return; 00082 s << b; 00083 } 00084 00085 extern "C" typedef const char* 00086 c_variable_output_function_type(ppl_dimension_type var); 00087 00088 // Holds a pointer to the C++ saved output function. 00089 Variable::output_function_type* saved_cxx_Variable_output_function; 00090 00091 void 00092 notify_error(enum ppl_enum_error_code code, const char* description) { 00093 if (user_error_handler != 0) 00094 user_error_handler(code, description); 00095 } 00096 00097 Parma_Polyhedra_Library::Watchdog* p_timeout_object = 0; 00098 00099 typedef 00100 Parma_Polyhedra_Library::Threshold_Watcher 00101 <Parma_Polyhedra_Library::Weightwatch_Traits> Weightwatch; 00102 00103 Weightwatch* p_deterministic_timeout_object = 0; 00104 00105 void 00106 reset_timeout() { 00107 if (p_timeout_object != 0) { 00108 delete p_timeout_object; 00109 p_timeout_object = 0; 00110 abandon_expensive_computations = 0; 00111 } 00112 } 00113 00114 void 00115 reset_deterministic_timeout() { 00116 if (p_deterministic_timeout_object != 0) { 00117 delete p_deterministic_timeout_object; 00118 p_deterministic_timeout_object = 0; 00119 abandon_expensive_computations = 0; 00120 } 00121 } 00122 00123 } // namespace C 00124 00125 } // namespace Interfaces 00126 00127 } // namespace Parma_Polyhedra_Library 00128 00129 using namespace Parma_Polyhedra_Library; 00130 using namespace Parma_Polyhedra_Library::Interfaces::C; 00131 00132 unsigned int PPL_POLY_CON_RELATION_IS_DISJOINT; 00133 unsigned int PPL_POLY_CON_RELATION_STRICTLY_INTERSECTS; 00134 unsigned int PPL_POLY_CON_RELATION_IS_INCLUDED; 00135 unsigned int PPL_POLY_CON_RELATION_SATURATES; 00136 00137 unsigned int PPL_POLY_GEN_RELATION_SUBSUMES; 00138 00139 unsigned int PPL_COMPLEXITY_CLASS_POLYNOMIAL; 00140 unsigned int PPL_COMPLEXITY_CLASS_SIMPLEX; 00141 unsigned int PPL_COMPLEXITY_CLASS_ANY; 00142 00143 int PPL_MIP_PROBLEM_STATUS_UNFEASIBLE; 00144 int PPL_MIP_PROBLEM_STATUS_UNBOUNDED; 00145 int PPL_MIP_PROBLEM_STATUS_OPTIMIZED; 00146 00147 int PPL_MIP_PROBLEM_CONTROL_PARAMETER_NAME_PRICING; 00148 int PPL_MIP_PROBLEM_CONTROL_PARAMETER_PRICING_STEEPEST_EDGE_FLOAT; 00149 int PPL_MIP_PROBLEM_CONTROL_PARAMETER_PRICING_STEEPEST_EDGE_EXACT; 00150 int PPL_MIP_PROBLEM_CONTROL_PARAMETER_PRICING_TEXTBOOK; 00151 00152 int PPL_PIP_PROBLEM_STATUS_UNFEASIBLE; 00153 int PPL_PIP_PROBLEM_STATUS_OPTIMIZED; 00154 00155 int PPL_PIP_PROBLEM_CONTROL_PARAMETER_NAME_CUTTING_STRATEGY; 00156 int PPL_PIP_PROBLEM_CONTROL_PARAMETER_CUTTING_STRATEGY_FIRST; 00157 int PPL_PIP_PROBLEM_CONTROL_PARAMETER_CUTTING_STRATEGY_DEEPEST; 00158 int PPL_PIP_PROBLEM_CONTROL_PARAMETER_CUTTING_STRATEGY_ALL; 00159 int PPL_PIP_PROBLEM_CONTROL_PARAMETER_NAME_PIVOT_ROW_STRATEGY; 00160 int PPL_PIP_PROBLEM_CONTROL_PARAMETER_PIVOT_ROW_STRATEGY_FIRST; 00161 int PPL_PIP_PROBLEM_CONTROL_PARAMETER_PIVOT_ROW_STRATEGY_MAX_COLUMN; 00162 00163 int PPL_OPTIMIZATION_MODE_MINIMIZATION; 00164 int PPL_OPTIMIZATION_MODE_MAXIMIZATION; 00165 00166 int 00167 ppl_set_error_handler(error_handler_type h) { 00168 user_error_handler = h; 00169 return 0; 00170 } 00171 00172 int 00173 ppl_initialize(void) try { 00174 initialize(); 00175 00176 PPL_POLY_CON_RELATION_IS_DISJOINT 00177 = Poly_Con_Relation::is_disjoint().get_flags(); 00178 PPL_POLY_CON_RELATION_STRICTLY_INTERSECTS 00179 = Poly_Con_Relation::strictly_intersects().get_flags(); 00180 PPL_POLY_CON_RELATION_IS_INCLUDED 00181 = Poly_Con_Relation::is_included().get_flags(); 00182 PPL_POLY_CON_RELATION_SATURATES 00183 = Poly_Con_Relation::saturates().get_flags(); 00184 00185 PPL_POLY_GEN_RELATION_SUBSUMES 00186 = Poly_Gen_Relation::subsumes().get_flags(); 00187 00188 PPL_COMPLEXITY_CLASS_POLYNOMIAL = POLYNOMIAL_COMPLEXITY; 00189 PPL_COMPLEXITY_CLASS_SIMPLEX = SIMPLEX_COMPLEXITY; 00190 PPL_COMPLEXITY_CLASS_ANY = ANY_COMPLEXITY; 00191 00192 PPL_MIP_PROBLEM_STATUS_UNFEASIBLE = UNFEASIBLE_MIP_PROBLEM; 00193 PPL_MIP_PROBLEM_STATUS_UNBOUNDED = UNBOUNDED_MIP_PROBLEM; 00194 PPL_MIP_PROBLEM_STATUS_OPTIMIZED = OPTIMIZED_MIP_PROBLEM; 00195 00196 PPL_MIP_PROBLEM_CONTROL_PARAMETER_NAME_PRICING 00197 = MIP_Problem::PRICING; 00198 PPL_MIP_PROBLEM_CONTROL_PARAMETER_PRICING_STEEPEST_EDGE_FLOAT 00199 = MIP_Problem::PRICING_STEEPEST_EDGE_FLOAT; 00200 PPL_MIP_PROBLEM_CONTROL_PARAMETER_PRICING_STEEPEST_EDGE_EXACT 00201 = MIP_Problem::PRICING_STEEPEST_EDGE_EXACT; 00202 PPL_MIP_PROBLEM_CONTROL_PARAMETER_PRICING_TEXTBOOK 00203 = MIP_Problem::PRICING_TEXTBOOK; 00204 00205 PPL_PIP_PROBLEM_STATUS_UNFEASIBLE = UNFEASIBLE_PIP_PROBLEM; 00206 PPL_PIP_PROBLEM_STATUS_OPTIMIZED = OPTIMIZED_PIP_PROBLEM; 00207 00208 PPL_PIP_PROBLEM_CONTROL_PARAMETER_NAME_CUTTING_STRATEGY 00209 = PIP_Problem::CUTTING_STRATEGY; 00210 PPL_PIP_PROBLEM_CONTROL_PARAMETER_CUTTING_STRATEGY_FIRST 00211 = PIP_Problem::CUTTING_STRATEGY_FIRST; 00212 PPL_PIP_PROBLEM_CONTROL_PARAMETER_CUTTING_STRATEGY_DEEPEST 00213 = PIP_Problem::CUTTING_STRATEGY_DEEPEST; 00214 PPL_PIP_PROBLEM_CONTROL_PARAMETER_CUTTING_STRATEGY_ALL 00215 = PIP_Problem::CUTTING_STRATEGY_ALL; 00216 PPL_PIP_PROBLEM_CONTROL_PARAMETER_NAME_PIVOT_ROW_STRATEGY 00217 = PIP_Problem::PIVOT_ROW_STRATEGY; 00218 PPL_PIP_PROBLEM_CONTROL_PARAMETER_PIVOT_ROW_STRATEGY_FIRST 00219 = PIP_Problem::PIVOT_ROW_STRATEGY_FIRST; 00220 PPL_PIP_PROBLEM_CONTROL_PARAMETER_PIVOT_ROW_STRATEGY_MAX_COLUMN 00221 = PIP_Problem::PIVOT_ROW_STRATEGY_MAX_COLUMN; 00222 00223 PPL_OPTIMIZATION_MODE_MINIMIZATION = MINIMIZATION; 00224 PPL_OPTIMIZATION_MODE_MAXIMIZATION = MAXIMIZATION; 00225 00226 c_variable_output_function = c_variable_default_output_function; 00227 saved_cxx_Variable_output_function = Variable::get_output_function(); 00228 Variable::set_output_function(cxx_Variable_output_function); 00229 00230 return 0; 00231 } 00232 CATCH_ALL 00233 00234 int 00235 ppl_finalize(void) try { 00236 Variable::set_output_function(saved_cxx_Variable_output_function); 00237 00238 finalize(); 00239 return 0; 00240 } 00241 CATCH_ALL 00242 00243 int 00244 ppl_set_timeout(unsigned csecs) try { 00245 // In case a timeout was already set. 00246 reset_timeout(); 00247 static timeout_exception e; 00248 using Parma_Polyhedra_Library::Watchdog; 00249 p_timeout_object = new Watchdog(csecs, abandon_expensive_computations, e); 00250 return 0; 00251 } 00252 CATCH_ALL 00253 00254 int 00255 ppl_reset_timeout(void) try { 00256 reset_timeout(); 00257 return 0; 00258 } 00259 CATCH_ALL 00260 00261 int 00262 ppl_set_deterministic_timeout(unsigned long unscaled_weight, 00263 unsigned scale) try { 00264 // In case a deterministic timeout was already set. 00265 reset_deterministic_timeout(); 00266 static timeout_exception e; 00267 typedef Parma_Polyhedra_Library::Weightwatch_Traits Traits; 00268 p_deterministic_timeout_object 00269 = new Weightwatch(Traits::compute_delta(unscaled_weight, scale), 00270 abandon_expensive_computations, e); 00271 return 0; 00272 } 00273 CATCH_ALL 00274 00275 int 00276 ppl_reset_deterministic_timeout(void) try { 00277 reset_deterministic_timeout(); 00278 return 0; 00279 } 00280 CATCH_ALL 00281 00282 int 00283 ppl_set_rounding_for_PPL(void) try { 00284 set_rounding_for_PPL(); 00285 return 0; 00286 } 00287 CATCH_ALL 00288 00289 int 00290 ppl_restore_pre_PPL_rounding(void) try { 00291 restore_pre_PPL_rounding(); 00292 return 0; 00293 } 00294 CATCH_ALL 00295 00296 int 00297 ppl_irrational_precision(unsigned* p) try { 00298 *p = irrational_precision(); 00299 return 0; 00300 } 00301 CATCH_ALL 00302 00303 int 00304 ppl_set_irrational_precision(unsigned p) try { 00305 set_irrational_precision(p); 00306 return 0; 00307 } 00308 CATCH_ALL 00309 00310 int 00311 ppl_version_major(void) try { 00312 return static_cast<int>(version_major()); 00313 } 00314 CATCH_ALL 00315 00316 int 00317 ppl_version_minor(void) try { 00318 return static_cast<int>(version_minor()); 00319 } 00320 CATCH_ALL 00321 00322 int 00323 ppl_version_revision(void) try { 00324 return static_cast<int>(version_revision()); 00325 } 00326 CATCH_ALL 00327 00328 int 00329 ppl_version_beta(void) try { 00330 return static_cast<int>(version_beta()); 00331 } 00332 CATCH_ALL 00333 00334 int 00335 ppl_version(const char** p) try { 00336 // Note: use explicit qualification to avoid clashes on, e.g., 00337 // Solaris 2.9, where `version' is the name of an enum defined in 00338 // math.h. 00339 *p = Parma_Polyhedra_Library::version(); 00340 return 0; 00341 } 00342 CATCH_ALL 00343 00344 int 00345 ppl_banner(const char** p) try { 00346 *p = banner(); 00347 return 0; 00348 } 00349 CATCH_ALL 00350 00351 int 00352 ppl_max_space_dimension(ppl_dimension_type* m) try { 00353 *m = max_space_dimension(); 00354 return 0; 00355 } 00356 CATCH_ALL 00357 00358 int 00359 ppl_not_a_dimension(ppl_dimension_type* m) try { 00360 *m = not_a_dimension(); 00361 return 0; 00362 } 00363 CATCH_ALL 00364 00365 int 00366 ppl_new_Coefficient(ppl_Coefficient_t* pc) try { 00367 *pc = to_nonconst(new Coefficient(0)); 00368 return 0; 00369 } 00370 CATCH_ALL 00371 00372 int 00373 ppl_new_Coefficient_from_mpz_t(ppl_Coefficient_t* pc, mpz_t z) try { 00374 *pc = to_nonconst(new Coefficient(reinterpret_mpz_class(z))); 00375 return 0; 00376 } 00377 CATCH_ALL 00378 00379 int 00380 ppl_new_Coefficient_from_Coefficient(ppl_Coefficient_t* pc, 00381 ppl_const_Coefficient_t c) try { 00382 const Coefficient& cc = *to_const(c); 00383 *pc = to_nonconst(new Coefficient(cc)); 00384 return 0; 00385 } 00386 CATCH_ALL 00387 00388 int 00389 ppl_Coefficient_to_mpz_t(ppl_const_Coefficient_t c, mpz_t z) try { 00390 assign_r(reinterpret_mpz_class(z), *to_const(c), ROUND_NOT_NEEDED); 00391 return 0; 00392 } 00393 CATCH_ALL 00394 00395 int 00396 ppl_delete_Coefficient(ppl_const_Coefficient_t c) try { 00397 delete to_const(c); 00398 return 0; 00399 } 00400 CATCH_ALL 00401 00402 int 00403 ppl_assign_Coefficient_from_mpz_t(ppl_Coefficient_t dst, mpz_t z) try { 00404 Coefficient& ddst = *to_nonconst(dst); 00405 ddst = reinterpret_mpz_class(z); 00406 return 0; 00407 } 00408 CATCH_ALL 00409 00410 int 00411 ppl_assign_Coefficient_from_Coefficient(ppl_Coefficient_t dst, 00412 ppl_const_Coefficient_t src) try { 00413 const Coefficient& ssrc = *to_const(src); 00414 Coefficient& ddst = *to_nonconst(dst); 00415 ddst = ssrc; 00416 return 0; 00417 } 00418 CATCH_ALL 00419 00420 int 00421 ppl_Coefficient_OK(ppl_const_Coefficient_t /* c */) try { 00422 return 1; 00423 } 00424 CATCH_ALL 00425 00426 int 00427 ppl_Coefficient_is_bounded(void) try { 00428 return std::numeric_limits<Coefficient>::is_bounded ? 1 : 0; 00429 } 00430 CATCH_ALL 00431 00432 int 00433 ppl_Coefficient_min(mpz_t min) try { 00434 if (std::numeric_limits<Coefficient>::is_bounded) { 00435 assign_r(reinterpret_mpz_class(min), 00436 std::numeric_limits<Coefficient>::min(), 00437 ROUND_NOT_NEEDED); 00438 return 1; 00439 } 00440 else 00441 return 0; 00442 } 00443 CATCH_ALL 00444 00445 int 00446 ppl_Coefficient_max(mpz_t max) try { 00447 if (std::numeric_limits<Coefficient>::is_bounded) { 00448 assign_r(reinterpret_mpz_class(max), 00449 std::numeric_limits<Coefficient>::max(), 00450 ROUND_NOT_NEEDED); 00451 return 1; 00452 } 00453 else 00454 return 0; 00455 } 00456 CATCH_ALL 00457 00458 /* Interface for Linear_Expression. */ 00459 00460 int 00461 ppl_new_Linear_Expression(ppl_Linear_Expression_t* ple) try { 00462 *ple = to_nonconst(new Linear_Expression()); 00463 return 0; 00464 } 00465 CATCH_ALL 00466 00467 int 00468 ppl_new_Linear_Expression_with_dimension(ppl_Linear_Expression_t* ple, 00469 ppl_dimension_type d) try { 00470 *ple = to_nonconst(d == 0 00471 ? new Linear_Expression(0) 00472 : new Linear_Expression(0*Variable(d-1))); 00473 return 0; 00474 } 00475 CATCH_ALL 00476 00477 int 00478 ppl_new_Linear_Expression_from_Linear_Expression 00479 (ppl_Linear_Expression_t* ple, ppl_const_Linear_Expression_t le) try { 00480 const Linear_Expression& lle = *to_const(le); 00481 *ple = to_nonconst(new Linear_Expression(lle)); 00482 return 0; 00483 } 00484 CATCH_ALL 00485 00486 int 00487 ppl_delete_Linear_Expression(ppl_const_Linear_Expression_t le) try { 00488 delete to_const(le); 00489 return 0; 00490 } 00491 CATCH_ALL 00492 00493 int 00494 ppl_assign_Linear_Expression_from_Linear_Expression 00495 (ppl_Linear_Expression_t dst, ppl_const_Linear_Expression_t src) try { 00496 const Linear_Expression& ssrc = *to_const(src); 00497 Linear_Expression& ddst = *to_nonconst(dst); 00498 ddst = ssrc; 00499 return 0; 00500 } 00501 CATCH_ALL 00502 00503 int 00504 ppl_Linear_Expression_add_to_coefficient(ppl_Linear_Expression_t le, 00505 ppl_dimension_type var, 00506 ppl_const_Coefficient_t n) try { 00507 Linear_Expression& lle = *to_nonconst(le); 00508 const Coefficient& nn = *to_const(n); 00509 add_mul_assign(lle, nn, Variable(var)); 00510 return 0; 00511 } 00512 CATCH_ALL 00513 00514 int 00515 ppl_Linear_Expression_add_to_inhomogeneous(ppl_Linear_Expression_t le, 00516 ppl_const_Coefficient_t n) try { 00517 Linear_Expression& lle = *to_nonconst(le); 00518 const Coefficient& nn = *to_const(n); 00519 lle += nn; 00520 return 0; 00521 } 00522 CATCH_ALL 00523 00524 int 00525 ppl_add_Linear_Expression_to_Linear_Expression 00526 (ppl_Linear_Expression_t dst, ppl_const_Linear_Expression_t src) try { 00527 Linear_Expression& ddst = *to_nonconst(dst); 00528 const Linear_Expression& ssrc = *to_const(src); 00529 ddst += ssrc; 00530 return 0; 00531 } 00532 CATCH_ALL 00533 00534 int 00535 ppl_subtract_Linear_Expression_from_Linear_Expression 00536 (ppl_Linear_Expression_t dst, ppl_const_Linear_Expression_t src) try { 00537 Linear_Expression& ddst = *to_nonconst(dst); 00538 const Linear_Expression& ssrc = *to_const(src); 00539 ddst -= ssrc; 00540 return 0; 00541 } 00542 CATCH_ALL 00543 00544 int 00545 ppl_multiply_Linear_Expression_by_Coefficient(ppl_Linear_Expression_t le, 00546 ppl_const_Coefficient_t n) try { 00547 Linear_Expression& lle = *to_nonconst(le); 00548 const Coefficient& nn = *to_const(n); 00549 lle *= nn; 00550 return 0; 00551 } 00552 CATCH_ALL 00553 00554 int 00555 ppl_Linear_Expression_space_dimension(ppl_const_Linear_Expression_t le, 00556 ppl_dimension_type* m) try { 00557 *m = to_const(le)->space_dimension(); 00558 return 0; 00559 } 00560 CATCH_ALL 00561 00562 int 00563 ppl_Linear_Expression_coefficient(ppl_const_Linear_Expression_t le, 00564 ppl_dimension_type var, 00565 ppl_Coefficient_t n) try { 00566 const Linear_Expression& lle = *to_const(le); 00567 Coefficient& nn = *to_nonconst(n); 00568 nn = lle.coefficient(Variable(var)); 00569 return 0; 00570 } 00571 CATCH_ALL 00572 00573 int 00574 ppl_Linear_Expression_inhomogeneous_term(ppl_const_Linear_Expression_t le, 00575 ppl_Coefficient_t n) try { 00576 const Linear_Expression& lle = *to_const(le); 00577 Coefficient& nn = *to_nonconst(n); 00578 nn = lle.inhomogeneous_term(); 00579 return 0; 00580 } 00581 CATCH_ALL 00582 00583 int 00584 ppl_Linear_Expression_OK(ppl_const_Linear_Expression_t le) try { 00585 return to_const(le)->OK() ? 1 : 0; 00586 } 00587 CATCH_ALL 00588 00589 int 00590 ppl_Linear_Expression_is_zero(ppl_const_Linear_Expression_t le) try { 00591 return to_const(le)->is_zero() ? 1 : 0; 00592 } 00593 CATCH_ALL 00594 00595 int 00596 ppl_Linear_Expression_all_homogeneous_terms_are_zero 00597 (ppl_const_Linear_Expression_t le) try { 00598 return to_const(le)->all_homogeneous_terms_are_zero() ? 1 : 0; 00599 } 00600 CATCH_ALL 00601 00602 /* Interface for Constraint. */ 00603 00604 int 00605 ppl_new_Constraint(ppl_Constraint_t* pc, 00606 ppl_const_Linear_Expression_t le, 00607 enum ppl_enum_Constraint_Type t) try { 00608 Constraint* ppc; 00609 const Linear_Expression& lle = *to_const(le); 00610 switch (t) { 00611 case PPL_CONSTRAINT_TYPE_EQUAL: 00612 ppc = new Constraint(lle == 0); 00613 break; 00614 case PPL_CONSTRAINT_TYPE_GREATER_OR_EQUAL: 00615 ppc = new Constraint(lle >= 0); 00616 break; 00617 case PPL_CONSTRAINT_TYPE_GREATER_THAN: 00618 ppc = new Constraint(lle > 0); 00619 break; 00620 case PPL_CONSTRAINT_TYPE_LESS_OR_EQUAL: 00621 ppc = new Constraint(lle <= 0); 00622 break; 00623 case PPL_CONSTRAINT_TYPE_LESS_THAN: 00624 ppc = new Constraint(lle < 0); 00625 break; 00626 default: 00627 throw std::invalid_argument("ppl_new_Constraint(pc, le, t): " 00628 "t invalid"); 00629 } 00630 *pc = to_nonconst(ppc); 00631 return 0; 00632 } 00633 CATCH_ALL 00634 00635 int 00636 ppl_new_Constraint_zero_dim_false(ppl_Constraint_t* pc) try { 00637 *pc = to_nonconst(new Constraint(Constraint::zero_dim_false())); 00638 return 0; 00639 } 00640 CATCH_ALL 00641 00642 int 00643 ppl_new_Constraint_zero_dim_positivity(ppl_Constraint_t* pc) try { 00644 *pc = to_nonconst(new Constraint(Constraint::zero_dim_positivity())); 00645 return 0; 00646 } 00647 CATCH_ALL 00648 00649 int 00650 ppl_new_Constraint_from_Constraint(ppl_Constraint_t* pc, 00651 ppl_const_Constraint_t c) try { 00652 const Constraint& cc = *to_const(c); 00653 *pc = to_nonconst(new Constraint(cc)); 00654 return 0; 00655 } 00656 CATCH_ALL 00657 00658 int 00659 ppl_delete_Constraint(ppl_const_Constraint_t le) try { 00660 delete to_const(le); 00661 return 0; 00662 } 00663 CATCH_ALL 00664 00665 int 00666 ppl_assign_Constraint_from_Constraint(ppl_Constraint_t dst, 00667 ppl_const_Constraint_t src) try { 00668 const Constraint& ssrc = *to_const(src); 00669 Constraint& ddst = *to_nonconst(dst); 00670 ddst = ssrc; 00671 return 0; 00672 } 00673 CATCH_ALL 00674 00675 int 00676 ppl_Constraint_space_dimension(ppl_const_Constraint_t c, 00677 ppl_dimension_type* m) try { 00678 *m = to_const(c)->space_dimension(); 00679 return 0; 00680 } 00681 CATCH_ALL 00682 00683 int 00684 ppl_Constraint_type(ppl_const_Constraint_t c) try { 00685 switch (to_const(c)->type()) { 00686 case Constraint::EQUALITY: 00687 return PPL_CONSTRAINT_TYPE_EQUAL; 00688 case Constraint::NONSTRICT_INEQUALITY: 00689 return PPL_CONSTRAINT_TYPE_GREATER_OR_EQUAL; 00690 case Constraint::STRICT_INEQUALITY: 00691 return PPL_CONSTRAINT_TYPE_GREATER_THAN; 00692 } 00693 PPL_UNREACHABLE; 00694 } 00695 CATCH_ALL 00696 00697 int 00698 ppl_Constraint_coefficient(ppl_const_Constraint_t c, 00699 ppl_dimension_type var, 00700 ppl_Coefficient_t n) try { 00701 const Constraint& cc = *to_const(c); 00702 Coefficient& nn = *to_nonconst(n); 00703 nn = cc.coefficient(Variable(var)); 00704 return 0; 00705 } 00706 CATCH_ALL 00707 00708 int 00709 ppl_Constraint_inhomogeneous_term(ppl_const_Constraint_t c, 00710 ppl_Coefficient_t n) try { 00711 const Constraint& cc = *to_const(c); 00712 Coefficient& nn = *to_nonconst(n); 00713 nn = cc.inhomogeneous_term(); 00714 return 0; 00715 } 00716 CATCH_ALL 00717 00718 int 00719 ppl_Constraint_OK(ppl_const_Constraint_t c) try { 00720 return to_const(c)->OK() ? 1 : 0; 00721 } 00722 CATCH_ALL 00723 00724 int 00725 ppl_new_Linear_Expression_from_Constraint(ppl_Linear_Expression_t* ple, 00726 ppl_const_Constraint_t c) try { 00727 const Constraint& cc = *to_const(c); 00728 *ple = to_nonconst(new Linear_Expression(cc)); 00729 return 0; 00730 } 00731 CATCH_ALL 00732 00733 /* Interface for Constraint_System. */ 00734 00735 int 00736 ppl_new_Constraint_System(ppl_Constraint_System_t* pcs) try { 00737 *pcs = to_nonconst(new Constraint_System()); 00738 return 0; 00739 } 00740 CATCH_ALL 00741 00742 int 00743 ppl_new_Constraint_System_zero_dim_empty(ppl_Constraint_System_t* pcs) try { 00744 *pcs = to_nonconst(new 00745 Constraint_System(Constraint_System::zero_dim_empty())); 00746 return 0; 00747 } 00748 CATCH_ALL 00749 00750 00751 int 00752 ppl_new_Constraint_System_from_Constraint(ppl_Constraint_System_t* pcs, 00753 ppl_const_Constraint_t c) try { 00754 const Constraint& cc = *to_const(c); 00755 *pcs = to_nonconst(new Constraint_System(cc)); 00756 return 0; 00757 } 00758 CATCH_ALL 00759 00760 int 00761 ppl_new_Constraint_System_from_Constraint_System 00762 (ppl_Constraint_System_t* pcs, ppl_const_Constraint_System_t cs) try { 00763 const Constraint_System& ccs = *to_const(cs); 00764 *pcs = to_nonconst(new Constraint_System(ccs)); 00765 return 0; 00766 } 00767 CATCH_ALL 00768 00769 int 00770 ppl_delete_Constraint_System(ppl_const_Constraint_System_t cs) try { 00771 delete to_const(cs); 00772 return 0; 00773 } 00774 CATCH_ALL 00775 00776 int 00777 ppl_assign_Constraint_System_from_Constraint_System 00778 (ppl_Constraint_System_t dst, ppl_const_Constraint_System_t src) try { 00779 const Constraint_System& ssrc = *to_const(src); 00780 Constraint_System& ddst = *to_nonconst(dst); 00781 ddst = ssrc; 00782 return 0; 00783 } 00784 CATCH_ALL 00785 00786 int 00787 ppl_Constraint_System_space_dimension(ppl_const_Constraint_System_t cs, 00788 ppl_dimension_type* m) try { 00789 *m = to_const(cs)->space_dimension(); 00790 return 0; 00791 } 00792 CATCH_ALL 00793 00794 int 00795 ppl_Constraint_System_empty 00796 (ppl_const_Constraint_System_t cs) try { 00797 const Constraint_System& ccs = *to_const(cs); 00798 return ccs.empty() ? 1 : 0; 00799 } 00800 CATCH_ALL 00801 00802 int 00803 ppl_Constraint_System_has_strict_inequalities 00804 (ppl_const_Constraint_System_t cs) try { 00805 const Constraint_System& ccs = *to_const(cs); 00806 return ccs.has_strict_inequalities() ? 1 : 0; 00807 } 00808 CATCH_ALL 00809 00810 int 00811 ppl_Constraint_System_clear(ppl_Constraint_System_t cs) try { 00812 to_nonconst(cs)->clear(); 00813 return 0; 00814 } 00815 CATCH_ALL 00816 00817 int 00818 ppl_Constraint_System_insert_Constraint(ppl_Constraint_System_t cs, 00819 ppl_const_Constraint_t c) try { 00820 const Constraint& cc = *to_const(c); 00821 Constraint_System& ccs = *to_nonconst(cs); 00822 ccs.insert(cc); 00823 return 0; 00824 } 00825 CATCH_ALL 00826 00827 int 00828 ppl_Constraint_System_OK(ppl_const_Constraint_System_t cs) try { 00829 return to_const(cs)->OK() ? 1 : 0; 00830 } 00831 CATCH_ALL 00832 00833 /* Interface for Constraint_System::const_iterator. */ 00834 00835 int 00836 ppl_new_Constraint_System_const_iterator 00837 (ppl_Constraint_System_const_iterator_t* pcit) try { 00838 *pcit = to_nonconst(new Constraint_System::const_iterator()); 00839 return 0; 00840 } 00841 CATCH_ALL 00842 00843 int 00844 ppl_new_Constraint_System_const_iterator_from_Constraint_System_const_iterator 00845 (ppl_Constraint_System_const_iterator_t* pcit, 00846 ppl_const_Constraint_System_const_iterator_t cit) try { 00847 *pcit = to_nonconst(new Constraint_System::const_iterator(*to_const(cit))); 00848 return 0; 00849 } 00850 CATCH_ALL 00851 00852 int 00853 ppl_delete_Constraint_System_const_iterator 00854 (ppl_const_Constraint_System_const_iterator_t cit) 00855 try { 00856 delete to_const(cit); 00857 return 0; 00858 } 00859 CATCH_ALL 00860 00861 int 00862 ppl_assign_Constraint_System_const_iterator_from_Constraint_System_const_iterator 00863 (ppl_Constraint_System_const_iterator_t dst, 00864 ppl_const_Constraint_System_const_iterator_t src) try { 00865 const Constraint_System::const_iterator& ssrc = *to_const(src); 00866 Constraint_System::const_iterator& ddst = *to_nonconst(dst); 00867 ddst = ssrc; 00868 return 0; 00869 } 00870 CATCH_ALL 00871 00872 int 00873 ppl_Constraint_System_begin(ppl_const_Constraint_System_t cs, 00874 ppl_Constraint_System_const_iterator_t cit) try { 00875 const Constraint_System& ccs = *to_const(cs); 00876 Constraint_System::const_iterator& ccit = *to_nonconst(cit); 00877 ccit = ccs.begin(); 00878 return 0; 00879 } 00880 CATCH_ALL 00881 00882 int 00883 ppl_Constraint_System_end(ppl_const_Constraint_System_t cs, 00884 ppl_Constraint_System_const_iterator_t cit) try { 00885 const Constraint_System& ccs = *to_const(cs); 00886 Constraint_System::const_iterator& ccit = *to_nonconst(cit); 00887 ccit = ccs.end(); 00888 return 0; 00889 } 00890 CATCH_ALL 00891 00892 int 00893 ppl_Constraint_System_const_iterator_dereference 00894 (ppl_const_Constraint_System_const_iterator_t cit, 00895 ppl_const_Constraint_t* pc) try { 00896 const Constraint_System::const_iterator& ccit = *to_const(cit); 00897 const Constraint& c = *ccit; 00898 *pc = to_const(&c); 00899 return 0; 00900 } 00901 CATCH_ALL 00902 00903 int 00904 ppl_Constraint_System_const_iterator_increment 00905 (ppl_Constraint_System_const_iterator_t cit) try { 00906 Constraint_System::const_iterator& ccit = *to_nonconst(cit); 00907 ++ccit; 00908 return 0; 00909 } 00910 CATCH_ALL 00911 00912 int 00913 ppl_Constraint_System_const_iterator_equal_test 00914 (ppl_const_Constraint_System_const_iterator_t x, 00915 ppl_const_Constraint_System_const_iterator_t y) try { 00916 const Constraint_System::const_iterator& xx = *to_const(x); 00917 const Constraint_System::const_iterator& yy = *to_const(y); 00918 return (xx == yy) ? 1 : 0; 00919 } 00920 CATCH_ALL 00921 00922 /* Interface for Generator. */ 00923 00924 int 00925 ppl_new_Generator(ppl_Generator_t* pg, 00926 ppl_const_Linear_Expression_t le, 00927 enum ppl_enum_Generator_Type t, 00928 ppl_const_Coefficient_t d) try { 00929 Generator* ppg; 00930 const Linear_Expression& lle = *to_const(le); 00931 const Coefficient& dd = *to_const(d); 00932 switch (t) { 00933 case PPL_GENERATOR_TYPE_POINT: 00934 ppg = new Generator(Generator::point(lle, dd)); 00935 break; 00936 case PPL_GENERATOR_TYPE_CLOSURE_POINT: 00937 ppg = new Generator(Generator::closure_point(lle, dd)); 00938 break; 00939 case PPL_GENERATOR_TYPE_RAY: 00940 ppg = new Generator(Generator::ray(lle)); 00941 break; 00942 case PPL_GENERATOR_TYPE_LINE: 00943 ppg = new Generator(Generator::line(lle)); 00944 break; 00945 default: 00946 throw std::invalid_argument("ppl_new_Generator(pg, le, t, d): t invalid"); 00947 } 00948 *pg = to_nonconst(ppg); 00949 return 0; 00950 } 00951 CATCH_ALL 00952 00953 int 00954 ppl_new_Generator_zero_dim_point(ppl_Generator_t* pg) try { 00955 *pg = to_nonconst(new Generator(Generator::zero_dim_point())); 00956 return 0; 00957 } 00958 CATCH_ALL 00959 00960 int 00961 ppl_new_Generator_zero_dim_closure_point(ppl_Generator_t* pg) try { 00962 *pg = to_nonconst(new Generator(Generator::zero_dim_closure_point())); 00963 return 0; 00964 } 00965 CATCH_ALL 00966 00967 int 00968 ppl_new_Generator_from_Generator(ppl_Generator_t* pg, 00969 ppl_const_Generator_t g) try { 00970 const Generator& gg = *to_const(g); 00971 *pg = to_nonconst(new Generator(gg)); 00972 return 0; 00973 } 00974 CATCH_ALL 00975 00976 int 00977 ppl_delete_Generator(ppl_const_Generator_t le) try { 00978 delete to_const(le); 00979 return 0; 00980 } 00981 CATCH_ALL 00982 00983 int 00984 ppl_assign_Generator_from_Generator(ppl_Generator_t dst, 00985 ppl_const_Generator_t src) try { 00986 const Generator& ssrc = *to_const(src); 00987 Generator& ddst = *to_nonconst(dst); 00988 ddst = ssrc; 00989 return 0; 00990 } 00991 CATCH_ALL 00992 00993 int 00994 ppl_Generator_space_dimension(ppl_const_Generator_t g, 00995 ppl_dimension_type* m) try { 00996 *m = to_const(g)->space_dimension(); 00997 return 0; 00998 } 00999 CATCH_ALL 01000 01001 int 01002 ppl_Generator_type(ppl_const_Generator_t g) try { 01003 switch (to_const(g)->type()) { 01004 case Generator::LINE: 01005 return PPL_GENERATOR_TYPE_LINE; 01006 case Generator::RAY: 01007 return PPL_GENERATOR_TYPE_RAY; 01008 case Generator::POINT: 01009 return PPL_GENERATOR_TYPE_POINT; 01010 case Generator::CLOSURE_POINT: 01011 return PPL_GENERATOR_TYPE_CLOSURE_POINT; 01012 } 01013 PPL_UNREACHABLE; 01014 } 01015 CATCH_ALL 01016 01017 int 01018 ppl_Generator_coefficient(ppl_const_Generator_t g, 01019 ppl_dimension_type var, 01020 ppl_Coefficient_t n) try { 01021 const Generator& gg = *to_const(g); 01022 Coefficient& nn = *to_nonconst(n); 01023 nn = gg.coefficient(Variable(var)); 01024 return 0; 01025 } 01026 CATCH_ALL 01027 01028 int 01029 ppl_Generator_divisor(ppl_const_Generator_t g, 01030 ppl_Coefficient_t n) try { 01031 const Generator& gg = *to_const(g); 01032 Coefficient& nn = *to_nonconst(n); 01033 nn = gg.divisor(); 01034 return 0; 01035 } 01036 CATCH_ALL 01037 01038 int 01039 ppl_Generator_OK(ppl_const_Generator_t g) try { 01040 return to_const(g)->OK() ? 1 : 0; 01041 } 01042 CATCH_ALL 01043 01044 int 01045 ppl_new_Linear_Expression_from_Generator(ppl_Linear_Expression_t* ple, 01046 ppl_const_Generator_t g) try { 01047 const Generator& gg = *to_const(g); 01048 *ple = to_nonconst(new Linear_Expression(gg)); 01049 return 0; 01050 } 01051 CATCH_ALL 01052 01053 /* Interface for Generator_System. */ 01054 01055 int 01056 ppl_new_Generator_System(ppl_Generator_System_t* pgs) try { 01057 *pgs = to_nonconst(new Generator_System()); 01058 return 0; 01059 } 01060 CATCH_ALL 01061 01062 int 01063 ppl_new_Generator_System_zero_dim_univ(ppl_Generator_System_t* pgs) try { 01064 *pgs = to_nonconst(new Generator_System(Generator_System::zero_dim_univ())); 01065 return 0; 01066 } 01067 CATCH_ALL 01068 01069 int 01070 ppl_new_Generator_System_from_Generator(ppl_Generator_System_t* pgs, 01071 ppl_const_Generator_t g) try { 01072 const Generator& gg = *to_const(g); 01073 *pgs = to_nonconst(new Generator_System(gg)); 01074 return 0; 01075 } 01076 CATCH_ALL 01077 01078 int 01079 ppl_new_Generator_System_from_Generator_System 01080 (ppl_Generator_System_t* pgs, ppl_const_Generator_System_t gs) try { 01081 const Generator_System& ggs = *to_const(gs); 01082 *pgs = to_nonconst(new Generator_System(ggs)); 01083 return 0; 01084 } 01085 CATCH_ALL 01086 01087 int 01088 ppl_delete_Generator_System(ppl_const_Generator_System_t gs) try { 01089 delete to_const(gs); 01090 return 0; 01091 } 01092 CATCH_ALL 01093 01094 int 01095 ppl_assign_Generator_System_from_Generator_System 01096 (ppl_Generator_System_t dst, ppl_const_Generator_System_t src) try { 01097 const Generator_System& ssrc = *to_const(src); 01098 Generator_System& ddst = *to_nonconst(dst); 01099 ddst = ssrc; 01100 return 0; 01101 } 01102 CATCH_ALL 01103 01104 int 01105 ppl_Generator_System_space_dimension(ppl_const_Generator_System_t gs, 01106 ppl_dimension_type* m) try { 01107 *m = to_const(gs)->space_dimension(); 01108 return 0; 01109 } 01110 CATCH_ALL 01111 01112 int 01113 ppl_Generator_System_empty 01114 (ppl_const_Generator_System_t gs) try { 01115 const Generator_System& cgs = *to_const(gs); 01116 return cgs.empty() ? 1 : 0; 01117 } 01118 CATCH_ALL 01119 01120 int 01121 ppl_Generator_System_clear(ppl_Generator_System_t gs) try { 01122 to_nonconst(gs)->clear(); 01123 return 0; 01124 } 01125 CATCH_ALL 01126 01127 int 01128 ppl_Generator_System_insert_Generator(ppl_Generator_System_t gs, 01129 ppl_const_Generator_t g) try { 01130 const Generator& gg = *to_const(g); 01131 Generator_System& ggs = *to_nonconst(gs); 01132 ggs.insert(gg); 01133 return 0; 01134 } 01135 CATCH_ALL 01136 01137 int 01138 ppl_Generator_System_OK(ppl_const_Generator_System_t gs) try { 01139 return to_const(gs)->OK() ? 1 : 0; 01140 } 01141 CATCH_ALL 01142 01143 /* Interface for Generator_System::const_iterator. */ 01144 01145 int 01146 ppl_new_Generator_System_const_iterator 01147 (ppl_Generator_System_const_iterator_t* pgit) try { 01148 *pgit = to_nonconst(new Generator_System::const_iterator()); 01149 return 0; 01150 } 01151 CATCH_ALL 01152 01153 int 01154 ppl_new_Generator_System_const_iterator_from_Generator_System_const_iterator 01155 (ppl_Generator_System_const_iterator_t* pgit, 01156 ppl_const_Generator_System_const_iterator_t git) try { 01157 *pgit = to_nonconst(new Generator_System::const_iterator(*to_const(git))); 01158 return 0; 01159 } 01160 CATCH_ALL 01161 01162 int 01163 ppl_delete_Generator_System_const_iterator 01164 (ppl_const_Generator_System_const_iterator_t git) try { 01165 delete to_const(git); 01166 return 0; 01167 } 01168 CATCH_ALL 01169 01170 int 01171 ppl_assign_Generator_System_const_iterator_from_Generator_System_const_iterator 01172 (ppl_Generator_System_const_iterator_t dst, 01173 ppl_const_Generator_System_const_iterator_t src) try { 01174 const Generator_System::const_iterator& ssrc = *to_const(src); 01175 Generator_System::const_iterator& ddst = *to_nonconst(dst); 01176 ddst = ssrc; 01177 return 0; 01178 } 01179 CATCH_ALL 01180 01181 int 01182 ppl_Generator_System_begin(ppl_const_Generator_System_t gs, 01183 ppl_Generator_System_const_iterator_t git) try { 01184 const Generator_System& ggs = *to_const(gs); 01185 Generator_System::const_iterator& ggit = *to_nonconst(git); 01186 ggit = ggs.begin(); 01187 return 0; 01188 } 01189 CATCH_ALL 01190 01191 int 01192 ppl_Generator_System_end(ppl_const_Generator_System_t gs, 01193 ppl_Generator_System_const_iterator_t git) try { 01194 const Generator_System& ggs = *to_const(gs); 01195 Generator_System::const_iterator& ggit = *to_nonconst(git); 01196 ggit = ggs.end(); 01197 return 0; 01198 } 01199 CATCH_ALL 01200 01201 int 01202 ppl_Generator_System_const_iterator_dereference 01203 (ppl_const_Generator_System_const_iterator_t git, 01204 ppl_const_Generator_t* pg) try { 01205 const Generator_System::const_iterator& ggit = *to_const(git); 01206 const Generator& c = *ggit; 01207 *pg = to_const(&c); 01208 return 0; 01209 } 01210 CATCH_ALL 01211 01212 int 01213 ppl_Generator_System_const_iterator_increment 01214 (ppl_Generator_System_const_iterator_t git) try { 01215 Generator_System::const_iterator& ggit = *to_nonconst(git); 01216 ++ggit; 01217 return 0; 01218 } 01219 CATCH_ALL 01220 01221 int 01222 ppl_Generator_System_const_iterator_equal_test 01223 (ppl_const_Generator_System_const_iterator_t x, 01224 ppl_const_Generator_System_const_iterator_t y) try { 01225 const Generator_System::const_iterator& xx = *to_const(x); 01226 const Generator_System::const_iterator& yy = *to_const(y); 01227 return (xx == yy) ? 1 : 0; 01228 } 01229 CATCH_ALL 01230 01231 /* Interface for Congruence. */ 01232 01233 int 01234 ppl_new_Congruence(ppl_Congruence_t* pc, 01235 ppl_const_Linear_Expression_t le, 01236 ppl_const_Coefficient_t m) try { 01237 Congruence* ppc; 01238 const Linear_Expression& lle = *to_const(le); 01239 const Coefficient& mm = *to_const(m); 01240 ppc = new Congruence((lle %= 0) / mm); 01241 *pc = to_nonconst(ppc); 01242 return 0; 01243 } 01244 CATCH_ALL 01245 01246 int 01247 ppl_new_Congruence_zero_dim_false(ppl_Congruence_t* pc) try { 01248 *pc = to_nonconst(new Congruence(Congruence::zero_dim_false())); 01249 return 0; 01250 } 01251 CATCH_ALL 01252 01253 int 01254 ppl_new_Congruence_zero_dim_integrality(ppl_Congruence_t* pc) try { 01255 *pc = to_nonconst(new Congruence(Congruence::zero_dim_integrality())); 01256 return 0; 01257 } 01258 CATCH_ALL 01259 01260 int 01261 ppl_new_Congruence_from_Congruence(ppl_Congruence_t* pc, 01262 ppl_const_Congruence_t c) try { 01263 const Congruence& cc = *to_const(c); 01264 *pc = to_nonconst(new Congruence(cc)); 01265 return 0; 01266 } 01267 CATCH_ALL 01268 01269 int 01270 ppl_delete_Congruence(ppl_const_Congruence_t le) try { 01271 delete to_const(le); 01272 return 0; 01273 } 01274 CATCH_ALL 01275 01276 int 01277 ppl_assign_Congruence_from_Congruence(ppl_Congruence_t dst, 01278 ppl_const_Congruence_t src) try { 01279 const Congruence& ssrc = *to_const(src); 01280 Congruence& ddst = *to_nonconst(dst); 01281 ddst = ssrc; 01282 return 0; 01283 } 01284 CATCH_ALL 01285 01286 int 01287 ppl_Congruence_space_dimension(ppl_const_Congruence_t c, 01288 ppl_dimension_type* m) try { 01289 *m = to_const(c)->space_dimension(); 01290 return 0; 01291 } 01292 CATCH_ALL 01293 01294 int 01295 ppl_Congruence_coefficient(ppl_const_Congruence_t c, 01296 ppl_dimension_type var, 01297 ppl_Coefficient_t n) try { 01298 const Congruence& cc = *to_const(c); 01299 Coefficient& nn = *to_nonconst(n); 01300 nn = cc.coefficient(Variable(var)); 01301 return 0; 01302 } 01303 CATCH_ALL 01304 01305 int 01306 ppl_Congruence_inhomogeneous_term(ppl_const_Congruence_t c, 01307 ppl_Coefficient_t n) try { 01308 const Congruence& cc = *to_const(c); 01309 Coefficient& nn = *to_nonconst(n); 01310 nn = cc.inhomogeneous_term(); 01311 return 0; 01312 } 01313 CATCH_ALL 01314 01315 int 01316 ppl_Congruence_modulus(ppl_const_Congruence_t c, 01317 ppl_Coefficient_t m) try { 01318 const Congruence& cc = *to_const(c); 01319 Coefficient& mm = *to_nonconst(m); 01320 mm = cc.modulus(); 01321 return 0; 01322 } 01323 CATCH_ALL 01324 01325 int 01326 ppl_Congruence_OK(ppl_const_Congruence_t c) try { 01327 return to_const(c)->OK() ? 1 : 0; 01328 } 01329 CATCH_ALL 01330 01331 int 01332 ppl_new_Linear_Expression_from_Congruence(ppl_Linear_Expression_t* ple, 01333 ppl_const_Congruence_t c) try { 01334 const Congruence& cc = *to_const(c); 01335 *ple = to_nonconst(new Linear_Expression(cc)); 01336 return 0; 01337 } 01338 CATCH_ALL 01339 01340 /* Interface for Congruence_System. */ 01341 01342 int 01343 ppl_new_Congruence_System(ppl_Congruence_System_t* pcs) try { 01344 *pcs = to_nonconst(new Congruence_System()); 01345 return 0; 01346 } 01347 CATCH_ALL 01348 01349 int 01350 ppl_new_Congruence_System_zero_dim_empty(ppl_Congruence_System_t* pcs) try { 01351 *pcs = to_nonconst(new 01352 Congruence_System(Congruence_System::zero_dim_empty())); 01353 return 0; 01354 } 01355 CATCH_ALL 01356 01357 01358 int 01359 ppl_new_Congruence_System_from_Congruence(ppl_Congruence_System_t* pcs, 01360 ppl_const_Congruence_t c) try { 01361 const Congruence& cc = *to_const(c); 01362 *pcs = to_nonconst(new Congruence_System(cc)); 01363 return 0; 01364 } 01365 CATCH_ALL 01366 01367 int 01368 ppl_new_Congruence_System_from_Congruence_System 01369 (ppl_Congruence_System_t* pcs, ppl_const_Congruence_System_t cs) try { 01370 const Congruence_System& ccs = *to_const(cs); 01371 *pcs = to_nonconst(new Congruence_System(ccs)); 01372 return 0; 01373 } 01374 CATCH_ALL 01375 01376 int 01377 ppl_delete_Congruence_System(ppl_const_Congruence_System_t cs) try { 01378 delete to_const(cs); 01379 return 0; 01380 } 01381 CATCH_ALL 01382 01383 int 01384 ppl_assign_Congruence_System_from_Congruence_System 01385 (ppl_Congruence_System_t dst, ppl_const_Congruence_System_t src) try { 01386 const Congruence_System& ssrc = *to_const(src); 01387 Congruence_System& ddst = *to_nonconst(dst); 01388 ddst = ssrc; 01389 return 0; 01390 } 01391 CATCH_ALL 01392 01393 int 01394 ppl_Congruence_System_space_dimension(ppl_const_Congruence_System_t cs, 01395 ppl_dimension_type* m) try { 01396 *m = to_const(cs)->space_dimension(); 01397 return 0; 01398 } 01399 CATCH_ALL 01400 01401 int 01402 ppl_Congruence_System_empty 01403 (ppl_const_Congruence_System_t cs) try { 01404 const Congruence_System& ccs = *to_const(cs); 01405 return ccs.empty() ? 1 : 0; 01406 } 01407 CATCH_ALL 01408 01409 int 01410 ppl_Congruence_System_clear(ppl_Congruence_System_t cs) try { 01411 to_nonconst(cs)->clear(); 01412 return 0; 01413 } 01414 CATCH_ALL 01415 01416 int 01417 ppl_Congruence_System_insert_Congruence(ppl_Congruence_System_t cs, 01418 ppl_const_Congruence_t c) try { 01419 const Congruence& cc = *to_const(c); 01420 Congruence_System& ccs = *to_nonconst(cs); 01421 ccs.insert(cc); 01422 return 0; 01423 } 01424 CATCH_ALL 01425 01426 int 01427 ppl_Congruence_System_OK(ppl_const_Congruence_System_t cs) try { 01428 return to_const(cs)->OK() ? 1 : 0; 01429 } 01430 CATCH_ALL 01431 01432 /* Interface for Congruence_System::const_iterator. */ 01433 01434 int 01435 ppl_new_Congruence_System_const_iterator 01436 (ppl_Congruence_System_const_iterator_t* pcit) try { 01437 *pcit = to_nonconst(new Congruence_System::const_iterator()); 01438 return 0; 01439 } 01440 CATCH_ALL 01441 01442 int 01443 ppl_new_Congruence_System_const_iterator_from_Congruence_System_const_iterator 01444 (ppl_Congruence_System_const_iterator_t* pcit, 01445 ppl_const_Congruence_System_const_iterator_t cit) try { 01446 *pcit = to_nonconst(new Congruence_System::const_iterator(*to_const(cit))); 01447 return 0; 01448 } 01449 CATCH_ALL 01450 01451 int 01452 ppl_delete_Congruence_System_const_iterator 01453 (ppl_const_Congruence_System_const_iterator_t cit) 01454 try { 01455 delete to_const(cit); 01456 return 0; 01457 } 01458 CATCH_ALL 01459 01460 int 01461 ppl_assign_Congruence_System_const_iterator_from_Congruence_System_const_iterator 01462 (ppl_Congruence_System_const_iterator_t dst, 01463 ppl_const_Congruence_System_const_iterator_t src) try { 01464 const Congruence_System::const_iterator& ssrc = *to_const(src); 01465 Congruence_System::const_iterator& ddst = *to_nonconst(dst); 01466 ddst = ssrc; 01467 return 0; 01468 } 01469 CATCH_ALL 01470 01471 int 01472 ppl_Congruence_System_begin(ppl_const_Congruence_System_t cs, 01473 ppl_Congruence_System_const_iterator_t cit) try { 01474 const Congruence_System& ccs = *to_const(cs); 01475 Congruence_System::const_iterator& ccit = *to_nonconst(cit); 01476 ccit = ccs.begin(); 01477 return 0; 01478 } 01479 CATCH_ALL 01480 01481 int 01482 ppl_Congruence_System_end(ppl_const_Congruence_System_t cs, 01483 ppl_Congruence_System_const_iterator_t cit) try { 01484 const Congruence_System& ccs = *to_const(cs); 01485 Congruence_System::const_iterator& ccit = *to_nonconst(cit); 01486 ccit = ccs.end(); 01487 return 0; 01488 } 01489 CATCH_ALL 01490 01491 int 01492 ppl_Congruence_System_const_iterator_dereference 01493 (ppl_const_Congruence_System_const_iterator_t cit, 01494 ppl_const_Congruence_t* pc) try { 01495 const Congruence_System::const_iterator& ccit = *to_const(cit); 01496 const Congruence& c = *ccit; 01497 *pc = to_const(&c); 01498 return 0; 01499 } 01500 CATCH_ALL 01501 01502 int 01503 ppl_Congruence_System_const_iterator_increment 01504 (ppl_Congruence_System_const_iterator_t cit) try { 01505 Congruence_System::const_iterator& ccit = *to_nonconst(cit); 01506 ++ccit; 01507 return 0; 01508 } 01509 CATCH_ALL 01510 01511 int 01512 ppl_Congruence_System_const_iterator_equal_test 01513 (ppl_const_Congruence_System_const_iterator_t x, 01514 ppl_const_Congruence_System_const_iterator_t y) try { 01515 const Congruence_System::const_iterator& xx = *to_const(x); 01516 const Congruence_System::const_iterator& yy = *to_const(y); 01517 return (xx == yy) ? 1 : 0; 01518 } 01519 CATCH_ALL 01520 01521 /* Interface for Grid_Generator. */ 01522 01523 int 01524 ppl_new_Grid_Generator(ppl_Grid_Generator_t* pg, 01525 ppl_const_Linear_Expression_t le, 01526 enum ppl_enum_Grid_Generator_Type t, 01527 ppl_const_Coefficient_t d) try { 01528 Grid_Generator* ppg; 01529 const Linear_Expression& lle = *to_const(le); 01530 const Coefficient& dd = *to_const(d); 01531 switch (t) { 01532 case PPL_GRID_GENERATOR_TYPE_LINE: 01533 ppg = new Grid_Generator(Grid_Generator::grid_line(lle)); 01534 break; 01535 case PPL_GRID_GENERATOR_TYPE_PARAMETER: 01536 ppg = new Grid_Generator(Grid_Generator::parameter(lle)); 01537 break; 01538 case PPL_GRID_GENERATOR_TYPE_POINT: 01539 ppg = new Grid_Generator(Grid_Generator::grid_point(lle, dd)); 01540 break; 01541 default: 01542 throw std::invalid_argument("ppl_new_Grid_Generator(pg, le, t, d): " 01543 "t invalid"); 01544 } 01545 *pg = to_nonconst(ppg); 01546 return 0; 01547 } 01548 CATCH_ALL 01549 01550 int 01551 ppl_new_Grid_Generator_zero_dim_point(ppl_Grid_Generator_t* pg) try { 01552 *pg = to_nonconst(new Grid_Generator(Grid_Generator::zero_dim_point())); 01553 return 0; 01554 } 01555 CATCH_ALL 01556 01557 int 01558 ppl_new_Grid_Generator_from_Grid_Generator(ppl_Grid_Generator_t* pg, 01559 ppl_const_Grid_Generator_t g) try { 01560 const Grid_Generator& gg = *to_const(g); 01561 *pg = to_nonconst(new Grid_Generator(gg)); 01562 return 0; 01563 } 01564 CATCH_ALL 01565 01566 int 01567 ppl_delete_Grid_Generator(ppl_const_Grid_Generator_t le) try { 01568 delete to_const(le); 01569 return 0; 01570 } 01571 CATCH_ALL 01572 01573 int 01574 ppl_assign_Grid_Generator_from_Grid_Generator 01575 (ppl_Grid_Generator_t dst, 01576 ppl_const_Grid_Generator_t src) try { 01577 const Grid_Generator& ssrc = *to_const(src); 01578 Grid_Generator& ddst = *to_nonconst(dst); 01579 ddst = ssrc; 01580 return 0; 01581 } 01582 CATCH_ALL 01583 01584 int 01585 ppl_Grid_Generator_space_dimension(ppl_const_Grid_Generator_t g, 01586 ppl_dimension_type* m) try { 01587 *m = to_const(g)->space_dimension(); 01588 return 0; 01589 } 01590 CATCH_ALL 01591 01592 int 01593 ppl_Grid_Generator_type(ppl_const_Grid_Generator_t g) try { 01594 switch (to_const(g)->type()) { 01595 case Grid_Generator::LINE: 01596 return PPL_GRID_GENERATOR_TYPE_LINE; 01597 case Grid_Generator::PARAMETER: 01598 return PPL_GRID_GENERATOR_TYPE_PARAMETER; 01599 case Grid_Generator::POINT: 01600 return PPL_GRID_GENERATOR_TYPE_POINT; 01601 } 01602 PPL_UNREACHABLE; 01603 } 01604 CATCH_ALL 01605 01606 int 01607 ppl_Grid_Generator_coefficient(ppl_const_Grid_Generator_t g, 01608 ppl_dimension_type var, 01609 ppl_Coefficient_t n) try { 01610 const Grid_Generator& gg = *to_const(g); 01611 Coefficient& nn = *to_nonconst(n); 01612 nn = gg.coefficient(Variable(var)); 01613 return 0; 01614 } 01615 CATCH_ALL 01616 01617 int 01618 ppl_Grid_Generator_divisor(ppl_const_Grid_Generator_t g, 01619 ppl_Coefficient_t n) try { 01620 const Grid_Generator& gg = *to_const(g); 01621 Coefficient& nn = *to_nonconst(n); 01622 nn = gg.divisor(); 01623 return 0; 01624 } 01625 CATCH_ALL 01626 01627 int 01628 ppl_Grid_Generator_OK(ppl_const_Grid_Generator_t g) try { 01629 return to_const(g)->OK() ? 1 : 0; 01630 } 01631 CATCH_ALL 01632 01633 // FIXME: to be restored soon. 01634 // int 01635 // ppl_new_Linear_Expression_from_Grid_Generator 01636 // (ppl_Linear_Expression_t* ple, 01637 // ppl_const_Grid_Generator_t g) try { 01638 // const Grid_Generator& gg = *to_const(g); 01639 // *ple = to_nonconst(new Linear_Expression(gg)); 01640 // return 0; 01641 // } 01642 // CATCH_ALL 01643 01644 /* Interface for Grid_Generator_System. */ 01645 01646 int 01647 ppl_new_Grid_Generator_System(ppl_Grid_Generator_System_t* pgs) try { 01648 *pgs = to_nonconst(new Grid_Generator_System()); 01649 return 0; 01650 } 01651 CATCH_ALL 01652 01653 int 01654 ppl_new_Grid_Generator_System_zero_dim_univ 01655 (ppl_Grid_Generator_System_t* pgs) try { 01656 *pgs = to_nonconst 01657 (new Grid_Generator_System(Grid_Generator_System::zero_dim_univ())); 01658 return 0; 01659 } 01660 CATCH_ALL 01661 01662 int 01663 ppl_new_Grid_Generator_System_from_Grid_Generator 01664 (ppl_Grid_Generator_System_t* pgs, ppl_const_Grid_Generator_t g) try { 01665 const Grid_Generator& gg = *to_const(g); 01666 *pgs = to_nonconst(new Grid_Generator_System(gg)); 01667 return 0; 01668 } 01669 CATCH_ALL 01670 01671 int 01672 ppl_new_Grid_Generator_System_from_Grid_Generator_System 01673 (ppl_Grid_Generator_System_t* pgs, ppl_const_Grid_Generator_System_t gs) try { 01674 const Grid_Generator_System& ggs = *to_const(gs); 01675 *pgs = to_nonconst(new Grid_Generator_System(ggs)); 01676 return 0; 01677 } 01678 CATCH_ALL 01679 01680 int 01681 ppl_delete_Grid_Generator_System(ppl_const_Grid_Generator_System_t gs) try { 01682 delete to_const(gs); 01683 return 0; 01684 } 01685 CATCH_ALL 01686 01687 int 01688 ppl_assign_Grid_Generator_System_from_Grid_Generator_System 01689 (ppl_Grid_Generator_System_t dst, ppl_const_Grid_Generator_System_t src) try { 01690 const Grid_Generator_System& ssrc = *to_const(src); 01691 Grid_Generator_System& ddst = *to_nonconst(dst); 01692 ddst = ssrc; 01693 return 0; 01694 } 01695 CATCH_ALL 01696 01697 int 01698 ppl_Grid_Generator_System_space_dimension(ppl_const_Grid_Generator_System_t gs, 01699 ppl_dimension_type* m) try { 01700 *m = to_const(gs)->space_dimension(); 01701 return 0; 01702 } 01703 CATCH_ALL 01704 01705 int 01706 ppl_Grid_Generator_System_empty 01707 (ppl_const_Grid_Generator_System_t gs) try { 01708 const Grid_Generator_System& cgs = *to_const(gs); 01709 return cgs.empty() ? 1 : 0; 01710 } 01711 CATCH_ALL 01712 01713 int 01714 ppl_Grid_Generator_System_clear(ppl_Grid_Generator_System_t gs) try { 01715 to_nonconst(gs)->clear(); 01716 return 0; 01717 } 01718 CATCH_ALL 01719 01720 int 01721 ppl_Grid_Generator_System_insert_Grid_Generator 01722 (ppl_Grid_Generator_System_t gs, 01723 ppl_const_Grid_Generator_t g) try { 01724 const Grid_Generator& gg = *to_const(g); 01725 Grid_Generator_System& ggs = *to_nonconst(gs); 01726 ggs.insert(gg); 01727 return 0; 01728 } 01729 CATCH_ALL 01730 01731 int 01732 ppl_Grid_Generator_System_OK(ppl_const_Grid_Generator_System_t gs) try { 01733 return to_const(gs)->OK() ? 1 : 0; 01734 } 01735 CATCH_ALL 01736 01737 /* Interface for Grid_Generator_System::const_iterator. */ 01738 01739 int 01740 ppl_new_Grid_Generator_System_const_iterator 01741 (ppl_Grid_Generator_System_const_iterator_t* pgit) try { 01742 *pgit = to_nonconst(new Grid_Generator_System::const_iterator()); 01743 return 0; 01744 } 01745 CATCH_ALL 01746 01747 int 01748 ppl_new_Grid_Generator_System_const_iterator_from_Grid_Generator_System_const_iterator 01749 (ppl_Grid_Generator_System_const_iterator_t* pgit, 01750 ppl_const_Grid_Generator_System_const_iterator_t git) try { 01751 *pgit = to_nonconst 01752 (new Grid_Generator_System::const_iterator(*to_const(git))); 01753 return 0; 01754 } 01755 CATCH_ALL 01756 01757 int 01758 ppl_delete_Grid_Generator_System_const_iterator 01759 (ppl_const_Grid_Generator_System_const_iterator_t git) try { 01760 delete to_const(git); 01761 return 0; 01762 } 01763 CATCH_ALL 01764 01765 int 01766 ppl_assign_Grid_Generator_System_const_iterator_from_Grid_Generator_System_const_iterator 01767 (ppl_Grid_Generator_System_const_iterator_t dst, 01768 ppl_const_Grid_Generator_System_const_iterator_t src) try { 01769 const Grid_Generator_System::const_iterator& ssrc = *to_const(src); 01770 Grid_Generator_System::const_iterator& ddst = *to_nonconst(dst); 01771 ddst = ssrc; 01772 return 0; 01773 } 01774 CATCH_ALL 01775 01776 int 01777 ppl_Grid_Generator_System_begin 01778 (ppl_const_Grid_Generator_System_t gs, 01779 ppl_Grid_Generator_System_const_iterator_t git) try { 01780 const Grid_Generator_System& ggs = *to_const(gs); 01781 Grid_Generator_System::const_iterator& ggit = *to_nonconst(git); 01782 ggit = ggs.begin(); 01783 return 0; 01784 } 01785 CATCH_ALL 01786 01787 int 01788 ppl_Grid_Generator_System_end 01789 (ppl_const_Grid_Generator_System_t gs, 01790 ppl_Grid_Generator_System_const_iterator_t git) try { 01791 const Grid_Generator_System& ggs = *to_const(gs); 01792 Grid_Generator_System::const_iterator& ggit = *to_nonconst(git); 01793 ggit = ggs.end(); 01794 return 0; 01795 } 01796 CATCH_ALL 01797 01798 int 01799 ppl_Grid_Generator_System_const_iterator_dereference 01800 (ppl_const_Grid_Generator_System_const_iterator_t git, 01801 ppl_const_Grid_Generator_t* pg) try { 01802 const Grid_Generator_System::const_iterator& ggit = *to_const(git); 01803 const Grid_Generator& g = *ggit; 01804 *pg = to_const(&g); 01805 return 0; 01806 } 01807 CATCH_ALL 01808 01809 int 01810 ppl_Grid_Generator_System_const_iterator_increment 01811 (ppl_Grid_Generator_System_const_iterator_t git) try { 01812 Grid_Generator_System::const_iterator& ggit = *to_nonconst(git); 01813 ++ggit; 01814 return 0; 01815 } 01816 CATCH_ALL 01817 01818 int 01819 ppl_Grid_Generator_System_const_iterator_equal_test 01820 (ppl_const_Grid_Generator_System_const_iterator_t x, 01821 ppl_const_Grid_Generator_System_const_iterator_t y) try { 01822 const Grid_Generator_System::const_iterator& xx = *to_const(x); 01823 const Grid_Generator_System::const_iterator& yy = *to_const(y); 01824 return (xx == yy) ? 1 : 0; 01825 } 01826 CATCH_ALL 01827 01828 int 01829 ppl_new_MIP_Problem_from_space_dimension(ppl_MIP_Problem_t* pmip, 01830 ppl_dimension_type d) try { 01831 *pmip = to_nonconst(new MIP_Problem(d)); 01832 return 0; 01833 } 01834 CATCH_ALL 01835 01836 int 01837 ppl_new_MIP_Problem(ppl_MIP_Problem_t* pmip, 01838 ppl_dimension_type d, 01839 ppl_const_Constraint_System_t cs, 01840 ppl_const_Linear_Expression_t le, int m) try { 01841 const Constraint_System& ccs = *to_const(cs); 01842 const Linear_Expression& lle = *to_const(le); 01843 Optimization_Mode mm = (m == PPL_OPTIMIZATION_MODE_MINIMIZATION) 01844 ? MINIMIZATION : MAXIMIZATION; 01845 *pmip = to_nonconst(new MIP_Problem(d, ccs, lle, mm)); 01846 return 0; 01847 } 01848 CATCH_ALL 01849 01850 int 01851 ppl_new_MIP_Problem_from_MIP_Problem(ppl_MIP_Problem_t* pmip, 01852 ppl_const_MIP_Problem_t mip) try { 01853 const MIP_Problem& mmip = *to_const(mip); 01854 *pmip = to_nonconst(new MIP_Problem(mmip)); 01855 return 0; 01856 } 01857 CATCH_ALL 01858 01859 int 01860 ppl_delete_MIP_Problem(ppl_const_MIP_Problem_t mip) try { 01861 delete to_const(mip); 01862 return 0; 01863 } 01864 CATCH_ALL 01865 01866 int 01867 ppl_assign_MIP_Problem_from_MIP_Problem(ppl_MIP_Problem_t dst, 01868 ppl_const_MIP_Problem_t src) try { 01869 const MIP_Problem& ssrc = *to_const(src); 01870 MIP_Problem& ddst = *to_nonconst(dst); 01871 ddst = ssrc; 01872 return 0; 01873 } 01874 CATCH_ALL 01875 01876 int 01877 ppl_MIP_Problem_space_dimension(ppl_const_MIP_Problem_t mip, 01878 ppl_dimension_type* m) try { 01879 *m = to_const(mip)->space_dimension(); 01880 return 0; 01881 } 01882 CATCH_ALL 01883 01884 int 01885 ppl_MIP_Problem_number_of_integer_space_dimensions(ppl_const_MIP_Problem_t mip, 01886 ppl_dimension_type* m) try { 01887 const MIP_Problem& mmip = *to_const(mip); 01888 *m = mmip.integer_space_dimensions().size(); 01889 return 0; 01890 } 01891 CATCH_ALL 01892 01893 int 01894 ppl_MIP_Problem_integer_space_dimensions(ppl_const_MIP_Problem_t mip, 01895 ppl_dimension_type ds[]) try { 01896 const Variables_Set& vars = to_const(mip)->integer_space_dimensions(); 01897 ppl_dimension_type* ds_i = ds; 01898 for (Variables_Set::const_iterator v_iter = vars.begin(), 01899 v_end = vars.end(); v_iter != v_end; ++v_iter, ++ds_i) 01900 *ds_i = *v_iter; 01901 return 0; 01902 } 01903 CATCH_ALL 01904 01905 int 01906 ppl_MIP_Problem_number_of_constraints(ppl_const_MIP_Problem_t mip, 01907 ppl_dimension_type* m) try { 01908 const MIP_Problem& mmip = *to_const(mip); 01909 *m = static_cast<ppl_dimension_type>(mmip.constraints_end() - mmip.constraints_begin()); 01910 return 0; 01911 } 01912 CATCH_ALL 01913 01914 int 01915 ppl_MIP_Problem_constraint_at_index(ppl_const_MIP_Problem_t mip, 01916 ppl_dimension_type i, 01917 ppl_const_Constraint_t* pc) try { 01918 #ifndef NDEBUG 01919 ppl_dimension_type num_constraints; 01920 ppl_MIP_Problem_number_of_constraints(mip, &num_constraints); 01921 assert(i < num_constraints); 01922 #endif 01923 const MIP_Problem& mmip = *to_const(mip); 01924 const Constraint& c = *(mmip.constraints_begin() + i); 01925 *pc = to_const(&c); 01926 return 0; 01927 } 01928 CATCH_ALL 01929 01930 int 01931 ppl_MIP_Problem_objective_function(ppl_const_MIP_Problem_t mip, 01932 ppl_const_Linear_Expression_t* ple) try { 01933 const Linear_Expression& le = to_const(mip)->objective_function(); 01934 *ple = to_const(&le); 01935 return 0; 01936 } 01937 CATCH_ALL 01938 01939 int 01940 ppl_MIP_Problem_optimization_mode(ppl_const_MIP_Problem_t mip) try { 01941 return to_const(mip)->optimization_mode(); 01942 } 01943 CATCH_ALL 01944 01945 int 01946 ppl_MIP_Problem_clear(ppl_MIP_Problem_t mip) try { 01947 to_nonconst(mip)->clear(); 01948 return 0; 01949 } 01950 CATCH_ALL 01951 01952 int 01953 ppl_MIP_Problem_add_space_dimensions_and_embed(ppl_MIP_Problem_t mip, 01954 ppl_dimension_type d) try { 01955 MIP_Problem& mmip = *to_nonconst(mip); 01956 mmip.add_space_dimensions_and_embed(d); 01957 return 0; 01958 } 01959 CATCH_ALL 01960 01961 int 01962 ppl_MIP_Problem_add_to_integer_space_dimensions(ppl_MIP_Problem_t mip, 01963 ppl_dimension_type ds[], 01964 size_t n) try { 01965 MIP_Problem& mmip = *to_nonconst(mip); 01966 Variables_Set vars; 01967 for (ppl_dimension_type i = n; i-- > 0; ) 01968 vars.insert(ds[i]); 01969 mmip.add_to_integer_space_dimensions(vars); 01970 return 0; 01971 } 01972 CATCH_ALL 01973 01974 int 01975 ppl_MIP_Problem_add_constraint(ppl_MIP_Problem_t mip, 01976 ppl_const_Constraint_t c) try { 01977 const Constraint& cc = *to_const(c); 01978 MIP_Problem& mmip = *to_nonconst(mip); 01979 mmip.add_constraint(cc); 01980 return 0; 01981 } 01982 CATCH_ALL 01983 01984 int 01985 ppl_MIP_Problem_add_constraints(ppl_MIP_Problem_t mip, 01986 ppl_const_Constraint_System_t cs) try { 01987 const Constraint_System& ccs = *to_const(cs); 01988 MIP_Problem& mmip = *to_nonconst(mip); 01989 mmip.add_constraints(ccs); 01990 return 0; 01991 } 01992 CATCH_ALL 01993 01994 int 01995 ppl_MIP_Problem_set_objective_function(ppl_MIP_Problem_t mip, 01996 ppl_const_Linear_Expression_t le) try { 01997 const Linear_Expression& lle = *to_const(le); 01998 MIP_Problem& mmip = *to_nonconst(mip); 01999 mmip.set_objective_function(lle); 02000 return 0; 02001 } 02002 CATCH_ALL 02003 02004 int 02005 ppl_MIP_Problem_set_optimization_mode(ppl_MIP_Problem_t mip, int mode) try { 02006 MIP_Problem& mmip = *to_nonconst(mip); 02007 Optimization_Mode m = (mode == PPL_OPTIMIZATION_MODE_MINIMIZATION) 02008 ? MINIMIZATION : MAXIMIZATION; 02009 mmip.set_optimization_mode(m); 02010 return 0; 02011 } 02012 CATCH_ALL 02013 02014 int 02015 ppl_MIP_Problem_is_satisfiable(ppl_const_MIP_Problem_t mip) try { 02016 return to_const(mip)->is_satisfiable() ? 1 : 0; 02017 } 02018 CATCH_ALL 02019 02020 int 02021 ppl_MIP_Problem_solve(ppl_const_MIP_Problem_t mip) try { 02022 return to_const(mip)->solve(); 02023 } 02024 CATCH_ALL 02025 02026 int 02027 ppl_MIP_Problem_evaluate_objective_function(ppl_const_MIP_Problem_t mip, 02028 ppl_const_Generator_t g, 02029 ppl_Coefficient_t num, 02030 ppl_Coefficient_t den) try { 02031 const MIP_Problem& mmip = *to_const(mip); 02032 const Generator& gg = *to_const(g); 02033 Coefficient& nnum = *to_nonconst(num); 02034 Coefficient& dden = *to_nonconst(den); 02035 mmip.evaluate_objective_function(gg, nnum, dden); 02036 return 0; 02037 } 02038 CATCH_ALL 02039 02040 int 02041 ppl_MIP_Problem_feasible_point(ppl_const_MIP_Problem_t mip, 02042 ppl_const_Generator_t* pg) try { 02043 const Generator& g = to_const(mip)->feasible_point(); 02044 *pg = to_const(&g); 02045 return 0; 02046 } 02047 CATCH_ALL 02048 02049 int 02050 ppl_MIP_Problem_optimizing_point(ppl_const_MIP_Problem_t mip, 02051 ppl_const_Generator_t* pg) try { 02052 const Generator& g = to_const(mip)->optimizing_point(); 02053 *pg = to_const(&g); 02054 return 0; 02055 } 02056 CATCH_ALL 02057 02058 int 02059 ppl_MIP_Problem_optimal_value(ppl_const_MIP_Problem_t mip, 02060 ppl_Coefficient_t num, 02061 ppl_Coefficient_t den) try { 02062 Coefficient& nnum = *to_nonconst(num); 02063 Coefficient& dden = *to_nonconst(den); 02064 to_const(mip)->optimal_value(nnum, dden); 02065 return 0; 02066 } 02067 CATCH_ALL 02068 02069 int 02070 ppl_MIP_Problem_get_control_parameter(ppl_const_MIP_Problem_t mip, 02071 int name) try { 02072 MIP_Problem::Control_Parameter_Name n 02073 = static_cast<MIP_Problem::Control_Parameter_Name>(name); 02074 return to_const(mip)->get_control_parameter(n); 02075 } 02076 CATCH_ALL 02077 02078 int 02079 ppl_MIP_Problem_set_control_parameter(ppl_MIP_Problem_t mip, 02080 int value) try { 02081 MIP_Problem::Control_Parameter_Value v 02082 = static_cast<MIP_Problem::Control_Parameter_Value>(value); 02083 to_nonconst(mip)->set_control_parameter(v); 02084 return 0; 02085 } 02086 CATCH_ALL 02087 02088 int 02089 ppl_MIP_Problem_OK(ppl_const_MIP_Problem_t mip) try { 02090 return to_const(mip)->OK() ? 1 : 0; 02091 } 02092 CATCH_ALL 02093 02094 int 02095 ppl_MIP_Problem_total_memory_in_bytes(ppl_const_MIP_Problem_t mip, 02096 size_t* sz) try { 02097 *sz = to_const(mip)->total_memory_in_bytes(); 02098 return 0; 02099 } 02100 CATCH_ALL 02101 02102 int 02103 ppl_MIP_Problem_external_memory_in_bytes(ppl_const_MIP_Problem_t mip, 02104 size_t* sz) try { 02105 *sz = to_const(mip)->external_memory_in_bytes(); 02106 return 0; 02107 } 02108 CATCH_ALL 02109 02110 int 02111 ppl_new_PIP_Problem_from_space_dimension(ppl_PIP_Problem_t* ppip, 02112 ppl_dimension_type d) try { 02113 *ppip = to_nonconst(new PIP_Problem(d)); 02114 return 0; 02115 } 02116 CATCH_ALL 02117 02118 int 02119 ppl_new_PIP_Problem_from_PIP_Problem(ppl_PIP_Problem_t* dpip, 02120 ppl_const_PIP_Problem_t pip) try { 02121 const PIP_Problem& spip = *to_const(pip); 02122 *dpip = to_nonconst(new PIP_Problem(spip)); 02123 return 0; 02124 } 02125 CATCH_ALL 02126 02127 int 02128 ppl_new_PIP_Problem_from_constraints 02129 (ppl_PIP_Problem_t* ppip, 02130 ppl_dimension_type d, 02131 ppl_Constraint_System_const_iterator_t first, 02132 ppl_Constraint_System_const_iterator_t last, 02133 size_t n, 02134 ppl_dimension_type ds[]) try { 02135 Variables_Set p_vars; 02136 for (ppl_dimension_type i = n; i-- > 0; ) 02137 p_vars.insert(ds[i]); 02138 *ppip = to_nonconst(new PIP_Problem(d, *to_const(first), 02139 *to_const(last), p_vars)); 02140 return 0; 02141 } 02142 CATCH_ALL 02143 02144 int 02145 ppl_assign_PIP_Problem_from_PIP_Problem(ppl_PIP_Problem_t dst, 02146 ppl_const_PIP_Problem_t src) try { 02147 const PIP_Problem& ssrc = *to_const(src); 02148 PIP_Problem& ddst = *to_nonconst(dst); 02149 ddst = ssrc; 02150 return 0; 02151 } 02152 CATCH_ALL 02153 02154 int 02155 ppl_delete_PIP_Problem(ppl_const_PIP_Problem_t pip) try { 02156 delete to_const(pip); 02157 return 0; 02158 } 02159 CATCH_ALL 02160 02161 int 02162 ppl_PIP_Problem_space_dimension(ppl_const_PIP_Problem_t pip, 02163 ppl_dimension_type* m) try { 02164 *m = to_const(pip)->space_dimension(); 02165 return 0; 02166 } 02167 CATCH_ALL 02168 02169 int 02170 ppl_PIP_Problem_number_of_parameter_space_dimensions 02171 (ppl_const_PIP_Problem_t pip, ppl_dimension_type* m) try { 02172 const PIP_Problem& ppip = *to_const(pip); 02173 *m = ppip.parameter_space_dimensions().size(); 02174 return 0; 02175 } 02176 CATCH_ALL 02177 02178 int 02179 ppl_PIP_Problem_parameter_space_dimensions(ppl_const_PIP_Problem_t pip, 02180 ppl_dimension_type ds[]) try { 02181 const Variables_Set& vars = to_const(pip)->parameter_space_dimensions(); 02182 ppl_dimension_type* ds_i = ds; 02183 for (Variables_Set::const_iterator v_iter = vars.begin(), 02184 v_end = vars.end(); v_iter != v_end; ++v_iter, ++ds_i) 02185 *ds_i = *v_iter; 02186 return 0; 02187 } 02188 CATCH_ALL 02189 02190 int 02191 ppl_PIP_Problem_number_of_constraints(ppl_const_PIP_Problem_t pip, 02192 ppl_dimension_type* m) try { 02193 const PIP_Problem& ppip = *to_const(pip); 02194 *m = static_cast<ppl_dimension_type>(ppip.constraints_end() - ppip.constraints_begin()); 02195 return 0; 02196 } 02197 CATCH_ALL 02198 02199 int 02200 ppl_PIP_Problem_constraint_at_index(ppl_const_PIP_Problem_t pip, 02201 ppl_dimension_type i, 02202 ppl_const_Constraint_t* pc) try { 02203 #ifndef NDEBUG 02204 ppl_dimension_type num_constraints; 02205 ppl_PIP_Problem_number_of_constraints(pip, &num_constraints); 02206 assert(i < num_constraints); 02207 #endif 02208 const PIP_Problem& ppip = *to_const(pip); 02209 const Constraint& c = *(ppip.constraints_begin() + i); 02210 *pc = to_const(&c); 02211 return 0; 02212 } 02213 CATCH_ALL 02214 int 02215 ppl_PIP_Problem_clear(ppl_PIP_Problem_t pip) try { 02216 to_nonconst(pip)->clear(); 02217 return 0; 02218 } 02219 CATCH_ALL 02220 int 02221 ppl_PIP_Problem_add_space_dimensions_and_embed(ppl_PIP_Problem_t pip, 02222 ppl_dimension_type pip_vars, 02223 ppl_dimension_type pip_params) 02224 try { 02225 PIP_Problem& spip = *to_nonconst(pip); 02226 spip.add_space_dimensions_and_embed(pip_vars,pip_params); 02227 return 0; 02228 } 02229 CATCH_ALL 02230 int 02231 ppl_PIP_Problem_add_to_parameter_space_dimensions(ppl_PIP_Problem_t pip, 02232 ppl_dimension_type ds[], 02233 size_t n) try { 02234 PIP_Problem& ppip = *to_nonconst(pip); 02235 Variables_Set vars; 02236 for (ppl_dimension_type i = n; i-- > 0; ) 02237 vars.insert(ds[i]); 02238 ppip.add_to_parameter_space_dimensions(vars); 02239 return 0; 02240 } 02241 CATCH_ALL 02242 int 02243 ppl_PIP_Problem_add_constraint(ppl_PIP_Problem_t pip, 02244 ppl_const_Constraint_t c) try { 02245 const Constraint& cc = *to_const(c); 02246 PIP_Problem& ppip = *to_nonconst(pip); 02247 ppip.add_constraint(cc); 02248 return 0; 02249 } 02250 CATCH_ALL 02251 02252 int 02253 ppl_PIP_Problem_add_constraints(ppl_PIP_Problem_t pip, 02254 ppl_const_Constraint_System_t cs) try { 02255 const Constraint_System& ccs = *to_const(cs); 02256 PIP_Problem& ppip = *to_nonconst(pip); 02257 ppip.add_constraints(ccs); 02258 return 0; 02259 } 02260 CATCH_ALL 02261 int 02262 ppl_PIP_Problem_is_satisfiable(ppl_const_PIP_Problem_t pip) try { 02263 return to_const(pip)->is_satisfiable() ? 1 : 0; 02264 } 02265 CATCH_ALL 02266 int 02267 ppl_PIP_Problem_solve(ppl_const_PIP_Problem_t pip) try { 02268 return to_const(pip)->solve(); 02269 } 02270 CATCH_ALL 02271 02272 int 02273 ppl_PIP_Problem_solution(ppl_const_PIP_Problem_t pip, 02274 ppl_const_PIP_Tree_Node_t* ppip_tree) try { 02275 *ppip_tree = to_const(to_const(pip)->solution()); 02276 return 0; 02277 } 02278 CATCH_ALL 02279 02280 int 02281 ppl_PIP_Problem_optimizing_solution(ppl_const_PIP_Problem_t pip, 02282 ppl_const_PIP_Tree_Node_t* ppip_tree) try { 02283 *ppip_tree = to_const(to_const(pip)->optimizing_solution()); 02284 return 0; 02285 } 02286 CATCH_ALL 02287 02288 int 02289 ppl_PIP_Problem_OK(ppl_const_PIP_Problem_t pip) try { 02290 return to_const(pip)->OK() ? 1 : 0; 02291 } 02292 CATCH_ALL 02293 02294 int 02295 ppl_PIP_Problem_get_control_parameter(ppl_const_PIP_Problem_t pip, 02296 int name) try { 02297 PIP_Problem::Control_Parameter_Name n 02298 = static_cast<PIP_Problem::Control_Parameter_Name>(name); 02299 return to_const(pip)->get_control_parameter(n); 02300 } 02301 CATCH_ALL 02302 02303 int 02304 ppl_PIP_Problem_set_control_parameter(ppl_PIP_Problem_t pip, 02305 int value) try { 02306 PIP_Problem::Control_Parameter_Value v 02307 = static_cast<PIP_Problem::Control_Parameter_Value>(value); 02308 to_nonconst(pip)->set_control_parameter(v); 02309 return 0; 02310 } 02311 CATCH_ALL 02312 02313 int 02314 ppl_PIP_Problem_get_big_parameter_dimension(ppl_const_PIP_Problem_t pip, 02315 ppl_dimension_type* pd) try { 02316 *pd = to_const(pip)->get_big_parameter_dimension(); 02317 return 0; 02318 } 02319 CATCH_ALL 02320 02321 int 02322 ppl_PIP_Problem_set_big_parameter_dimension(ppl_PIP_Problem_t pip, 02323 ppl_dimension_type d) try { 02324 to_nonconst(pip)->set_big_parameter_dimension(d); 02325 return 0; 02326 } 02327 CATCH_ALL 02328 02329 int 02330 ppl_PIP_Problem_total_memory_in_bytes(ppl_const_PIP_Problem_t pip, 02331 size_t* sz) try { 02332 *sz = to_const(pip)->total_memory_in_bytes(); 02333 return 0; 02334 } 02335 CATCH_ALL 02336 02337 int 02338 ppl_PIP_Problem_external_memory_in_bytes(ppl_const_PIP_Problem_t pip, 02339 size_t* sz) try { 02340 *sz = to_const(pip)->external_memory_in_bytes(); 02341 return 0; 02342 } 02343 CATCH_ALL 02344 02345 int 02346 ppl_PIP_Tree_Node_as_solution(ppl_const_PIP_Tree_Node_t spip_tree, 02347 ppl_const_PIP_Solution_Node_t* dpip_tree) try { 02348 *dpip_tree = to_const(to_const(spip_tree)->as_solution()); 02349 return 0; 02350 } 02351 CATCH_ALL 02352 02353 int 02354 ppl_PIP_Tree_Node_as_decision(ppl_const_PIP_Tree_Node_t spip_tree, 02355 ppl_const_PIP_Decision_Node_t* dpip_tree) try { 02356 *dpip_tree = to_const(to_const(spip_tree)->as_decision()); 02357 return 0; 02358 } 02359 CATCH_ALL 02360 02361 int 02362 ppl_PIP_Tree_Node_get_constraints(ppl_const_PIP_Tree_Node_t pip_tree, 02363 ppl_const_Constraint_System_t* pcs) try { 02364 const PIP_Tree_Node& spip_tree = *to_const(pip_tree); 02365 const Constraint_System& cs = spip_tree.constraints(); 02366 *pcs = to_const(&cs); 02367 return 0; 02368 } 02369 CATCH_ALL 02370 02371 int 02372 ppl_PIP_Tree_Node_OK(ppl_const_PIP_Tree_Node_t pip_tree) try { 02373 return to_const(pip_tree)->OK() ? 1 : 0; 02374 } 02375 CATCH_ALL 02376 02377 int 02378 ppl_PIP_Tree_Node_number_of_artificials(ppl_const_PIP_Tree_Node_t pip_tree, 02379 ppl_dimension_type* m) try { 02380 const PIP_Tree_Node& node = *to_const(pip_tree); 02381 *m = node.art_parameter_count(); 02382 return 0; 02383 } 02384 CATCH_ALL 02385 02386 int 02387 ppl_PIP_Tree_Node_begin 02388 (ppl_const_PIP_Tree_Node_t pip_tree, 02389 ppl_Artificial_Parameter_Sequence_const_iterator_t pit) try { 02390 PIP_Tree_Node::Artificial_Parameter_Sequence::const_iterator& spit 02391 = *to_nonconst(pit); 02392 spit = to_const(pip_tree)->art_parameter_begin(); 02393 return 0; 02394 } 02395 CATCH_ALL 02396 02397 int 02398 ppl_PIP_Tree_Node_end 02399 (ppl_const_PIP_Tree_Node_t pip_tree, 02400 ppl_Artificial_Parameter_Sequence_const_iterator_t pit) try { 02401 PIP_Tree_Node::Artificial_Parameter_Sequence::const_iterator& spit 02402 = *to_nonconst(pit); 02403 spit = to_const(pip_tree)->art_parameter_end(); 02404 return 0; 02405 } 02406 CATCH_ALL 02407 02408 int 02409 ppl_PIP_Solution_Node_get_parametric_values 02410 (ppl_const_PIP_Solution_Node_t pip_sol, 02411 ppl_dimension_type var, 02412 ppl_const_Linear_Expression_t* le) try { 02413 const PIP_Solution_Node& spip_sol = *to_const(pip_sol); 02414 const Linear_Expression& lle = spip_sol.parametric_values(Variable(var)); 02415 *le = to_const(&lle); 02416 return 0; 02417 } 02418 CATCH_ALL 02419 02420 int 02421 ppl_PIP_Solution_Node_OK(ppl_const_PIP_Solution_Node_t pip_sol) try { 02422 return to_const(pip_sol)->OK() ? 1 : 0; 02423 } 02424 CATCH_ALL 02425 02426 int 02427 ppl_PIP_Decision_Node_OK(ppl_const_PIP_Decision_Node_t pip_dec) try { 02428 return to_const(pip_dec)->OK() ? 1 : 0; 02429 } 02430 CATCH_ALL 02431 02432 int 02433 ppl_PIP_Decision_Node_get_child_node(ppl_const_PIP_Decision_Node_t pip_dec, 02434 int b, 02435 ppl_const_PIP_Tree_Node_t* pip_tree) try { 02436 *pip_tree = to_const(to_const(pip_dec)->child_node(b != 0)); 02437 return 0; 02438 } 02439 CATCH_ALL 02440 02441 int 02442 ppl_Artificial_Parameter_get_Linear_Expression 02443 (ppl_const_Artificial_Parameter_t ap, 02444 ppl_Linear_Expression_t le) try { 02445 const Artificial_Parameter& sap = *to_const(ap); 02446 Linear_Expression& lle = *to_nonconst(le); 02447 lle = sap; 02448 return 0; 02449 } 02450 CATCH_ALL 02451 02452 int 02453 ppl_Artificial_Parameter_coefficient(ppl_const_Artificial_Parameter_t ap, 02454 ppl_dimension_type var, 02455 ppl_Coefficient_t n) try { 02456 const Artificial_Parameter& sap = *to_const(ap); 02457 Coefficient& nn = *to_nonconst(n); 02458 nn = sap.coefficient(Variable(var)); 02459 return 0; 02460 } 02461 CATCH_ALL 02462 02463 int 02464 ppl_Artificial_Parameter_inhomogeneous_term 02465 (ppl_const_Artificial_Parameter_t ap, ppl_Coefficient_t n) try { 02466 const Artificial_Parameter& sap = *to_const(ap); 02467 Coefficient& nn = *to_nonconst(n); 02468 nn = sap.inhomogeneous_term(); 02469 return 0; 02470 } 02471 CATCH_ALL 02472 02473 02474 int 02475 ppl_Artificial_Parameter_denominator(ppl_const_Artificial_Parameter_t ap, 02476 ppl_Coefficient_t n) try { 02477 const Artificial_Parameter& sap = *to_const(ap); 02478 Coefficient& nn = *to_nonconst(n); 02479 nn = sap.denominator(); 02480 return 0; 02481 } 02482 CATCH_ALL 02483 02484 02485 /* Interface for Artificial_Parameter_Sequence::const_iterator. */ 02486 02487 int 02488 ppl_new_Artificial_Parameter_Sequence_const_iterator 02489 (ppl_Artificial_Parameter_Sequence_const_iterator_t* papit) try { 02490 *papit = to_nonconst(new Artificial_Parameter_Sequence::const_iterator()); 02491 return 0; 02492 } 02493 CATCH_ALL 02494 02495 int 02496 ppl_new_Artificial_Parameter_Sequence_const_iterator_from_Artificial_Parameter_Sequence_const_iterator 02497 (ppl_Artificial_Parameter_Sequence_const_iterator_t* papit, 02498 ppl_const_Artificial_Parameter_Sequence_const_iterator_t apit) try { 02499 *papit = to_nonconst(new Artificial_Parameter_Sequence::const_iterator(*to_const(apit))); 02500 return 0; 02501 } 02502 CATCH_ALL 02503 02504 int 02505 ppl_delete_Artificial_Parameter_Sequence_const_iterator 02506 (ppl_const_Artificial_Parameter_Sequence_const_iterator_t apit) 02507 try { 02508 delete to_const(apit); 02509 return 0; 02510 } 02511 CATCH_ALL 02512 02513 int 02514 ppl_assign_Artificial_Parameter_Sequence_const_iterator_from_Artificial_Parameter_Sequence_const_iterator 02515 (ppl_Artificial_Parameter_Sequence_const_iterator_t dst, 02516 ppl_const_Artificial_Parameter_Sequence_const_iterator_t src) try { 02517 const Artificial_Parameter_Sequence::const_iterator& ssrc = *to_const(src); 02518 Artificial_Parameter_Sequence::const_iterator& ddst = *to_nonconst(dst); 02519 ddst = ssrc; 02520 return 0; 02521 } 02522 CATCH_ALL 02523 02524 int 02525 ppl_Artificial_Parameter_Sequence_const_iterator_dereference 02526 (ppl_const_Artificial_Parameter_Sequence_const_iterator_t apit, 02527 ppl_const_Artificial_Parameter_t* pap) try { 02528 const Artificial_Parameter_Sequence::const_iterator& papit = *to_const(apit); 02529 const Artificial_Parameter& ap = *papit; 02530 *pap = to_const(&ap); 02531 return 0; 02532 } 02533 CATCH_ALL 02534 02535 int 02536 ppl_Artificial_Parameter_Sequence_const_iterator_increment 02537 (ppl_Artificial_Parameter_Sequence_const_iterator_t apit) try { 02538 Artificial_Parameter_Sequence::const_iterator& papit = *to_nonconst(apit); 02539 ++papit; 02540 return 0; 02541 } 02542 CATCH_ALL 02543 02544 int 02545 ppl_Artificial_Parameter_Sequence_const_iterator_equal_test 02546 (ppl_const_Artificial_Parameter_Sequence_const_iterator_t x, 02547 ppl_const_Artificial_Parameter_Sequence_const_iterator_t y) try { 02548 const Artificial_Parameter_Sequence::const_iterator& xx = *to_const(x); 02549 const Artificial_Parameter_Sequence::const_iterator& yy = *to_const(y); 02550 return (xx == yy) ? 1 : 0; 02551 } 02552 CATCH_ALL 02553 02554 int 02555 ppl_io_print_variable(ppl_dimension_type var) try { 02556 const char* b = c_variable_output_function(var); 02557 if (b == 0 || puts(b) < 0) 02558 return PPL_STDIO_ERROR; 02559 return 0; 02560 } 02561 CATCH_ALL 02562 02563 int 02564 ppl_io_fprint_variable(FILE* stream, ppl_dimension_type var) try { 02565 const char* b = c_variable_output_function(var); 02566 if (b == 0 || fputs(b, stream) < 0) 02567 return PPL_STDIO_ERROR; 02568 return 0; 02569 } 02570 CATCH_ALL 02571 02572 int 02573 ppl_io_asprint_variable(char** strp, ppl_dimension_type var) try { 02574 const char* b = c_variable_output_function(var); 02575 if (b == 0) 02576 return PPL_STDIO_ERROR; 02577 *strp = strdup(b); 02578 if (*strp == 0) 02579 return PPL_ERROR_OUT_OF_MEMORY; 02580 return 0; 02581 } 02582 CATCH_ALL 02583 02584 /* No ascii dump for Coefficient. */ 02585 DEFINE_PRINT_FUNCTIONS(Coefficient) 02586 02587 DEFINE_OUTPUT_FUNCTIONS(Linear_Expression) 02588 02589 DEFINE_OUTPUT_FUNCTIONS(Constraint) 02590 02591 DEFINE_OUTPUT_FUNCTIONS(Constraint_System) 02592 02593 DEFINE_OUTPUT_FUNCTIONS(Generator) 02594 02595 DEFINE_OUTPUT_FUNCTIONS(Generator_System) 02596 02597 DEFINE_OUTPUT_FUNCTIONS(Congruence) 02598 02599 DEFINE_OUTPUT_FUNCTIONS(Congruence_System) 02600 02601 DEFINE_OUTPUT_FUNCTIONS(Grid_Generator) 02602 02603 DEFINE_OUTPUT_FUNCTIONS(Grid_Generator_System) 02604 02605 DEFINE_OUTPUT_FUNCTIONS(MIP_Problem) 02606 02607 DEFINE_OUTPUT_FUNCTIONS(PIP_Problem) 02608 02609 DEFINE_OUTPUT_FUNCTIONS(PIP_Tree_Node) 02610 02611 DEFINE_OUTPUT_FUNCTIONS(PIP_Decision_Node) 02612 02613 DEFINE_OUTPUT_FUNCTIONS(PIP_Solution_Node) 02614 02615 DEFINE_OUTPUT_FUNCTIONS(Artificial_Parameter) 02616 02617 char* 02618 ppl_io_wrap_string(const char* src, 02619 unsigned indent_depth, 02620 unsigned preferred_first_line_length, 02621 unsigned preferred_line_length) { 02622 using namespace IO_Operators; 02623 return strdup(wrap_string(src, indent_depth, 02624 preferred_first_line_length, 02625 preferred_line_length).c_str()); 02626 } 02627 02628 int 02629 ppl_io_set_variable_output_function(ppl_io_variable_output_function_type* p) 02630 try { 02631 c_variable_output_function = p; 02632 return 0; 02633 } 02634 CATCH_ALL 02635 02636 int 02637 ppl_io_get_variable_output_function(ppl_io_variable_output_function_type** pp) 02638 try { 02639 *pp = c_variable_output_function; 02640 return 0; 02641 } 02642 CATCH_ALL