00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024 #ifndef PPL_BD_Shape_inlines_hh
00025 #define PPL_BD_Shape_inlines_hh 1
00026
00027 #include "Constraint_System.defs.hh"
00028 #include "Constraint_System.inlines.hh"
00029 #include "C_Polyhedron.defs.hh"
00030 #include "Grid.defs.hh"
00031 #include "Octagonal_Shape.defs.hh"
00032 #include "Poly_Con_Relation.defs.hh"
00033 #include "Poly_Gen_Relation.defs.hh"
00034 #include "Temp.defs.hh"
00035 #include "meta_programming.hh"
00036 #include "wrap_assign.hh"
00037 #include "assert.hh"
00038 #include <vector>
00039 #include <iostream>
00040 #include <algorithm>
00041
00042 namespace Parma_Polyhedra_Library {
00043
00044 template <typename T>
00045 inline dimension_type
00046 BD_Shape<T>::max_space_dimension() {
00047
00048
00049 return std::min(DB_Matrix<N>::max_num_rows() - 1,
00050 DB_Matrix<N>::max_num_columns() - 1);
00051 }
00052
00053 template <typename T>
00054 inline bool
00055 BD_Shape<T>::marked_zero_dim_univ() const {
00056 return status.test_zero_dim_univ();
00057 }
00058
00059 template <typename T>
00060 inline bool
00061 BD_Shape<T>::marked_empty() const {
00062 return status.test_empty();
00063 }
00064
00065 template <typename T>
00066 inline bool
00067 BD_Shape<T>::marked_shortest_path_closed() const {
00068 return status.test_shortest_path_closed();
00069 }
00070
00071 template <typename T>
00072 inline bool
00073 BD_Shape<T>::marked_shortest_path_reduced() const {
00074 return status.test_shortest_path_reduced();
00075 }
00076
00077 template <typename T>
00078 inline void
00079 BD_Shape<T>::set_zero_dim_univ() {
00080 status.set_zero_dim_univ();
00081 }
00082
00083 template <typename T>
00084 inline void
00085 BD_Shape<T>::set_empty() {
00086 status.set_empty();
00087 }
00088
00089 template <typename T>
00090 inline void
00091 BD_Shape<T>::set_shortest_path_closed() {
00092 status.set_shortest_path_closed();
00093 }
00094
00095 template <typename T>
00096 inline void
00097 BD_Shape<T>::set_shortest_path_reduced() {
00098 status.set_shortest_path_reduced();
00099 }
00100
00101 template <typename T>
00102 inline void
00103 BD_Shape<T>::reset_shortest_path_closed() {
00104 status.reset_shortest_path_closed();
00105 }
00106
00107 template <typename T>
00108 inline void
00109 BD_Shape<T>::reset_shortest_path_reduced() {
00110 status.reset_shortest_path_reduced();
00111 }
00112
00113 template <typename T>
00114 inline
00115 BD_Shape<T>::BD_Shape(const dimension_type num_dimensions,
00116 const Degenerate_Element kind)
00117 : dbm(num_dimensions + 1), status(), redundancy_dbm() {
00118 if (kind == EMPTY)
00119 set_empty();
00120 else {
00121 if (num_dimensions > 0)
00122
00123 set_shortest_path_closed();
00124 }
00125 PPL_ASSERT(OK());
00126 }
00127
00128 template <typename T>
00129 inline
00130 BD_Shape<T>::BD_Shape(const BD_Shape& y, Complexity_Class)
00131 : dbm(y.dbm), status(y.status), redundancy_dbm() {
00132 if (y.marked_shortest_path_reduced())
00133 redundancy_dbm = y.redundancy_dbm;
00134 }
00135
00136 template <typename T>
00137 template <typename U>
00138 inline
00139 BD_Shape<T>::BD_Shape(const BD_Shape<U>& y, Complexity_Class)
00140
00141
00142 : dbm((y.shortest_path_closure_assign(), y.dbm)),
00143 status(),
00144 redundancy_dbm() {
00145
00146 if (y.marked_empty())
00147 set_empty();
00148 else if (y.marked_zero_dim_univ())
00149 set_zero_dim_univ();
00150 }
00151
00152 template <typename T>
00153 inline Congruence_System
00154 BD_Shape<T>::congruences() const {
00155 return minimized_congruences();
00156 }
00157
00158 template <typename T>
00159 inline void
00160 BD_Shape<T>::add_constraints(const Constraint_System& cs) {
00161 for (Constraint_System::const_iterator i = cs.begin(),
00162 cs_end = cs.end(); i != cs_end; ++i)
00163 add_constraint(*i);
00164 }
00165
00166 template <typename T>
00167 inline void
00168 BD_Shape<T>::add_recycled_constraints(Constraint_System& cs) {
00169 add_constraints(cs);
00170 }
00171
00172 template <typename T>
00173 inline void
00174 BD_Shape<T>::add_congruences(const Congruence_System& cgs) {
00175 for (Congruence_System::const_iterator i = cgs.begin(),
00176 cgs_end = cgs.end(); i != cgs_end; ++i)
00177 add_congruence(*i);
00178 }
00179
00180 template <typename T>
00181 inline void
00182 BD_Shape<T>::add_recycled_congruences(Congruence_System& cgs) {
00183 add_congruences(cgs);
00184 }
00185
00186 template <typename T>
00187 inline void
00188 BD_Shape<T>::refine_with_constraint(const Constraint& c) {
00189 const dimension_type c_space_dim = c.space_dimension();
00190
00191 if (c_space_dim > space_dimension())
00192 throw_dimension_incompatible("refine_with_constraint(c)", c);
00193
00194 if (!marked_empty())
00195 refine_no_check(c);
00196 }
00197
00198 template <typename T>
00199 inline void
00200 BD_Shape<T>::refine_with_constraints(const Constraint_System& cs) {
00201
00202 if (cs.space_dimension() > space_dimension())
00203 throw_generic("refine_with_constraints(cs)",
00204 "cs and *this are space-dimension incompatible");
00205
00206 for (Constraint_System::const_iterator i = cs.begin(),
00207 cs_end = cs.end(); !marked_empty() && i != cs_end; ++i)
00208 refine_no_check(*i);
00209 }
00210
00211 template <typename T>
00212 inline void
00213 BD_Shape<T>::refine_with_congruence(const Congruence& cg) {
00214 const dimension_type cg_space_dim = cg.space_dimension();
00215
00216 if (cg_space_dim > space_dimension())
00217 throw_dimension_incompatible("refine_with_congruence(cg)", cg);
00218
00219 if (!marked_empty())
00220 refine_no_check(cg);
00221 }
00222
00223 template <typename T>
00224 void
00225 BD_Shape<T>::refine_with_congruences(const Congruence_System& cgs) {
00226
00227 if (cgs.space_dimension() > space_dimension())
00228 throw_generic("refine_with_congruences(cgs)",
00229 "cgs and *this are space-dimension incompatible");
00230
00231 for (Congruence_System::const_iterator i = cgs.begin(),
00232 cgs_end = cgs.end(); !marked_empty() && i != cgs_end; ++i)
00233 refine_no_check(*i);
00234 }
00235
00236 template <typename T>
00237 inline void
00238 BD_Shape<T>::refine_no_check(const Congruence& cg) {
00239 PPL_ASSERT(!marked_empty());
00240 PPL_ASSERT(cg.space_dimension() <= space_dimension());
00241
00242 if (cg.is_proper_congruence()) {
00243 if (cg.is_inconsistent())
00244 set_empty();
00245
00246 return;
00247 }
00248
00249 PPL_ASSERT(cg.is_equality());
00250 Constraint c(cg);
00251 refine_no_check(c);
00252 }
00253
00254 template <typename T>
00255 inline bool
00256 BD_Shape<T>::can_recycle_constraint_systems() {
00257 return false;
00258 }
00259
00260
00261 template <typename T>
00262 inline bool
00263 BD_Shape<T>::can_recycle_congruence_systems() {
00264 return false;
00265 }
00266
00267 template <typename T>
00268 inline
00269 BD_Shape<T>::BD_Shape(const Constraint_System& cs)
00270 : dbm(cs.space_dimension() + 1), status(), redundancy_dbm() {
00271 if (cs.space_dimension() > 0)
00272
00273 set_shortest_path_closed();
00274 add_constraints(cs);
00275 }
00276
00277 template <typename T>
00278 template <typename Interval>
00279 inline
00280 BD_Shape<T>::BD_Shape(const Box<Interval>& box,
00281 Complexity_Class)
00282 : dbm(box.space_dimension() + 1), status(), redundancy_dbm() {
00283
00284 if (box.is_empty())
00285 set_empty();
00286 else if (box.space_dimension() > 0) {
00287
00288 set_shortest_path_closed();
00289 refine_with_constraints(box.constraints());
00290 }
00291 }
00292
00293 template <typename T>
00294 inline
00295 BD_Shape<T>::BD_Shape(const Grid& grid,
00296 Complexity_Class)
00297 : dbm(grid.space_dimension() + 1), status(), redundancy_dbm() {
00298 if (grid.space_dimension() > 0)
00299
00300 set_shortest_path_closed();
00301
00302 refine_with_congruences(grid.minimized_congruences());
00303 }
00304
00305 template <typename T>
00306 template <typename U>
00307 inline
00308 BD_Shape<T>::BD_Shape(const Octagonal_Shape<U>& os,
00309 Complexity_Class)
00310 : dbm(os.space_dimension() + 1), status(), redundancy_dbm() {
00311
00312 if (os.is_empty())
00313 set_empty();
00314 else if (os.space_dimension() > 0) {
00315
00316 set_shortest_path_closed();
00317 refine_with_constraints(os.constraints());
00318
00319
00320
00321 }
00322 }
00323
00324 template <typename T>
00325 inline BD_Shape<T>&
00326 BD_Shape<T>::operator=(const BD_Shape& y) {
00327 dbm = y.dbm;
00328 status = y.status;
00329 if (y.marked_shortest_path_reduced())
00330 redundancy_dbm = y.redundancy_dbm;
00331 return *this;
00332 }
00333
00334 template <typename T>
00335 inline
00336 BD_Shape<T>::~BD_Shape() {
00337 }
00338
00339 template <typename T>
00340 inline void
00341 BD_Shape<T>::swap(BD_Shape& y) {
00342 std::swap(dbm, y.dbm);
00343 std::swap(status, y.status);
00344 std::swap(redundancy_dbm, y.redundancy_dbm);
00345 }
00346
00347 template <typename T>
00348 inline dimension_type
00349 BD_Shape<T>::space_dimension() const {
00350 return dbm.num_rows() - 1;
00351 }
00352
00353 template <typename T>
00354 inline bool
00355 BD_Shape<T>::is_empty() const {
00356 shortest_path_closure_assign();
00357 return marked_empty();
00358 }
00359
00360 template <typename T>
00361 inline bool
00362 BD_Shape<T>::bounds_from_above(const Linear_Expression& expr) const {
00363 return bounds(expr, true);
00364 }
00365
00366 template <typename T>
00367 inline bool
00368 BD_Shape<T>::bounds_from_below(const Linear_Expression& expr) const {
00369 return bounds(expr, false);
00370 }
00371
00372 template <typename T>
00373 inline bool
00374 BD_Shape<T>::maximize(const Linear_Expression& expr,
00375 Coefficient& sup_n, Coefficient& sup_d,
00376 bool& maximum) const {
00377 return max_min(expr, true, sup_n, sup_d, maximum);
00378 }
00379
00380 template <typename T>
00381 inline bool
00382 BD_Shape<T>::maximize(const Linear_Expression& expr,
00383 Coefficient& sup_n, Coefficient& sup_d, bool& maximum,
00384 Generator& g) const {
00385 return max_min(expr, true, sup_n, sup_d, maximum, g);
00386 }
00387
00388 template <typename T>
00389 inline bool
00390 BD_Shape<T>::minimize(const Linear_Expression& expr,
00391 Coefficient& inf_n, Coefficient& inf_d,
00392 bool& minimum) const {
00393 return max_min(expr, false, inf_n, inf_d, minimum);
00394 }
00395
00396 template <typename T>
00397 inline bool
00398 BD_Shape<T>::minimize(const Linear_Expression& expr,
00399 Coefficient& inf_n, Coefficient& inf_d, bool& minimum,
00400 Generator& g) const {
00401 return max_min(expr, false, inf_n, inf_d, minimum, g);
00402 }
00403
00404 template <typename T>
00405 inline bool
00406 BD_Shape<T>::is_topologically_closed() const {
00407 return true;
00408 }
00409
00410 template <typename T>
00411 inline bool
00412 BD_Shape<T>::is_discrete() const {
00413 return affine_dimension() == 0;
00414 }
00415
00416 template <typename T>
00417 inline void
00418 BD_Shape<T>::topological_closure_assign() {
00419 }
00420
00422 template <typename T>
00423 inline bool
00424 operator==(const BD_Shape<T>& x, const BD_Shape<T>& y) {
00425 const dimension_type x_space_dim = x.space_dimension();
00426
00427 if (x_space_dim != y.space_dimension())
00428 return false;
00429
00430
00431 if (x_space_dim == 0) {
00432 if (x.marked_empty())
00433 return y.marked_empty();
00434 else
00435 return !y.marked_empty();
00436 }
00437
00438
00439 x.shortest_path_closure_assign();
00440 y.shortest_path_closure_assign();
00441
00442
00443
00444 if (x.marked_empty())
00445 return y.marked_empty();
00446 if (y.marked_empty())
00447 return false;
00448
00449
00450 return x.dbm == y.dbm;
00451 }
00452
00454 template <typename T>
00455 inline bool
00456 operator!=(const BD_Shape<T>& x, const BD_Shape<T>& y) {
00457 return !(x == y);
00458 }
00459
00461 template <typename Temp, typename To, typename T>
00462 inline bool
00463 rectilinear_distance_assign(Checked_Number<To, Extended_Number_Policy>& r,
00464 const BD_Shape<T>& x,
00465 const BD_Shape<T>& y,
00466 const Rounding_Dir dir,
00467 Temp& tmp0,
00468 Temp& tmp1,
00469 Temp& tmp2) {
00470 const dimension_type x_space_dim = x.space_dimension();
00471
00472 if (x_space_dim != y.space_dimension())
00473 return false;
00474
00475
00476 if (x_space_dim == 0) {
00477 if (x.marked_empty() == y.marked_empty())
00478 assign_r(r, 0, ROUND_NOT_NEEDED);
00479 else
00480 assign_r(r, PLUS_INFINITY, ROUND_NOT_NEEDED);
00481 return true;
00482 }
00483
00484
00485 x.shortest_path_closure_assign();
00486 y.shortest_path_closure_assign();
00487
00488
00489
00490 if (x.marked_empty() || y.marked_empty()) {
00491 if (x.marked_empty() == y.marked_empty())
00492 assign_r(r, 0, ROUND_NOT_NEEDED);
00493 else
00494 assign_r(r, PLUS_INFINITY, ROUND_NOT_NEEDED);
00495 return true;
00496 }
00497
00498 return rectilinear_distance_assign(r, x.dbm, y.dbm, dir, tmp0, tmp1, tmp2);
00499 }
00500
00502 template <typename Temp, typename To, typename T>
00503 inline bool
00504 rectilinear_distance_assign(Checked_Number<To, Extended_Number_Policy>& r,
00505 const BD_Shape<T>& x,
00506 const BD_Shape<T>& y,
00507 const Rounding_Dir dir) {
00508 typedef Checked_Number<Temp, Extended_Number_Policy> Checked_Temp;
00509 PPL_DIRTY_TEMP(Checked_Temp, tmp0);
00510 PPL_DIRTY_TEMP(Checked_Temp, tmp1);
00511 PPL_DIRTY_TEMP(Checked_Temp, tmp2);
00512 return rectilinear_distance_assign(r, x, y, dir, tmp0, tmp1, tmp2);
00513 }
00514
00516 template <typename To, typename T>
00517 inline bool
00518 rectilinear_distance_assign(Checked_Number<To, Extended_Number_Policy>& r,
00519 const BD_Shape<T>& x,
00520 const BD_Shape<T>& y,
00521 const Rounding_Dir dir) {
00522 return rectilinear_distance_assign<To, To, T>(r, x, y, dir);
00523 }
00524
00526 template <typename Temp, typename To, typename T>
00527 inline bool
00528 euclidean_distance_assign(Checked_Number<To, Extended_Number_Policy>& r,
00529 const BD_Shape<T>& x,
00530 const BD_Shape<T>& y,
00531 const Rounding_Dir dir,
00532 Temp& tmp0,
00533 Temp& tmp1,
00534 Temp& tmp2) {
00535 const dimension_type x_space_dim = x.space_dimension();
00536
00537 if (x_space_dim != y.space_dimension())
00538 return false;
00539
00540
00541 if (x_space_dim == 0) {
00542 if (x.marked_empty() == y.marked_empty())
00543 assign_r(r, 0, ROUND_NOT_NEEDED);
00544 else
00545 assign_r(r, PLUS_INFINITY, ROUND_NOT_NEEDED);
00546 return true;
00547 }
00548
00549
00550 x.shortest_path_closure_assign();
00551 y.shortest_path_closure_assign();
00552
00553
00554
00555 if (x.marked_empty() || y.marked_empty()) {
00556 if (x.marked_empty() == y.marked_empty())
00557 assign_r(r, 0, ROUND_NOT_NEEDED);
00558 else
00559 assign_r(r, PLUS_INFINITY, ROUND_NOT_NEEDED);
00560 return true;
00561 }
00562
00563 return euclidean_distance_assign(r, x.dbm, y.dbm, dir, tmp0, tmp1, tmp2);
00564 }
00565
00567 template <typename Temp, typename To, typename T>
00568 inline bool
00569 euclidean_distance_assign(Checked_Number<To, Extended_Number_Policy>& r,
00570 const BD_Shape<T>& x,
00571 const BD_Shape<T>& y,
00572 const Rounding_Dir dir) {
00573 typedef Checked_Number<Temp, Extended_Number_Policy> Checked_Temp;
00574 PPL_DIRTY_TEMP(Checked_Temp, tmp0);
00575 PPL_DIRTY_TEMP(Checked_Temp, tmp1);
00576 PPL_DIRTY_TEMP(Checked_Temp, tmp2);
00577 return euclidean_distance_assign(r, x, y, dir, tmp0, tmp1, tmp2);
00578 }
00579
00581 template <typename To, typename T>
00582 inline bool
00583 euclidean_distance_assign(Checked_Number<To, Extended_Number_Policy>& r,
00584 const BD_Shape<T>& x,
00585 const BD_Shape<T>& y,
00586 const Rounding_Dir dir) {
00587 return euclidean_distance_assign<To, To, T>(r, x, y, dir);
00588 }
00589
00591 template <typename Temp, typename To, typename T>
00592 inline bool
00593 l_infinity_distance_assign(Checked_Number<To, Extended_Number_Policy>& r,
00594 const BD_Shape<T>& x,
00595 const BD_Shape<T>& y,
00596 const Rounding_Dir dir,
00597 Temp& tmp0,
00598 Temp& tmp1,
00599 Temp& tmp2) {
00600 const dimension_type x_space_dim = x.space_dimension();
00601
00602 if (x_space_dim != y.space_dimension())
00603 return false;
00604
00605
00606 if (x_space_dim == 0) {
00607 if (x.marked_empty() == y.marked_empty())
00608 assign_r(r, 0, ROUND_NOT_NEEDED);
00609 else
00610 assign_r(r, PLUS_INFINITY, ROUND_NOT_NEEDED);
00611 return true;
00612 }
00613
00614
00615 x.shortest_path_closure_assign();
00616 y.shortest_path_closure_assign();
00617
00618
00619
00620 if (x.marked_empty() || y.marked_empty()) {
00621 if (x.marked_empty() == y.marked_empty())
00622 assign_r(r, 0, ROUND_NOT_NEEDED);
00623 else
00624 assign_r(r, PLUS_INFINITY, ROUND_NOT_NEEDED);
00625 return true;
00626 }
00627
00628 return l_infinity_distance_assign(r, x.dbm, y.dbm, dir, tmp0, tmp1, tmp2);
00629 }
00630
00632 template <typename Temp, typename To, typename T>
00633 inline bool
00634 l_infinity_distance_assign(Checked_Number<To, Extended_Number_Policy>& r,
00635 const BD_Shape<T>& x,
00636 const BD_Shape<T>& y,
00637 const Rounding_Dir dir) {
00638 typedef Checked_Number<Temp, Extended_Number_Policy> Checked_Temp;
00639 PPL_DIRTY_TEMP(Checked_Temp, tmp0);
00640 PPL_DIRTY_TEMP(Checked_Temp, tmp1);
00641 PPL_DIRTY_TEMP(Checked_Temp, tmp2);
00642 return l_infinity_distance_assign(r, x, y, dir, tmp0, tmp1, tmp2);
00643 }
00644
00646 template <typename To, typename T>
00647 inline bool
00648 l_infinity_distance_assign(Checked_Number<To, Extended_Number_Policy>& r,
00649 const BD_Shape<T>& x,
00650 const BD_Shape<T>& y,
00651 const Rounding_Dir dir) {
00652 return l_infinity_distance_assign<To, To, T>(r, x, y, dir);
00653 }
00654
00655 template <typename T>
00656 inline void
00657 BD_Shape<T>::add_dbm_constraint(const dimension_type i,
00658 const dimension_type j,
00659 const N& k) {
00660
00661 PPL_ASSERT(i <= space_dimension() && j <= space_dimension() && i != j);
00662 N& dbm_ij = dbm[i][j];
00663 if (dbm_ij > k) {
00664 dbm_ij = k;
00665 if (marked_shortest_path_closed())
00666 reset_shortest_path_closed();
00667 }
00668 }
00669
00670 template <typename T>
00671 inline void
00672 BD_Shape<T>::add_dbm_constraint(const dimension_type i,
00673 const dimension_type j,
00674 Coefficient_traits::const_reference num,
00675 Coefficient_traits::const_reference den) {
00676
00677 PPL_ASSERT(i <= space_dimension() && j <= space_dimension() && i != j);
00678 PPL_ASSERT(den != 0);
00679 PPL_DIRTY_TEMP(N, k);
00680 div_round_up(k, num, den);
00681 add_dbm_constraint(i, j, k);
00682 }
00683
00684 template <typename T>
00685 inline void
00686 BD_Shape<T>::time_elapse_assign(const BD_Shape& y) {
00687
00688 if (space_dimension() != y.space_dimension())
00689 throw_dimension_incompatible("time_elapse_assign(y)", y);
00690
00691 C_Polyhedron px(constraints());
00692 C_Polyhedron py(y.constraints());
00693 px.time_elapse_assign(py);
00694 BD_Shape<T> x(px);
00695 swap(x);
00696 PPL_ASSERT(OK());
00697 }
00698
00699 template <typename T>
00700 inline bool
00701 BD_Shape<T>::strictly_contains(const BD_Shape& y) const {
00702 const BD_Shape<T>& x = *this;
00703 return x.contains(y) && !y.contains(x);
00704 }
00705
00706 template <typename T>
00707 inline bool
00708 BD_Shape<T>::upper_bound_assign_if_exact(const BD_Shape& y) {
00709 if (space_dimension() != y.space_dimension())
00710 throw_dimension_incompatible("upper_bound_assign_if_exact(y)", y);
00711 #if 0
00712 return BFT00_upper_bound_assign_if_exact(y);
00713 #else
00714 const bool integer_upper_bound = false;
00715 return BHZ09_upper_bound_assign_if_exact<integer_upper_bound>(y);
00716 #endif
00717 }
00718
00719 template <typename T>
00720 inline bool
00721 BD_Shape<T>::integer_upper_bound_assign_if_exact(const BD_Shape& y) {
00722 PPL_COMPILE_TIME_CHECK(std::numeric_limits<T>::is_integer,
00723 "BD_Shape<T>::integer_upper_bound_assign_if_exact(y):"
00724 " T in not an integer datatype.");
00725 if (space_dimension() != y.space_dimension())
00726 throw_dimension_incompatible("integer_upper_bound_assign_if_exact(y)", y);
00727 const bool integer_upper_bound = true;
00728 return BHZ09_upper_bound_assign_if_exact<integer_upper_bound>(y);
00729 }
00730
00731 template <typename T>
00732 inline void
00733 BD_Shape<T>::remove_higher_space_dimensions(const dimension_type new_dim) {
00734
00735
00736 if (new_dim > space_dimension())
00737 throw_dimension_incompatible("remove_higher_space_dimensions(nd)",
00738 new_dim);
00739
00740
00741
00742
00743 if (new_dim == space_dimension()) {
00744 PPL_ASSERT(OK());
00745 return;
00746 }
00747
00748
00749 shortest_path_closure_assign();
00750 dbm.resize_no_copy(new_dim + 1);
00751
00752
00753
00754 if (marked_shortest_path_reduced())
00755 reset_shortest_path_reduced();
00756
00757
00758
00759 if (new_dim == 0 && !marked_empty())
00760 set_zero_dim_univ();
00761 PPL_ASSERT(OK());
00762 }
00763
00764 template <typename T>
00765 void
00766 BD_Shape<T>::wrap_assign(const Variables_Set& vars,
00767 Bounded_Integer_Type_Width w,
00768 Bounded_Integer_Type_Representation r,
00769 Bounded_Integer_Type_Overflow o,
00770 const Constraint_System* pcs,
00771 unsigned complexity_threshold,
00772 bool wrap_individually) {
00773 Implementation::wrap_assign(*this,
00774 vars, w, r, o, pcs,
00775 complexity_threshold, wrap_individually,
00776 "BD_Shape");
00777 }
00778
00779 template <typename T>
00780 inline void
00781 BD_Shape<T>::CC76_extrapolation_assign(const BD_Shape& y, unsigned* tp) {
00782 static N stop_points[] = {
00783 N(-2, ROUND_UP),
00784 N(-1, ROUND_UP),
00785 N( 0, ROUND_UP),
00786 N( 1, ROUND_UP),
00787 N( 2, ROUND_UP)
00788 };
00789 CC76_extrapolation_assign(y,
00790 stop_points,
00791 stop_points
00792 + sizeof(stop_points)/sizeof(stop_points[0]),
00793 tp);
00794 }
00795
00796 template <typename T>
00797 inline void
00798 BD_Shape<T>::H79_widening_assign(const BD_Shape& y, unsigned* tp) {
00799
00800 C_Polyhedron px(constraints());
00801 C_Polyhedron py(y.constraints());
00802 px.H79_widening_assign(py, tp);
00803 BD_Shape x(px);
00804 swap(x);
00805 PPL_ASSERT(OK());
00806 }
00807
00808 template <typename T>
00809 inline void
00810 BD_Shape<T>::widening_assign(const BD_Shape& y, unsigned* tp) {
00811 H79_widening_assign(y, tp);
00812 }
00813
00814 template <typename T>
00815 inline void
00816 BD_Shape<T>::limited_H79_extrapolation_assign(const BD_Shape& y,
00817 const Constraint_System& cs,
00818 unsigned* tp) {
00819
00820 C_Polyhedron px(constraints());
00821 C_Polyhedron py(y.constraints());
00822 px.limited_H79_extrapolation_assign(py, cs, tp);
00823 BD_Shape x(px);
00824 swap(x);
00825 PPL_ASSERT(OK());
00826 }
00827
00828 template <typename T>
00829 inline memory_size_type
00830 BD_Shape<T>::total_memory_in_bytes() const {
00831 return sizeof(*this) + external_memory_in_bytes();
00832 }
00833
00834 template <typename T>
00835 inline int32_t
00836 BD_Shape<T>::hash_code() const {
00837 return space_dimension() & 0x7fffffff;
00838 }
00839
00840 template <typename T>
00841 inline void
00842 BD_Shape<T>::drop_some_non_integer_points_helper(N& elem) {
00843 if (!is_integer(elem)) {
00844 Result r = floor_assign_r(elem, elem, ROUND_DOWN);
00845 used(r);
00846 PPL_ASSERT(r == V_EQ);
00847 reset_shortest_path_closed();
00848 }
00849 }
00850
00851 }
00852
00853 namespace std {
00854
00856 template <typename T>
00857 inline void
00858 swap(Parma_Polyhedra_Library::BD_Shape<T>& x,
00859 Parma_Polyhedra_Library::BD_Shape<T>& y) {
00860 x.swap(y);
00861 }
00862
00863 }
00864
00865 #endif // !defined(PPL_BD_Shape_inlines_hh)