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_Pointset_Powerset_inlines_hh
00025 #define PPL_Pointset_Powerset_inlines_hh 1
00026
00027 #include "Constraint.defs.hh"
00028 #include "Constraint_System.defs.hh"
00029 #include "Constraint_System.inlines.hh"
00030 #include "Congruence.defs.hh"
00031 #include "Congruence_System.defs.hh"
00032 #include "Congruence_System.inlines.hh"
00033 #include "C_Polyhedron.defs.hh"
00034 #include "NNC_Polyhedron.defs.hh"
00035 #include <algorithm>
00036 #include <deque>
00037
00038 namespace Parma_Polyhedra_Library {
00039
00040 template <typename PSET>
00041 inline dimension_type
00042 Pointset_Powerset<PSET>::space_dimension() const {
00043 return space_dim;
00044 }
00045
00046 template <typename PSET>
00047 inline dimension_type
00048 Pointset_Powerset<PSET>::max_space_dimension() {
00049 return PSET::max_space_dimension();
00050 }
00051
00052 template <typename PSET>
00053 inline
00054 Pointset_Powerset<PSET>::Pointset_Powerset(dimension_type num_dimensions,
00055 Degenerate_Element kind)
00056 : Base(), space_dim(num_dimensions) {
00057 Pointset_Powerset& x = *this;
00058 if (kind == UNIVERSE)
00059 x.sequence.push_back(Determinate<PSET>(PSET(num_dimensions, kind)));
00060 PPL_ASSERT_HEAVY(x.OK());
00061 }
00062
00063 template <typename PSET>
00064 inline
00065 Pointset_Powerset<PSET>::Pointset_Powerset(const Pointset_Powerset& y,
00066 Complexity_Class)
00067 : Base(y), space_dim(y.space_dim) {
00068 }
00069
00070 template <typename PSET>
00071 inline
00072 Pointset_Powerset<PSET>::Pointset_Powerset(const C_Polyhedron& ph,
00073 Complexity_Class complexity)
00074 : Base(), space_dim(ph.space_dimension()) {
00075 Pointset_Powerset& x = *this;
00076 if (complexity == ANY_COMPLEXITY) {
00077 if (ph.is_empty())
00078 return;
00079 }
00080 else
00081 x.reduced = false;
00082 x.sequence.push_back(Determinate<PSET>(PSET(ph, complexity)));
00083 x.reduced = false;
00084 PPL_ASSERT_HEAVY(OK());
00085 }
00086
00087 template <typename PSET>
00088 inline
00089 Pointset_Powerset<PSET>::Pointset_Powerset(const NNC_Polyhedron& ph,
00090 Complexity_Class complexity)
00091 : Base(), space_dim(ph.space_dimension()) {
00092 Pointset_Powerset& x = *this;
00093 if (complexity == ANY_COMPLEXITY) {
00094 if (ph.is_empty())
00095 return;
00096 }
00097 else
00098 x.reduced = false;
00099 x.sequence.push_back(Determinate<PSET>(PSET(ph, complexity)));
00100 PPL_ASSERT_HEAVY(OK());
00101 }
00102
00103 template <typename PSET>
00104 inline
00105 Pointset_Powerset<PSET>::Pointset_Powerset(const Grid& gr,
00106 Complexity_Class)
00107 : Base(), space_dim(gr.space_dimension()) {
00108 Pointset_Powerset& x = *this;
00109 if (!gr.is_empty()) {
00110 x.sequence.push_back(Determinate<PSET>(PSET(gr)));
00111 }
00112 PPL_ASSERT_HEAVY(OK());
00113 }
00114
00115 template <typename PSET>
00116 template <typename QH1, typename QH2, typename R>
00117 inline
00118 Pointset_Powerset<PSET>
00119 ::Pointset_Powerset(const Partially_Reduced_Product<QH1, QH2, R>& prp,
00120 Complexity_Class complexity)
00121 : Base(), space_dim(prp.space_dimension()) {
00122 Pointset_Powerset& x = *this;
00123 if (complexity == ANY_COMPLEXITY) {
00124 if (prp.is_empty())
00125 return;
00126 }
00127 else
00128 x.reduced = false;
00129 x.sequence.push_back(Determinate<PSET>(PSET(prp, complexity)));
00130 x.reduced = false;
00131 PPL_ASSERT_HEAVY(OK());
00132 }
00133
00134 template <typename PSET>
00135 template <typename Interval>
00136 Pointset_Powerset<PSET>::Pointset_Powerset(const Box<Interval>& box,
00137 Complexity_Class)
00138 : Base(), space_dim(box.space_dimension()) {
00139 Pointset_Powerset& x = *this;
00140 if (!box.is_empty())
00141 x.sequence.push_back(Determinate<PSET>(PSET(box)));
00142 PPL_ASSERT_HEAVY(OK());
00143 }
00144
00145 template <typename PSET>
00146 template <typename T>
00147 Pointset_Powerset<PSET>::Pointset_Powerset(const Octagonal_Shape<T>& os,
00148 Complexity_Class)
00149 : Base(), space_dim(os.space_dimension()) {
00150 Pointset_Powerset& x = *this;
00151 if (!os.is_empty())
00152 x.sequence.push_back(Determinate<PSET>(PSET(os)));
00153 PPL_ASSERT_HEAVY(OK());
00154 }
00155
00156 template <typename PSET>
00157 template <typename T>
00158 Pointset_Powerset<PSET>::Pointset_Powerset(const BD_Shape<T>& bds,
00159 Complexity_Class)
00160 : Base(), space_dim(bds.space_dimension()) {
00161 Pointset_Powerset& x = *this;
00162 if (!bds.is_empty())
00163 x.sequence.push_back(Determinate<PSET>(PSET(bds)));
00164 PPL_ASSERT_HEAVY(OK());
00165 }
00166
00167 template <typename PSET>
00168 inline
00169 Pointset_Powerset<PSET>::Pointset_Powerset(const Constraint_System& cs)
00170 : Base(Determinate<PSET>(cs)), space_dim(cs.space_dimension()) {
00171 PPL_ASSERT_HEAVY(OK());
00172 }
00173
00174 template <typename PSET>
00175 inline
00176 Pointset_Powerset<PSET>::Pointset_Powerset(const Congruence_System& cgs)
00177 : Base(Determinate<PSET>(cgs)), space_dim(cgs.space_dimension()) {
00178 PPL_ASSERT_HEAVY(OK());
00179 }
00180
00181 template <typename PSET>
00182 inline Pointset_Powerset<PSET>&
00183 Pointset_Powerset<PSET>::operator=(const Pointset_Powerset& y) {
00184 Pointset_Powerset& x = *this;
00185 x.Base::operator=(y);
00186 x.space_dim = y.space_dim;
00187 return x;
00188 }
00189
00190 template <typename PSET>
00191 inline void
00192 Pointset_Powerset<PSET>::swap(Pointset_Powerset& y) {
00193 Pointset_Powerset& x = *this;
00194 x.Base::swap(y);
00195 std::swap(x.space_dim, y.space_dim);
00196 }
00197
00198 template <typename PSET>
00199 template <typename QH>
00200 inline Pointset_Powerset<PSET>&
00201 Pointset_Powerset<PSET>::operator=(const Pointset_Powerset<QH>& y) {
00202 Pointset_Powerset& x = *this;
00203 Pointset_Powerset<PSET> pps(y);
00204 x.swap(pps);
00205 return x;
00206 }
00207
00208 template <typename PSET>
00209 inline void
00210 Pointset_Powerset<PSET>::intersection_assign(const Pointset_Powerset& y) {
00211 Pointset_Powerset& x = *this;
00212 x.pairwise_apply_assign
00213 (y,
00214 Det_PSET::lift_op_assign(std::mem_fun_ref(&PSET::intersection_assign)));
00215 }
00216
00217 template <typename PSET>
00218 inline void
00219 Pointset_Powerset<PSET>::time_elapse_assign(const Pointset_Powerset& y) {
00220 Pointset_Powerset& x = *this;
00221 x.pairwise_apply_assign
00222 (y,
00223 Det_PSET::lift_op_assign(std::mem_fun_ref(&PSET::time_elapse_assign)));
00224 }
00225
00226 template <typename PSET>
00227 inline bool
00228 Pointset_Powerset<PSET>
00229 ::geometrically_covers(const Pointset_Powerset& y) const {
00230
00231 const Pointset_Powerset<NNC_Polyhedron> xx(*this);
00232 const Pointset_Powerset<NNC_Polyhedron> yy(y);
00233 return xx.geometrically_covers(yy);
00234 }
00235
00236 template <typename PSET>
00237 inline bool
00238 Pointset_Powerset<PSET>
00239 ::geometrically_equals(const Pointset_Powerset& y) const {
00240
00241 const Pointset_Powerset<NNC_Polyhedron> xx(*this);
00242 const Pointset_Powerset<NNC_Polyhedron> yy(y);
00243 return xx.geometrically_covers(yy) && yy.geometrically_covers(xx);
00244 }
00245
00246 template <>
00247 inline bool
00248 Pointset_Powerset<Grid>
00249 ::geometrically_equals(const Pointset_Powerset& y) const {
00250 const Pointset_Powerset& x = *this;
00251 return x.geometrically_covers(y) && y.geometrically_covers(x);
00252 }
00253
00254 template <>
00255 inline bool
00256 Pointset_Powerset<NNC_Polyhedron>
00257 ::geometrically_equals(const Pointset_Powerset& y) const {
00258 const Pointset_Powerset& x = *this;
00259 return x.geometrically_covers(y) && y.geometrically_covers(x);
00260 }
00261
00262 template <typename PSET>
00263 inline memory_size_type
00264 Pointset_Powerset<PSET>::external_memory_in_bytes() const {
00265 return Base::external_memory_in_bytes();
00266 }
00267
00268 template <typename PSET>
00269 inline memory_size_type
00270 Pointset_Powerset<PSET>::total_memory_in_bytes() const {
00271 return sizeof(*this) + external_memory_in_bytes();
00272 }
00273
00274 template <typename PSET>
00275 inline int32_t
00276 Pointset_Powerset<PSET>::hash_code() const {
00277 return space_dimension() & 0x7fffffff;
00278 }
00279
00280 template <typename PSET>
00281 inline void
00282 Pointset_Powerset<PSET>
00283 ::difference_assign(const Pointset_Powerset& y) {
00284
00285 Pointset_Powerset<NNC_Polyhedron> nnc_this(*this);
00286 Pointset_Powerset<NNC_Polyhedron> nnc_y(y);
00287 nnc_this.difference_assign(nnc_y);
00288 *this = nnc_this;
00289 }
00290
00292 template <typename PSET>
00293 inline bool
00294 check_containment(const PSET& ph, const Pointset_Powerset<PSET>& ps) {
00295
00296 const NNC_Polyhedron pph = NNC_Polyhedron(ph.constraints());
00297 const Pointset_Powerset<NNC_Polyhedron> pps(ps);
00298 return check_containment(pph, pps);
00299 }
00300
00302 template <>
00303 inline bool
00304 check_containment(const C_Polyhedron& ph,
00305 const Pointset_Powerset<C_Polyhedron>& ps) {
00306 return check_containment(NNC_Polyhedron(ph),
00307 Pointset_Powerset<NNC_Polyhedron>(ps));
00308 }
00309
00310 }
00311
00312
00313 namespace std {
00314
00316 template <typename PSET>
00317 inline void
00318 swap(Parma_Polyhedra_Library::Pointset_Powerset<PSET>& x,
00319 Parma_Polyhedra_Library::Pointset_Powerset<PSET>& y) {
00320 x.swap(y);
00321 }
00322
00323 }
00324
00325 #endif // !defined(PPL_Pointset_Powerset_inlines_hh)