#include <OR_Matrix.defs.hh>
Public Types | |
typedef Pseudo_Row< T > | row_reference_type |
A (non const) reference to a matrix's row. | |
typedef Pseudo_Row< const T > | const_row_reference_type |
A const reference to a matrix's row. | |
typedef any_row_iterator< T > | row_iterator |
A (non const) row iterator. | |
typedef any_row_iterator< const T > | const_row_iterator |
A const row iterator. | |
typedef DB_Row< T >::iterator | element_iterator |
A (non const) element iterator. | |
typedef DB_Row< T >::const_iterator | const_element_iterator |
A const element iterator. | |
Public Member Functions | |
OR_Matrix (dimension_type space_dim) | |
Builds a matrix with specified dimensions. | |
OR_Matrix (const OR_Matrix &y) | |
Copy-constructor. | |
template<typename U> | |
OR_Matrix (const OR_Matrix< U > &y) | |
Constructs a conservative approximation of y . | |
~OR_Matrix () | |
Destructor. | |
OR_Matrix & | operator= (const OR_Matrix &y) |
Assignment operator. | |
void | swap (OR_Matrix &y) |
Swaps *this with y . | |
void | grow (dimension_type new_dim) |
Makes the matrix grow by adding more space dimensions. | |
void | shrink (dimension_type new_dim) |
Makes the matrix shrink by removing the last space dimensions. | |
void | resize_no_copy (dimension_type new_dim) |
Resizes the matrix without worrying about the old contents. | |
dimension_type | space_dimension () const |
Returns the space-dimension of the matrix. | |
dimension_type | num_rows () const |
Returns the number of rows in the matrix. | |
row_iterator | row_begin () |
Returns an iterator pointing to the first row, if *this is not empty; otherwise, returns the past-the-end const_iterator. | |
row_iterator | row_end () |
Returns the past-the-end const_iterator. | |
const_row_iterator | row_begin () const |
Returns a const row iterator pointing to the first row, if *this is not empty; otherwise, returns the past-the-end const_iterator. | |
const_row_iterator | row_end () const |
Returns the past-the-end const row iterator. | |
element_iterator | element_begin () |
Returns an iterator pointing to the first element, if *this is not empty; otherwise, returns the past-the-end const_iterator. | |
element_iterator | element_end () |
Returns the past-the-end const_iterator. | |
const_element_iterator | element_begin () const |
Returns a const element iterator pointing to the first element, if *this is not empty; otherwise, returns the past-the-end const_iterator. | |
const_element_iterator | element_end () const |
Returns the past-the-end const element iterator. | |
void | clear () |
Clears the matrix deallocating all its rows. | |
void | ascii_dump () const |
Writes to std::cerr an ASCII representation of *this . | |
void | ascii_dump (std::ostream &s) const |
Writes to s an ASCII representation of *this . | |
void | print () const |
Prints *this to std::cerr using operator<< . | |
bool | ascii_load (std::istream &s) |
Loads from s an ASCII representation (as produced by ascii_dump(std::ostream&) const) and sets *this accordingly. Returns true if successful, false otherwise. | |
memory_size_type | total_memory_in_bytes () const |
Returns the total size in bytes of the memory occupied by *this . | |
memory_size_type | external_memory_in_bytes () const |
Returns the size in bytes of the memory managed by *this . | |
bool | OK () const |
Checks if all the invariants are satisfied. | |
Subscript operators. | |
row_reference_type | operator[] (dimension_type k) |
Returns a reference to the k-th row of the matrix. | |
const_row_reference_type | operator[] (dimension_type k) const |
Returns a constant reference to the k-th row of the matrix. | |
Static Public Member Functions | |
static dimension_type | max_num_rows () |
Returns the maximum number of rows of a OR_Matrix. | |
static dimension_type | row_size (dimension_type k) |
Returns the size of the row of index k . | |
Private Member Functions | |
OR_Matrix () | |
Private and not implemented: default construction is not allowed. | |
Static Private Member Functions | |
static dimension_type | row_first_element_index (dimension_type k) |
Returns the index into vec of the first element of the row of index k . | |
Private Attributes | |
DB_Row< T > | vec |
Contains the rows of the matrix. | |
dimension_type | space_dim |
Contains the dimension of the space of the matrix. | |
dimension_type | vec_capacity |
Contains the capacity of vec . | |
Friends | |
class | OR_Matrix |
bool | operator== (const OR_Matrix< T > &x, const OR_Matrix< T > &y) |
Returns true if and only if x and y are identical. | |
Related Functions | |
(Note that these are not member functions.) | |
template<typename T> | |
std::ostream & | operator<< (std::ostream &s, const OR_Matrix< T > &m) |
Output operator. | |
template<typename T> | |
void | swap (Parma_Polyhedra_Library::OR_Matrix< T > &x, Parma_Polyhedra_Library::OR_Matrix< T > &y) |
Specializes std::swap . | |
template<typename T> | |
bool | operator!= (const OR_Matrix< T > &x, const OR_Matrix< T > &y) |
Returns true if and only if x and y are different. | |
template<typename Temp, typename To, typename T> | |
bool | rectilinear_distance_assign (Checked_Number< To, Extended_Number_Policy > &r, const OR_Matrix< T > &x, const OR_Matrix< T > &y, Rounding_Dir dir, Temp &tmp0, Temp &tmp1, Temp &tmp2) |
Computes the rectilinear (or Manhattan) distance between x and y . | |
template<typename Temp, typename To, typename T> | |
bool | euclidean_distance_assign (Checked_Number< To, Extended_Number_Policy > &r, const OR_Matrix< T > &x, const OR_Matrix< T > &y, Rounding_Dir dir, Temp &tmp0, Temp &tmp1, Temp &tmp2) |
Computes the euclidean distance between x and y . | |
template<typename Temp, typename To, typename T> | |
bool | l_infinity_distance_assign (Checked_Number< To, Extended_Number_Policy > &r, const OR_Matrix< T > &x, const OR_Matrix< T > &y, Rounding_Dir dir, Temp &tmp0, Temp &tmp1, Temp &tmp2) |
Computes the ![]() x and y . | |
template<typename Specialization, typename Temp, typename To, typename T> | |
bool | l_m_distance_assign (Checked_Number< To, Extended_Number_Policy > &r, const OR_Matrix< T > &x, const OR_Matrix< T > &y, const Rounding_Dir dir, Temp &tmp0, Temp &tmp1, Temp &tmp2) |
Classes | |
class | any_row_iterator |
A template class to derive both OR_Matrix::iterator and OR_Matrix::const_iterator. More... | |
class | Pseudo_Row |
An object that behaves like a matrix's row with respect to the subscript operators. More... |
An OR_Matrix object is a DB_Row object that allows the representation of a pseudo-triangular matrix, like the following:
_ _ 0 |_|_| 1 |_|_|_ _ 2 |_|_|_|_| 3 |_|_|_|_|_ _ 4 |_|_|_|_|_|_| 5 |_|_|_|_|_|_| . . . _ _ _ _ _ _ _ 2n-2 |_|_|_|_|_|_| ... |_| 2n-1 |_|_|_|_|_|_| ... |_| 0 1 2 3 4 5 ... 2n-1
It is characterized by parameter n that defines the structure, and such that there are 2*n rows (and 2*n columns). It provides row_iterators for the access to the rows and element_iterators for the access to the elements.
Definition at line 105 of file OR_Matrix.defs.hh.
typedef Pseudo_Row<T> Parma_Polyhedra_Library::OR_Matrix< T >::row_reference_type |
typedef Pseudo_Row<const T> Parma_Polyhedra_Library::OR_Matrix< T >::const_row_reference_type |
typedef any_row_iterator<T> Parma_Polyhedra_Library::OR_Matrix< T >::row_iterator |
typedef any_row_iterator<const T> Parma_Polyhedra_Library::OR_Matrix< T >::const_row_iterator |
typedef DB_Row<T>::iterator Parma_Polyhedra_Library::OR_Matrix< T >::element_iterator |
typedef DB_Row<T>::const_iterator Parma_Polyhedra_Library::OR_Matrix< T >::const_element_iterator |
Parma_Polyhedra_Library::OR_Matrix< T >::OR_Matrix | ( | dimension_type | space_dim | ) | [inline] |
Builds a matrix with specified dimensions.
space_dim | The space dimension of the matrix that will be created. |
2*space_dim
rows. Each element is initialized to plus infinity.
Definition at line 436 of file OR_Matrix.inlines.hh.
00437 : vec(2*dim*(dim+1)), 00438 space_dim(dim), 00439 vec_capacity(vec.size()) { 00440 }
Parma_Polyhedra_Library::OR_Matrix< T >::OR_Matrix | ( | const OR_Matrix< T > & | y | ) | [inline] |
Copy-constructor.
Definition at line 505 of file OR_Matrix.inlines.hh.
00506 : vec(y.vec), 00507 space_dim(y.space_dim), 00508 vec_capacity(compute_capacity(y.vec.size())) { 00509 }
Parma_Polyhedra_Library::OR_Matrix< T >::OR_Matrix | ( | const OR_Matrix< U > & | y | ) | [inline, explicit] |
Constructs a conservative approximation of y
.
Definition at line 514 of file OR_Matrix.inlines.hh.
References Parma_Polyhedra_Library::OR_Matrix< T >::OK(), Parma_Polyhedra_Library::OR_Matrix< T >::vec, and Parma_Polyhedra_Library::OR_Matrix< T >::vec_capacity.
00515 : vec(), 00516 space_dim(y.space_dim), 00517 vec_capacity(compute_capacity(y.vec.size())) { 00518 vec.construct_upward_approximation(y.vec, vec_capacity); 00519 assert(OK()); 00520 }
Parma_Polyhedra_Library::OR_Matrix< T >::~OR_Matrix | ( | ) | [inline] |
Parma_Polyhedra_Library::OR_Matrix< T >::OR_Matrix | ( | ) | [private] |
Private and not implemented: default construction is not allowed.
dimension_type Parma_Polyhedra_Library::OR_Matrix< T >::max_num_rows | ( | ) | [inline, static] |
Returns the maximum number of rows of a OR_Matrix.
Definition at line 420 of file OR_Matrix.inlines.hh.
References Parma_Polyhedra_Library::isqrt().
00420 { 00421 // Compute the maximum number of rows that 00422 // are contained in a DB_Row that allocates 00423 // a pseudo-triangular matrix. 00424 dimension_type k = isqrt(2*DB_Row<T>::max_size() + 1); 00425 return (k-1) & ~dimension_type(1); 00426 }
OR_Matrix< T > & Parma_Polyhedra_Library::OR_Matrix< T >::operator= | ( | const OR_Matrix< T > & | y | ) | [inline] |
Assignment operator.
Definition at line 524 of file OR_Matrix.inlines.hh.
References Parma_Polyhedra_Library::compute_capacity(), Parma_Polyhedra_Library::OR_Matrix< T >::space_dim, Parma_Polyhedra_Library::OR_Matrix< T >::vec, and Parma_Polyhedra_Library::OR_Matrix< T >::vec_capacity.
00524 { 00525 vec = y.vec; 00526 space_dim = y.space_dim; 00527 vec_capacity = compute_capacity(y.vec.size()); 00528 return *this; 00529 }
dimension_type Parma_Polyhedra_Library::OR_Matrix< T >::row_first_element_index | ( | dimension_type | k | ) | [inline, static, private] |
Returns the index into vec
of the first element of the row of index k
.
Definition at line 39 of file OR_Matrix.inlines.hh.
Referenced by Parma_Polyhedra_Library::OR_Matrix< T >::operator[]().
dimension_type Parma_Polyhedra_Library::OR_Matrix< T >::row_size | ( | dimension_type | k | ) | [inline, static] |
Returns the size of the row of index k
.
Definition at line 45 of file OR_Matrix.inlines.hh.
Referenced by Parma_Polyhedra_Library::Octagonal_Shape< T >::add_octagonal_constraint(), Parma_Polyhedra_Library::Octagonal_Shape< T >::constrains(), Parma_Polyhedra_Library::Octagonal_Shape< T >::forget_all_octagonal_constraints(), Parma_Polyhedra_Library::OR_Matrix< T >::any_row_iterator< U >::operator+=(), and Parma_Polyhedra_Library::OR_Matrix< T >::operator[]().
00045 { 00046 return (k+2) & ~dimension_type(1); 00047 }
void Parma_Polyhedra_Library::OR_Matrix< T >::swap | ( | OR_Matrix< T > & | y | ) | [inline] |
Swaps *this
with y
.
Definition at line 397 of file OR_Matrix.inlines.hh.
References Parma_Polyhedra_Library::OR_Matrix< T >::space_dim, Parma_Polyhedra_Library::swap(), Parma_Polyhedra_Library::OR_Matrix< T >::vec, and Parma_Polyhedra_Library::OR_Matrix< T >::vec_capacity.
Referenced by Parma_Polyhedra_Library::OR_Matrix< T >::clear(), Parma_Polyhedra_Library::OR_Matrix< T >::grow(), Parma_Polyhedra_Library::OR_Matrix< T >::resize_no_copy(), and Parma_Polyhedra_Library::OR_Matrix< T >::swap().
00397 { 00398 std::swap(vec, y.vec); 00399 std::swap(space_dim, y.space_dim); 00400 std::swap(vec_capacity, y.vec_capacity); 00401 }
void Parma_Polyhedra_Library::OR_Matrix< T >::grow | ( | dimension_type | new_dim | ) | [inline] |
Makes the matrix grow by adding more space dimensions.
new_dim | The new dimension of the resized matrix. |
*this
. Each new element is initialized to plus infinity.
Definition at line 533 of file OR_Matrix.inlines.hh.
References Parma_Polyhedra_Library::OR_Matrix< T >::element_begin(), Parma_Polyhedra_Library::OR_Matrix< T >::element_end(), Parma_Polyhedra_Library::OR_Matrix< T >::space_dim, Parma_Polyhedra_Library::OR_Matrix< T >::swap(), Parma_Polyhedra_Library::OR_Matrix< T >::vec, and Parma_Polyhedra_Library::OR_Matrix< T >::vec_capacity.
00533 { 00534 assert(new_dim >= space_dim); 00535 if (new_dim > space_dim) { 00536 const dimension_type new_size = 2*new_dim*(new_dim + 1); 00537 if (new_size <= vec_capacity) { 00538 // We can recycle the old vec. 00539 vec.expand_within_capacity(new_size); 00540 space_dim = new_dim; 00541 } 00542 else { 00543 // We cannot recycle the old vec. 00544 OR_Matrix<T> new_matrix(new_dim); 00545 element_iterator j = new_matrix.element_begin(); 00546 for (element_iterator i = element_begin(), 00547 mend = element_end(); i != mend; ++i, ++j) 00548 assign_or_swap(*j, *i); 00549 swap(new_matrix); 00550 } 00551 } 00552 }
void Parma_Polyhedra_Library::OR_Matrix< T >::shrink | ( | dimension_type | new_dim | ) | [inline] |
Makes the matrix shrink by removing the last space dimensions.
new_dim | The new dimension of the resized matrix. |
Definition at line 556 of file OR_Matrix.inlines.hh.
References Parma_Polyhedra_Library::OR_Matrix< T >::space_dim, and Parma_Polyhedra_Library::OR_Matrix< T >::vec.
Referenced by Parma_Polyhedra_Library::OR_Matrix< T >::resize_no_copy().
00556 { 00557 assert(new_dim <= space_dim); 00558 const dimension_type new_size = 2*new_dim*(new_dim + 1); 00559 vec.shrink(new_size); 00560 space_dim = new_dim; 00561 }
void Parma_Polyhedra_Library::OR_Matrix< T >::resize_no_copy | ( | dimension_type | new_dim | ) | [inline] |
Resizes the matrix without worrying about the old contents.
new_dim | The new dimension of the resized matrix. |
*this
. If the new dimension is less than the old one, it erase from the matrix the rows having index greater than 2*new_dim-1
Definition at line 565 of file OR_Matrix.inlines.hh.
References Parma_Polyhedra_Library::OR_Matrix< T >::shrink(), Parma_Polyhedra_Library::OR_Matrix< T >::space_dim, Parma_Polyhedra_Library::OR_Matrix< T >::swap(), Parma_Polyhedra_Library::OR_Matrix< T >::vec, and Parma_Polyhedra_Library::OR_Matrix< T >::vec_capacity.
Referenced by Parma_Polyhedra_Library::OR_Matrix< T >::ascii_load().
00565 { 00566 if (new_dim > space_dim) { 00567 const dimension_type new_size = 2*new_dim*(new_dim + 1); 00568 if (new_size <= vec_capacity) { 00569 // We can recycle the old vec. 00570 vec.expand_within_capacity(new_size); 00571 space_dim = new_dim; 00572 } 00573 else { 00574 // We cannot recycle the old vec. 00575 OR_Matrix<T> new_matrix(new_dim); 00576 swap(new_matrix); 00577 } 00578 } 00579 else if (new_dim < space_dim) 00580 shrink(new_dim); 00581 }
dimension_type Parma_Polyhedra_Library::OR_Matrix< T >::space_dimension | ( | ) | const [inline] |
Returns the space-dimension of the matrix.
Definition at line 469 of file OR_Matrix.inlines.hh.
References Parma_Polyhedra_Library::OR_Matrix< T >::space_dim.
Referenced by Parma_Polyhedra_Library::OR_Matrix< T >::ascii_dump(), Parma_Polyhedra_Library::OR_Matrix< T >::num_rows(), and Parma_Polyhedra_Library::OR_Matrix< T >::OK().
00469 { 00470 return space_dim; 00471 }
dimension_type Parma_Polyhedra_Library::OR_Matrix< T >::num_rows | ( | ) | const [inline] |
Returns the number of rows in the matrix.
Definition at line 475 of file OR_Matrix.inlines.hh.
References Parma_Polyhedra_Library::OR_Matrix< T >::space_dimension().
Referenced by Parma_Polyhedra_Library::OR_Matrix< T >::l_m_distance_assign(), Parma_Polyhedra_Library::OR_Matrix< T >::row_begin(), and Parma_Polyhedra_Library::OR_Matrix< T >::row_end().
00475 { 00476 return 2*space_dimension(); 00477 }
OR_Matrix< T >::row_reference_type Parma_Polyhedra_Library::OR_Matrix< T >::operator[] | ( | dimension_type | k | ) | [inline] |
Returns a reference to the k-th
row of the matrix.
Definition at line 449 of file OR_Matrix.inlines.hh.
References PPL_OR_MATRIX_EXTRA_DEBUG, Parma_Polyhedra_Library::OR_Matrix< T >::row_first_element_index(), Parma_Polyhedra_Library::OR_Matrix< T >::row_size(), and Parma_Polyhedra_Library::OR_Matrix< T >::vec.
00449 { 00450 return row_reference_type(vec[row_first_element_index(k)] 00451 #if PPL_OR_MATRIX_EXTRA_DEBUG 00452 , row_size(k) 00453 #endif 00454 ); 00455 }
OR_Matrix< T >::const_row_reference_type Parma_Polyhedra_Library::OR_Matrix< T >::operator[] | ( | dimension_type | k | ) | const [inline] |
Returns a constant reference to the k-th
row of the matrix.
Definition at line 459 of file OR_Matrix.inlines.hh.
References PPL_OR_MATRIX_EXTRA_DEBUG, Parma_Polyhedra_Library::OR_Matrix< T >::row_first_element_index(), Parma_Polyhedra_Library::OR_Matrix< T >::row_size(), and Parma_Polyhedra_Library::OR_Matrix< T >::vec.
00459 { 00460 return const_row_reference_type(vec[row_first_element_index(k)] 00461 #if PPL_OR_MATRIX_EXTRA_DEBUG 00462 , row_size(k) 00463 #endif 00464 ); 00465 }
OR_Matrix< T >::row_iterator Parma_Polyhedra_Library::OR_Matrix< T >::row_begin | ( | ) | [inline] |
Returns an iterator pointing to the first row, if *this
is not empty; otherwise, returns the past-the-end const_iterator.
Definition at line 349 of file OR_Matrix.inlines.hh.
References Parma_Polyhedra_Library::OR_Matrix< T >::num_rows(), and Parma_Polyhedra_Library::OR_Matrix< T >::vec.
Referenced by Parma_Polyhedra_Library::OR_Matrix< T >::ascii_dump(), Parma_Polyhedra_Library::OR_Matrix< T >::ascii_load(), Parma_Polyhedra_Library::Octagonal_Shape< T >::get_limiting_octagon(), and Parma_Polyhedra_Library::Octagonal_Shape< T >::map_space_dimensions().
00349 { 00350 return num_rows() == 0 ? row_iterator(0) : row_iterator(vec[0]); 00351 }
OR_Matrix< T >::row_iterator Parma_Polyhedra_Library::OR_Matrix< T >::row_end | ( | ) | [inline] |
Returns the past-the-end const_iterator.
Definition at line 355 of file OR_Matrix.inlines.hh.
References Parma_Polyhedra_Library::OR_Matrix< T >::num_rows().
Referenced by Parma_Polyhedra_Library::OR_Matrix< T >::ascii_dump(), Parma_Polyhedra_Library::OR_Matrix< T >::ascii_load(), and Parma_Polyhedra_Library::Octagonal_Shape< T >::map_space_dimensions().
00355 { 00356 return row_iterator(num_rows()); 00357 }
OR_Matrix< T >::const_row_iterator Parma_Polyhedra_Library::OR_Matrix< T >::row_begin | ( | ) | const [inline] |
Returns a const row iterator pointing to the first row, if *this
is not empty; otherwise, returns the past-the-end const_iterator.
Definition at line 361 of file OR_Matrix.inlines.hh.
References Parma_Polyhedra_Library::OR_Matrix< T >::num_rows(), and Parma_Polyhedra_Library::OR_Matrix< T >::vec.
00361 { 00362 return num_rows() == 0 ? const_row_iterator(0) : const_row_iterator(vec[0]); 00363 }
OR_Matrix< T >::const_row_iterator Parma_Polyhedra_Library::OR_Matrix< T >::row_end | ( | ) | const [inline] |
Returns the past-the-end const row iterator.
Definition at line 367 of file OR_Matrix.inlines.hh.
References Parma_Polyhedra_Library::OR_Matrix< T >::num_rows().
00367 { 00368 return const_row_iterator(num_rows()); 00369 }
OR_Matrix< T >::element_iterator Parma_Polyhedra_Library::OR_Matrix< T >::element_begin | ( | ) | [inline] |
Returns an iterator pointing to the first element, if *this
is not empty; otherwise, returns the past-the-end const_iterator.
Definition at line 373 of file OR_Matrix.inlines.hh.
References Parma_Polyhedra_Library::OR_Matrix< T >::vec.
Referenced by Parma_Polyhedra_Library::OR_Matrix< T >::grow(), and Parma_Polyhedra_Library::OR_Matrix< T >::l_m_distance_assign().
00373 { 00374 return vec.begin(); 00375 }
OR_Matrix< T >::element_iterator Parma_Polyhedra_Library::OR_Matrix< T >::element_end | ( | ) | [inline] |
Returns the past-the-end const_iterator.
Definition at line 379 of file OR_Matrix.inlines.hh.
References Parma_Polyhedra_Library::OR_Matrix< T >::vec.
Referenced by Parma_Polyhedra_Library::OR_Matrix< T >::grow(), and Parma_Polyhedra_Library::OR_Matrix< T >::l_m_distance_assign().
00379 { 00380 return vec.end(); 00381 }
OR_Matrix< T >::const_element_iterator Parma_Polyhedra_Library::OR_Matrix< T >::element_begin | ( | ) | const [inline] |
Returns a const element iterator pointing to the first element, if *this
is not empty; otherwise, returns the past-the-end const_iterator.
Definition at line 385 of file OR_Matrix.inlines.hh.
References Parma_Polyhedra_Library::OR_Matrix< T >::vec.
00385 { 00386 return vec.begin(); 00387 }
OR_Matrix< T >::const_element_iterator Parma_Polyhedra_Library::OR_Matrix< T >::element_end | ( | ) | const [inline] |
Returns the past-the-end const element iterator.
Definition at line 391 of file OR_Matrix.inlines.hh.
References Parma_Polyhedra_Library::OR_Matrix< T >::vec.
00391 { 00392 return vec.end(); 00393 }
void Parma_Polyhedra_Library::OR_Matrix< T >::clear | ( | ) | [inline] |
Clears the matrix deallocating all its rows.
Definition at line 481 of file OR_Matrix.inlines.hh.
References Parma_Polyhedra_Library::OR_Matrix< T >::swap().
00481 { 00482 OR_Matrix<T>(0).swap(*this); 00483 }
void Parma_Polyhedra_Library::OR_Matrix< T >::ascii_dump | ( | ) | const |
Writes to std::cerr
an ASCII representation of *this
.
void Parma_Polyhedra_Library::OR_Matrix< T >::ascii_dump | ( | std::ostream & | s | ) | const [inline] |
Writes to s
an ASCII representation of *this
.
Definition at line 64 of file OR_Matrix.templates.hh.
References Parma_Polyhedra_Library::OR_Matrix< T >::row_begin(), Parma_Polyhedra_Library::OR_Matrix< T >::row_end(), and Parma_Polyhedra_Library::OR_Matrix< T >::space_dimension().
00064 { 00065 const OR_Matrix<T>& x = *this; 00066 const char separator = ' '; 00067 dimension_type space = x.space_dimension(); 00068 s << space << separator << "\n"; 00069 for (const_row_iterator i = x.row_begin(), 00070 x_row_end = x.row_end(); i != x_row_end; ++i) { 00071 const_row_reference_type r = *i; 00072 dimension_type rs = i.row_size(); 00073 for (dimension_type j = 0; j < rs; ++j) { 00074 using namespace IO_Operators; 00075 s << r[j] << separator; 00076 } 00077 s << "\n"; 00078 } 00079 }
void Parma_Polyhedra_Library::OR_Matrix< T >::print | ( | ) | const |
Prints *this
to std::cerr
using operator<<
.
bool Parma_Polyhedra_Library::OR_Matrix< T >::ascii_load | ( | std::istream & | s | ) | [inline] |
Loads from s
an ASCII representation (as produced by ascii_dump(std::ostream&) const) and sets *this
accordingly. Returns true
if successful, false
otherwise.
Definition at line 85 of file OR_Matrix.templates.hh.
References Parma_Polyhedra_Library::OR_Matrix< T >::OK(), Parma_Polyhedra_Library::OR_Matrix< T >::resize_no_copy(), Parma_Polyhedra_Library::OR_Matrix< T >::row_begin(), and Parma_Polyhedra_Library::OR_Matrix< T >::row_end().
00085 { 00086 dimension_type space; 00087 if (!(s >> space)) 00088 return false; 00089 resize_no_copy(space); 00090 for (row_iterator i = row_begin(), 00091 this_row_end = row_end(); i != this_row_end; ++i) { 00092 row_reference_type r_i = *i; 00093 const dimension_type rs = i.row_size(); 00094 for (dimension_type j = 0; j < rs; ++j) { 00095 Result r = input(r_i[j], s, ROUND_UP); 00096 // FIXME: V_CVT_STR_UNK is probably not the only possible error. 00097 if (!s || r == V_CVT_STR_UNK) 00098 return false; 00099 } 00100 } 00101 assert(OK()); 00102 return true; 00103 }
memory_size_type Parma_Polyhedra_Library::OR_Matrix< T >::total_memory_in_bytes | ( | ) | const [inline] |
Returns the total size in bytes of the memory occupied by *this
.
Definition at line 430 of file OR_Matrix.inlines.hh.
References Parma_Polyhedra_Library::OR_Matrix< T >::external_memory_in_bytes().
00430 { 00431 return sizeof(*this) + external_memory_in_bytes(); 00432 }
memory_size_type Parma_Polyhedra_Library::OR_Matrix< T >::external_memory_in_bytes | ( | ) | const [inline] |
Returns the size in bytes of the memory managed by *this
.
Definition at line 32 of file OR_Matrix.templates.hh.
References Parma_Polyhedra_Library::OR_Matrix< T >::vec.
Referenced by Parma_Polyhedra_Library::OR_Matrix< T >::total_memory_in_bytes().
00032 { 00033 return vec.external_memory_in_bytes(); 00034 }
bool Parma_Polyhedra_Library::OR_Matrix< T >::OK | ( | ) | const [inline] |
Checks if all the invariants are satisfied.
Definition at line 38 of file OR_Matrix.templates.hh.
References Parma_Polyhedra_Library::OR_Matrix< T >::space_dimension(), Parma_Polyhedra_Library::OR_Matrix< T >::vec, and Parma_Polyhedra_Library::OR_Matrix< T >::vec_capacity.
Referenced by Parma_Polyhedra_Library::OR_Matrix< T >::ascii_load(), and Parma_Polyhedra_Library::OR_Matrix< T >::OR_Matrix().
00038 { 00039 #ifndef NDEBUG 00040 using std::endl; 00041 using std::cerr; 00042 #endif 00043 // The right number of cells should be in use. 00044 const dimension_type dim = space_dimension(); 00045 if (vec.size() != 2*dim*(dim + 1)) { 00046 #ifndef NDEBUG 00047 cerr << "OR_Matrix has a wrong number of cells:\n" 00048 << "vec.size() is " << vec.size() 00049 << ", expected size is " << 2*dim*(dim+1) << "!\n"; 00050 #endif 00051 return false; 00052 } 00053 00054 // The underlying DB_Row should be OK. 00055 if (!vec.OK(vec.size(), vec_capacity)) 00056 return false; 00057 00058 // All checks passed. 00059 return true; 00060 }
friend class OR_Matrix [friend] |
Definition at line 361 of file OR_Matrix.defs.hh.
bool operator== | ( | const OR_Matrix< T > & | x, | |
const OR_Matrix< T > & | y | |||
) | [friend] |
Returns true
if and only if x
and y
are identical.
Definition at line 490 of file OR_Matrix.inlines.hh.
std::ostream & operator<< | ( | std::ostream & | s, | |
const OR_Matrix< T > & | m | |||
) | [related] |
Output operator.
Definition at line 110 of file OR_Matrix.templates.hh.
00110 { 00111 for (typename OR_Matrix<T>::const_row_iterator m_iter = m.row_begin(), 00112 m_end = m.row_end(); m_iter != m_end; ++m_iter) { 00113 typename OR_Matrix<T>::const_row_reference_type r_m = *m_iter; 00114 const dimension_type mr_size = m_iter.row_size(); 00115 for (dimension_type j = 0; j < mr_size; ++j) 00116 s << r_m[j] << " "; 00117 s << "\n"; 00118 } 00119 return s; 00120 }
void swap | ( | Parma_Polyhedra_Library::OR_Matrix< T > & | x, | |
Parma_Polyhedra_Library::OR_Matrix< T > & | y | |||
) | [related] |
Specializes std::swap
.
Definition at line 703 of file OR_Matrix.inlines.hh.
References Parma_Polyhedra_Library::OR_Matrix< T >::swap().
00704 { 00705 x.swap(y); 00706 }
bool operator!= | ( | const OR_Matrix< T > & | x, | |
const OR_Matrix< T > & | y | |||
) | [related] |
Returns true
if and only if x
and y
are different.
Definition at line 499 of file OR_Matrix.inlines.hh.
bool rectilinear_distance_assign | ( | Checked_Number< To, Extended_Number_Policy > & | r, | |
const OR_Matrix< T > & | x, | |||
const OR_Matrix< T > & | y, | |||
Rounding_Dir | dir, | |||
Temp & | tmp0, | |||
Temp & | tmp1, | |||
Temp & | tmp2 | |||
) | [related] |
Computes the rectilinear (or Manhattan) distance between x
and y
.
If the rectilinear distance between x
and y
is defined, stores an approximation of it into to r
and returns true
; returns false
otherwise.
The direction of the approximation is specified by dir
.
All computations are performed using the temporary variables tmp0
, tmp1
and tmp2
.
Definition at line 641 of file OR_Matrix.inlines.hh.
00647 { 00648 return 00649 l_m_distance_assign<Rectilinear_Distance_Specialization<Temp> >(r, x, y, 00650 dir, 00651 tmp0, 00652 tmp1, 00653 tmp2); 00654 }
bool euclidean_distance_assign | ( | Checked_Number< To, Extended_Number_Policy > & | r, | |
const OR_Matrix< T > & | x, | |||
const OR_Matrix< T > & | y, | |||
Rounding_Dir | dir, | |||
Temp & | tmp0, | |||
Temp & | tmp1, | |||
Temp & | tmp2 | |||
) | [related] |
Computes the euclidean distance between x
and y
.
If the Euclidean distance between x
and y
is defined, stores an approximation of it into to r
and returns true
; returns false
otherwise.
The direction of the approximation is specified by dir
.
All computations are performed using the temporary variables tmp0
, tmp1
and tmp2
.
Definition at line 661 of file OR_Matrix.inlines.hh.
00667 { 00668 return 00669 l_m_distance_assign<Euclidean_Distance_Specialization<Temp> >(r, x, y, 00670 dir, 00671 tmp0, 00672 tmp1, 00673 tmp2); 00674 }
bool l_infinity_distance_assign | ( | Checked_Number< To, Extended_Number_Policy > & | r, | |
const OR_Matrix< T > & | x, | |||
const OR_Matrix< T > & | y, | |||
Rounding_Dir | dir, | |||
Temp & | tmp0, | |||
Temp & | tmp1, | |||
Temp & | tmp2 | |||
) | [related] |
Computes the distance between
x
and y
.
If the distance between
x
and y
is defined, stores an approximation of it into to r
and returns true
; returns false
otherwise.
The direction of the approximation is specified by dir
.
All computations are performed using the temporary variables tmp0
, tmp1
and tmp2
.
Definition at line 681 of file OR_Matrix.inlines.hh.
00687 { 00688 return 00689 l_m_distance_assign<L_Infinity_Distance_Specialization<Temp> >(r, x, y, 00690 dir, 00691 tmp0, 00692 tmp1, 00693 tmp2); 00694 }
bool l_m_distance_assign | ( | Checked_Number< To, Extended_Number_Policy > & | r, | |
const OR_Matrix< T > & | x, | |||
const OR_Matrix< T > & | y, | |||
const Rounding_Dir | dir, | |||
Temp & | tmp0, | |||
Temp & | tmp1, | |||
Temp & | tmp2 | |||
) | [related] |
Definition at line 588 of file OR_Matrix.inlines.hh.
References Parma_Polyhedra_Library::assign_r(), Parma_Polyhedra_Library::combine(), Parma_Polyhedra_Library::OR_Matrix< T >::element_begin(), Parma_Polyhedra_Library::OR_Matrix< T >::element_end(), Parma_Polyhedra_Library::finalize(), Parma_Polyhedra_Library::is_plus_infinity(), Parma_Polyhedra_Library::maybe_assign(), Parma_Polyhedra_Library::OR_Matrix< T >::num_rows(), and PLUS_INFINITY.
00594 { 00595 if (x.num_rows() != y.num_rows()) 00596 return false; 00597 assign_r(tmp0, 0, ROUND_NOT_NEEDED); 00598 for (typename OR_Matrix<T>::const_element_iterator 00599 i = x.element_begin(), j = y.element_begin(), 00600 mat_end = x.element_end(); i != mat_end; ++i, ++j) { 00601 const T& x_i = *i; 00602 const T& y_i = *j; 00603 if (is_plus_infinity(x_i)) { 00604 if (is_plus_infinity(y_i)) 00605 continue; 00606 else { 00607 pinf: 00608 assign_r(r, PLUS_INFINITY, ROUND_NOT_NEEDED); 00609 return true; 00610 } 00611 } 00612 else if (is_plus_infinity(y_i)) 00613 goto pinf; 00614 00615 const Temp* tmp1p; 00616 const Temp* tmp2p; 00617 if (x_i > y_i) { 00618 maybe_assign(tmp1p, tmp1, x_i, dir); 00619 maybe_assign(tmp2p, tmp2, y_i, inverse(dir)); 00620 } 00621 else { 00622 maybe_assign(tmp1p, tmp1, y_i, dir); 00623 maybe_assign(tmp2p, tmp2, x_i, inverse(dir)); 00624 } 00625 sub_assign_r(tmp1, *tmp1p, *tmp2p, dir); 00626 assert(sgn(tmp1) >= 0); 00627 Specialization::combine(tmp0, tmp1, dir); 00628 } 00629 00630 Specialization::finalize(tmp0, dir); 00631 assign_r(r, tmp0, dir); 00632 return true; 00633 }
DB_Row<T> Parma_Polyhedra_Library::OR_Matrix< T >::vec [private] |
Contains the rows of the matrix.
A DB_Row which contains the rows of the OR_Matrix inserting each successive row to the end of the vec. To contain all the elements of OR_Matrix the size of the DB_Row is 2*n*(n+1), where the n is the characteristic parameter of OR_Matrix.
Definition at line 371 of file OR_Matrix.defs.hh.
Referenced by Parma_Polyhedra_Library::OR_Matrix< T >::element_begin(), Parma_Polyhedra_Library::OR_Matrix< T >::element_end(), Parma_Polyhedra_Library::OR_Matrix< T >::external_memory_in_bytes(), Parma_Polyhedra_Library::OR_Matrix< T >::grow(), Parma_Polyhedra_Library::OR_Matrix< T >::OK(), Parma_Polyhedra_Library::OR_Matrix< T >::operator=(), Parma_Polyhedra_Library::OR_Matrix< T >::operator[](), Parma_Polyhedra_Library::OR_Matrix< T >::OR_Matrix(), Parma_Polyhedra_Library::OR_Matrix< T >::resize_no_copy(), Parma_Polyhedra_Library::OR_Matrix< T >::row_begin(), Parma_Polyhedra_Library::OR_Matrix< T >::shrink(), and Parma_Polyhedra_Library::OR_Matrix< T >::swap().
dimension_type Parma_Polyhedra_Library::OR_Matrix< T >::space_dim [private] |
Contains the dimension of the space of the matrix.
Definition at line 374 of file OR_Matrix.defs.hh.
Referenced by Parma_Polyhedra_Library::OR_Matrix< T >::grow(), Parma_Polyhedra_Library::OR_Matrix< T >::operator=(), Parma_Polyhedra_Library::OR_Matrix< T >::resize_no_copy(), Parma_Polyhedra_Library::OR_Matrix< T >::shrink(), Parma_Polyhedra_Library::OR_Matrix< T >::space_dimension(), and Parma_Polyhedra_Library::OR_Matrix< T >::swap().
dimension_type Parma_Polyhedra_Library::OR_Matrix< T >::vec_capacity [private] |
Contains the capacity of vec
.
Definition at line 377 of file OR_Matrix.defs.hh.
Referenced by Parma_Polyhedra_Library::OR_Matrix< T >::grow(), Parma_Polyhedra_Library::OR_Matrix< T >::OK(), Parma_Polyhedra_Library::OR_Matrix< T >::operator=(), Parma_Polyhedra_Library::OR_Matrix< T >::OR_Matrix(), Parma_Polyhedra_Library::OR_Matrix< T >::resize_no_copy(), and Parma_Polyhedra_Library::OR_Matrix< T >::swap().