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_Determinate_inlines_hh
00025 #define PPL_Determinate_inlines_hh 1
00026
00027 #include "assert.hh"
00028
00029 namespace Parma_Polyhedra_Library {
00030
00031 template <typename PSET>
00032 inline
00033 Determinate<PSET>::Rep::Rep(dimension_type num_dimensions,
00034 Degenerate_Element kind)
00035 : references(0), pset(num_dimensions, kind) {
00036 }
00037
00038 template <typename PSET>
00039 inline
00040 Determinate<PSET>::Rep::Rep(const PSET& p)
00041 : references(0), pset(p) {
00042 }
00043
00044 template <typename PSET>
00045 inline
00046 Determinate<PSET>::Rep::Rep(const Constraint_System& cs)
00047 : references(0), pset(cs) {
00048 }
00049
00050 template <typename PSET>
00051 inline
00052 Determinate<PSET>::Rep::Rep(const Congruence_System& cgs)
00053 : references(0), pset(cgs) {
00054 }
00055
00056 template <typename PSET>
00057 inline
00058 Determinate<PSET>::Rep::~Rep() {
00059 PPL_ASSERT(references == 0);
00060 }
00061
00062 template <typename PSET>
00063 inline void
00064 Determinate<PSET>::Rep::new_reference() const {
00065 ++references;
00066 }
00067
00068 template <typename PSET>
00069 inline bool
00070 Determinate<PSET>::Rep::del_reference() const {
00071 return --references == 0;
00072 }
00073
00074 template <typename PSET>
00075 inline bool
00076 Determinate<PSET>::Rep::is_shared() const {
00077 return references > 1;
00078 }
00079
00080 template <typename PSET>
00081 inline memory_size_type
00082 Determinate<PSET>::Rep::external_memory_in_bytes() const {
00083 return pset.external_memory_in_bytes();
00084 }
00085
00086 template <typename PSET>
00087 inline memory_size_type
00088 Determinate<PSET>::Rep::total_memory_in_bytes() const {
00089 return sizeof(*this) + external_memory_in_bytes();
00090 }
00091
00092 template <typename PSET>
00093 inline
00094 Determinate<PSET>::Determinate(const PSET& pset)
00095 : prep(new Rep(pset)) {
00096 prep->new_reference();
00097 }
00098
00099 template <typename PSET>
00100 inline
00101 Determinate<PSET>::Determinate(const Constraint_System& cs)
00102 : prep(new Rep(cs)) {
00103 prep->new_reference();
00104 }
00105
00106 template <typename PSET>
00107 inline
00108 Determinate<PSET>::Determinate(const Congruence_System& cgs)
00109 : prep(new Rep(cgs)) {
00110 prep->new_reference();
00111 }
00112
00113 template <typename PSET>
00114 inline
00115 Determinate<PSET>::Determinate(const Determinate& y)
00116 : prep(y.prep) {
00117 prep->new_reference();
00118 }
00119
00120 template <typename PSET>
00121 inline
00122 Determinate<PSET>::~Determinate() {
00123 if (prep->del_reference())
00124 delete prep;
00125 }
00126
00127 template <typename PSET>
00128 inline Determinate<PSET>&
00129 Determinate<PSET>::operator=(const Determinate& y) {
00130 y.prep->new_reference();
00131 if (prep->del_reference())
00132 delete prep;
00133 prep = y.prep;
00134 return *this;
00135 }
00136
00137 template <typename PSET>
00138 inline void
00139 Determinate<PSET>::swap(Determinate& y) {
00140 std::swap(prep, y.prep);
00141 }
00142
00143 template <typename PSET>
00144 inline void
00145 Determinate<PSET>::mutate() {
00146 if (prep->is_shared()) {
00147 Rep* new_prep = new Rep(prep->pset);
00148 (void) prep->del_reference();
00149 new_prep->new_reference();
00150 prep = new_prep;
00151 }
00152 }
00153
00154 template <typename PSET>
00155 inline const PSET&
00156 Determinate<PSET>::pointset() const {
00157 return prep->pset;
00158 }
00159
00160 template <typename PSET>
00161 inline PSET&
00162 Determinate<PSET>::pointset() {
00163 mutate();
00164 return prep->pset;
00165 }
00166
00167 template <typename PSET>
00168 inline void
00169 Determinate<PSET>::upper_bound_assign(const Determinate& y) {
00170 pointset().upper_bound_assign(y.pointset());
00171 }
00172
00173 template <typename PSET>
00174 inline void
00175 Determinate<PSET>::meet_assign(const Determinate& y) {
00176 pointset().intersection_assign(y.pointset());
00177 }
00178
00179 template <typename PSET>
00180 inline bool
00181 Determinate<PSET>::has_nontrivial_weakening() {
00182
00183
00184
00185 return false;
00186 }
00187
00188 template <typename PSET>
00189 inline void
00190 Determinate<PSET>::weakening_assign(const Determinate& y) {
00191
00192
00193
00194 pointset().difference_assign(y.pointset());
00195 }
00196
00197 template <typename PSET>
00198 inline void
00199 Determinate<PSET>::concatenate_assign(const Determinate& y) {
00200 pointset().concatenate_assign(y.pointset());
00201 }
00202
00203 template <typename PSET>
00204 inline bool
00205 Determinate<PSET>::definitely_entails(const Determinate& y) const {
00206 return prep == y.prep || y.prep->pset.contains(prep->pset);
00207 }
00208
00209 template <typename PSET>
00210 inline bool
00211 Determinate<PSET>::is_definitely_equivalent_to(const Determinate& y) const {
00212 return prep == y.prep || prep->pset == y.prep->pset;
00213 }
00214
00215 template <typename PSET>
00216 inline bool
00217 Determinate<PSET>::is_top() const {
00218 return prep->pset.is_universe();
00219 }
00220
00221 template <typename PSET>
00222 inline bool
00223 Determinate<PSET>::is_bottom() const {
00224 return prep->pset.is_empty();
00225 }
00226
00227 template <typename PSET>
00228 inline memory_size_type
00229 Determinate<PSET>::external_memory_in_bytes() const {
00230 return prep->total_memory_in_bytes();
00231 }
00232
00233 template <typename PSET>
00234 inline memory_size_type
00235 Determinate<PSET>::total_memory_in_bytes() const {
00236 return sizeof(*this) + external_memory_in_bytes();
00237 }
00238
00239 template <typename PSET>
00240 inline bool
00241 Determinate<PSET>::OK() const {
00242 return prep->pset.OK();
00243 }
00244
00245 namespace IO_Operators {
00246
00248 template <typename PSET>
00249 inline std::ostream&
00250 operator<<(std::ostream& s, const Determinate<PSET>& x) {
00251 s << x.pointset();
00252 return s;
00253 }
00254
00255 }
00256
00258 template <typename PSET>
00259 inline bool
00260 operator==(const Determinate<PSET>& x, const Determinate<PSET>& y) {
00261 return x.prep == y.prep || x.prep->pset == y.prep->pset;
00262 }
00263
00265 template <typename PSET>
00266 inline bool
00267 operator!=(const Determinate<PSET>& x, const Determinate<PSET>& y) {
00268 return x.prep != y.prep && x.prep->pset != y.prep->pset;
00269 }
00270
00271 template <typename PSET>
00272 template <typename Binary_Operator_Assign>
00273 inline
00274 Determinate<PSET>::Binary_Operator_Assign_Lifter<Binary_Operator_Assign>::
00275 Binary_Operator_Assign_Lifter(Binary_Operator_Assign op_assign)
00276 : op_assign_(op_assign) {
00277 }
00278
00279 template <typename PSET>
00280 template <typename Binary_Operator_Assign>
00281 inline void
00282 Determinate<PSET>::Binary_Operator_Assign_Lifter<Binary_Operator_Assign>::
00283 operator()(Determinate& x, const Determinate& y) const {
00284 op_assign_(x.pointset(), y.pointset());
00285 }
00286
00287 template <typename PSET>
00288 template <typename Binary_Operator_Assign>
00289 inline
00290 Determinate<PSET>::Binary_Operator_Assign_Lifter<Binary_Operator_Assign>
00291 Determinate<PSET>::lift_op_assign(Binary_Operator_Assign op_assign) {
00292 return Binary_Operator_Assign_Lifter<Binary_Operator_Assign>(op_assign);
00293 }
00294
00295 }
00296
00297
00298 namespace std {
00299
00301 template <typename PSET>
00302 inline void
00303 swap(Parma_Polyhedra_Library::Determinate<PSET>& x,
00304 Parma_Polyhedra_Library::Determinate<PSET>& y) {
00305 x.swap(y);
00306 }
00307
00308 }
00309
00310 #endif // !defined(PPL_Determinate_inlines_hh)