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_Partially_Reduced_Product_inlines_hh
00025 #define PPL_Partially_Reduced_Product_inlines_hh 1
00026
00027 #include "Constraint_System.defs.hh"
00028 #include "Congruence_System.defs.hh"
00029 #include "C_Polyhedron.defs.hh"
00030 #include "NNC_Polyhedron.defs.hh"
00031 #include "Grid.defs.hh"
00032
00033 namespace Parma_Polyhedra_Library {
00034
00035 template <typename D1, typename D2, typename R>
00036 inline dimension_type
00037 Partially_Reduced_Product<D1, D2, R>::max_space_dimension() {
00038 return (D1::max_space_dimension() < D2::max_space_dimension())
00039 ? D1::max_space_dimension()
00040 : D2::max_space_dimension();
00041 }
00042
00043 template <typename D1, typename D2, typename R>
00044 inline
00045 Partially_Reduced_Product<D1, D2, R>
00046 ::Partially_Reduced_Product(dimension_type num_dimensions,
00047 const Degenerate_Element kind)
00048 : d1(num_dimensions, kind),
00049 d2(num_dimensions, kind) {
00050 set_reduced_flag();
00051 }
00052
00053 template <typename D1, typename D2, typename R>
00054 inline
00055 Partially_Reduced_Product<D1, D2, R>
00056 ::Partially_Reduced_Product(const Congruence_System& ccgs)
00057 : d1(ccgs), d2(ccgs) {
00058 clear_reduced_flag();
00059 }
00060
00061 template <typename D1, typename D2, typename R>
00062 inline
00063 Partially_Reduced_Product<D1, D2, R>
00064 ::Partially_Reduced_Product(Congruence_System& cgs)
00065 : d1(const_cast<const Congruence_System&>(cgs)), d2(cgs) {
00066 clear_reduced_flag();
00067 }
00068
00069 template <typename D1, typename D2, typename R>
00070 inline
00071 Partially_Reduced_Product<D1, D2, R>
00072 ::Partially_Reduced_Product(const Constraint_System& ccs)
00073 : d1(ccs), d2(ccs) {
00074 clear_reduced_flag();
00075 }
00076
00077 template <typename D1, typename D2, typename R>
00078 inline
00079 Partially_Reduced_Product<D1, D2, R>
00080 ::Partially_Reduced_Product(Constraint_System& cs)
00081 : d1(const_cast<const Constraint_System&>(cs)), d2(cs) {
00082 clear_reduced_flag();
00083 }
00084
00085 template <typename D1, typename D2, typename R>
00086 inline
00087 Partially_Reduced_Product<D1, D2, R>
00088 ::Partially_Reduced_Product(const C_Polyhedron& ph,
00089 Complexity_Class complexity)
00090 : d1(ph, complexity), d2(ph, complexity) {
00091 set_reduced_flag();
00092 }
00093
00094 template <typename D1, typename D2, typename R>
00095 inline
00096 Partially_Reduced_Product<D1, D2, R>
00097 ::Partially_Reduced_Product(const NNC_Polyhedron& ph,
00098 Complexity_Class complexity)
00099 : d1(ph, complexity), d2(ph, complexity) {
00100 set_reduced_flag();
00101 }
00102
00103 template <typename D1, typename D2, typename R>
00104 inline
00105 Partially_Reduced_Product<D1, D2, R>
00106 ::Partially_Reduced_Product(const Grid& gr, Complexity_Class)
00107 : d1(gr), d2(gr) {
00108 set_reduced_flag();
00109 }
00110
00111 template <typename D1, typename D2, typename R>
00112 template <typename Interval>
00113 inline
00114 Partially_Reduced_Product<D1, D2, R>
00115 ::Partially_Reduced_Product(const Box<Interval>& box, Complexity_Class)
00116 : d1(box), d2(box) {
00117 set_reduced_flag();
00118 }
00119
00120 template <typename D1, typename D2, typename R>
00121 template <typename U>
00122 inline
00123 Partially_Reduced_Product<D1, D2, R>
00124 ::Partially_Reduced_Product(const BD_Shape<U>& bd, Complexity_Class)
00125 : d1(bd), d2(bd) {
00126 set_reduced_flag();
00127 }
00128
00129 template <typename D1, typename D2, typename R>
00130 template <typename U>
00131 inline
00132 Partially_Reduced_Product<D1, D2, R>
00133 ::Partially_Reduced_Product(const Octagonal_Shape<U>& os, Complexity_Class)
00134 : d1(os), d2(os) {
00135 set_reduced_flag();
00136 }
00137
00138 template <typename D1, typename D2, typename R>
00139 inline
00140 Partially_Reduced_Product<D1, D2, R>
00141 ::Partially_Reduced_Product(const Partially_Reduced_Product& y,
00142 Complexity_Class)
00143 : d1(y.d1), d2(y.d2) {
00144 reduced = y.reduced;
00145 }
00146
00147 template <typename D1, typename D2, typename R>
00148 template <typename E1, typename E2, typename S>
00149 inline
00150 Partially_Reduced_Product<D1, D2, R>
00151 ::Partially_Reduced_Product(const Partially_Reduced_Product<E1, E2, S>& y,
00152 Complexity_Class complexity)
00153 : d1(y.space_dimension()), d2(y.space_dimension()) {
00154 Partially_Reduced_Product<D1, D2, R> pg1(y.domain1(), complexity);
00155 Partially_Reduced_Product<D1, D2, R> pg2(y.domain2(), complexity);
00156 pg1.intersection_assign(pg2);
00157 swap(pg1);
00158
00159
00160 clear_reduced_flag();
00161 }
00162
00163 template <typename D1, typename D2, typename R>
00164 inline
00165 Partially_Reduced_Product<D1, D2, R>::~Partially_Reduced_Product() {
00166 }
00167
00168 template <typename D1, typename D2, typename R>
00169 inline memory_size_type
00170 Partially_Reduced_Product<D1, D2, R>::external_memory_in_bytes() const {
00171 return d1.external_memory_in_bytes() + d2.external_memory_in_bytes();
00172 }
00173
00174 template <typename D1, typename D2, typename R>
00175 inline memory_size_type
00176 Partially_Reduced_Product<D1, D2, R>::total_memory_in_bytes() const {
00177 return sizeof(*this) + external_memory_in_bytes();
00178 }
00179
00180 template <typename D1, typename D2, typename R>
00181 inline dimension_type
00182 Partially_Reduced_Product<D1, D2, R>::space_dimension() const {
00183 PPL_ASSERT(d1.space_dimension() == d2.space_dimension());
00184 return d1.space_dimension();
00185 }
00186
00187 template <typename D1, typename D2, typename R>
00188 inline dimension_type
00189 Partially_Reduced_Product<D1, D2, R>::affine_dimension() const {
00190 reduce();
00191 const dimension_type d1_dim = d1.affine_dimension();
00192 const dimension_type d2_dim = d2.affine_dimension();
00193 return std::min(d1_dim, d2_dim);
00194 }
00195
00196 template <typename D1, typename D2, typename R>
00197 inline void
00198 Partially_Reduced_Product<D1, D2, R>
00199 ::unconstrain(const Variable var) {
00200 reduce();
00201 d1.unconstrain(var);
00202 d2.unconstrain(var);
00203 }
00204
00205 template <typename D1, typename D2, typename R>
00206 inline void
00207 Partially_Reduced_Product<D1, D2, R>::unconstrain(const Variables_Set& vars) {
00208 reduce();
00209 d1.unconstrain(vars);
00210 d2.unconstrain(vars);
00211 }
00212
00213 template <typename D1, typename D2, typename R>
00214 inline void
00215 Partially_Reduced_Product<D1, D2, R>
00216 ::intersection_assign(const Partially_Reduced_Product& y) {
00217 d1.intersection_assign(y.d1);
00218 d2.intersection_assign(y.d2);
00219 clear_reduced_flag();
00220 }
00221
00222 template <typename D1, typename D2, typename R>
00223 inline void
00224 Partially_Reduced_Product<D1, D2, R>
00225 ::difference_assign(const Partially_Reduced_Product& y) {
00226 reduce();
00227 y.reduce();
00228 d1.difference_assign(y.d1);
00229 d2.difference_assign(y.d2);
00230 clear_reduced_flag();
00231 }
00232
00233 template <typename D1, typename D2, typename R>
00234 inline void
00235 Partially_Reduced_Product<D1, D2, R>
00236 ::upper_bound_assign(const Partially_Reduced_Product& y) {
00237 reduce();
00238 y.reduce();
00239 d1.upper_bound_assign(y.d1);
00240 d2.upper_bound_assign(y.d2);
00241 }
00242
00243 template <typename D1, typename D2, typename R>
00244 inline bool
00245 Partially_Reduced_Product<D1, D2, R>
00246 ::upper_bound_assign_if_exact(const Partially_Reduced_Product& y) {
00247 reduce();
00248 y.reduce();
00249 D1 d1_copy = d1;
00250 bool ub_exact = d1_copy.upper_bound_assign_if_exact(y.d1);
00251 if (!ub_exact)
00252 return false;
00253 ub_exact = d2.upper_bound_assign_if_exact(y.d2);
00254 if (!ub_exact)
00255 return false;
00256 std::swap(d1,d1_copy);
00257 return true;
00258 }
00259
00260 template <typename D1, typename D2, typename R>
00261 inline void
00262 Partially_Reduced_Product<D1, D2, R>
00263 ::affine_image(Variable var,
00264 const Linear_Expression& expr,
00265 Coefficient_traits::const_reference denominator) {
00266 d1.affine_image(var, expr, denominator);
00267 d2.affine_image(var, expr, denominator);
00268 clear_reduced_flag();
00269 }
00270
00271 template <typename D1, typename D2, typename R>
00272 inline void
00273 Partially_Reduced_Product<D1, D2, R>
00274 ::affine_preimage(Variable var,
00275 const Linear_Expression& expr,
00276 Coefficient_traits::const_reference denominator) {
00277 d1.affine_preimage(var, expr, denominator);
00278 d2.affine_preimage(var, expr, denominator);
00279 clear_reduced_flag();
00280 }
00281
00282 template <typename D1, typename D2, typename R>
00283 inline void
00284 Partially_Reduced_Product<D1, D2, R>
00285 ::generalized_affine_image(Variable var,
00286 const Relation_Symbol relsym,
00287 const Linear_Expression& expr,
00288 Coefficient_traits::const_reference denominator) {
00289 d1.generalized_affine_image(var, relsym, expr, denominator);
00290 d2.generalized_affine_image(var, relsym, expr, denominator);
00291 clear_reduced_flag();
00292 }
00293
00294 template <typename D1, typename D2, typename R>
00295 inline void
00296 Partially_Reduced_Product<D1, D2, R>
00297 ::generalized_affine_preimage(Variable var,
00298 const Relation_Symbol relsym,
00299 const Linear_Expression& expr,
00300 Coefficient_traits::const_reference denominator) {
00301 d1.generalized_affine_preimage(var, relsym, expr, denominator);
00302 d2.generalized_affine_preimage(var, relsym, expr, denominator);
00303 clear_reduced_flag();
00304 }
00305
00306 template <typename D1, typename D2, typename R>
00307 inline void
00308 Partially_Reduced_Product<D1, D2, R>
00309 ::generalized_affine_image(const Linear_Expression& lhs,
00310 const Relation_Symbol relsym,
00311 const Linear_Expression& rhs) {
00312 d1.generalized_affine_image(lhs, relsym, rhs);
00313 d2.generalized_affine_image(lhs, relsym, rhs);
00314 clear_reduced_flag();
00315 }
00316
00317 template <typename D1, typename D2, typename R>
00318 inline void
00319 Partially_Reduced_Product<D1, D2, R>
00320 ::generalized_affine_preimage(const Linear_Expression& lhs,
00321 const Relation_Symbol relsym,
00322 const Linear_Expression& rhs) {
00323 d1.generalized_affine_preimage(lhs, relsym, rhs);
00324 d2.generalized_affine_preimage(lhs, relsym, rhs);
00325 clear_reduced_flag();
00326 }
00327
00328
00329 template <typename D1, typename D2, typename R>
00330 inline void
00331 Partially_Reduced_Product<D1, D2, R>
00332 ::bounded_affine_image(Variable var,
00333 const Linear_Expression& lb_expr,
00334 const Linear_Expression& ub_expr,
00335 Coefficient_traits::const_reference denominator) {
00336 d1.bounded_affine_image(var, lb_expr, ub_expr, denominator);
00337 d2.bounded_affine_image(var, lb_expr, ub_expr, denominator);
00338 clear_reduced_flag();
00339 }
00340
00341 template <typename D1, typename D2, typename R>
00342 inline void
00343 Partially_Reduced_Product<D1, D2, R>
00344 ::bounded_affine_preimage(Variable var,
00345 const Linear_Expression& lb_expr,
00346 const Linear_Expression& ub_expr,
00347 Coefficient_traits::const_reference denominator) {
00348 d1.bounded_affine_preimage(var, lb_expr, ub_expr, denominator);
00349 d2.bounded_affine_preimage(var, lb_expr, ub_expr, denominator);
00350 clear_reduced_flag();
00351 }
00352
00353 template <typename D1, typename D2, typename R>
00354 inline void
00355 Partially_Reduced_Product<D1, D2, R>
00356 ::time_elapse_assign(const Partially_Reduced_Product& y) {
00357 reduce();
00358 y.reduce();
00359 d1.time_elapse_assign(y.d1);
00360 d2.time_elapse_assign(y.d2);
00361 PPL_ASSERT_HEAVY(OK());
00362 }
00363
00364 template <typename D1, typename D2, typename R>
00365 inline void
00366 Partially_Reduced_Product<D1, D2, R>::topological_closure_assign() {
00367 d1.topological_closure_assign();
00368 d2.topological_closure_assign();
00369 }
00370
00371 template <typename D1, typename D2, typename R>
00372 inline void
00373 Partially_Reduced_Product<D1, D2, R>::swap(Partially_Reduced_Product& y) {
00374 std::swap(d1, y.d1);
00375 std::swap(d2, y.d2);
00376 std::swap(reduced, y.reduced);
00377 }
00378
00379 template <typename D1, typename D2, typename R>
00380 inline void
00381 Partially_Reduced_Product<D1, D2, R>::add_constraint(const Constraint& c) {
00382 d1.add_constraint(c);
00383 d2.add_constraint(c);
00384 clear_reduced_flag();
00385 }
00386
00387 template <typename D1, typename D2, typename R>
00388 inline void
00389 Partially_Reduced_Product<D1, D2, R>::refine_with_constraint(const Constraint& c) {
00390 d1.refine_with_constraint(c);
00391 d2.refine_with_constraint(c);
00392 clear_reduced_flag();
00393 }
00394
00395 template <typename D1, typename D2, typename R>
00396 inline void
00397 Partially_Reduced_Product<D1, D2, R>::add_congruence(const Congruence& cg) {
00398 d1.add_congruence(cg);
00399 d2.add_congruence(cg);
00400 clear_reduced_flag();
00401 }
00402
00403 template <typename D1, typename D2, typename R>
00404 inline void
00405 Partially_Reduced_Product<D1, D2, R>::refine_with_congruence(const Congruence& cg) {
00406 d1.refine_with_congruence(cg);
00407 d2.refine_with_congruence(cg);
00408 clear_reduced_flag();
00409 }
00410
00411 template <typename D1, typename D2, typename R>
00412 inline void
00413 Partially_Reduced_Product<D1, D2, R>
00414 ::add_constraints(const Constraint_System& cs) {
00415 d1.add_constraints(cs);
00416 d2.add_constraints(cs);
00417 clear_reduced_flag();
00418 }
00419
00420 template <typename D1, typename D2, typename R>
00421 inline void
00422 Partially_Reduced_Product<D1, D2, R>
00423 ::refine_with_constraints(const Constraint_System& cs) {
00424 d1.refine_with_constraints(cs);
00425 d2.refine_with_constraints(cs);
00426 clear_reduced_flag();
00427 }
00428
00429 template <typename D1, typename D2, typename R>
00430 inline void
00431 Partially_Reduced_Product<D1, D2, R>
00432 ::add_congruences(const Congruence_System& cgs) {
00433 d1.add_congruences(cgs);
00434 d2.add_congruences(cgs);
00435 clear_reduced_flag();
00436 }
00437
00438 template <typename D1, typename D2, typename R>
00439 inline void
00440 Partially_Reduced_Product<D1, D2, R>
00441 ::refine_with_congruences(const Congruence_System& cgs) {
00442 d1.refine_with_congruences(cgs);
00443 d2.refine_with_congruences(cgs);
00444 clear_reduced_flag();
00445 }
00446
00447 template <typename D1, typename D2, typename R>
00448 inline void
00449 Partially_Reduced_Product<D1, D2, R>
00450 ::drop_some_non_integer_points(Complexity_Class complexity) {
00451 reduce();
00452 d1.drop_some_non_integer_points(complexity);
00453 d2.drop_some_non_integer_points(complexity);
00454 clear_reduced_flag();
00455 }
00456
00457 template <typename D1, typename D2, typename R>
00458 inline void
00459 Partially_Reduced_Product<D1, D2, R>
00460 ::drop_some_non_integer_points(const Variables_Set& vars,
00461 Complexity_Class complexity) {
00462 reduce();
00463 d1.drop_some_non_integer_points(vars, complexity);
00464 d2.drop_some_non_integer_points(vars, complexity);
00465 clear_reduced_flag();
00466 }
00467
00468 template <typename D1, typename D2, typename R>
00469 inline Partially_Reduced_Product<D1, D2, R>&
00470 Partially_Reduced_Product<D1, D2, R>
00471 ::operator=(const Partially_Reduced_Product& y) {
00472 d1 = y.d1;
00473 d2 = y.d2;
00474 reduced = y.reduced;
00475 return *this;
00476 }
00477
00478 template <typename D1, typename D2, typename R>
00479 inline const D1&
00480 Partially_Reduced_Product<D1, D2, R>::domain1() const {
00481 reduce();
00482 return d1;
00483 }
00484
00485 template <typename D1, typename D2, typename R>
00486 inline const D2&
00487 Partially_Reduced_Product<D1, D2, R>::domain2() const {
00488 reduce();
00489 return d2;
00490 }
00491
00492 template <typename D1, typename D2, typename R>
00493 inline bool
00494 Partially_Reduced_Product<D1, D2, R>::is_empty() const {
00495 reduce();
00496 return d1.is_empty() || d2.is_empty();
00497 }
00498
00499 template <typename D1, typename D2, typename R>
00500 inline bool
00501 Partially_Reduced_Product<D1, D2, R>::is_universe() const {
00502 return d1.is_universe() && d2.is_universe();
00503 }
00504
00505 template <typename D1, typename D2, typename R>
00506 inline bool
00507 Partially_Reduced_Product<D1, D2, R>::is_topologically_closed() const {
00508 reduce();
00509 return d1.is_topologically_closed() && d2.is_topologically_closed();
00510 }
00511
00512 template <typename D1, typename D2, typename R>
00513 inline bool
00514 Partially_Reduced_Product<D1, D2, R>
00515 ::is_disjoint_from(const Partially_Reduced_Product& y) const {
00516 reduce();
00517 y.reduce();
00518 return d1.is_disjoint_from(y.d1) || d2.is_disjoint_from(y.d2);
00519 }
00520
00521 template <typename D1, typename D2, typename R>
00522 inline bool
00523 Partially_Reduced_Product<D1, D2, R>::is_discrete() const {
00524 reduce();
00525 return d1.is_discrete() || d2.is_discrete();
00526 }
00527
00528 template <typename D1, typename D2, typename R>
00529 inline bool
00530 Partially_Reduced_Product<D1, D2, R>::is_bounded() const {
00531 reduce();
00532 return d1.is_bounded() || d2.is_bounded();
00533 }
00534
00535 template <typename D1, typename D2, typename R>
00536 inline bool
00537 Partially_Reduced_Product<D1, D2, R>
00538 ::bounds_from_above(const Linear_Expression& expr) const {
00539 reduce();
00540 return d1.bounds_from_above(expr) || d2.bounds_from_above(expr);
00541 }
00542
00543 template <typename D1, typename D2, typename R>
00544 inline bool
00545 Partially_Reduced_Product<D1, D2, R>
00546 ::bounds_from_below(const Linear_Expression& expr) const {
00547 reduce();
00548 return d1.bounds_from_below(expr) || d2.bounds_from_below(expr);
00549 }
00550
00551 template <typename D1, typename D2, typename R>
00552 inline bool
00553 Partially_Reduced_Product<D1, D2, R>::constrains(Variable var) const {
00554 reduce();
00555 return d1.constrains(var) || d2.constrains(var);
00556 }
00557
00558 template <typename D1, typename D2, typename R>
00559 inline void
00560 Partially_Reduced_Product<D1, D2, R>
00561 ::widening_assign(const Partially_Reduced_Product& y,
00562 unsigned* tp) {
00563
00564
00565
00566
00567
00568 reduce();
00569 y.reduce();
00570 d1.widening_assign(y.d1, tp);
00571 d2.widening_assign(y.d2, tp);
00572 }
00573
00574 template <typename D1, typename D2, typename R>
00575 inline void
00576 Partially_Reduced_Product<D1, D2, R>
00577 ::add_space_dimensions_and_embed(dimension_type m) {
00578 d1.add_space_dimensions_and_embed(m);
00579 d2.add_space_dimensions_and_embed(m);
00580 }
00581
00582 template <typename D1, typename D2, typename R>
00583 inline void
00584 Partially_Reduced_Product<D1, D2, R>
00585 ::add_space_dimensions_and_project(dimension_type m) {
00586 d1.add_space_dimensions_and_project(m);
00587 d2.add_space_dimensions_and_project(m);
00588 }
00589
00590 template <typename D1, typename D2, typename R>
00591 inline void
00592 Partially_Reduced_Product<D1, D2, R>
00593 ::concatenate_assign(const Partially_Reduced_Product& y) {
00594 d1.concatenate_assign(y.d1);
00595 d2.concatenate_assign(y.d2);
00596 if (!is_reduced() || !y.is_reduced())
00597 clear_reduced_flag();
00598 }
00599
00600 template <typename D1, typename D2, typename R>
00601 inline void
00602 Partially_Reduced_Product<D1, D2, R>
00603 ::remove_space_dimensions(const Variables_Set& vars) {
00604 d1.remove_space_dimensions(vars);
00605 d2.remove_space_dimensions(vars);
00606 }
00607
00608 template <typename D1, typename D2, typename R>
00609 inline void
00610 Partially_Reduced_Product<D1, D2, R>
00611 ::remove_higher_space_dimensions(dimension_type new_dimension) {
00612 d1.remove_higher_space_dimensions(new_dimension);
00613 d2.remove_higher_space_dimensions(new_dimension);
00614 }
00615
00616 template <typename D1, typename D2, typename R>
00617 template <typename Partial_Function>
00618 inline void
00619 Partially_Reduced_Product<D1, D2, R>
00620 ::map_space_dimensions(const Partial_Function& pfunc) {
00621 d1.map_space_dimensions(pfunc);
00622 d2.map_space_dimensions(pfunc);
00623 }
00624
00625 template <typename D1, typename D2, typename R>
00626 inline void
00627 Partially_Reduced_Product<D1, D2, R>
00628 ::expand_space_dimension(Variable var, dimension_type m) {
00629 d1.expand_space_dimension(var, m);
00630 d2.expand_space_dimension(var, m);
00631 }
00632
00633 template <typename D1, typename D2, typename R>
00634 inline void
00635 Partially_Reduced_Product<D1, D2, R>
00636 ::fold_space_dimensions(const Variables_Set& vars,
00637 Variable dest) {
00638 d1.fold_space_dimensions(vars, dest);
00639 d2.fold_space_dimensions(vars, dest);
00640 }
00641
00642 template <typename D1, typename D2, typename R>
00643 inline bool
00644 Partially_Reduced_Product<D1, D2, R>
00645 ::contains(const Partially_Reduced_Product& y) const {
00646 reduce();
00647 y.reduce();
00648 return d1.contains(y.d1) && d2.contains(y.d2);
00649 }
00650
00651 template <typename D1, typename D2, typename R>
00652 inline bool
00653 Partially_Reduced_Product<D1, D2, R>
00654 ::strictly_contains(const Partially_Reduced_Product& y) const {
00655 reduce();
00656 y.reduce();
00657 return (d1.contains(y.d1) && d2.strictly_contains(y.d2))
00658 || (d2.contains(y.d2) && d1.strictly_contains(y.d1));
00659 }
00660
00661 template <typename D1, typename D2, typename R>
00662 inline bool
00663 Partially_Reduced_Product<D1, D2, R>::reduce() const {
00664 Partially_Reduced_Product& dp
00665 = const_cast<Partially_Reduced_Product&>(*this);
00666 if (dp.is_reduced())
00667 return false;
00668 R r;
00669 r.product_reduce(dp.d1, dp.d2);
00670 set_reduced_flag();
00671 return true;
00672 }
00673
00674 template <typename D1, typename D2, typename R>
00675 inline bool
00676 Partially_Reduced_Product<D1, D2, R>::is_reduced() const {
00677 return reduced;
00678 }
00679
00680 template <typename D1, typename D2, typename R>
00681 inline void
00682 Partially_Reduced_Product<D1, D2, R>::clear_reduced_flag() const {
00683 const_cast<Partially_Reduced_Product&>(*this).reduced = false;
00684 }
00685
00686 template <typename D1, typename D2, typename R>
00687 inline void
00688 Partially_Reduced_Product<D1, D2, R>::set_reduced_flag() const {
00689 const_cast<Partially_Reduced_Product&>(*this).reduced = true;
00690 }
00691
00692 PPL_OUTPUT_3_PARAM_TEMPLATE_DEFINITIONS(D1, D2, R, Partially_Reduced_Product)
00693
00694 template <typename D1, typename D2, typename R>
00695 inline void
00696 Partially_Reduced_Product<D1, D2, R>::ascii_dump(std::ostream& s) const {
00697 const char yes = '+';
00698 const char no = '-';
00699 s << "Partially_Reduced_Product\n";
00700 s << (reduced ? yes : no) << "reduced\n";
00701 s << "Domain 1:\n";
00702 d1.ascii_dump(s);
00703 s << "Domain 2:\n";
00704 d2.ascii_dump(s);
00705 }
00706
00707 template <typename D1, typename D2, typename R>
00708 inline int32_t
00709 Partially_Reduced_Product<D1, D2, R>::hash_code() const {
00710 return space_dimension() & 0x7fffffff;
00711 }
00712
00714 template <typename D1, typename D2, typename R>
00715 inline bool
00716 operator==(const Partially_Reduced_Product<D1, D2, R>& x,
00717 const Partially_Reduced_Product<D1, D2, R>& y) {
00718 x.reduce();
00719 y.reduce();
00720 return x.d1 == y.d1 && x.d2 == y.d2;
00721 }
00722
00724 template <typename D1, typename D2, typename R>
00725 inline bool
00726 operator!=(const Partially_Reduced_Product<D1, D2, R>& x,
00727 const Partially_Reduced_Product<D1, D2, R>& y) {
00728 return !(x == y);
00729 }
00730
00732 template <typename D1, typename D2, typename R>
00733 inline std::ostream&
00734 IO_Operators::operator<<(std::ostream& s, const Partially_Reduced_Product<D1, D2, R>& pd) {
00735 return s << "Domain 1:\n"
00736 << pd.d1
00737 << "Domain 2:\n"
00738 << pd.d2;
00739 }
00740
00741 }
00742
00743 namespace Parma_Polyhedra_Library {
00744
00745 template <typename D1, typename D2>
00746 inline
00747 No_Reduction<D1, D2>::No_Reduction() {
00748 }
00749
00750 template <typename D1, typename D2>
00751 void No_Reduction<D1, D2>::product_reduce(D1&, D2&) {
00752 }
00753
00754 template <typename D1, typename D2>
00755 inline
00756 No_Reduction<D1, D2>::~No_Reduction() {
00757 }
00758
00759 template <typename D1, typename D2>
00760 inline
00761 Smash_Reduction<D1, D2>::Smash_Reduction() {
00762 }
00763
00764 template <typename D1, typename D2>
00765 inline
00766 Smash_Reduction<D1, D2>::~Smash_Reduction() {
00767 }
00768
00769 template <typename D1, typename D2>
00770 inline
00771 Constraints_Reduction<D1, D2>::Constraints_Reduction() {
00772 }
00773
00774 template <typename D1, typename D2>
00775 inline
00776 Constraints_Reduction<D1, D2>::~Constraints_Reduction() {
00777 }
00778
00779 template <typename D1, typename D2>
00780 inline
00781 Congruences_Reduction<D1, D2>::Congruences_Reduction() {
00782 }
00783
00784 template <typename D1, typename D2>
00785 inline
00786 Congruences_Reduction<D1, D2>::~Congruences_Reduction() {
00787 }
00788
00789 template <typename D1, typename D2>
00790 inline
00791 Shape_Preserving_Reduction<D1, D2>::Shape_Preserving_Reduction() {
00792 }
00793
00794 template <typename D1, typename D2>
00795 inline
00796 Shape_Preserving_Reduction<D1, D2>::~Shape_Preserving_Reduction() {
00797 }
00798
00799 }
00800
00802 template <typename D1, typename D2, typename R>
00803 inline void
00804 std::swap(Parma_Polyhedra_Library::Partially_Reduced_Product<D1, D2, R>& x,
00805 Parma_Polyhedra_Library::Partially_Reduced_Product<D1, D2, R>& y) {
00806 x.swap(y);
00807 }
00808
00809 #endif // !defined(PPL_Partially_Reduced_Product_inlines_hh)