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_Grid_inlines_hh
00024 #define PPL_Grid_inlines_hh 1
00025
00026 #include "Grid_Generator.defs.hh"
00027 #include "Grid_Generator_System.defs.hh"
00028 #include <algorithm>
00029
00030 namespace Parma_Polyhedra_Library {
00031
00032 inline dimension_type
00033 Grid::max_space_dimension() {
00034 using std::min;
00035
00036
00037 return min(std::numeric_limits<dimension_type>::max() - 1,
00038 min(Congruence_System::max_space_dimension(),
00039 Grid_Generator_System::max_space_dimension()
00040 )
00041 );
00042 }
00043
00044 inline void
00045 Grid::set_congruences_up_to_date() {
00046 status.set_c_up_to_date();
00047 }
00048
00049 inline
00050 Grid::Grid(const Congruence_System& ccgs) {
00051 if (ccgs.space_dimension() > max_space_dimension())
00052 throw_space_dimension_overflow("Grid(ccgs)",
00053 "the space dimension of ccgs "
00054 "exceeds the maximum allowed "
00055 "space dimension");
00056 construct(ccgs);
00057 }
00058
00059 inline
00060 Grid::Grid(Congruence_System& cgs) {
00061 if (cgs.space_dimension() > max_space_dimension())
00062 throw_space_dimension_overflow("Grid(cgs)",
00063 "the space dimension of cgs "
00064 "exceeds the maximum allowed "
00065 "space dimension");
00066 construct(cgs);
00067 }
00068
00069 inline
00070 Grid::Grid(const Grid_Generator_System& gs) {
00071 if (gs.space_dimension() > max_space_dimension())
00072 throw_space_dimension_overflow("Grid(gs)",
00073 "the space dimension of gs "
00074 "exceeds the maximum allowed "
00075 "space dimension");
00076 construct(gs);
00077 }
00078
00079 inline
00080 Grid::Grid(Grid_Generator_System& gs) {
00081 if (gs.space_dimension() > max_space_dimension())
00082 throw_space_dimension_overflow("Grid(gs)",
00083 "the space dimension of gs "
00084 "exceeds the maximum allowed "
00085 "space dimension");
00086 construct(gs);
00087 }
00088
00089 inline
00090 Grid::~Grid() {
00091 }
00092
00093 inline memory_size_type
00094 Grid::total_memory_in_bytes() const {
00095 return sizeof(*this) + external_memory_in_bytes();
00096 }
00097
00098 inline dimension_type
00099 Grid::space_dimension() const {
00100 return space_dim;
00101 }
00102
00103 inline void
00104 Grid::upper_bound_assign(const Grid& y) {
00105 join_assign(y);
00106 }
00107
00108 inline bool
00109 Grid::upper_bound_assign_if_exact(const Grid& y) {
00110 return join_assign_if_exact(y);
00111 }
00112
00113 inline void
00114 Grid::difference_assign(const Grid& y) {
00115 grid_difference_assign(y);
00116 }
00117
00118 inline void
00119 Grid::swap(Grid& y) {
00120 std::swap(con_sys, y.con_sys);
00121 std::swap(gen_sys, y.gen_sys);
00122 std::swap(status, y.status);
00123 std::swap(space_dim, y.space_dim);
00124 std::swap(dim_kinds, y.dim_kinds);
00125 }
00126
00127 }
00128
00130 inline void
00131 std::swap(Parma_Polyhedra_Library::Grid& x,
00132 Parma_Polyhedra_Library::Grid& y) {
00133 x.swap(y);
00134 }
00135
00136 namespace Parma_Polyhedra_Library {
00137
00138 inline bool
00139 Grid::marked_empty() const {
00140 return status.test_empty();
00141 }
00142
00143 inline bool
00144 Grid::congruences_are_up_to_date() const {
00145 return status.test_c_up_to_date();
00146 }
00147
00148 inline bool
00149 Grid::generators_are_up_to_date() const {
00150 return status.test_g_up_to_date();
00151 }
00152
00153 inline bool
00154 Grid::congruences_are_minimized() const {
00155 return status.test_c_minimized();
00156 }
00157
00158 inline bool
00159 Grid::generators_are_minimized() const {
00160 return status.test_g_minimized();
00161 }
00162
00163 inline void
00164 Grid::set_generators_up_to_date() {
00165 status.set_g_up_to_date();
00166 }
00167
00168 inline void
00169 Grid::set_congruences_minimized() {
00170 set_congruences_up_to_date();
00171 status.set_c_minimized();
00172 }
00173
00174 inline void
00175 Grid::set_generators_minimized() {
00176 set_generators_up_to_date();
00177 status.set_g_minimized();
00178 }
00179
00180 inline void
00181 Grid::clear_empty() {
00182 status.reset_empty();
00183 }
00184
00185 inline void
00186 Grid::clear_congruences_minimized() {
00187 status.reset_c_minimized();
00188 }
00189
00190 inline void
00191 Grid::clear_generators_minimized() {
00192 status.reset_g_minimized();
00193 }
00194
00195 inline void
00196 Grid::clear_congruences_up_to_date() {
00197 clear_congruences_minimized();
00198 status.reset_c_up_to_date();
00199
00200 }
00201
00202 inline void
00203 Grid::clear_generators_up_to_date() {
00204 clear_generators_minimized();
00205 status.reset_g_up_to_date();
00206
00207 }
00208
00209 inline bool
00210 Grid::bounds_from_above(const Linear_Expression& expr) const {
00211 return bounds(expr, "bounds_from_above(e)");
00212 }
00213
00214 inline bool
00215 Grid::bounds_from_below(const Linear_Expression& expr) const {
00216 return bounds(expr, "bounds_from_below(e)");
00217 }
00218
00219 inline bool
00220 Grid::maximize(const Linear_Expression& expr,
00221 Coefficient& sup_n, Coefficient& sup_d, bool& maximum) const {
00222 return max_min(expr, "maximize(e, ...)", sup_n, sup_d, maximum);
00223 }
00224
00225 inline bool
00226 Grid::maximize(const Linear_Expression& expr,
00227 Coefficient& sup_n, Coefficient& sup_d, bool& maximum,
00228 Grid_Generator& point) const {
00229 return max_min(expr, "maximize(e, ...)", sup_n, sup_d, maximum, &point);
00230 }
00231
00232 inline bool
00233 Grid::minimize(const Linear_Expression& expr,
00234 Coefficient& inf_n, Coefficient& inf_d, bool& minimum) const {
00235 return max_min(expr, "minimize(e, ...)", inf_n, inf_d, minimum);
00236 }
00237
00238 inline bool
00239 Grid::minimize(const Linear_Expression& expr,
00240 Coefficient& inf_n, Coefficient& inf_d, bool& minimum,
00241 Grid_Generator& point) const {
00242 return max_min(expr, "minimize(e, ...)", inf_n, inf_d, minimum, &point);
00243 }
00244
00246 inline bool
00247 operator!=(const Grid& x, const Grid& y) {
00248 return !(x == y);
00249 }
00250
00251 inline bool
00252 Grid::strictly_contains(const Grid& y) const {
00253 const Grid& x = *this;
00254 return x.contains(y) && !y.contains(x);
00255 }
00256
00257 inline void
00258 Grid::topological_closure_assign() {
00259 return;
00260 }
00261
00262 }
00263
00264 #endif // !defined(PPL_Grid_inlines_hh)