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_Linear_Row_inlines_hh
00024 #define PPL_Linear_Row_inlines_hh 1
00025
00026 #include "globals.defs.hh"
00027 #include <cassert>
00028 #include <algorithm>
00029
00030 namespace Parma_Polyhedra_Library {
00031
00032 inline
00033 Linear_Row::Flags::Flags()
00034 : Row::Flags() {
00035
00036 }
00037
00038 inline
00039 Linear_Row::Flags::Flags(const Topology t)
00040 : Row::Flags(t << nnc_bit) {
00041 #ifndef NDEBUG
00042 set_bits(1 << nnc_validity_bit);
00043 #endif
00044 }
00045
00046 inline
00047 Linear_Row::Flags::Flags(const Topology t, const Kind k)
00048 : Row::Flags((k << rpi_bit) | (t << nnc_bit)) {
00049 #ifndef NDEBUG
00050 set_bits((1 << rpi_validity_bit)
00051 | (1 << nnc_validity_bit));
00052 #endif
00053 }
00054
00055 inline bool
00056 Linear_Row::Flags::is_ray_or_point_or_inequality() const {
00057 assert(test_bits(1 << rpi_validity_bit));
00058 return test_bits(RAY_OR_POINT_OR_INEQUALITY << rpi_bit);
00059 }
00060
00061 inline void
00062 Linear_Row::Flags::set_is_ray_or_point_or_inequality() {
00063 #ifndef NDEBUG
00064 set_bits(1 << rpi_validity_bit);
00065 #endif
00066 set_bits(RAY_OR_POINT_OR_INEQUALITY << rpi_bit);
00067 }
00068
00069 inline bool
00070 Linear_Row::Flags::is_line_or_equality() const {
00071 assert(test_bits(1 << rpi_validity_bit));
00072 return !is_ray_or_point_or_inequality();
00073 }
00074
00075 inline void
00076 Linear_Row::Flags::set_is_line_or_equality() {
00077 #ifndef NDEBUG
00078 set_bits(1 << rpi_validity_bit);
00079 #endif
00080 reset_bits(RAY_OR_POINT_OR_INEQUALITY << rpi_bit);
00081 }
00082
00083 inline bool
00084 Linear_Row::Flags::is_not_necessarily_closed() const {
00085 assert(test_bits(1 << nnc_validity_bit));
00086 return test_bits(NOT_NECESSARILY_CLOSED << nnc_bit);
00087 }
00088
00089 inline bool
00090 Linear_Row::Flags::is_necessarily_closed() const {
00091 assert(test_bits(1 << nnc_validity_bit));
00092 return !is_not_necessarily_closed();
00093 }
00094
00095 inline void
00096 Linear_Row::Flags::set_not_necessarily_closed() {
00097 #ifndef NDEBUG
00098 set_bits(1 << nnc_validity_bit);
00099 #endif
00100 set_bits(NOT_NECESSARILY_CLOSED << nnc_bit);
00101 }
00102
00103 inline void
00104 Linear_Row::Flags::set_necessarily_closed() {
00105 #ifndef NDEBUG
00106 set_bits(1 << nnc_validity_bit);
00107 #endif
00108 reset_bits(NOT_NECESSARILY_CLOSED << nnc_bit);
00109 }
00110
00111 inline Topology
00112 Linear_Row::Flags::topology() const {
00113 return is_necessarily_closed() ? NECESSARILY_CLOSED : NOT_NECESSARILY_CLOSED;
00114 }
00115
00116 inline bool
00117 Linear_Row::Flags::operator==(const Flags& y) const {
00118 base_type mask = low_bits_mask<base_type>(first_free_bit);
00119 return (get_bits() & mask) == (y.get_bits() & mask);
00120 }
00121
00122 inline bool
00123 Linear_Row::Flags::operator!=(const Flags& y) const {
00124 return !operator==(y);
00125 }
00126
00127 inline const Linear_Row::Flags&
00128 Linear_Row::flags() const {
00129 return static_cast<const Flags&>(Row::flags());
00130 }
00131
00132 inline Linear_Row::Flags&
00133 Linear_Row::flags() {
00134 return static_cast<Flags&>(Row::flags());
00135 }
00136
00137 inline bool
00138 Linear_Row::is_necessarily_closed() const {
00139 return flags().is_necessarily_closed();
00140 }
00141
00142 inline dimension_type
00143 Linear_Row::max_space_dimension() {
00144
00145
00146 return max_size() - 2;
00147 }
00148
00149 inline dimension_type
00150 Linear_Row::space_dimension() const {
00151 const dimension_type sz = size();
00152 return (sz == 0)
00153 ? 0
00154 : sz - (is_necessarily_closed() ? 1 : 2);
00155 }
00156
00157 inline
00158 Linear_Row::Linear_Row()
00159 : Row() {
00160 }
00161
00162 inline void
00163 Linear_Row::construct(const dimension_type sz, const dimension_type capacity,
00164 const Flags f) {
00165 Row::construct(sz, capacity, f);
00166 }
00167
00168 inline
00169 Linear_Row::Linear_Row(const dimension_type sz, const dimension_type capacity,
00170 const Flags f) {
00171 construct(sz, capacity, f);
00172 }
00173
00174 inline void
00175 Linear_Row::construct(const dimension_type sz, const Flags f) {
00176 construct(sz, sz, f);
00177 }
00178
00179 inline
00180 Linear_Row::Linear_Row(const dimension_type sz, const Flags f) {
00181 construct(sz, f);
00182 }
00183
00184 inline
00185 Linear_Row::Linear_Row(const Linear_Row& y)
00186 : Row(y) {
00187 }
00188
00189 inline
00190 Linear_Row::Linear_Row(const Linear_Row& y,
00191 const dimension_type capacity)
00192 : Row(y, capacity) {
00193 }
00194
00195 inline
00196 Linear_Row::Linear_Row(const Linear_Row& y,
00197 const dimension_type sz, const dimension_type capacity)
00198 : Row(y, sz, capacity) {
00199 }
00200
00201 inline
00202 Linear_Row::~Linear_Row() {
00203 }
00204
00205 inline bool
00206 Linear_Row::is_line_or_equality() const {
00207 return flags().is_line_or_equality();
00208 }
00209
00210 inline bool
00211 Linear_Row::is_ray_or_point_or_inequality() const {
00212 return flags().is_ray_or_point_or_inequality();
00213 }
00214
00215 inline Topology
00216 Linear_Row::topology() const {
00217 return flags().topology();
00218 }
00219
00220 inline void
00221 Linear_Row::set_is_line_or_equality() {
00222 flags().set_is_line_or_equality();
00223 }
00224
00225 inline void
00226 Linear_Row::set_is_ray_or_point_or_inequality() {
00227 flags().set_is_ray_or_point_or_inequality();
00228 }
00229
00230 inline void
00231 Linear_Row::set_necessarily_closed() {
00232 flags().set_necessarily_closed();
00233 }
00234
00235 inline void
00236 Linear_Row::set_not_necessarily_closed() {
00237 flags().set_not_necessarily_closed();
00238 }
00239
00240 inline Coefficient_traits::const_reference
00241 Linear_Row::inhomogeneous_term() const {
00242 return (*this)[0];
00243 }
00244
00245 inline Coefficient_traits::const_reference
00246 Linear_Row::coefficient(const dimension_type k) const {
00247 return (*this)[k+1];
00248 }
00249
00250 inline void
00251 Linear_Row::strong_normalize() {
00252 normalize();
00253 sign_normalize();
00254 }
00255
00257 inline bool
00258 operator==(const Linear_Row& x, const Linear_Row& y) {
00259 return x.flags() == y.flags()
00260 && static_cast<const Row&>(x) == static_cast<const Row&>(y);
00261 }
00262
00264 inline bool
00265 operator!=(const Linear_Row& x, const Linear_Row& y) {
00266 return !(x == y);
00267 }
00268
00269 }
00270
00271
00272 namespace std {
00273
00275 inline void
00276 swap(Parma_Polyhedra_Library::Linear_Row& x,
00277 Parma_Polyhedra_Library::Linear_Row& y) {
00278 x.swap(y);
00279 }
00280
00282 inline void
00283 iter_swap(std::vector<Parma_Polyhedra_Library::Linear_Row>::iterator x,
00284 std::vector<Parma_Polyhedra_Library::Linear_Row>::iterator y) {
00285 swap(*x, *y);
00286 }
00287
00288 }
00289
00290 #endif // !defined(PPL_Linear_Row_inlines_hh)