PPL  1.2
DB_Matrix_defs.hh
Go to the documentation of this file.
1 /* DB_Matrix 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_DB_Matrix_defs_hh
25 #define PPL_DB_Matrix_defs_hh 1
26 
27 #include "DB_Matrix_types.hh"
28 #include "globals_defs.hh"
29 #include "DB_Row_defs.hh"
30 #include "Checked_Number_types.hh"
31 #include "Rounding_Dir_defs.hh"
32 #include <vector>
33 #include <cstddef>
34 #include <iosfwd>
35 
36 namespace Parma_Polyhedra_Library {
37 
38 namespace IO_Operators {
39 
40 #ifdef PPL_DOXYGEN_INCLUDE_IMPLEMENTATION_DETAILS
41 
43 #endif // defined(PPL_DOXYGEN_INCLUDE_IMPLEMENTATION_DETAILS)
44 template <typename T>
45 std::ostream&
46 operator<<(std::ostream& s, const DB_Matrix<T>& c);
47 
48 } // namespace IO_Operators
49 
50 } // namespace Parma_Polyhedra_Library
51 
52 
53 #ifdef PPL_DOXYGEN_INCLUDE_IMPLEMENTATION_DETAILS
54 
60 #endif // defined(PPL_DOXYGEN_INCLUDE_IMPLEMENTATION_DETAILS)
61 template <typename T>
63 public:
66 
69 
71 
74  DB_Matrix();
75 
77  explicit DB_Matrix(dimension_type n_rows);
78 
80  DB_Matrix(const DB_Matrix& y);
81 
83  template <typename U>
84  explicit DB_Matrix(const DB_Matrix<U>& y);
85 
87  ~DB_Matrix();
88 
90  DB_Matrix& operator=(const DB_Matrix& y);
91 
92 #ifdef PPL_DOXYGEN_INCLUDE_IMPLEMENTATION_DETAILS
93 
95 #endif // defined(PPL_DOXYGEN_INCLUDE_IMPLEMENTATION_DETAILS)
97  private:
98  typedef typename std::vector<DB_Row<T> >::const_iterator Iter;
100  Iter i;
101 
102  public:
103  typedef std::forward_iterator_tag iterator_category;
104  typedef typename std::iterator_traits<Iter>::value_type value_type;
105  typedef typename std::iterator_traits<Iter>::difference_type
107  typedef typename std::iterator_traits<Iter>::pointer pointer;
108  typedef typename std::iterator_traits<Iter>::reference reference;
109 
111  const_iterator();
112 
117  explicit const_iterator(const Iter& b);
118 
120  const_iterator(const const_iterator& y);
121 
124 
126  reference operator*() const;
127 
129  pointer operator->() const;
130 
133 
136 
141  bool operator==(const const_iterator& y) const;
142 
147  bool operator!=(const const_iterator& y) const;
148  };
149 
155  const_iterator begin() const;
156 
158  const_iterator end() const;
159 
160 private:
161  template <typename U> friend class DB_Matrix;
162 
164  std::vector<DB_Row<T> > rows;
165 
168 
174 
175 public:
177  void m_swap(DB_Matrix& y);
178 
180 
188  void grow(dimension_type new_n_rows);
189 
191 
198  void resize_no_copy(dimension_type new_n_rows);
199 
201  dimension_type num_rows() const;
202 
204 
207 
209  const DB_Row<T>& operator[](dimension_type k) const;
211 
213 
219  bool ascii_load(std::istream& s);
220 
223 
226 
228  bool OK() const;
229 };
230 
231 namespace Parma_Polyhedra_Library {
232 
233 #ifdef PPL_DOXYGEN_INCLUDE_IMPLEMENTATION_DETAILS
234 
236 #endif // defined(PPL_DOXYGEN_INCLUDE_IMPLEMENTATION_DETAILS)
237 template <typename T>
238 void swap(DB_Matrix<T>& x, DB_Matrix<T>& y);
239 
240 #ifdef PPL_DOXYGEN_INCLUDE_IMPLEMENTATION_DETAILS
241 
243 #endif // defined(PPL_DOXYGEN_INCLUDE_IMPLEMENTATION_DETAILS)
244 template <typename T>
245 bool operator==(const DB_Matrix<T>& x, const DB_Matrix<T>& y);
246 
247 #ifdef PPL_DOXYGEN_INCLUDE_IMPLEMENTATION_DETAILS
248 
250 #endif // defined(PPL_DOXYGEN_INCLUDE_IMPLEMENTATION_DETAILS)
251 template <typename T>
252 bool operator!=(const DB_Matrix<T>& x, const DB_Matrix<T>& y);
253 
254 #ifdef PPL_DOXYGEN_INCLUDE_IMPLEMENTATION_DETAILS
255 
266 #endif // defined(PPL_DOXYGEN_INCLUDE_IMPLEMENTATION_DETAILS)
267 template <typename Temp, typename To, typename T>
268 bool rectilinear_distance_assign(Checked_Number<To, Extended_Number_Policy>& r,
269  const DB_Matrix<T>& x,
270  const DB_Matrix<T>& y,
271  Rounding_Dir dir,
272  Temp& tmp0,
273  Temp& tmp1,
274  Temp& tmp2);
275 
276 #ifdef PPL_DOXYGEN_INCLUDE_IMPLEMENTATION_DETAILS
277 
288 #endif // defined(PPL_DOXYGEN_INCLUDE_IMPLEMENTATION_DETAILS)
289 template <typename Temp, typename To, typename T>
290 bool euclidean_distance_assign(Checked_Number<To, Extended_Number_Policy>& r,
291  const DB_Matrix<T>& x,
292  const DB_Matrix<T>& y,
293  Rounding_Dir dir,
294  Temp& tmp0,
295  Temp& tmp1,
296  Temp& tmp2);
297 
298 #ifdef PPL_DOXYGEN_INCLUDE_IMPLEMENTATION_DETAILS
299 
310 #endif // defined(PPL_DOXYGEN_INCLUDE_IMPLEMENTATION_DETAILS)
311 template <typename Temp, typename To, typename T>
312 bool l_infinity_distance_assign(Checked_Number<To, Extended_Number_Policy>& r,
313  const DB_Matrix<T>& x,
314  const DB_Matrix<T>& y,
315  Rounding_Dir dir,
316  Temp& tmp0,
317  Temp& tmp1,
318  Temp& tmp2);
319 
320 } // namespace Parma_Polyhedra_Library
321 
322 #include "DB_Matrix_inlines.hh"
323 #include "DB_Matrix_templates.hh"
324 
325 #endif // !defined(PPL_DB_Matrix_defs_hh)
bool operator!=(const const_iterator &y) const
Returns true if and only if *this and y are different.
bool operator!=(const Box< ITV > &x, const Box< ITV > &y)
Definition: Box_inlines.hh:264
A read-only iterator over the rows of the matrix.
void swap(CO_Tree &x, CO_Tree &y)
size_t dimension_type
An unsigned integral type for representing space dimensions.
Iter i
The const iterator on the rows' vector rows.
memory_size_type external_memory_in_bytes() const
Returns the size in bytes of the memory managed by *this.
std::vector< DB_Row< T > >::const_iterator Iter
Rounding_Dir
Rounding directions for arithmetic computations.
std::iterator_traits< Iter >::difference_type difference_type
const_iterator end() const
Returns the past-the-end const_iterator.
std::vector< DB_Row< T > > rows
The rows of the matrix.
reference operator*() const
Dereference operator.
const_iterator & operator=(const const_iterator &y)
Assignment operator.
void grow(dimension_type new_n_rows)
Makes the matrix grow by adding more rows and more columns.
DB_Matrix()
Builds an empty matrix.
DB_Matrix & operator=(const DB_Matrix &y)
Assignment operator.
const_iterator begin() const
Returns the const_iterator pointing to the first row, if *this is not empty; otherwise, returns the past-the-end const_iterator.
void resize_no_copy(dimension_type new_n_rows)
Resizes the matrix without worrying about the old contents.
The base class for the single rows of matrices.
Definition: DB_Row_defs.hh:120
bool OK() const
Checks if all the invariants are satisfied.
A wrapper for numeric types implementing a given policy.
#define PPL_OUTPUT_DECLARATIONS
static dimension_type max_num_rows()
Returns the maximum number of rows a DB_Matrix can handle.
dimension_type row_size
Size of the initialized part of each row.
std::iterator_traits< Iter >::pointer pointer
DB_Row< T > & operator[](dimension_type k)
Returns a reference to the k-th row of the matrix.
const_iterator & operator++()
Prefix increment operator.
bool operator==(const const_iterator &y) const
Returns true if and only if *this and y are identical.
bool ascii_load(std::istream &s)
Loads from s an ASCII representation (as produced by ascii_dump(std::ostream&) const) and sets *this ...
dimension_type num_rows() const
Returns the number of rows in the matrix.
dimension_type row_capacity
Capacity allocated for each row, i.e., number of long objects that each row can contain.
std::iterator_traits< Iter >::value_type value_type
void m_swap(DB_Matrix &y)
Swaps *this with y.
The entire library is confined to this namespace.
Definition: version.hh:61
static dimension_type max_num_columns()
Returns the maximum number of columns a DB_Matrix can handle.
pointer operator->() const
Indirect member selector.
memory_size_type total_memory_in_bytes() const
Returns the total size in bytes of the memory occupied by *this.
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.
Coefficient c
Definition: PIP_Tree.cc:64
The base class for the square matrices.
std::iterator_traits< Iter >::reference reference