Parma_Polyhedra_Library::OR_Matrix< T > Class Template Reference

A matrix representing octagonal constraints. More...

#include <OR_Matrix.defs.hh>

Inheritance diagram for Parma_Polyhedra_Library::OR_Matrix< T >:
Inheritance graph
[legend]

List of all members.

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...

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_Matrixoperator= (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 $L_\infty$ distance between 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)

Detailed Description

template<typename T>
class Parma_Polyhedra_Library::OR_Matrix< T >

A matrix representing octagonal constraints.

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 106 of file OR_Matrix.defs.hh.


Member Typedef Documentation

template<typename T>
typedef DB_Row<T>::const_iterator Parma_Polyhedra_Library::OR_Matrix< T >::const_element_iterator

A const element iterator.

Definition at line 332 of file OR_Matrix.defs.hh.

template<typename T>
typedef any_row_iterator<const T> Parma_Polyhedra_Library::OR_Matrix< T >::const_row_iterator

A const row iterator.

Definition at line 326 of file OR_Matrix.defs.hh.

template<typename T>
typedef Pseudo_Row<const T> Parma_Polyhedra_Library::OR_Matrix< T >::const_row_reference_type

A const reference to a matrix's row.

Definition at line 194 of file OR_Matrix.defs.hh.

template<typename T>
typedef DB_Row<T>::iterator Parma_Polyhedra_Library::OR_Matrix< T >::element_iterator

A (non const) element iterator.

Definition at line 329 of file OR_Matrix.defs.hh.

template<typename T>
typedef any_row_iterator<T> Parma_Polyhedra_Library::OR_Matrix< T >::row_iterator

A (non const) row iterator.

Definition at line 323 of file OR_Matrix.defs.hh.

template<typename T>
typedef Pseudo_Row<T> Parma_Polyhedra_Library::OR_Matrix< T >::row_reference_type

A (non const) reference to a matrix's row.

Definition at line 191 of file OR_Matrix.defs.hh.


Constructor & Destructor Documentation

template<typename T >
Parma_Polyhedra_Library::OR_Matrix< T >::OR_Matrix ( dimension_type  space_dim  )  [inline]

Builds a matrix with specified dimensions.

Parameters:
space_dim The space dimension of the matrix that will be created.

This constructor creates a matrix with 2*space_dim rows. Each element is initialized to plus infinity.

Definition at line 439 of file OR_Matrix.inlines.hh.

00440   : vec(2*dim*(dim+1)),
00441     space_dim(dim),
00442     vec_capacity(vec.size()) {
00443 }

template<typename T >
Parma_Polyhedra_Library::OR_Matrix< T >::OR_Matrix ( const OR_Matrix< T > &  y  )  [inline]

Copy constructor.

Definition at line 508 of file OR_Matrix.inlines.hh.

00509   : vec(y.vec),
00510     space_dim(y.space_dim),
00511     vec_capacity(compute_capacity(y.vec.size(),
00512                                   DB_Row<T>::max_size())) {
00513 }

template<typename T >
template<typename U >
Parma_Polyhedra_Library::OR_Matrix< T >::OR_Matrix ( const OR_Matrix< U > &  y  )  [inline, explicit]

Constructs a conservative approximation of y.

Definition at line 518 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.

00519   : vec(),
00520     space_dim(y.space_dim),
00521     vec_capacity(compute_capacity(y.vec.size(),
00522                                   DB_Row<T>::max_size())) {
00523   vec.construct_upward_approximation(y.vec, vec_capacity);
00524   PPL_ASSERT(OK());
00525 }

template<typename T >
Parma_Polyhedra_Library::OR_Matrix< T >::~OR_Matrix (  )  [inline]

Destructor.

Definition at line 447 of file OR_Matrix.inlines.hh.

00447                          {
00448 }

template<typename T>
Parma_Polyhedra_Library::OR_Matrix< T >::OR_Matrix (  )  [private]

Private and not implemented: default construction is not allowed.


Member Function Documentation

template<typename T >
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 65 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().

00065                                             {
00066   const OR_Matrix<T>& x = *this;
00067   const char separator = ' ';
00068   dimension_type space = x.space_dimension();
00069   s << space << separator << "\n";
00070   for (const_row_iterator i = x.row_begin(),
00071          x_row_end = x.row_end(); i != x_row_end; ++i) {
00072     const_row_reference_type r = *i;
00073     dimension_type rs = i.row_size();
00074     for (dimension_type j = 0; j < rs; ++j) {
00075       using namespace IO_Operators;
00076       s << r[j] << separator;
00077     }
00078     s << "\n";
00079   }
00080 }

