PPL  0.12.1
Linear_Row.defs.hh
Go to the documentation of this file.
00001 /* Linear_Row class declaration.
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_Linear_Row_defs_hh
00025 #define PPL_Linear_Row_defs_hh 1
00026 
00027 #include "Linear_Row.types.hh"
00028 #include "globals.defs.hh"
00029 #include "Dense_Row.defs.hh"
00030 #include "Topology.types.hh"
00031 #include "Linear_Expression.types.hh"
00032 #include "Constraint.types.hh"
00033 #include "Generator.types.hh"
00034 
00035 #ifdef PPL_DOXYGEN_INCLUDE_IMPLEMENTATION_DETAILS
00036 
00037 
00123 #endif // defined(PPL_DOXYGEN_INCLUDE_IMPLEMENTATION_DETAILS)
00124 
00125 class Parma_Polyhedra_Library::Linear_Row : public Dense_Row {
00126 public:
00128   enum Kind {
00129     LINE_OR_EQUALITY = 0,
00130     RAY_OR_POINT_OR_INEQUALITY = 1
00131   };
00132 
00133 #ifdef PPL_DOXYGEN_INCLUDE_IMPLEMENTATION_DETAILS
00134 
00143 #endif // defined(PPL_DOXYGEN_INCLUDE_IMPLEMENTATION_DETAILS)
00144   class Flags : public Dense_Row::Flags {
00145   public:
00147     Flags();
00148 
00150     explicit Flags(Topology t);
00151 
00153     Flags(Topology t, Kind k);
00154 
00156 
00157     Topology topology() const;
00158     bool is_necessarily_closed() const;
00159     bool is_not_necessarily_closed() const;
00160     bool is_line_or_equality() const;
00161     bool is_ray_or_point_or_inequality() const;
00162 
00163     void set_necessarily_closed();
00164     void set_not_necessarily_closed();
00165     void set_is_line_or_equality();
00166     void set_is_ray_or_point_or_inequality();
00168 
00170     bool operator==(const Flags& y) const;
00171 
00176     bool operator!=(const Flags& y) const;
00177 
00178     PPL_OUTPUT_DECLARATIONS
00179 
00185     bool ascii_load(std::istream& s);
00186 
00187   private:
00189     explicit Flags(base_type mask);
00190 
00192     explicit Flags(Dense_Row::Flags flags);
00193 
00195 
00196     // NB: ascii_load assumes that these are sequential.
00197     static const unsigned rpi_validity_bit
00198     = Dense_Row::Flags::first_free_bit + 0;
00199     static const unsigned rpi_bit
00200     = Dense_Row::Flags::first_free_bit + 1;
00201     static const unsigned nnc_validity_bit
00202     = Dense_Row::Flags::first_free_bit + 2;
00203     static const unsigned nnc_bit
00204     = Dense_Row::Flags::first_free_bit + 3;
00206 
00207   protected:
00209     static const unsigned first_free_bit
00210     = Dense_Row::Flags::first_free_bit + 4;
00211 
00212     friend class Parma_Polyhedra_Library::Linear_Row;
00213   };
00214 
00216   Linear_Row();
00217 
00219   Linear_Row(dimension_type sz, Flags f);
00220 
00222   Linear_Row(dimension_type sz, dimension_type capacity, Flags f);
00223 
00225   Linear_Row(const Linear_Row& y);
00226 
00228 
00231   Linear_Row(const Linear_Row& y, dimension_type capacity);
00232 
00234 
00238   Linear_Row(const Linear_Row& y, dimension_type sz, dimension_type capacity);
00239 
00241   ~Linear_Row();
00242 
00244 
00245 
00246   const Flags flags() const;
00247 
00249   void set_flags(Flags f);
00250 
00252   Topology topology() const;
00253 
00258   bool is_not_necessarily_closed() const;
00259 
00264   bool is_necessarily_closed() const;
00265 
00270   bool is_line_or_equality() const;
00271 
00276   bool is_ray_or_point_or_inequality() const;
00278 
00280 
00281 
00282   void set_necessarily_closed();
00283 
00285   void set_not_necessarily_closed();
00286 
00288   void set_is_line_or_equality();
00289 
00291   void set_is_ray_or_point_or_inequality();
00293 
00295   static dimension_type max_space_dimension();
00296 
00298   dimension_type space_dimension() const;
00299 
00301   Coefficient_traits::const_reference inhomogeneous_term() const;
00302 
00304   Coefficient_traits::const_reference coefficient(dimension_type n) const;
00305 
00310   void sign_normalize();
00311 
00318   void strong_normalize();
00319 
00324   bool check_strong_normalized() const;
00325 
00327 
00338   void linear_combine(const Linear_Row& y, dimension_type k);
00339 
00344   bool is_zero() const;
00345 
00350   bool all_homogeneous_terms_are_zero() const;
00351 
00352   PPL_OUTPUT_DECLARATIONS
00353 
00359   bool ascii_load(std::istream& s);
00360 
00362   bool OK() const;
00363 
00368   bool OK(dimension_type row_size, dimension_type row_capacity) const;
00369 
00370 private:
00371   friend class Parma_Polyhedra_Library::Linear_Expression;
00372   friend class Parma_Polyhedra_Library::Constraint;
00373   friend class Parma_Polyhedra_Library::Generator;
00374 };
00375 
00376 namespace Parma_Polyhedra_Library {
00377 
00378 #ifdef PPL_DOXYGEN_INCLUDE_IMPLEMENTATION_DETAILS
00379 
00380 
00381 #endif // defined(PPL_DOXYGEN_INCLUDE_IMPLEMENTATION_DETAILS)
00382 void swap(Linear_Row& x, Linear_Row& y);
00383 
00384 #ifdef PPL_DOXYGEN_INCLUDE_IMPLEMENTATION_DETAILS
00385 
00386 
00387 #endif // defined(PPL_DOXYGEN_INCLUDE_IMPLEMENTATION_DETAILS)
00388 void iter_swap(std::vector<Linear_Row>::iterator x,
00389                std::vector<Linear_Row>::iterator y);
00390 
00392 
00393 bool operator==(const Linear_Row& x, const Linear_Row& y);
00394 
00396 
00397 bool operator!=(const Linear_Row& x, const Linear_Row& y);
00398 
00399 #ifdef PPL_DOXYGEN_INCLUDE_IMPLEMENTATION_DETAILS
00400 
00401 
00435 #endif // defined(PPL_DOXYGEN_INCLUDE_IMPLEMENTATION_DETAILS)
00436 int compare(const Linear_Row& x, const Linear_Row& y);
00437 
00438 } // namespace Parma_Polyhedra_Library
00439 
00440 #include "Linear_Row.inlines.hh"
00441 
00442 #endif // !defined(PPL_Linear_Row_defs_hh)