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_defs_hh
00025 #define PPL_Partially_Reduced_Product_defs_hh 1
00026
00027 #include "Partially_Reduced_Product.types.hh"
00028 #include "globals.types.hh"
00029 #include "Coefficient.defs.hh"
00030 #include "Variable.types.hh"
00031 #include "Variables_Set.types.hh"
00032 #include "Linear_Expression.types.hh"
00033 #include "Constraint.types.hh"
00034 #include "Generator.types.hh"
00035 #include "Congruence.types.hh"
00036 #include "Grid_Generator.types.hh"
00037 #include "Constraint_System.types.hh"
00038 #include "Generator_System.types.hh"
00039 #include "Congruence_System.types.hh"
00040 #include "Grid_Generator_System.types.hh"
00041 #include "Poly_Con_Relation.defs.hh"
00042 #include "Poly_Gen_Relation.defs.hh"
00043 #include "C_Polyhedron.types.hh"
00044 #include "NNC_Polyhedron.types.hh"
00045 #include "Grid.types.hh"
00046 #include "Box.types.hh"
00047 #include "BD_Shape.types.hh"
00048 #include "Octagonal_Shape.types.hh"
00049
00050 namespace Parma_Polyhedra_Library {
00051
00052 namespace IO_Operators {
00053
00055
00059 template <typename D1, typename D2, typename R>
00060 std::ostream&
00061 operator<<(std::ostream& s, const Partially_Reduced_Product<D1, D2, R>& dp);
00062
00063 }
00064
00073 template <typename D1, typename D2, typename R>
00074 bool operator==(const Partially_Reduced_Product<D1, D2, R>& x,
00075 const Partially_Reduced_Product<D1, D2, R>& y);
00076
00085 template <typename D1, typename D2, typename R>
00086 bool operator!=(const Partially_Reduced_Product<D1, D2, R>& x,
00087 const Partially_Reduced_Product<D1, D2, R>& y);
00088
00089 }
00090
00091
00100 template <typename D1, typename D2>
00101 class Parma_Polyhedra_Library::Smash_Reduction {
00102 public:
00104 Smash_Reduction();
00105
00119 void product_reduce(D1& d1, D2& d2);
00120
00122 ~Smash_Reduction();
00123 };
00124
00134 template <typename D1, typename D2>
00135 class Parma_Polyhedra_Library::Constraints_Reduction {
00136 public:
00138 Constraints_Reduction();
00139
00162 void product_reduce(D1& d1, D2& d2);
00163
00165 ~Constraints_Reduction();
00166 };
00167
00192 template <typename D1, typename D2>
00193 class Parma_Polyhedra_Library::Congruences_Reduction {
00194 public:
00196 Congruences_Reduction();
00197
00219 void product_reduce(D1& d1, D2& d2);
00220
00222 ~Congruences_Reduction();
00223 };
00224
00242 template <typename D1, typename D2>
00243 class Parma_Polyhedra_Library::Shape_Preserving_Reduction {
00244 public:
00246 Shape_Preserving_Reduction();
00247
00269 void product_reduce(D1& d1, D2& d2);
00270
00272 ~Shape_Preserving_Reduction();
00273 };
00274
00282 template <typename D1, typename D2>
00283 class Parma_Polyhedra_Library::No_Reduction {
00284 public:
00286 No_Reduction();
00287
00293 void product_reduce(D1& d1, D2& d2);
00294
00296 ~No_Reduction();
00297 };
00298
00300
00411 template <typename D1, typename D2, typename R>
00412 class Parma_Polyhedra_Library::Partially_Reduced_Product {
00413 public:
00418 static dimension_type max_space_dimension();
00419
00421
00432 explicit Partially_Reduced_Product(dimension_type num_dimensions = 0,
00433 Degenerate_Element kind = UNIVERSE);
00434
00436
00446 explicit Partially_Reduced_Product(const Congruence_System& cgs);
00447
00449
00460 explicit Partially_Reduced_Product(Congruence_System& cgs);
00461
00463
00473 explicit Partially_Reduced_Product(const Constraint_System& cs);
00474
00476
00486 explicit Partially_Reduced_Product(Constraint_System& cs);
00487
00489
00506 explicit
00507 Partially_Reduced_Product(const C_Polyhedron& ph,
00508 Complexity_Class complexity = ANY_COMPLEXITY);
00509
00511
00528 explicit
00529 Partially_Reduced_Product(const NNC_Polyhedron& ph,
00530 Complexity_Class complexity = ANY_COMPLEXITY);
00531
00533
00547 explicit
00548 Partially_Reduced_Product(const Grid& gr,
00549 Complexity_Class complexity = ANY_COMPLEXITY);
00550
00552
00566 template <typename Interval>
00567 Partially_Reduced_Product(const Box<Interval>& box,
00568 Complexity_Class complexity = ANY_COMPLEXITY);
00569
00571
00585 template <typename U>
00586 Partially_Reduced_Product(const BD_Shape<U>& bd,
00587 Complexity_Class complexity = ANY_COMPLEXITY);
00588
00590
00604 template <typename U>
00605 Partially_Reduced_Product(const Octagonal_Shape<U>& os,
00606 Complexity_Class complexity = ANY_COMPLEXITY);
00607
00609 Partially_Reduced_Product(const Partially_Reduced_Product& y,
00610 Complexity_Class complexity = ANY_COMPLEXITY);
00611
00613
00616 template <typename E1, typename E2, typename S>
00617 explicit
00618 Partially_Reduced_Product(const Partially_Reduced_Product<E1, E2, S>& y,
00619 Complexity_Class complexity = ANY_COMPLEXITY);
00620
00625 Partially_Reduced_Product& operator=(const Partially_Reduced_Product& y);
00626
00628
00629
00631 dimension_type space_dimension() const;
00632
00639 dimension_type affine_dimension() const;
00640
00642 const D1& domain1() const;
00643
00645 const D2& domain2() const;
00646
00648 Constraint_System constraints() const;
00649
00654 Constraint_System minimized_constraints() const;
00655
00657 Congruence_System congruences() const;
00658
00663 Congruence_System minimized_congruences() const;
00664
00666
00667
00668
00669
00670
00671
00672
00673
00674
00675
00676
00677
00678
00679
00680
00681
00682
00683
00684
00685 Poly_Con_Relation relation_with(const Constraint& c) const;
00686
00688
00689
00690
00691
00692 Poly_Con_Relation relation_with(const Congruence& cg) const;
00693
00695
00696
00697
00698
00699
00700
00701
00702
00703
00704
00705
00706 Poly_Gen_Relation relation_with(const Generator& g) const;
00707
00712 bool is_empty() const;
00713
00718 bool is_universe() const;
00719
00724 bool is_topologically_closed() const;
00725
00733 bool is_disjoint_from(const Partially_Reduced_Product& y) const;
00734
00739 bool is_discrete() const;
00740
00745 bool is_bounded() const;
00746
00754 bool constrains(Variable var) const;
00755
00757
00763 bool bounds_from_above(const Linear_Expression& expr) const;
00764
00766
00772 bool bounds_from_below(const Linear_Expression& expr) const;
00773
00798 bool maximize(const Linear_Expression& expr,
00799 Coefficient& sup_n, Coefficient& sup_d, bool& maximum) const;
00800
00829 bool maximize(const Linear_Expression& expr,
00830 Coefficient& sup_n, Coefficient& sup_d, bool& maximum,
00831 Generator& point) const;
00832
00857 bool minimize(const Linear_Expression& expr,
00858 Coefficient& inf_n, Coefficient& inf_d, bool& minimum) const;
00859
00888 bool minimize(const Linear_Expression& expr,
00889 Coefficient& inf_n, Coefficient& inf_d, bool& minimum,
00890 Generator& point) const;
00891
00899 bool contains(const Partially_Reduced_Product& y) const;
00900
00908 bool strictly_contains(const Partially_Reduced_Product& y) const;
00909
00911 bool OK() const;
00912
00914
00916
00917
00919
00923 void add_constraint(const Constraint& c);
00924
00934 void refine_with_constraint(const Constraint& c);
00935
00937
00942 void add_congruence(const Congruence& cg);
00943
00953 void refine_with_congruence(const Congruence& cg);
00954
00956
00963 void add_congruences(const Congruence_System& cgs);
00964
00974 void refine_with_congruences(const Congruence_System& cgs);
00975
00977
00988 void add_recycled_congruences(Congruence_System& cgs);
00989
00991
00998 void add_constraints(const Constraint_System& cs);
00999
01009 void refine_with_constraints(const Constraint_System& cs);
01010
01012
01023 void add_recycled_constraints(Constraint_System& cs);
01024
01035 void unconstrain(Variable var);
01036
01049 void unconstrain(const Variables_Set& vars);
01050
01057 void intersection_assign(const Partially_Reduced_Product& y);
01058
01066 void upper_bound_assign(const Partially_Reduced_Product& y);
01067
01077 bool upper_bound_assign_if_exact(const Partially_Reduced_Product& y);
01078
01086 void difference_assign(const Partially_Reduced_Product& y);
01087
01110 void affine_image(Variable var,
01111 const Linear_Expression& expr,
01112 Coefficient_traits::const_reference denominator
01113 = Coefficient_one());
01114
01135 void affine_preimage(Variable var,
01136 const Linear_Expression& expr,
01137 Coefficient_traits::const_reference denominator
01138 = Coefficient_one());
01139
01167 void generalized_affine_image(Variable var,
01168 Relation_Symbol relsym,
01169 const Linear_Expression& expr,
01170 Coefficient_traits::const_reference denominator
01171 = Coefficient_one());
01172
01200 void
01201 generalized_affine_preimage(Variable var,
01202 Relation_Symbol relsym,
01203 const Linear_Expression& expr,
01204 Coefficient_traits::const_reference denominator
01205 = Coefficient_one());
01206
01228 void generalized_affine_image(const Linear_Expression& lhs,
01229 Relation_Symbol relsym,
01230 const Linear_Expression& rhs);
01231
01253 void generalized_affine_preimage(const Linear_Expression& lhs,
01254 Relation_Symbol relsym,
01255 const Linear_Expression& rhs);
01256
01283 void bounded_affine_image(Variable var,
01284 const Linear_Expression& lb_expr,
01285 const Linear_Expression& ub_expr,
01286 Coefficient_traits::const_reference denominator
01287 = Coefficient_one());
01288
01315 void bounded_affine_preimage(Variable var,
01316 const Linear_Expression& lb_expr,
01317 const Linear_Expression& ub_expr,
01318 Coefficient_traits::const_reference denominator
01319 = Coefficient_one());
01320
01329 void time_elapse_assign(const Partially_Reduced_Product& y);
01330
01332 void topological_closure_assign();
01333
01334
01335
01336
01337
01338
01358 void widening_assign(const Partially_Reduced_Product& y,
01359 unsigned* tp = NULL);
01360
01372 void drop_some_non_integer_points(Complexity_Class complexity
01373 = ANY_COMPLEXITY);
01374
01390 void drop_some_non_integer_points(const Variables_Set& vars,
01391 Complexity_Class complexity
01392 = ANY_COMPLEXITY);
01393
01395
01397
01398
01410 void add_space_dimensions_and_embed(dimension_type m);
01411
01423 void add_space_dimensions_and_project(dimension_type m);
01424
01435 void concatenate_assign(const Partially_Reduced_Product& y);
01436
01438
01447 void remove_space_dimensions(const Variables_Set& vars);
01448
01457 void remove_higher_space_dimensions(dimension_type new_dimension);
01458
01507 template <typename Partial_Function>
01508 void map_space_dimensions(const Partial_Function& pfunc);
01509
01511
01533 void expand_space_dimension(Variable var, dimension_type m);
01534
01536
01559 void fold_space_dimensions(const Variables_Set& vars, Variable dest);
01560
01562
01563 friend bool operator==<>(const Partially_Reduced_Product<D1, D2, R>& x,
01564 const Partially_Reduced_Product<D1, D2, R>& y);
01565
01566 friend std::ostream&
01567 Parma_Polyhedra_Library::IO_Operators::
01568 operator<<<>(std::ostream& s, const Partially_Reduced_Product<D1, D2, R>& dp);
01569
01571
01572
01574 ~Partially_Reduced_Product();
01575
01580 void swap(Partially_Reduced_Product& y);
01581
01582 PPL_OUTPUT_DECLARATIONS
01583
01589 bool ascii_load(std::istream& s);
01590
01592 memory_size_type total_memory_in_bytes() const;
01593
01595 memory_size_type external_memory_in_bytes() const;
01596
01603 int32_t hash_code() const;
01604
01606
01608
01609
01610
01611
01612
01613 bool reduce() const;
01614
01615 protected:
01617 typedef D1 Domain1;
01618
01620 typedef D2 Domain2;
01621
01623 D1 d1;
01624
01626 D2 d2;
01627
01628 protected:
01630 void clear_reduced_flag() const;
01631
01633 void set_reduced_flag() const;
01634
01636 bool is_reduced() const;
01637
01642 bool reduced;
01643 };
01644
01645 namespace Parma_Polyhedra_Library {
01646
01655 template <typename D1, typename D2>
01656 class Domain_Product {
01657 public:
01658 typedef Partially_Reduced_Product<D1, D2, No_Reduction<D1, D2> >
01659 Direct_Product;
01660
01661 typedef Partially_Reduced_Product<D1, D2, Smash_Reduction<D1, D2> >
01662 Smash_Product;
01663
01664 typedef Partially_Reduced_Product<D1, D2, Constraints_Reduction<D1, D2> >
01665 Constraints_Product;
01666
01667 typedef Partially_Reduced_Product<D1, D2, Congruences_Reduction<D1, D2> >
01668 Congruences_Product;
01669
01670 typedef Partially_Reduced_Product<D1, D2, Shape_Preserving_Reduction<D1, D2> >
01671 Shape_Preserving_Product;
01672 };
01673
01674 }
01675
01676 namespace std {
01677
01679
01680 template <typename D1, typename D2, typename R>
01681 void swap(Parma_Polyhedra_Library::Partially_Reduced_Product<D1, D2, R>& x,
01682 Parma_Polyhedra_Library::Partially_Reduced_Product<D1, D2, R>& y);
01683
01684 }
01685
01686 #include "Partially_Reduced_Product.inlines.hh"
01687 #include "Partially_Reduced_Product.templates.hh"
01688
01689 #endif // !defined(PPL_Partially_Reduced_Product_defs_hh)