PPL  1.2
Dense_Row_defs.hh
Go to the documentation of this file.
1 /* Dense_Row class declaration.
2  Copyright (C) 2001-2010 Roberto Bagnara <bagnara@cs.unipr.it>
3  Copyright (C) 2010-2016 BUGSENG srl (http://bugseng.com)
4 
5 This file is part of the Parma Polyhedra Library (PPL).
6 
7 The PPL is free software; you can redistribute it and/or modify it
8 under the terms of the GNU General Public License as published by the
9 Free Software Foundation; either version 3 of the License, or (at your
10 option) any later version.
11 
12 The PPL is distributed in the hope that it will be useful, but WITHOUT
13 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
14 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
15 for more details.
16 
17 You should have received a copy of the GNU General Public License
18 along with this program; if not, write to the Free Software Foundation,
19 Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1307, USA.
20 
21 For the most up-to-date information see the Parma Polyhedra Library
22 site: http://bugseng.com/products/ppl/ . */
23 
24 #ifndef PPL_Dense_Row_defs_hh
25 #define PPL_Dense_Row_defs_hh 1
26 
27 #include "Dense_Row_types.hh"
28 
29 #include "globals_defs.hh"
30 
31 #include "Sparse_Row_types.hh"
32 #include "Coefficient_defs.hh"
33 #include <memory>
34 #include <vector>
35 #include <limits>
36 #include <cstddef>
37 
38 #ifdef PPL_DOXYGEN_INCLUDE_IMPLEMENTATION_DETAILS
39 
41 #endif // defined(PPL_DOXYGEN_INCLUDE_IMPLEMENTATION_DETAILS)
43 public:
44  class iterator;
45  class const_iterator;
46 
48  Dense_Row();
49 
50  explicit Dense_Row(const Sparse_Row& row);
51 
53 
57 
59 
70 
72  Dense_Row(const Dense_Row& y);
73 
75 
79  Dense_Row(const Dense_Row& y, dimension_type capacity);
80 
82 
85  Dense_Row(const Dense_Row& y, dimension_type sz, dimension_type capacity);
86 
88 
91  Dense_Row(const Sparse_Row& y, dimension_type sz, dimension_type capacity);
92 
94  ~Dense_Row();
95 
97  Dense_Row& operator=(const Dense_Row& y);
98 
100  Dense_Row& operator=(const Sparse_Row& y);
101 
103  void m_swap(Dense_Row& y);
104 
106  void resize(dimension_type sz);
107 
109  void resize(dimension_type sz, dimension_type capacity);
110 
112  void clear();
113 
115 
128 
130 
136  void expand_within_capacity(dimension_type new_size);
137 
139 
144  void shrink(dimension_type new_size);
145 
147  static dimension_type max_size();
148 
150  dimension_type size() const;
151 
153 
156 
158  Coefficient_traits::const_reference operator[](dimension_type k) const;
160 
162 
166  void normalize();
167 
171 
175 
176  iterator begin();
177  const_iterator begin() const;
178 
179  iterator end();
180  const_iterator end() const;
181 
184  void reset(dimension_type i);
185 
188  void reset(dimension_type first, dimension_type last);
189 
192  iterator reset(iterator itr);
193 
196  Coefficient_traits::const_reference get(dimension_type i) const;
197 
200 
203 
206 
209 
212 
215 
218 
221 
223  iterator insert(dimension_type i, Coefficient_traits::const_reference x);
224 
227 
230  Coefficient_traits::const_reference x);
231 
234 
236 
258  template <typename Func1, typename Func2>
259  void combine_needs_first(const Dense_Row& y,
260  const Func1& f, const Func2& g);
261 
263 
286  template <typename Func1, typename Func2>
287  void combine_needs_second(const Dense_Row& y,
288  const Func1& g, const Func2& h);
289 
291 
318  template <typename Func1, typename Func2, typename Func3>
319  void combine(const Dense_Row& y,
320  const Func1& f, const Func2& g, const Func3& h);
321 
324 
342  void linear_combine(const Dense_Row& y,
343  Coefficient_traits::const_reference coeff1,
344  Coefficient_traits::const_reference coeff2);
345 
348 
354  void linear_combine(const Dense_Row& y,
355  Coefficient_traits::const_reference c1,
356  Coefficient_traits::const_reference c2,
357  dimension_type start, dimension_type end);
358 
360 
366  bool ascii_load(std::istream& s);
367 
373 
379 
385 
391 
393  bool OK() const;
394 
399  bool OK(dimension_type row_size) const;
400 
401 private:
402  void init(const Sparse_Row& row);
403 
404  void destroy();
405 
406  struct Impl {
407 
408  Impl();
409 
410  ~Impl();
411 
414 
417 
419  std::allocator<Coefficient> coeff_allocator;
420 
424  };
425 
427 
429  dimension_type capacity() const;
430 };
431 
433 public:
434 
435  typedef std::bidirectional_iterator_tag iterator_category;
437  typedef std::ptrdiff_t difference_type;
438  typedef value_type* pointer;
439  typedef value_type& reference;
440 
441  iterator();
443 
445  Coefficient_traits::const_reference operator*() const;
446 
448 
454  dimension_type index() const;
455 
456  iterator& operator++();
457  iterator operator++(int);
458 
459  iterator& operator--();
460  iterator operator--(int);
461 
462  bool operator==(const iterator& x) const;
463  bool operator!=(const iterator& x) const;
464 
465  operator const_iterator() const;
466 
467  bool OK() const;
468 
469 private:
472 };
473 
475 public:
476 
477  typedef const Coefficient value_type;
478  typedef std::ptrdiff_t difference_type;
479  typedef value_type* pointer;
480  typedef Coefficient_traits::const_reference reference;
481 
482  const_iterator();
484 
485  Coefficient_traits::const_reference operator*() const;
486 
488 
494  dimension_type index() const;
495 
498 
501 
502  bool operator==(const const_iterator& x) const;
503  bool operator!=(const const_iterator& x) const;
504 
505  bool OK() const;
506 
507 private:
508  const Dense_Row* row;
510 };
511 
512 
513 namespace Parma_Polyhedra_Library {
514 
515 #ifdef PPL_DOXYGEN_INCLUDE_IMPLEMENTATION_DETAILS
516 
518 #endif // defined(PPL_DOXYGEN_INCLUDE_IMPLEMENTATION_DETAILS)
519 void swap(Dense_Row& x, Dense_Row& y);
520 
521 #ifdef PPL_DOXYGEN_INCLUDE_IMPLEMENTATION_DETAILS
522 
524 #endif // defined(PPL_DOXYGEN_INCLUDE_IMPLEMENTATION_DETAILS)
525 void iter_swap(std::vector<Dense_Row>::iterator x,
526  std::vector<Dense_Row>::iterator y);
527 
528 #ifdef PPL_DOXYGEN_INCLUDE_IMPLEMENTATION_DETAILS
529 
531 #endif // defined(PPL_DOXYGEN_INCLUDE_IMPLEMENTATION_DETAILS)
532 bool operator==(const Dense_Row& x, const Dense_Row& y);
533 
534 #ifdef PPL_DOXYGEN_INCLUDE_IMPLEMENTATION_DETAILS
535 
537 #endif // defined(PPL_DOXYGEN_INCLUDE_IMPLEMENTATION_DETAILS)
538 bool operator!=(const Dense_Row& x, const Dense_Row& y);
539 
540 #ifdef PPL_DOXYGEN_INCLUDE_IMPLEMENTATION_DETAILS
541 
542 #endif // defined(PPL_DOXYGEN_INCLUDE_IMPLEMENTATION_DETAILS)
543 void linear_combine(Dense_Row& x, const Dense_Row& y,
544  Coefficient_traits::const_reference coeff1,
545  Coefficient_traits::const_reference coeff2);
546 
547 #ifdef PPL_DOXYGEN_INCLUDE_IMPLEMENTATION_DETAILS
548 
551 #endif // defined(PPL_DOXYGEN_INCLUDE_IMPLEMENTATION_DETAILS)
552 void linear_combine(Dense_Row& x, const Dense_Row& y,
553  Coefficient_traits::const_reference c1,
554  Coefficient_traits::const_reference c2,
555  dimension_type start, dimension_type end);
556 
557 } // namespace Parma_Polyhedra_Library
558 
559 #include "Dense_Row_inlines.hh"
560 #include "Dense_Row_templates.hh"
561 
562 #endif // !defined(PPL_Dense_Row_defs_hh)
bool operator!=(const Box< ITV > &x, const Box< ITV > &y)
Definition: Box_inlines.hh:264
void swap(CO_Tree &x, CO_Tree &y)
A finite sequence of coefficients.
memory_size_type external_memory_in_bytes() const
Returns a lower bound to the size in bytes of the memory managed by *this.
Definition: Dense_Row.cc:519
Dense_Row & operator=(const Dense_Row &y)
Assignment operator.
size_t dimension_type
An unsigned integral type for representing space dimensions.
void normalize()
Normalizes the modulo of coefficients so that they are mutually prime.
Definition: Dense_Row.cc:329
void linear_combine(Dense_Row &x, const Dense_Row &y, Coefficient_traits::const_reference coeff1, Coefficient_traits::const_reference coeff2)
std::allocator< Coefficient > coeff_allocator
The allocator used to allocate/deallocate vec.
void combine(const Dense_Row &y, const Func1 &f, const Func2 &g, const Func3 &h)
Calls g(x[i],y[i]), for each i.
void linear_combine(const Dense_Row &y, Coefficient_traits::const_reference coeff1, Coefficient_traits::const_reference coeff2)
Definition: Dense_Row.cc:389
Dense_Row()
Constructs an empty row.
void swap_coefficients(dimension_type i, dimension_type j)
A finite sparse sequence of coefficients.
Coefficient_traits::const_reference reference
memory_size_type total_memory_in_bytes() const
Returns a lower bound to the total size in bytes of the memory occupied by *this. ...
Coefficient_traits::const_reference operator*() const
dimension_type size() const
Gives the number of coefficients currently in use.
#define PPL_OUTPUT_DECLARATIONS
dimension_type size
The number of coefficients in the row.
Coefficient & operator[](dimension_type k)
Returns a reference to the element of the row indexed by k.
static dimension_type max_size()
Returns the size() of the largest possible Dense_Row.
void add_zeroes_and_shift(dimension_type n, dimension_type i)
Adds n zeroes before index i.
Definition: Dense_Row.cc:140
dimension_type index() const
Returns the index of the element pointed to by *this.
bool operator==(const const_iterator &x) const
void m_swap(Dense_Row &y)
Swaps *this with y.
void clear()
Resets all the elements of this row.
Definition: Dense_Row.cc:133
dimension_type index() const
Returns the index of the element pointed to by *this.
PPL_COEFFICIENT_TYPE Coefficient
An alias for easily naming the type of PPL coefficients.
iterator find(dimension_type i)
Provided for compatibility with Sparse_Row.
void expand_within_capacity(dimension_type new_size)
Expands the row to size new_size.
Definition: Dense_Row.cc:213
void init(const Sparse_Row &row)
Definition: Dense_Row.cc:250
void shrink(dimension_type new_size)
Shrinks the row by erasing elements at the end.
Definition: Dense_Row.cc:225
bool OK() const
Checks if all the invariants are satisfied.
Definition: Dense_Row.cc:528
The entire library is confined to this namespace.
Definition: version.hh:61
std::bidirectional_iterator_tag iterator_category
iterator lower_bound(dimension_type i)
Provided for compatibility with Sparse_Row.
void combine_needs_first(const Dense_Row &y, const Func1 &f, const Func2 &g)
Calls g(x[i],y[i]), for each i.
void combine_needs_second(const Dense_Row &y, const Func1 &g, const Func2 &h)
Calls g(x[i],y[i]), for each i.
void resize(dimension_type sz)
Resizes the row to sz.
Definition: Dense_Row.cc:45
dimension_type capacity
The capacity of the row.
iterator insert(dimension_type i, Coefficient_traits::const_reference x)
Provided for compatibility with Sparse_Row.
dimension_type capacity() const
Returns the capacity of the row.
bool operator==(const Box< ITV > &x, const Box< ITV > &y)
size_t memory_size_type
An unsigned integral type for representing memory size in bytes.
bool ascii_load(std::istream &s)
Loads from s an ASCII representation (as produced by ascii_dump(std::ostream&) const) and sets *this ...
Definition: Dense_Row.cc:492
bool operator!=(const const_iterator &x) const