template<typename T>
void Parma_Polyhedra_Library::OR_Matrix< T >::ascii_dump (  )  const

Writes to std::cerr an ASCII representation of *this.

Referenced by Parma_Polyhedra_Library::Octagonal_Shape< T >::ascii_dump().

template<typename T >
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 86 of file OR_Matrix.templates.hh.

References Parma_Polyhedra_Library::is_minus_infinity(), Parma_Polyhedra_Library::Checked::Result, and Parma_Polyhedra_Library::Checked::result_relation().

00086                                       {
00087   dimension_type space;
00088   if (!(s >> space))
00089     return false;
00090   resize_no_copy(space);
00091   for (row_iterator i = row_begin(),
00092          this_row_end = row_end(); i != this_row_end; ++i) {
00093     row_reference_type r_i = *i;
00094     const dimension_type rs = i.row_size();
00095     for (dimension_type j = 0; j < rs; ++j) {
00096       Result r = input(r_i[j], s, ROUND_CHECK);
00097       if (result_relation(r) != VR_EQ || is_minus_infinity(r_i[j]))
00098         return false;
00099     }
00100   }
00101   PPL_ASSERT(OK());
00102   return true;
00103 }

template<typename T >
void Parma_Polyhedra_Library::OR_Matrix< T >::clear (  )  [inline]

Clears the matrix deallocating all its rows.

Definition at line 484 of file OR_Matrix.inlines.hh.

References Parma_Polyhedra_Library::OR_Matrix< T >::swap().

00484                     {
00485   OR_Matrix<T>(0).swap(*this);
00486 }

template<typename T >
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 389 of file OR_Matrix.inlines.hh.

References Parma_Polyhedra_Library::OR_Matrix< T >::vec.

00389                                   {
00390   return vec.begin();
00391 }

template<typename T >
OR_Matrix< T >::element_iterator Parma_Polyhedra_Library::OR_Matrix< T >::element_begin (  )  [inline]
template<typename T >
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 395 of file OR_Matrix.inlines.hh.

References Parma_Polyhedra_Library::OR_Matrix< T >::vec.

00395                                 {
00396   return vec.end();
00397 }

template<typename T >
OR_Matrix< T >::element_iterator Parma_Polyhedra_Library::OR_Matrix< T >::element_end (  )  [inline]
template<typename T >
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 33 of file OR_Matrix.templates.hh.

References Parma_Polyhedra_Library::OR_Matrix< T >::vec.

Referenced by Parma_Polyhedra_Library::Octagonal_Shape< T >::external_memory_in_bytes(), and Parma_Polyhedra_Library::OR_Matrix< T >::total_memory_in_bytes().

00033                                             {
00034   return vec.external_memory_in_bytes();
00035 }

template<typename T >
void Parma_Polyhedra_Library::OR_Matrix< T >::grow ( dimension_type  new_dim  )  [inline]

Makes the matrix grow by adding more space dimensions.

Parameters:
new_dim The new dimension of the resized matrix.

Adds new rows of right dimension to the end if there is enough capacity; otherwise, creates a new matrix, with the specified dimension, copying the old elements in the upper part of the new matrix, which is then assigned to *this. Each new element is initialized to plus infinity.

Definition at line 538 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.

Referenced by Parma_Polyhedra_Library::Octagonal_Shape< T >::add_space_dimensions_and_embed().

00538                                                {
00539   PPL_ASSERT(new_dim >= space_dim);
00540   if (new_dim > space_dim) {
00541     const dimension_type new_size = 2*new_dim*(new_dim + 1);
00542     if (new_size <= vec_capacity) {
00543       // We can recycle the old vec.
00544       vec.expand_within_capacity(new_size);
00545       space_dim = new_dim;
00546     }
00547     else {
00548       // We cannot recycle the old vec.
00549       OR_Matrix<T> new_matrix(new_dim);
00550       element_iterator j = new_matrix.element_begin();
00551       for (element_iterator i = element_begin(),
00552              mend = element_end(); i != mend; ++i, ++j)
00553         assign_or_swap(*j, *i);
00554       swap(new_matrix);
00555     }
00556   }
00557 }

template<typename T >
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 424 of file OR_Matrix.inlines.hh.

