PPL  0.12.1
Pointset_Ask_Tell.inlines.hh
Go to the documentation of this file.
00001 /* Pointset_Ask_Tell 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_Pointset_Ask_Tell_inlines_hh
00025 #define PPL_Pointset_Ask_Tell_inlines_hh 1
00026 
00027 #include "Constraint.defs.hh"
00028 #include "Constraint_System.defs.hh"
00029 #include "Constraint_System.inlines.hh"
00030 #include "Congruence.defs.hh"
00031 #include "Congruence_System.defs.hh"
00032 #include "Congruence_System.inlines.hh"
00033 #include "C_Polyhedron.defs.hh"
00034 #include "NNC_Polyhedron.defs.hh"
00035 #include <algorithm>
00036 #include <deque>
00037 
00038 namespace Parma_Polyhedra_Library {
00039 
00040 template <typename PSET>
00041 inline dimension_type
00042 Pointset_Ask_Tell<PSET>::space_dimension() const {
00043   return space_dim;
00044 }
00045 
00046 template <typename PSET>
00047 inline dimension_type
00048 Pointset_Ask_Tell<PSET>::max_space_dimension() {
00049   return PSET::max_space_dimension();
00050 }
00051 
00052 template <typename PSET>
00053 inline
00054 Pointset_Ask_Tell<PSET>::Pointset_Ask_Tell(dimension_type num_dimensions,
00055                                          Degenerate_Element kind)
00056   : Base(), space_dim(num_dimensions) {
00057   if (kind == EMPTY)
00058     pair_insert(Determinate<PSET>(PSET(num_dimensions, UNIVERSE)),
00059                 Determinate<PSET>(PSET(num_dimensions, EMPTY)));
00060   PPL_ASSERT_HEAVY(OK());
00061 }
00062 
00063 template <typename PSET>
00064 inline
00065 Pointset_Ask_Tell<PSET>::Pointset_Ask_Tell(const Pointset_Ask_Tell& y)
00066   : Base(y), space_dim(y.space_dim) {
00067 }
00068 
00069 template <typename PSET>
00070 inline
00071 Pointset_Ask_Tell<PSET>::Pointset_Ask_Tell(const PSET& ph)
00072   : Base(ph), space_dim(ph.space_dimension()) {
00073 }
00074 
00075 template <typename PSET>
00076 inline
00077 Pointset_Ask_Tell<PSET>::Pointset_Ask_Tell(const Constraint_System& cs)
00078   : Base(Determinate<PSET>(cs)), space_dim(cs.space_dimension()) {
00079   PPL_ASSERT_HEAVY(OK());
00080 }
00081 
00082 template <typename PSET>
00083 inline
00084 Pointset_Ask_Tell<PSET>::Pointset_Ask_Tell(const Congruence_System& cgs)
00085   : Base(Determinate<PSET>(cgs)), space_dim(cgs.space_dimension()) {
00086   PPL_ASSERT_HEAVY(OK());
00087 }
00088 
00089 template <typename PSET>
00090 inline Pointset_Ask_Tell<PSET>&
00091 Pointset_Ask_Tell<PSET>::operator=(const Pointset_Ask_Tell& y) {
00092   Pointset_Ask_Tell& x = *this;
00093   x.Base::operator=(y);
00094   x.space_dim = y.space_dim;
00095   return x;
00096 }
00097 
00098 template <typename PSET>
00099 inline void
00100 Pointset_Ask_Tell<PSET>::m_swap(Pointset_Ask_Tell& y) {
00101   Pointset_Ask_Tell& x = *this;
00102   x.Base::m_swap(y);
00103   using std::swap;
00104   swap(x.space_dim, y.space_dim);
00105 }
00106 
00107 template <typename PSET>
00108 template <typename QH>
00109 inline Pointset_Ask_Tell<PSET>&
00110 Pointset_Ask_Tell<PSET>::operator=(const Pointset_Ask_Tell<QH>& y) {
00111   Pointset_Ask_Tell& x = *this;
00112   Pointset_Ask_Tell<PSET> pps(y);
00113   swap(x, pps);
00114   return x;
00115 }
00116 
00117 template <typename PSET>
00118 inline void
00119 Pointset_Ask_Tell<PSET>::intersection_assign(const Pointset_Ask_Tell& y) {
00120   Pointset_Ask_Tell& x = *this;
00121   x.pairwise_apply_assign
00122     (y,
00123      Det_PSET::lift_op_assign(std::mem_fun_ref(&PSET::intersection_assign)));
00124 }
00125 
00126 template <typename PSET>
00127 inline void
00128 Pointset_Ask_Tell<PSET>::time_elapse_assign(const Pointset_Ask_Tell& y) {
00129   Pointset_Ask_Tell& x = *this;
00130   x.pairwise_apply_assign
00131     (y,
00132      Det_PSET::lift_op_assign(std::mem_fun_ref(&PSET::time_elapse_assign)));
00133 }
00134 
00135 template <typename PSET>
00136 inline bool
00137 Pointset_Ask_Tell<PSET>
00138 ::geometrically_covers(const Pointset_Ask_Tell& y) const {
00139   const Pointset_Ask_Tell<NNC_Polyhedron> xx(*this);
00140   const Pointset_Ask_Tell<NNC_Polyhedron> yy(y);
00141   return xx.geometrically_covers(yy);
00142 }
00143 
00144 template <typename PSET>
00145 inline bool
00146 Pointset_Ask_Tell<PSET>
00147 ::geometrically_equals(const Pointset_Ask_Tell& y) const {
00148   const Pointset_Ask_Tell<NNC_Polyhedron> xx(*this);
00149   const Pointset_Ask_Tell<NNC_Polyhedron> yy(y);
00150   return xx.geometrically_covers(yy) && yy.geometrically_covers(xx);
00151 }
00152 
00153 template <>
00154 inline bool
00155 Pointset_Ask_Tell<NNC_Polyhedron>
00156 ::geometrically_equals(const Pointset_Ask_Tell& y) const {
00157   const Pointset_Ask_Tell& x = *this;
00158   return x.geometrically_covers(y) && y.geometrically_covers(x);
00159 }
00160 
00161 template <typename PSET>
00162 inline memory_size_type
00163 Pointset_Ask_Tell<PSET>::external_memory_in_bytes() const {
00164   return Base::external_memory_in_bytes();
00165 }
00166 
00167 template <typename PSET>
00168 inline memory_size_type
00169 Pointset_Ask_Tell<PSET>::total_memory_in_bytes() const {
00170   return sizeof(*this) + external_memory_in_bytes();
00171 }
00172 
00173 template <typename PSET>
00174 inline int32_t
00175 Pointset_Ask_Tell<PSET>::hash_code() const {
00176   return hash_code_from_dimension(space_dimension());
00177 }
00178 
00179 template <>
00180 inline void
00181 Pointset_Ask_Tell<C_Polyhedron>
00182 ::poly_difference_assign(const Pointset_Ask_Tell& y) {
00183   Pointset_Ask_Tell<NNC_Polyhedron> nnc_this(*this);
00184   Pointset_Ask_Tell<NNC_Polyhedron> nnc_y(y);
00185   nnc_this.poly_difference_assign(nnc_y);
00186   *this = nnc_this;
00187 }
00188 
00190 template <typename PSET>
00191 inline bool
00192 check_containment(const PSET& ph, const Pointset_Ask_Tell<PSET>& ps) {
00193   const NNC_Polyhedron pph = NNC_Polyhedron(ph.constraints());
00194   const Pointset_Ask_Tell<NNC_Polyhedron> pps(ps);
00195   return check_containment(pph, pps);
00196 }
00197 
00199 template <>
00200 inline bool
00201 check_containment(const C_Polyhedron& ph,
00202                   const Pointset_Ask_Tell<C_Polyhedron>& ps) {
00203   return check_containment(NNC_Polyhedron(ph),
00204                            Pointset_Ask_Tell<NNC_Polyhedron>(ps));
00205 }
00206 
00208 template <typename PSET>
00209 inline void
00210 swap(Pointset_Ask_Tell<PSET>& x, Pointset_Ask_Tell<PSET>& y) {
00211   x.m_swap(y);
00212 }
00213 
00214 } // namespace Parma_Polyhedra_Library
00215 
00216 #endif // !defined(PPL_Pointset_Ask_Tell_inlines_hh)