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