References Parma_Polyhedra_Library::isqrt().

00424                            {
00425   // Compute the maximum number of rows that are contained in a DB_Row
00426   // that allocates a pseudo-triangular matrix.
00427   dimension_type k = isqrt(2*DB_Row<T>::max_size() + 1);
00428   return (k - 1) - (k - 1)%2;
00429 }

template<typename T >
dimension_type Parma_Polyhedra_Library::OR_Matrix< T >::num_rows (  )  const [inline]
template<typename T >
bool Parma_Polyhedra_Library::OR_Matrix< T >::OK (  )  const [inline]

Checks if all the invariants are satisfied.

Definition at line 39 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::Octagonal_Shape< T >::OK(), and Parma_Polyhedra_Library::OR_Matrix< T >::OR_Matrix().

00039                        {
00040 #ifndef NDEBUG
00041   using std::endl;
00042   using std::cerr;
00043 #endif
00044   // The right number of cells should be in use.
00045   const dimension_type dim = space_dimension();
00046   if (vec.size() != 2*dim*(dim + 1)) {
00047 #ifndef NDEBUG
00048     cerr << "OR_Matrix has a wrong number of cells:\n"
00049          << "vec.size() is " << vec.size()
00050          << ", expected size is " << 2*dim*(dim+1) << "!\n";
00051 #endif
00052     return false;
00053   }
00054 
00055   // The underlying DB_Row should be OK.
00056   if (!vec.OK(vec.size(), vec_capacity))
00057     return false;
00058 
00059   // All checks passed.
00060   return true;
00061 }

template<typename T >
OR_Matrix< T > & Parma_Polyhedra_Library::OR_Matrix< T >::operator= ( const OR_Matrix< T > &  y  )  [inline]

Assignment operator.

Definition at line 529 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.

00529                                           {
00530   vec = y.vec;
00531   space_dim = y.space_dim;
00532   vec_capacity = compute_capacity(y.vec.size(), DB_Row<T>::max_size());
00533   return *this;
00534 }

template<typename T >
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 462 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.

00462                                                {
00463   return const_row_reference_type(vec[row_first_element_index(k)]
00464 #if PPL_OR_MATRIX_EXTRA_DEBUG
00465                                   , row_size(k)
00466 #endif
00467                                   );
00468 }

template<typename T >
OR_Matrix< T >::row_reference_type Parma_Polyhedra_Library::OR_Matrix< T >::operator[] ( dimension_type  k  )  [inline]
template<typename T>
void Parma_Polyhedra_Library::OR_Matrix< T >::print (  )  const

Prints *this to std::cerr using operator<<.

template<typename T >
void Parma_Polyhedra_Library::OR_Matrix< T >::resize_no_copy ( dimension_type  new_dim  )  [inline]

Resizes the matrix without worrying about the old contents.

Parameters:
new_dim The new dimension of the resized matrix.

If the new dimension is greater than the old one, it adds new rows of right dimension to the end if there is enough capacity; otherwise, it creates a new matrix, with the specified dimension, which is then assigned to *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 570 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.

00570                                                          {
00571   if (new_dim > space_dim) {
00572     const dimension_type new_size = 2*new_dim*(new_dim + 1);
00573     if (new_size <= vec_capacity) {
00574       // We can recycle the old vec.
00575       vec.expand_within_capacity(new_size);
00576       space_dim = new_dim;
00577     }
00578     else {
00579       // We cannot recycle the old vec.
00580       OR_Matrix<T> new_matrix(new_dim);
00581       swap(new_matrix);
00582     }
00583   }
00584   else if (new_dim < space_dim)
00585     shrink(new_dim);
00586 }

template<typename T >
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 365 of file OR_Matrix.inlines.hh.

References Parma_Polyhedra_Library::OR_Matrix< T >::num_rows(), and Parma_Polyhedra_Library::OR_Matrix< T >::vec.

00365                               {
00366   return num_rows() == 0 ? const_row_iterator(0) : const_row_iterator(vec[0]);
00367 }

