|
PPL
0.12.1
|
00001 /* Constraint_System class implementation: inline functions. 00002 Copyright (C) 2001-2010 Roberto Bagnara <bagnara@cs.unipr.it> 00003 Copyright (C) 2010-2012 BUGSENG srl (http://bugseng.com) 00004 00005 This file is part of the Parma Polyhedra Library (PPL). 00006 00007 The PPL is free software; you can redistribute it and/or modify it 00008 under the terms of the GNU General Public License as published by the 00009 Free Software Foundation; either version 3 of the License, or (at your 00010 option) any later version. 00011 00012 The PPL is distributed in the hope that it will be useful, but WITHOUT 00013 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 00014 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 00015 for more details. 00016 00017 You should have received a copy of the GNU General Public License 00018 along with this program; if not, write to the Free Software Foundation, 00019 Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1307, USA. 00020 00021 For the most up-to-date information see the Parma Polyhedra Library 00022 site: http://bugseng.com/products/ppl/ . */ 00023 00024 #ifndef PPL_Constraint_System_inlines_hh 00025 #define PPL_Constraint_System_inlines_hh 1 00026 00027 #include "Constraint.defs.hh" 00028 00029 namespace Parma_Polyhedra_Library { 00030 00031 inline 00032 Constraint_System::Constraint_System() 00033 : Linear_System(NECESSARILY_CLOSED) { 00034 } 00035 00036 inline 00037 Constraint_System::Constraint_System(const Constraint& c) 00038 : Linear_System(c.topology()) { 00039 Linear_System::insert(c); 00040 } 00041 00042 inline 00043 Constraint_System::Constraint_System(const Constraint_System& cs) 00044 : Linear_System(cs) { 00045 } 00046 00047 inline 00048 Constraint_System::Constraint_System(const Topology topol) 00049 : Linear_System(topol) { 00050 } 00051 00052 inline 00053 Constraint_System::Constraint_System(const Topology topol, 00054 const dimension_type n_rows, 00055 const dimension_type n_columns) 00056 : Linear_System(topol, n_rows, n_columns) { 00057 } 00058 00059 inline 00060 Constraint_System::~Constraint_System() { 00061 } 00062 00063 inline Constraint_System& 00064 Constraint_System::operator=(const Constraint_System& y) { 00065 Linear_System::operator=(y); 00066 return *this; 00067 } 00068 00069 inline Constraint& 00070 Constraint_System::operator[](const dimension_type k) { 00071 return static_cast<Constraint&>(Linear_System::operator[](k)); 00072 } 00073 00074 inline const Constraint& 00075 Constraint_System::operator[](const dimension_type k) const { 00076 return static_cast<const Constraint&>(Linear_System::operator[](k)); 00077 } 00078 00079 inline dimension_type 00080 Constraint_System::max_space_dimension() { 00081 return Linear_System::max_space_dimension(); 00082 } 00083 00084 inline dimension_type 00085 Constraint_System::space_dimension() const { 00086 return Linear_System::space_dimension(); 00087 } 00088 00089 inline void 00090 Constraint_System::clear() { 00091 Linear_System::clear(); 00092 } 00093 00094 inline const Constraint_System& 00095 Constraint_System::zero_dim_empty() { 00096 PPL_ASSERT(zero_dim_empty_p != 0); 00097 return *zero_dim_empty_p; 00098 } 00099 00100 inline 00101 Constraint_System::const_iterator::const_iterator() 00102 : i(), csp(0) { 00103 } 00104 00105 inline 00106 Constraint_System::const_iterator::const_iterator(const const_iterator& y) 00107 : i(y.i), csp(y.csp) { 00108 } 00109 00110 inline 00111 Constraint_System::const_iterator::~const_iterator() { 00112 } 00113 00114 inline Constraint_System::const_iterator& 00115 Constraint_System::const_iterator::operator=(const const_iterator& y) { 00116 i = y.i; 00117 csp = y.csp; 00118 return *this; 00119 } 00120 00121 inline const Constraint& 00122 Constraint_System::const_iterator::operator*() const { 00123 return static_cast<const Constraint&>(*i); 00124 } 00125 00126 inline const Constraint* 00127 Constraint_System::const_iterator::operator->() const { 00128 return static_cast<const Constraint*>(i.operator->()); 00129 } 00130 00131 inline Constraint_System::const_iterator& 00132 Constraint_System::const_iterator::operator++() { 00133 ++i; 00134 skip_forward(); 00135 return *this; 00136 } 00137 00138 inline Constraint_System::const_iterator 00139 Constraint_System::const_iterator::operator++(int) { 00140 const const_iterator tmp = *this; 00141 operator++(); 00142 return tmp; 00143 } 00144 00145 inline bool 00146 Constraint_System::const_iterator::operator==(const const_iterator& y) const { 00147 return i == y.i; 00148 } 00149 00150 inline bool 00151 Constraint_System::const_iterator::operator!=(const const_iterator& y) const { 00152 return i != y.i; 00153 } 00154 00155 inline 00156 Constraint_System::const_iterator:: 00157 const_iterator(const Linear_System::const_iterator& iter, 00158 const Constraint_System& cs) 00159 : i(iter), csp(&cs) { 00160 } 00161 00162 inline Constraint_System::const_iterator 00163 Constraint_System::begin() const { 00164 const_iterator i(Linear_System::begin(), *this); 00165 i.skip_forward(); 00166 return i; 00167 } 00168 00169 inline Constraint_System::const_iterator 00170 Constraint_System::end() const { 00171 const const_iterator i(Linear_System::end(), *this); 00172 return i; 00173 } 00174 00175 inline bool 00176 Constraint_System::empty() const { 00177 return begin() == end(); 00178 } 00179 00180 inline void 00181 Constraint_System::add_low_level_constraints() { 00182 if (is_necessarily_closed()) 00183 // The positivity constraint. 00184 insert(Constraint::zero_dim_positivity()); 00185 else { 00186 // Add the epsilon constraints. 00187 insert(Constraint::epsilon_leq_one()); 00188 insert(Constraint::epsilon_geq_zero()); 00189 } 00190 } 00191 00192 inline void 00193 Constraint_System::m_swap(Constraint_System& y) { 00194 Linear_System::m_swap(y); 00195 } 00196 00197 inline memory_size_type 00198 Constraint_System::external_memory_in_bytes() const { 00199 return Linear_System::external_memory_in_bytes(); 00200 } 00201 00202 inline memory_size_type 00203 Constraint_System::total_memory_in_bytes() const { 00204 return Linear_System::total_memory_in_bytes(); 00205 } 00206 00207 inline void 00208 Constraint_System::simplify() { 00209 Linear_System::simplify(); 00210 } 00211 00213 inline void 00214 swap(Constraint_System& x, Constraint_System& y) { 00215 x.m_swap(y); 00216 } 00217 00218 namespace Implementation { 00219 00220 #ifdef PPL_DOXYGEN_INCLUDE_IMPLEMENTATION_DETAILS 00221 00222 #endif // defined(PPL_DOXYGEN_INCLUDE_IMPLEMENTATION_DETAILS) 00223 inline dimension_type 00224 num_constraints(const Constraint_System& cs) { 00225 return static_cast<dimension_type>(std::distance(cs.begin(), cs.end())); 00226 } 00227 00228 } // namespace Implementation 00229 00230 } // namespace Parma_Polyhedra_Library 00231 00232 #endif // !defined(PPL_Constraint_System_inlines_hh)