PPL  1.2
Matrix_defs.hh
Go to the documentation of this file.
1 /* 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_Matrix_defs_hh
25 #define PPL_Matrix_defs_hh 1
26 
27 #include "Matrix_types.hh"
28 #include "globals_defs.hh"
29 #include "Coefficient_defs.hh"
30 #include "Swapping_Vector_defs.hh"
31 #include <ostream>
32 
33 #ifdef PPL_DOXYGEN_INCLUDE_IMPLEMENTATION_DETAILS
34 #endif // defined(PPL_DOXYGEN_INCLUDE_IMPLEMENTATION_DETAILS)
36 template <typename Row>
38 
39 public:
42 
45 
48 
58  explicit Matrix(dimension_type n = 0);
59 
73 
75 
82  void m_swap(Matrix& x);
83 
85 
88  dimension_type num_rows() const;
89 
91 
95 
96  // TODO: Check if this can be removed.
98  dimension_type capacity() const;
99 
101 
109  bool has_no_rows() const;
110 
112  void resize(dimension_type n);
113 
114  // TODO: Check if this can become private.
117 
119 
147 
149 
165 
167 
179 
181 
191  void add_row(const Row& x);
192 
194 
205  void add_recycled_row(Row& y);
206 
220 
221  void remove_rows(iterator first, iterator last);
222 
224 
253  void permute_columns(const std::vector<dimension_type>& cycles);
254 
257 
259 
270 
272 
291 
293 
309 
311 
327 
329  void clear();
330 
332 
335  iterator begin();
336 
338 
341  iterator end();
342 
344 
347  const_iterator begin() const;
348 
350 
353  const_iterator end() const;
354 
356 
362  Row& operator[](dimension_type i);
363 
365 
371  const Row& operator[](dimension_type i) const;
372 
374 
380  bool ascii_load(std::istream& s);
381 
383 
385 
390 
392 
397 
399  bool OK() const;
400 
401 private:
404 
407 };
408 
409 namespace Parma_Polyhedra_Library {
410 
411 #ifdef PPL_DOXYGEN_INCLUDE_IMPLEMENTATION_DETAILS
412 
413 #endif // defined(PPL_DOXYGEN_INCLUDE_IMPLEMENTATION_DETAILS)
414 template <typename Row>
415 void swap(Matrix<Row>& x, Matrix<Row>& y);
416 
417 #ifdef PPL_DOXYGEN_INCLUDE_IMPLEMENTATION_DETAILS
418 
420 #endif // defined(PPL_DOXYGEN_INCLUDE_IMPLEMENTATION_DETAILS)
421 template <typename Row>
422 bool operator==(const Matrix<Row>& x, const Matrix<Row>& y);
423 
424 #ifdef PPL_DOXYGEN_INCLUDE_IMPLEMENTATION_DETAILS
425 
427 #endif // defined(PPL_DOXYGEN_INCLUDE_IMPLEMENTATION_DETAILS)
428 template <typename Row>
429 bool operator!=(const Matrix<Row>& x, const Matrix<Row>& y);
430 
431 } // namespace Parma_Polyhedra_Library
432 
433 
434 #include "Matrix_inlines.hh"
435 #include "Matrix_templates.hh"
436 
437 #endif // !defined(PPL_Matrix_defs_hh)
bool operator!=(const Box< ITV > &x, const Box< ITV > &y)
Definition: Box_inlines.hh:264
memory_size_type external_memory_in_bytes() const
Returns the size in bytes of the memory managed by *this.
void swap(CO_Tree &x, CO_Tree &y)
void swap_columns(dimension_type i, dimension_type j)
Swaps the columns having indexes i and j.
size_t dimension_type
An unsigned integral type for representing space dimensions.
bool ascii_load(std::istream &s)
Loads the row from an ASCII representation generated using ascii_dump().
static dimension_type max_num_columns()
Returns the maximum number of columns of a Sparse_Matrix.
iterator end()
Returns an iterator pointing after the last row.
void remove_trailing_columns(dimension_type n)
Shrinks the matrix by removing its n trailing columns.
Matrix(dimension_type n=0)
Constructs a square matrix with the given size, filled with unstored zeroes.
Swapping_Vector< Row >::iterator iterator
Definition: Matrix_defs.hh:40
A sparse matrix of Coefficient.
Definition: Matrix_defs.hh:37
void permute_columns(const std::vector< dimension_type > &cycles)
Permutes the columns of the matrix.
Swapping_Vector< Row >::const_iterator const_iterator
Definition: Matrix_defs.hh:41
memory_size_type total_memory_in_bytes() const
Returns the total size in bytes of the memory occupied by *this.
void add_zero_rows_and_columns(dimension_type n, dimension_type m)
Adds n rows and m columns of zeroes to the matrix.
void add_zero_rows(dimension_type n)
Adds to the matrix n rows of zeroes.
void clear()
Equivalent to resize(0,0).
#define PPL_OUTPUT_DECLARATIONS
void remove_rows(iterator first, iterator last)
iterator begin()
Returns an iterator pointing to the first row.
void add_row(const Row &x)
Adds a copy of the row x at the end of the matrix.
dimension_type num_columns() const
Returns the number of columns in the matrix.
bool has_no_rows() const
Returns true if and only if *this has no rows.
void remove_trailing_rows(dimension_type n)
Removes from the matrix the last n rows.
dimension_type num_columns_
The number of columns in this matrix.
Definition: Matrix_defs.hh:406
static dimension_type max_num_rows()
Returns the maximum number of rows of a Sparse_Matrix.
The entire library is confined to this namespace.
Definition: version.hh:61
Swapping_Vector< Row > rows
The vector that stores the matrix's elements.
Definition: Matrix_defs.hh:403
Row & operator[](dimension_type i)
Returns a reference to the i-th row.
dimension_type capacity() const
Returns the capacity of the row vector.
void reserve_rows(dimension_type n)
Reserves space for at least n rows.
void add_recycled_row(Row &y)
Adds the row y to the matrix.
void resize(dimension_type n)
Equivalent to resize(n, n).
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 OK() const
Checks if all the invariants are satisfied.
void remove_column(dimension_type i)
Removes the i-th from the matrix, shifting other columns to the left.
void add_zero_columns(dimension_type n)
Adds n columns of zeroes to the matrix.
dimension_type num_rows() const
Returns the number of rows in the matrix.
void m_swap(Matrix &x)
Swaps (*this) with x.