template<typename T >
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 353 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::Octagonal_Shape< T >::add_constraint(), Parma_Polyhedra_Library::Octagonal_Shape< T >::add_octagonal_constraint(), Parma_Polyhedra_Library::Octagonal_Shape< T >::add_space_dimensions_and_project(), Parma_Polyhedra_Library::Octagonal_Shape< T >::affine_image(), Parma_Polyhedra_Library::OR_Matrix< T >::ascii_dump(), Parma_Polyhedra_Library::Octagonal_Shape< T >::bounded_affine_image(), Parma_Polyhedra_Library::Octagonal_Shape< T >::bounds(), Parma_Polyhedra_Library::Octagonal_Shape< T >::concatenate_assign(), Parma_Polyhedra_Library::Octagonal_Shape< T >::constrains(), Parma_Polyhedra_Library::Octagonal_Shape< T >::constraints(), Parma_Polyhedra_Library::Octagonal_Shape< T >::expand_space_dimension(), Parma_Polyhedra_Library::Octagonal_Shape< T >::fold_space_dimensions(), Parma_Polyhedra_Library::Octagonal_Shape< T >::frequency(), Parma_Polyhedra_Library::Octagonal_Shape< T >::get_limiting_octagon(), Parma_Polyhedra_Library::Octagonal_Shape< T >::incremental_strong_closure_assign(), Parma_Polyhedra_Library::Octagonal_Shape< T >::integer_upper_bound_assign_if_exact(), Parma_Polyhedra_Library::Octagonal_Shape< T >::is_bounded(), Parma_Polyhedra_Library::Octagonal_Shape< T >::is_disjoint_from(), Parma_Polyhedra_Library::Octagonal_Shape< T >::is_strong_coherent(), Parma_Polyhedra_Library::Octagonal_Shape< T >::is_strongly_reduced(), Parma_Polyhedra_Library::Octagonal_Shape< T >::map_space_dimensions(), Parma_Polyhedra_Library::Octagonal_Shape< T >::max_min(), Parma_Polyhedra_Library::Octagonal_Shape< T >::Octagonal_Shape(), Parma_Polyhedra_Library::Octagonal_Shape< T >::OK(), Parma_Polyhedra_Library::Octagonal_Shape< T >::refine(), Parma_Polyhedra_Library::Octagonal_Shape< T >::refine_no_check(), Parma_Polyhedra_Library::Octagonal_Shape< T >::relation_with(), Parma_Polyhedra_Library::Octagonal_Shape< T >::remove_space_dimensions(), Parma_Polyhedra_Library::Octagonal_Shape< T >::strong_closure_assign(), Parma_Polyhedra_Library::Octagonal_Shape< T >::strong_coherence_assign(), and Parma_Polyhedra_Library::Octagonal_Shape< T >::upper_bound_assign_if_exact().

00353                         {
00354   return num_rows() == 0 ? row_iterator(0) : row_iterator(vec[0]);
00355 }

template<typename T >
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 371 of file OR_Matrix.inlines.hh.

References Parma_Polyhedra_Library::OR_Matrix< T >::num_rows().

00371                             {
00372   return const_row_iterator(num_rows());
00373 }

template<typename T >
OR_Matrix< T >::row_iterator Parma_Polyhedra_Library::OR_Matrix< T >::row_end (  )  [inline]
template<typename T >
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 40 of file OR_Matrix.inlines.hh.

Referenced by Parma_Polyhedra_Library::OR_Matrix< T >::operator[]().

00040                                                             {
00041   return ((k + 1)*(k + 1))/2;
00042 }

template<typename T >
dimension_type Parma_Polyhedra_Library::OR_Matrix< T >::row_size ( dimension_type  k  )  [inline, static]
template<typename T >
void Parma_Polyhedra_Library::OR_Matrix< T >::shrink ( dimension_type  new_dim  )  [inline]

Makes the matrix shrink by removing the last space dimensions.

Parameters:
new_dim The new dimension of the resized matrix.

Erases from matrix to the end the rows with index greater than 2*new_dim-1.

Definition at line 561 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::Octagonal_Shape< T >::remove_space_dimensions(), and Parma_Polyhedra_Library::OR_Matrix< T >::resize_no_copy().

00561                                                  {
00562   PPL_ASSERT(new_dim <= space_dim);
00563   const dimension_type new_size = 2*new_dim*(new_dim + 1);
00564   vec.shrink(new_size);
00565   space_dim = new_dim;
00566 }

template<typename T >
dimension_type Parma_Polyhedra_Library::OR_Matrix< T >::space_dimension (  )  const [inline]
template<typename T >
void Parma_Polyhedra_Library::OR_Matrix< T >::swap ( OR_Matrix< T > &  y  )  [inline]
template<typename T >
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 433 of file OR_Matrix.inlines.hh.

References Parma_Polyhedra_Library::OR_Matrix< T >::external_memory_in_bytes().

