00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025 #include <ppl-config.h>
00026
00027 #include "Grid.defs.hh"
00028 #include "Grid_Generator.defs.hh"
00029 #include "Scalar_Products.defs.hh"
00030 #include "assert.hh"
00031 #include <string>
00032 #include <iostream>
00033 #include <sstream>
00034 #include <stdexcept>
00035
00036 #ifdef PPL_DOXYGEN_INCLUDE_IMPLEMENTATION_DETAILS
00037
00046 #endif // defined(PPL_DOXYGEN_INCLUDE_IMPLEMENTATION_DETAILS)
00047 #define BE_LAZY 1
00048
00049 namespace PPL = Parma_Polyhedra_Library;
00050
00051 void
00052 PPL::Grid::construct(dimension_type num_dimensions,
00053 const Degenerate_Element kind) {
00054 space_dim = num_dimensions;
00055
00056 if (kind == EMPTY) {
00057
00058
00059
00060 status.set_empty();
00061
00062
00063
00064 Congruence_System cgs(Congruence::zero_dim_false());
00065 cgs.increase_space_dimension(space_dim);
00066 const_cast<Congruence_System&>(con_sys).swap(cgs);
00067
00068 PPL_ASSERT(OK());
00069 return;
00070 }
00071
00072 if (num_dimensions > 0) {
00073 con_sys.increase_space_dimension(num_dimensions);
00074
00075
00076
00077 set_congruences_minimized();
00078 set_generators_minimized();
00079 dim_kinds.resize(num_dimensions + 1);
00080
00081
00082
00083 Congruence_System cgs(Congruence::zero_dim_integrality());
00084 cgs.increase_space_dimension(space_dim);
00085 cgs[0][0] = 1;
00086 con_sys.swap(cgs);
00087
00088 dim_kinds[0] = PROPER_CONGRUENCE ;
00089
00090
00091 gen_sys.insert(grid_point(0*(Variable(0))));
00092
00093
00094 dimension_type dim = 0;
00095 while (dim < num_dimensions) {
00096 gen_sys.insert(grid_line(Variable(dim)));
00097 dim_kinds[++dim] = CON_VIRTUAL ;
00098 }
00099 }
00100 else
00101 set_zero_dim_univ();
00102 }
00103
00104 void
00105 PPL::Grid::construct(Congruence_System& cgs) {
00106
00107 PPL_ASSERT(cgs.space_dimension() <= max_space_dimension());
00108
00109 PPL_ASSERT(cgs.space_dimension() == con_sys.space_dimension());
00110 PPL_ASSERT(cgs.space_dimension() == gen_sys.space_dimension());
00111 PPL_ASSERT(con_sys.has_no_rows());
00112 PPL_ASSERT(gen_sys.has_no_rows());
00113
00114
00115 space_dim = cgs.space_dimension();
00116
00117 if (space_dim > 0) {
00118
00119 std::swap(con_sys, cgs);
00120 con_sys.normalize_moduli();
00121 set_congruences_up_to_date();
00122 }
00123 else {
00124
00125 if (cgs.num_columns() > 1)
00126
00127 for (dimension_type i = cgs.num_rows(); i-- > 0; )
00128 if (cgs[i].is_inconsistent()) {
00129
00130 status.set_empty();
00131
00132
00133 con_sys.insert(Congruence::zero_dim_false());
00134 PPL_ASSERT(OK());
00135 return;
00136 }
00137 set_zero_dim_univ();
00138 }
00139 PPL_ASSERT(OK());
00140 }
00141
00142 void
00143 PPL::Grid::construct(Grid_Generator_System& ggs) {
00144
00145 PPL_ASSERT(ggs.space_dimension() <= max_space_dimension());
00146
00147 PPL_ASSERT(ggs.space_dimension() == con_sys.space_dimension());
00148 PPL_ASSERT(ggs.space_dimension() == gen_sys.space_dimension());
00149 PPL_ASSERT(con_sys.has_no_rows());
00150 PPL_ASSERT(gen_sys.has_no_rows());
00151
00152
00153 space_dim = ggs.space_dimension();
00154
00155
00156 if (ggs.has_no_rows()) {
00157 status.set_empty();
00158
00159
00160 con_sys.insert(Congruence::zero_dim_false());
00161 return;
00162 }
00163
00164
00165 if (!ggs.has_points())
00166 throw_invalid_generators("Grid(ggs)", "ggs");
00167
00168 if (space_dim == 0)
00169 set_zero_dim_univ();
00170 else {
00171
00172 std::swap(gen_sys, ggs);
00173 normalize_divisors(gen_sys);
00174
00175 set_generators_up_to_date();
00176 }
00177
00178 PPL_ASSERT(OK());
00179 }
00180
00181 PPL::Grid::Three_Valued_Boolean
00182 PPL::Grid::quick_equivalence_test(const Grid& y) const {
00183
00184 PPL_ASSERT(space_dim == y.space_dim);
00185 PPL_ASSERT(!marked_empty() && !y.marked_empty() && space_dim > 0);
00186
00187 const Grid& x = *this;
00188
00189 bool css_normalized = false;
00190
00191 if (x.congruences_are_minimized() && y.congruences_are_minimized()) {
00192
00193
00194 if (x.con_sys.num_rows() != y.con_sys.num_rows())
00195 return Grid::TVB_FALSE;
00196
00197 dimension_type x_num_equalities = x.con_sys.num_equalities();
00198 if (x_num_equalities != y.con_sys.num_equalities())
00199 return Grid::TVB_FALSE;
00200
00201
00202 css_normalized = (x_num_equalities == 0);
00203 }
00204
00205 if (x.generators_are_minimized() && y.generators_are_minimized()) {
00206
00207
00208 if (x.gen_sys.num_rows() != y.gen_sys.num_rows())
00209 return Grid::TVB_FALSE;
00210
00211 const dimension_type x_num_lines = x.gen_sys.num_lines();
00212 if (x_num_lines != y.gen_sys.num_lines())
00213 return Grid::TVB_FALSE;
00214
00215 if (x_num_lines == 0) {
00216
00217 if (x.gen_sys == y.gen_sys)
00218 return Grid::TVB_TRUE;
00219 else
00220 return Grid::TVB_FALSE;
00221 }
00222 }
00223
00224
00225
00226
00227 if (css_normalized) {
00228 if (x.con_sys == y.con_sys)
00229 return Grid::TVB_TRUE;
00230 else
00231 return Grid::TVB_FALSE;
00232 }
00233
00234 return Grid::TVB_DONT_KNOW;
00235 }
00236
00237 bool
00238 PPL::Grid::is_included_in(const Grid& y) const {
00239
00240 PPL_ASSERT(space_dim == y.space_dim);
00241 PPL_ASSERT(!marked_empty() && !y.marked_empty() && space_dim > 0);
00242
00243 const Grid& x = *this;
00244
00245 #if BE_LAZY
00246 if (!x.generators_are_up_to_date() && !x.update_generators())
00247
00248 return true;
00249 if (!y.congruences_are_up_to_date())
00250 y.update_congruences();
00251 #else
00252 if (!x.generators_are_minimized() && !x.minimize())
00253
00254 return true;
00255 if (!y.congruences_are_minimized())
00256 y.minimize();
00257 #endif
00258
00259 PPL_ASSERT(x.OK());
00260 PPL_ASSERT(y.OK());
00261
00262 const Grid_Generator_System& gs = x.gen_sys;
00263 const Congruence_System& cgs = y.con_sys;
00264
00265 dimension_type num_rows = gs.num_rows();
00266 for (dimension_type i = num_rows; i-- > 0; )
00267 if (!cgs.satisfies_all_congruences(gs[i]))
00268 return false;
00269
00270
00271 return true;
00272 }
00273
00274 bool
00275 PPL::Grid::bounds(const Linear_Expression& expr,
00276 const char* method_call) const {
00277
00278 if (space_dim < expr.space_dimension())
00279 throw_dimension_incompatible(method_call, "e", expr);
00280
00281
00282 if (space_dim == 0
00283 || marked_empty()
00284 || (!generators_are_up_to_date() && !update_generators()))
00285 return true;
00286 if (!generators_are_minimized() && !minimize())
00287
00288 return true;
00289
00290 return bounds_no_check(expr);
00291 }
00292
00293 bool
00294 PPL::Grid::bounds_no_check(const Linear_Expression& expr) const {
00295
00296 PPL_ASSERT(space_dim > 0 && space_dim >= expr.space_dimension());
00297 PPL_ASSERT(generators_are_minimized() && !marked_empty());
00298
00299
00300 for (dimension_type i = gen_sys.num_rows(); i-- > 0; ) {
00301 const Grid_Generator& g = gen_sys[i];
00302
00303
00304 if (g.is_line_or_parameter()) {
00305 const int sp_sign = Scalar_Products::homogeneous_sign(expr, g);
00306 if (sp_sign != 0)
00307
00308 return false;
00309 }
00310 }
00311 return true;
00312 }
00313
00314 bool
00315 PPL::Grid::frequency_no_check(const Linear_Expression& expr,
00316 Coefficient& freq_n, Coefficient& freq_d,
00317 Coefficient& val_n, Coefficient& val_d) const {
00318
00319
00320 PPL_ASSERT(space_dim >= expr.space_dimension());
00321 PPL_ASSERT(generators_are_minimized() && !marked_empty());
00322
00323
00324
00325
00326
00327 if (bounds_no_check(expr)) {
00328 freq_n = 0;
00329 freq_d = 1;
00330
00331 const Grid_Generator& point = gen_sys[0];
00332 val_d = point.divisor();
00333 Scalar_Products::homogeneous_assign(val_n, expr, point);
00334 val_n += expr.inhomogeneous_term() * val_d;
00335
00336 PPL_DIRTY_TEMP_COEFFICIENT(gcd);
00337 gcd_assign(gcd, val_n, val_d);
00338 exact_div_assign(val_n, val_n, gcd);
00339 exact_div_assign(val_d, val_d, gcd);
00340 return true;
00341 }
00342
00343
00344
00345 dimension_type num_rows = gen_sys.num_rows();
00346 PPL_DIRTY_TEMP_COEFFICIENT(sp);
00347 freq_n = 0;
00348
00349
00350
00351 for (dimension_type row = 1; row < num_rows; ++row) {
00352 const Grid_Generator& gen = gen_sys[row];
00353 Scalar_Products::homogeneous_assign(sp, expr, gen);
00354 if (gen.is_line()) {
00355 if (sgn(sp) != 0)
00356 return false;
00357 continue;
00358 }
00359
00360 PPL_ASSERT(gen.is_parameter());
00361 if (sgn(sp) != 0)
00362 gcd_assign(freq_n, freq_n, sp);
00363 }
00364 const Grid_Generator& point = gen_sys[0];
00365 PPL_ASSERT(point.is_point());
00366
00367
00368
00369 freq_d = point.divisor();
00370 val_d = freq_d;
00371
00372
00373 Scalar_Products::homogeneous_assign(val_n, expr, point);
00374 val_n += expr.inhomogeneous_term() * val_d;
00375
00376
00377 val_n %= freq_n;
00378
00379 PPL_DIRTY_TEMP_COEFFICIENT(gcd);
00380
00381 gcd_assign(gcd, freq_n, freq_d);
00382 exact_div_assign(freq_n, freq_n, gcd);
00383 exact_div_assign(freq_d, freq_d, gcd);
00384
00385
00386 gcd_assign(gcd, val_n, val_d);
00387 exact_div_assign(val_n, val_n, gcd);
00388 exact_div_assign(val_d, val_d, gcd);
00389
00390 return true;
00391 }
00392
00393 bool
00394 PPL::Grid::max_min(const Linear_Expression& expr,
00395 const char* method_call,
00396 Coefficient& ext_n, Coefficient& ext_d, bool& included,
00397 Generator* point) const {
00398 if (bounds(expr, method_call)) {
00399 if (marked_empty())
00400 return false;
00401 if (space_dim == 0) {
00402 ext_n = 0;
00403 ext_d = 1;
00404 included = true;
00405 if (point)
00406 *point = Generator::point();
00407 return true;
00408 }
00409
00410 if (!generators_are_minimized()) {
00411
00412 Grid& gr = const_cast<Grid&>(*this);
00413 gr.simplify(gr.gen_sys, gr.dim_kinds);
00414 gr.set_generators_minimized();
00415 }
00416
00417 const Grid_Generator& gen = gen_sys[0];
00418 Scalar_Products::homogeneous_assign(ext_n, expr, gen);
00419 ext_n += expr.inhomogeneous_term();
00420 ext_d = gen.divisor();
00421
00422 PPL_DIRTY_TEMP_COEFFICIENT(gcd);
00423 gcd_assign(gcd, ext_n, ext_d);
00424 exact_div_assign(ext_n, ext_n, gcd);
00425 exact_div_assign(ext_d, ext_d, gcd);
00426
00427 included = true;
00428 if (point) {
00429 Linear_Expression e;
00430 for (dimension_type i = space_dim; i-- > 0; )
00431 e += gen.coefficient(Variable(i)) * Variable(i);
00432 *point = Generator::point(e, gen.divisor());
00433 }
00434 return true;
00435 }
00436 return false;
00437 }
00438
00439 void
00440 PPL::Grid::set_zero_dim_univ() {
00441 status.set_zero_dim_univ();
00442 space_dim = 0;
00443 con_sys.clear();
00444 gen_sys.clear();
00445 gen_sys.insert(grid_point());
00446 }
00447
00448 void
00449 PPL::Grid::set_empty() {
00450 status.set_empty();
00451
00452
00453 Grid_Generator_System gs(space_dim);
00454 gen_sys.swap(gs);
00455
00456
00457
00458 Congruence_System cgs(Congruence::zero_dim_false());
00459 cgs.increase_space_dimension(space_dim);
00460 const_cast<Congruence_System&>(con_sys).swap(cgs);
00461 }
00462
00463 void
00464 PPL::Grid::update_congruences() const {
00465
00466 PPL_ASSERT(space_dim > 0);
00467 PPL_ASSERT(!marked_empty());
00468 PPL_ASSERT(!gen_sys.has_no_rows());
00469 PPL_ASSERT(gen_sys.space_dimension() > 0);
00470
00471 Grid& gr = const_cast<Grid&>(*this);
00472
00473 if (!generators_are_minimized())
00474 gr.simplify(gr.gen_sys, gr.dim_kinds);
00475
00476
00477
00478 PPL_ASSERT(!gen_sys.has_no_rows());
00479
00480
00481
00482 gr.conversion(gr.gen_sys, gr.con_sys, gr.dim_kinds);
00483
00484
00485 gr.set_congruences_minimized();
00486 gr.set_generators_minimized();
00487 }
00488
00489 bool
00490 PPL::Grid::update_generators() const {
00491 PPL_ASSERT(space_dim > 0);
00492 PPL_ASSERT(!marked_empty());
00493 PPL_ASSERT(congruences_are_up_to_date());
00494
00495 Grid& x = const_cast<Grid&>(*this);
00496
00497 if (!congruences_are_minimized())
00498
00499
00500 if (simplify(x.con_sys, x.dim_kinds)) {
00501 x.set_empty();
00502 return false;
00503 }
00504
00505
00506
00507 conversion(x.con_sys, x.gen_sys, x.dim_kinds);
00508
00509
00510 x.set_congruences_minimized();
00511 x.set_generators_minimized();
00512 return true;
00513 }
00514
00515 bool
00516 PPL::Grid::minimize() const {
00517
00518 if (marked_empty())
00519 return false;
00520 if (space_dim == 0)
00521 return true;
00522
00523
00524 if (congruences_are_minimized() && generators_are_minimized())
00525 return true;
00526
00527
00528
00529 if (congruences_are_up_to_date()) {
00530 if (generators_are_up_to_date()) {
00531 Grid& gr = const_cast<Grid&>(*this);
00532
00533 if (congruences_are_minimized()) {
00534
00535 gr.simplify(gr.gen_sys, gr.dim_kinds);
00536 gr.set_generators_minimized();
00537 }
00538 else {
00539 #ifndef NDEBUG
00540
00541
00542 bool empty = simplify(gr.con_sys, gr.dim_kinds);
00543 PPL_ASSERT(!empty);
00544 #else
00545 simplify(gr.con_sys, gr.dim_kinds);
00546 #endif
00547 gr.set_congruences_minimized();
00548 if (!generators_are_minimized()) {
00549
00550 gr.simplify(gr.gen_sys, gr.dim_kinds);
00551 gr.set_generators_minimized();
00552 }
00553 }
00554 }
00555 else {
00556
00557 const bool ret = update_generators();
00558 PPL_ASSERT(OK());
00559 return ret;
00560 }
00561 }
00562 else {
00563 PPL_ASSERT(generators_are_up_to_date());
00564 update_congruences();
00565 }
00566 PPL_ASSERT(OK());
00567 return true;
00568 }
00569
00570 void
00571 PPL::Grid::normalize_divisors(Grid_Generator_System& sys,
00572 Grid_Generator_System& gen_sys) {
00573 #ifndef NDEBUG
00574 const dimension_type num_rows = gen_sys.num_rows();
00575 #endif
00576 PPL_ASSERT(num_rows > 0);
00577
00578
00579 dimension_type row = 0;
00580 while (gen_sys[row].is_line_or_parameter()) {
00581 ++row;
00582
00583 PPL_ASSERT(row < num_rows);
00584 }
00585 Grid_Generator& first_point = gen_sys[row];
00586 const Coefficient& gen_sys_divisor = first_point.divisor();
00587
00588 #ifndef NDEBUG
00589
00590 for (dimension_type i = row + 1; i < num_rows; ++i) {
00591 Grid_Generator& g = gen_sys[i];
00592 if (g.is_parameter_or_point())
00593 PPL_ASSERT(gen_sys_divisor == g.divisor());
00594 }
00595 #endif // !defined(NDEBUG)
00596
00597 PPL_DIRTY_TEMP_COEFFICIENT(divisor);
00598 divisor = gen_sys_divisor;
00599
00600 normalize_divisors(sys, divisor);
00601 if (divisor != gen_sys_divisor)
00602
00603
00604
00605
00606
00607 normalize_divisors(gen_sys, divisor, &first_point);
00608 }
00609
00610 void
00611 PPL::Grid::normalize_divisors(Grid_Generator_System& sys,
00612 Coefficient& divisor,
00613 const Grid_Generator* first_point) {
00614 PPL_ASSERT(divisor >= 0);
00615 if (sys.space_dimension() > 0 && divisor > 0) {
00616 dimension_type row = 0;
00617 dimension_type num_rows = sys.num_rows();
00618
00619 if (first_point)
00620 lcm_assign(divisor, divisor, (*first_point).divisor());
00621 else {
00622 PPL_ASSERT(num_rows > 0);
00623
00624 while (sys[row].is_line())
00625 if (++row == num_rows)
00626
00627 return;
00628
00629
00630
00631 while (row < num_rows) {
00632 const Grid_Generator& g = sys[row];
00633 if (g.is_parameter_or_point())
00634 lcm_assign(divisor, divisor, g.divisor());
00635 ++row;
00636 }
00637 }
00638
00639
00640
00641 for (row = num_rows; row-- > 0; )
00642 sys[row].scale_to_divisor(divisor);
00643 }
00644 }
00645
00646 void
00647 PPL::Grid::add_congruence_no_check(const Congruence& cg) {
00648 PPL_ASSERT(!marked_empty());
00649 PPL_ASSERT(space_dim >= cg.space_dimension());
00650
00651
00652 if (space_dim == 0) {
00653 if (cg.is_inconsistent())
00654 set_empty();
00655 return;
00656 }
00657
00658 if (!congruences_are_up_to_date())
00659 update_congruences();
00660
00661 con_sys.insert(cg);
00662
00663 clear_congruences_minimized();
00664 set_congruences_up_to_date();
00665 clear_generators_up_to_date();
00666
00667
00668
00669 PPL_ASSERT(OK());
00670 }
00671
00672 void
00673 PPL::Grid::add_constraint_no_check(const Constraint& c) {
00674 PPL_ASSERT(!marked_empty());
00675 PPL_ASSERT(space_dim >= c.space_dimension());
00676
00677 if (c.is_inequality()) {
00678
00679 if (c.is_inconsistent()) {
00680 set_empty();
00681 return;
00682 }
00683 if (c.is_tautological())
00684 return;
00685
00686 throw_invalid_constraint("add_constraint(c)", "c");
00687 }
00688
00689 PPL_ASSERT(c.is_equality());
00690 Congruence cg(c);
00691 add_congruence_no_check(cg);
00692 }
00693
00694 void
00695 PPL::Grid::refine_no_check(const Constraint& c) {
00696 PPL_ASSERT(!marked_empty());
00697 PPL_ASSERT(space_dim >= c.space_dimension());
00698
00699 if (c.is_equality()) {
00700 Congruence cg(c);
00701 add_congruence_no_check(cg);
00702 }
00703 else if (c.is_inconsistent())
00704 set_empty();
00705 }
00706
00707 void
00708 PPL::Grid::throw_runtime_error(const char* method) const {
00709 std::ostringstream s;
00710 s << "PPL::Grid::" << method << "." << std::endl;
00711 throw std::runtime_error(s.str());
00712 }
00713
00714 void
00715 PPL::Grid::throw_invalid_argument(const char* method,
00716 const char* reason) const {
00717 std::ostringstream s;
00718 s << "PPL::Grid::" << method << ":" << std::endl
00719 << reason << ".";
00720 throw std::invalid_argument(s.str());
00721 }
00722
00723 void
00724 PPL::Grid::throw_dimension_incompatible(const char* method,
00725 const char* other_name,
00726 dimension_type other_dim) const {
00727 std::ostringstream s;
00728 s << "PPL::Grid::" << method << ":\n"
00729 << "this->space_dimension() == " << space_dimension() << ", "
00730 << other_name << ".space_dimension() == " << other_dim << ".";
00731 throw std::invalid_argument(s.str());
00732 }
00733
00734 void
00735 PPL::Grid::throw_dimension_incompatible(const char* method,
00736 const char* gr_name,
00737 const Grid& gr) const {
00738 throw_dimension_incompatible(method, gr_name, gr.space_dimension());
00739 }
00740
00741 void
00742 PPL::Grid::throw_dimension_incompatible(const char* method,
00743 const char* e_name,
00744 const Linear_Expression& e) const {
00745 throw_dimension_incompatible(method, e_name, e.space_dimension());
00746 }
00747
00748 void
00749 PPL::Grid::throw_dimension_incompatible(const char* method,
00750 const char* cg_name,
00751 const Congruence& cg) const {
00752 throw_dimension_incompatible(method, cg_name, cg.space_dimension());
00753 }
00754
00755 void
00756 PPL::Grid::throw_dimension_incompatible(const char* method,
00757 const char* c_name,
00758 const Constraint& c) const {
00759 throw_dimension_incompatible(method, c_name, c.space_dimension());
00760 }
00761
00762 void
00763 PPL::Grid::throw_dimension_incompatible(const char* method,
00764 const char* g_name,
00765 const Grid_Generator& g) const {
00766 throw_dimension_incompatible(method, g_name, g.space_dimension());
00767 }
00768
00769 void
00770 PPL::Grid::throw_dimension_incompatible(const char* method,
00771 const char* g_name,
00772 const Generator& g) const {
00773 throw_dimension_incompatible(method, g_name, g.space_dimension());
00774 }
00775
00776 void
00777 PPL::Grid::throw_dimension_incompatible(const char* method,
00778 const char* cgs_name,
00779 const Congruence_System& cgs) const {
00780 throw_dimension_incompatible(method, cgs_name, cgs.space_dimension());
00781 }
00782
00783 void
00784 PPL::Grid::throw_dimension_incompatible(const char* method,
00785 const char* cs_name,
00786 const Constraint_System& cs) const {
00787 throw_dimension_incompatible(method, cs_name, cs.space_dimension());
00788 }
00789
00790 void
00791 PPL::Grid::throw_dimension_incompatible(const char* method,
00792 const char* gs_name,
00793 const Grid_Generator_System& gs) const {
00794 throw_dimension_incompatible(method, gs_name, gs.space_dimension());
00795 }
00796
00797 void
00798 PPL::Grid::throw_dimension_incompatible(const char* method,
00799 const char* var_name,
00800 const Variable var) const {
00801 std::ostringstream s;
00802 s << "PPL::Grid::" << method << ":" << std::endl
00803 << "this->space_dimension() == " << space_dimension() << ", "
00804 << var_name << ".space_dimension() == " << var.space_dimension() << ".";
00805 throw std::invalid_argument(s.str());
00806 }
00807
00808 void
00809 PPL::Grid::
00810 throw_dimension_incompatible(const char* method,
00811 dimension_type required_space_dim) const {
00812 std::ostringstream s;
00813 s << "PPL::Grid::" << method << ":" << std::endl
00814 << "this->space_dimension() == " << space_dimension()
00815 << ", required space dimension == " << required_space_dim << ".";
00816 throw std::invalid_argument(s.str());
00817 }
00818
00819 void
00820 PPL::Grid::throw_space_dimension_overflow(const char* method,
00821 const char* reason) {
00822 std::ostringstream s;
00823 s << "PPL::Grid::" << method << ":" << std::endl
00824 << reason << ".";
00825 throw std::length_error(s.str());
00826 }
00827
00828 void
00829 PPL::Grid::throw_invalid_constraint(const char* method,
00830 const char* c_name) const {
00831 std::ostringstream s;
00832 s << "PPL::Grid::" << method << ":" << std::endl
00833 << c_name << " is not an equality constraint.";
00834 throw std::invalid_argument(s.str());
00835 }
00836
00837 void
00838 PPL::Grid::throw_invalid_constraints(const char* method,
00839 const char* cs_name) const {
00840 std::ostringstream s;
00841 s << "PPL::Grid::" << method << ":" << std::endl
00842 << "the constraint system " << cs_name
00843 << " contains inequalities.";
00844 throw std::invalid_argument(s.str());
00845 }
00846
00847 void
00848 PPL::Grid::throw_invalid_generator(const char* method,
00849 const char* g_name) const {
00850 std::ostringstream s;
00851 s << "PPL::Grid::" << method << ":" << std::endl
00852 << "*this is an empty grid and "
00853 << g_name << " is not a point.";
00854 throw std::invalid_argument(s.str());
00855 }
00856
00857 void
00858 PPL::Grid::throw_invalid_generators(const char* method,
00859 const char* gs_name) const {
00860 std::ostringstream s;
00861 s << "PPL::Grid::" << method << ":" << std::endl
00862 << "*this is an empty grid and" << std::endl
00863 << "the non-empty generator system " << gs_name << " contains no points.";
00864 throw std::invalid_argument(s.str());
00865 }