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