00433                                           {
00434   return sizeof(*this) + external_memory_in_bytes();
00435 }


Friends And Related Function Documentation

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 
) [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 666 of file OR_Matrix.inlines.hh.

00672                                       {
00673   return
00674     l_m_distance_assign<Euclidean_Distance_Specialization<Temp> >(r, x, y,
00675                                                                   dir,
00676                                                                   tmp0,
00677                                                                   tmp1,
00678                                                                   tmp2);
00679 }

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 
) [related]

Computes the $L_\infty$ distance between x and y.

If the $L_\infty$ 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 686 of file OR_Matrix.inlines.hh.

00692                                        {
00693   return
00694     l_m_distance_assign<L_Infinity_Distance_Specialization<Temp> >(r, x, y,
00695                                                                    dir,
00696                                                                    tmp0,
00697                                                                    tmp1,
00698                                                                    tmp2);
00699 }

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 
) [related]

Definition at line 593 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 Parma_Polyhedra_Library::PLUS_INFINITY.

00599                                 {
00600   if (x.num_rows() != y.num_rows())
00601     return false;
00602   assign_r(tmp0, 0, ROUND_NOT_NEEDED);
00603   for (typename OR_Matrix<T>::const_element_iterator
00604          i = x.element_begin(), j = y.element_begin(),
00605          mat_end = x.element_end(); i != mat_end; ++i, ++j) {
00606     const T& x_i = *i;
00607     const T& y_i = *j;
00608     if (is_plus_infinity(x_i)) {
00609       if (is_plus_infinity(y_i))
00610         continue;
00611       else {
00612       pinf:
00613         assign_r(r, PLUS_INFINITY, ROUND_NOT_NEEDED);
00614         return true;
00615       }
00616     }
00617     else if (is_plus_infinity(y_i))
00618       goto pinf;
00619 
00620     const Temp* tmp1p;
00621     const Temp* tmp2p;
00622     if (x_i > y_i) {
00623       maybe_assign(tmp1p, tmp1, x_i, dir);
00624       maybe_assign(tmp2p, tmp2, y_i, inverse(dir));
00625     }
00626     else {
00627       maybe_assign(tmp1p, tmp1, y_i, dir);
00628       maybe_assign(tmp2p, tmp2, x_i, inverse(dir));
00629     }
00630     sub_assign_r(tmp1, *tmp1p, *tmp2p, dir);
00631     PPL_ASSERT(sgn(tmp1) >= 0);
00632     Specialization::combine(tmp0, tmp1, dir);
00633   }
00634 
00635   Specialization::finalize(tmp0, dir);
00636   assign_r(r, tmp0, dir);
00637   return true;
00638 }

template<typename T >
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 502 of file OR_Matrix.inlines.hh.

00502                                                          {
00503   return !(x == y);
00504 }

template<typename T >
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 }

template<typename T>
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 493 of file OR_Matrix.inlines.hh.

00493                                                          {
00494   return x.space_dim == y.space_dim && x.vec == y.vec;
00495 }

template<typename T>
friend class OR_Matrix [friend]

Definition at line 362 of file OR_Matrix.defs.hh.

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 
) [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 646 of file OR_Matrix.inlines.hh.

00652                                         {
00653   return
00654     l_m_distance_assign<Rectilinear_Distance_Specialization<Temp> >(r, x, y,
00655                                                                     dir,
00656                                                                     tmp0,
00657                                                                     tmp1,
00658                                                                     tmp2);
00659 }

template<typename T >
void swap ( Parma_Polyhedra_Library::OR_Matrix< T > &  x,
Parma_Polyhedra_Library::OR_Matrix< T > &  y 
) [related]

Specializes std::swap.

Definition at line 708 of file OR_Matrix.inlines.hh.

References Parma_Polyhedra_Library::OR_Matrix< T >::swap().

00709                                              {
00710   x.swap(y);
00711 }


Member Data Documentation

template<typename T>
dimension_type Parma_Polyhedra_Library::OR_Matrix< T >::space_dim [private]
template<typename T>
DB_Row<T> Parma_Polyhedra_Library::OR_Matrix< T >::vec [private]
template<typename T>
dimension_type Parma_Polyhedra_Library::OR_Matrix< T >::vec_capacity [private]

The documentation for this class was generated from the following files:
Generated on Sun Feb 27 16:20:31 2011 for PPL by  doxygen 1.6.3