Parma_Polyhedra_Library::Row Class Reference
[C++ Language Interface]

A finite sequence of coefficients. More...

#include <Row.defs.hh>

Inheritance diagram for Parma_Polyhedra_Library::Row:

Inheritance graph
[legend]
Collaboration diagram for Parma_Polyhedra_Library::Row:

Collaboration graph
[legend]

List of all members.

Public Member Functions

 Row ()
 Pre-constructs a row: construction must be completed by construct().
 Row (dimension_type sz, Flags f)
 Tight constructor: resizing may require reallocation.
 Row (dimension_type sz, dimension_type capacity, Flags f)
 Sizing constructor with capacity.
 Row (const Row &y)
 Ordinary copy constructor.
 Row (const Row &y, dimension_type capacity)
 Copy constructor with specified capacity.
 Row (const Row &y, dimension_type sz, dimension_type capacity)
 Copy constructor with specified size and capacity.
 ~Row ()
 Destructor.
Rowoperator= (const Row &y)
 Assignment operator.
void swap (Row &y)
 Swaps *this with y.
void assign (Row &y)
 Assigns the implementation of y to *this.
void allocate (dimension_type capacity, Flags f)
 Allocates memory for a default constructed Row object, setting flags to f and allowing for capacity coefficients at most.
void expand_within_capacity (dimension_type new_size)
 Expands the row to size new_size.
void shrink (dimension_type new_size)
 Shrinks the row by erasing elements at the end.
const Flagsflags () const
 Returns a const reference to the flags of *this.
Flagsflags ()
 Returns a non-const reference to the flags of *this.
dimension_type size () const
 Gives the number of coefficients currently in use.
void normalize ()
 Normalizes the modulo of coefficients so that they are mutually prime.
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 a lower bound to the total size in bytes of the memory occupied by *this.
memory_size_type external_memory_in_bytes () const
 Returns a lower bound to the size in bytes of the memory managed by *this.
memory_size_type total_memory_in_bytes (dimension_type capacity) const
 Returns the total size in bytes of the memory occupied by *this, provided the capacity of *this is given by capacity.
memory_size_type external_memory_in_bytes (dimension_type capacity) const
 Returns the size in bytes of the memory managed by *this, provided the capacity of *this is given by capacity.
bool OK () const
 Checks if all the invariants are satisfied.
bool OK (dimension_type row_size, dimension_type row_capacity) const
 Checks if all the invariants are satisfied and that the actual size and capacity match the values provided as arguments.
Post-constructors
void construct (dimension_type sz, Flags f)
 Constructs properly a default-constructed element.
void construct (dimension_type sz, dimension_type capacity, Flags f)
 Constructs properly a default-constructed element.
Subscript operators
Coefficientoperator[] (dimension_type k)
 Returns a reference to the element of the row indexed by k.
Coefficient_traits::const_reference operator[] (dimension_type k) const
 Returns a constant reference to the element of the row indexed by k.

Static Public Member Functions

static dimension_type max_size ()
 Returns the size() of the largest possible Row.

Private Member Functions

void copy_construct_coefficients (const Row &y)
 Exception-safe copy construction mechanism for coefficients.

Related Functions

(Note that these are not member functions.)

bool operator== (const Row &x, const Row &y)
 Returns true if and only if x and y are equal.
bool operator!= (const Row &x, const Row &y)
 Returns true if and only if x and y are different.
void swap (Parma_Polyhedra_Library::Row &x, Parma_Polyhedra_Library::Row &y)
 Specializes std::swap.
void iter_swap (std::vector< Parma_Polyhedra_Library::Row >::iterator x, std::vector< Parma_Polyhedra_Library::Row >::iterator y)
 Specializes std::iter_swap.

Classes

class  Flags
 Wrapper class to represent a set of flags with bits in a native unsigned integral type. More...


Detailed Description

A finite sequence of coefficients.

Definition at line 88 of file Row.defs.hh.


Constructor & Destructor Documentation

Parma_Polyhedra_Library::Row::Row (  )  [inline]

Pre-constructs a row: construction must be completed by construct().

Definition at line 205 of file Row.inlines.hh.

00206   : Row_Impl_Handler() {
00207 }

Parma_Polyhedra_Library::Row::Row ( dimension_type  sz,
Flags  f 
) [inline]

Tight constructor: resizing may require reallocation.

Constructs a row with size and capacity sz, and flags f.

Definition at line 270 of file Row.inlines.hh.

References construct().

00271   : Row_Impl_Handler() {
00272   construct(sz, f);
00273 }

Parma_Polyhedra_Library::Row::Row ( dimension_type  sz,
dimension_type  capacity,
Flags  f 
) [inline]

Sizing constructor with capacity.

Parameters:
sz The size of the row that will be constructed;
capacity The capacity of the row that will be constructed;
f Flags for the row that will be constructed.
The row that is constructed has storage for capacity elements, sz of which are default-constructed now. The row flags are set to f.

Definition at line 262 of file Row.inlines.hh.

References construct().

00265   : Row_Impl_Handler() {
00266   construct(sz, capacity, f);
00267 }

Parma_Polyhedra_Library::Row::Row ( const Row y  )  [inline]

Ordinary copy constructor.

Definition at line 276 of file Row.inlines.hh.

References allocate(), Parma_Polyhedra_Library::compute_capacity(), copy_construct_coefficients(), flags(), Parma_Polyhedra_Library::Row_Impl_Handler::impl, max_size(), and size().

00277   : Row_Impl_Handler() {
00278   if (y.impl) {
00279     allocate(compute_capacity(y.size(), max_size()), y.flags());
00280     copy_construct_coefficients(y);
00281   }
00282 }

Parma_Polyhedra_Library::Row::Row ( const Row y,
dimension_type  capacity 
) [inline]

Copy constructor with specified capacity.

It is assumed that capacity is greater than or equal to the size of y.

Definition at line 285 of file Row.inlines.hh.

References allocate(), copy_construct_coefficients(), flags(), Parma_Polyhedra_Library::Row_Impl_Handler::impl, max_size(), and size().

00287   : Row_Impl_Handler() {
00288   assert(y.impl);
00289   assert(y.size() <= capacity && capacity <= max_size());
00290   allocate(capacity, y.flags());
00291   copy_construct_coefficients(y);
00292 }

Parma_Polyhedra_Library::Row::Row ( const Row y,
dimension_type  sz,
dimension_type  capacity 
) [inline]

Copy constructor with specified size and capacity.

It is assumed that sz is greater than or equal to the size of y and, of course, that sz is less than or equal to capacity.

Definition at line 295 of file Row.inlines.hh.

References allocate(), copy_construct_coefficients(), expand_within_capacity(), flags(), Parma_Polyhedra_Library::Row_Impl_Handler::impl, max_size(), and size().

00298   : Row_Impl_Handler() {
00299   assert(y.impl);
00300   assert(y.size() <= sz && sz <= capacity && capacity <= max_size());
00301   allocate(capacity, y.flags());
00302   copy_construct_coefficients(y);
00303   expand_within_capacity(sz);
00304 }

Parma_Polyhedra_Library::Row::~Row (  )  [inline]

Destructor.

Definition at line 307 of file Row.inlines.hh.

00307           {
00308 }


Member Function Documentation

void Parma_Polyhedra_Library::Row::construct ( dimension_type  sz,
Flags  f 
) [inline]

Constructs properly a default-constructed element.

Builds a row with size and capacity sz and flags f.

Reimplemented in Parma_Polyhedra_Library::Linear_Row.

Definition at line 257 of file Row.inlines.hh.

Referenced by Row().

00257                                                      {
00258   construct(sz, sz, f);
00259 }

void Parma_Polyhedra_Library::Row::construct ( dimension_type  sz,
dimension_type  capacity,
Flags  f 
) [inline]

Constructs properly a default-constructed element.

Parameters:
sz The size of the row that will be constructed;
capacity The capacity of the row that will be constructed;
f Flags for the row that will be constructed.
The row that is constructed has storage for capacity elements, sz of which are default-constructed now. The row flags are set to f.

Reimplemented in Parma_Polyhedra_Library::Linear_Row.

Definition at line 248 of file Row.inlines.hh.

References allocate(), expand_within_capacity(), and max_size().

00250                               {
00251   assert(sz <= capacity && capacity <= max_size());
00252   allocate(capacity, f);
00253   expand_within_capacity(sz);
00254 }

Row & Parma_Polyhedra_Library::Row::operator= ( const Row y  )  [inline]

Assignment operator.

Definition at line 333 of file Row.inlines.hh.

References swap().

Referenced by Parma_Polyhedra_Library::Generator::operator=(), Parma_Polyhedra_Library::Constraint::operator=(), and Parma_Polyhedra_Library::Congruence::operator=().

00333                            {
00334   // Copy-construct `tmp' from `y'.
00335   Row tmp(y);
00336   // Swap the implementation of `*this' with the one of `tmp'.
00337   swap(tmp);
00338   // Now `tmp' goes out of scope, so the old `*this' will be destroyed.
00339   return *this;
00340 }

void Parma_Polyhedra_Library::Row::swap ( Row y  )  [inline]

void Parma_Polyhedra_Library::Row::assign ( Row y  )  [inline]

Assigns the implementation of y to *this.

To be used with extra care, since it may easily cause memory leaks or undefined behavior.

Definition at line 325 of file Row.inlines.hh.

References Parma_Polyhedra_Library::Row_Impl_Handler::impl.

00325                   {
00326   impl = y.impl;
00327 #if PPL_ROW_EXTRA_DEBUG
00328   capacity_ = y.capacity_;
00329 #endif
00330 }

void Parma_Polyhedra_Library::Row::allocate ( dimension_type  capacity,
Flags  f 
) [inline]

Allocates memory for a default constructed Row object, setting flags to f and allowing for capacity coefficients at most.

It is assumed that no allocation has been performed before (otherwise, a memory leak will occur). After execution, the size of the Row object is zero.

Definition at line 210 of file Row.inlines.hh.

References Parma_Polyhedra_Library::Row_Impl_Handler::impl, and max_size().

Referenced by construct(), and Row().

00215                               {
00216   assert(capacity <= max_size());
00217 #if !PPL_CXX_SUPPORTS_FLEXIBLE_ARRAYS
00218   if (capacity == 0)
00219     ++capacity;
00220 #endif
00221   assert(impl == 0);
00222   impl = new (capacity) Impl(f);
00223 #if PPL_ROW_EXTRA_DEBUG
00224   assert(capacity_ == 0);
00225   capacity_ = capacity;
00226 #endif
00227 }

void Parma_Polyhedra_Library::Row::expand_within_capacity ( dimension_type  new_size  )  [inline]

Expands the row to size new_size.

Adds new positions to the implementation of the row obtaining a new row with size new_size. It is assumed that new_size is between the current size and capacity of the row.

Definition at line 230 of file Row.inlines.hh.

References Parma_Polyhedra_Library::Row_Impl_Handler::Impl::expand_within_capacity(), and Parma_Polyhedra_Library::Row_Impl_Handler::impl.

Referenced by construct(), and Row().

00230                                                          {
00231   assert(impl);
00232 #if PPL_ROW_EXTRA_DEBUG
00233   assert(new_size <= capacity_);
00234 #endif
00235   impl->expand_within_capacity(new_size);
00236 }

void Parma_Polyhedra_Library::Row::shrink ( dimension_type  new_size  )  [inline]

Shrinks the row by erasing elements at the end.

Destroys elements of the row implementation from position new_size to the end. It is assumed that new_size is not greater than the current size.

Definition at line 311 of file Row.inlines.hh.

References Parma_Polyhedra_Library::Row_Impl_Handler::impl, and Parma_Polyhedra_Library::Row_Impl_Handler::Impl::shrink().

Referenced by ascii_load(), Parma_Polyhedra_Library::Linear_Row::ascii_load(), Parma_Polyhedra_Library::Grid_Generator::ascii_load(), Parma_Polyhedra_Library::Congruence::ascii_load(), and Parma_Polyhedra_Library::MIP_Problem::erase_artificials().

00311                                          {
00312   assert(impl);
00313   impl->shrink(new_size);
00314 }

const Row::Flags & Parma_Polyhedra_Library::Row::flags (  )  const [inline]

Returns a const reference to the flags of *this.

Reimplemented in Parma_Polyhedra_Library::Linear_Row.

Definition at line 175 of file Row.inlines.hh.

References Parma_Polyhedra_Library::Row_Impl_Handler::Impl::flags(), and Parma_Polyhedra_Library::Row_Impl_Handler::impl.

Referenced by ascii_dump(), ascii_load(), Parma_Polyhedra_Library::Linear_Row::flags(), operator==(), and Row().

00175                  {
00176   return impl->flags();
00177 }

Row::Flags & Parma_Polyhedra_Library::Row::flags (  )  [inline]

Returns a non-const reference to the flags of *this.

Reimplemented in Parma_Polyhedra_Library::Linear_Row.

Definition at line 180 of file Row.inlines.hh.

References Parma_Polyhedra_Library::Row_Impl_Handler::Impl::flags(), and Parma_Polyhedra_Library::Row_Impl_Handler::impl.

00180            {
00181   return impl->flags();
00182 }

dimension_type Parma_Polyhedra_Library::Row::max_size (  )  [inline, static]

dimension_type Parma_Polyhedra_Library::Row::size (  )  const [inline]

Gives the number of coefficients currently in use.

Reimplemented in Parma_Polyhedra_Library::Grid_Generator.

Definition at line 170 of file Row.inlines.hh.

References Parma_Polyhedra_Library::Row_Impl_Handler::impl, and Parma_Polyhedra_Library::Row_Impl_Handler::Impl::size().

Referenced by Parma_Polyhedra_Library::Linear_System::add_pending_row(), Parma_Polyhedra_Library::Linear_System::add_row(), Parma_Polyhedra_Library::Constraint_System::affine_preimage(), Parma_Polyhedra_Library::Congruence_System::affine_preimage(), Parma_Polyhedra_Library::Linear_Row::all_homogeneous_terms_are_zero(), ascii_dump(), Parma_Polyhedra_Library::MIP_Problem::ascii_dump(), Parma_Polyhedra_Library::Linear_Row::ascii_dump(), Parma_Polyhedra_Library::Congruence::ascii_dump(), ascii_load(), Parma_Polyhedra_Library::Linear_Row::ascii_load(), Parma_Polyhedra_Library::Grid_Generator::ascii_load(), Parma_Polyhedra_Library::Congruence::ascii_load(), Parma_Polyhedra_Library::Scalar_Products::assign(), Parma_Polyhedra_Library::Linear_Row::compare(), Parma_Polyhedra_Library::MIP_Problem::compute_simplex_using_exact_pricing(), Parma_Polyhedra_Library::MIP_Problem::compute_simplex_using_steepest_edge_float(), Parma_Polyhedra_Library::Congruence::Congruence(), copy_construct_coefficients(), Parma_Polyhedra_Library::MIP_Problem::erase_artificials(), Parma_Polyhedra_Library::Scalar_Products::homogeneous_assign(), Parma_Polyhedra_Library::Linear_System::insert(), Parma_Polyhedra_Library::Linear_System::insert_pending(), Parma_Polyhedra_Library::Congruence_System::insert_verbatim(), Parma_Polyhedra_Library::Constraint::is_inconsistent(), Parma_Polyhedra_Library::Constraint::is_tautological(), Parma_Polyhedra_Library::MIP_Problem::linear_combine(), Parma_Polyhedra_Library::Linear_Row::linear_combine(), Parma_Polyhedra_Library::Linear_Expression::Linear_Expression(), Parma_Polyhedra_Library::Congruence::modulus(), normalize(), Parma_Polyhedra_Library::Congruence::normalize(), Parma_Polyhedra_Library::Congruence_System::normalize_moduli(), OK(), Parma_Polyhedra_Library::MIP_Problem::OK(), Parma_Polyhedra_Library::Generator::OK(), Parma_Polyhedra_Library::Constraint::OK(), Parma_Polyhedra_Library::Congruence::operator/=(), operator==(), Parma_Polyhedra_Library::MIP_Problem::process_pending_constraints(), Parma_Polyhedra_Library::Scalar_Products::reduced_assign(), Row(), Parma_Polyhedra_Library::MIP_Problem::second_phase(), Parma_Polyhedra_Library::Congruence::set_is_equality(), Parma_Polyhedra_Library::Linear_Row::sign_normalize(), Parma_Polyhedra_Library::Congruence::sign_normalize(), Parma_Polyhedra_Library::Grid_Generator::size(), Parma_Polyhedra_Library::Linear_Row::space_dimension(), Parma_Polyhedra_Library::Linear_Expression::space_dimension(), Parma_Polyhedra_Library::Congruence::space_dimension(), Parma_Polyhedra_Library::MIP_Problem::steepest_edge_exact_entering_index(), Parma_Polyhedra_Library::MIP_Problem::steepest_edge_float_entering_index(), Parma_Polyhedra_Library::MIP_Problem::textbook_entering_index(), Parma_Polyhedra_Library::Generator::type(), and Parma_Polyhedra_Library::Constraint::type().

00170                 {
00171   return impl->size();
00172 }

Coefficient & Parma_Polyhedra_Library::Row::operator[] ( dimension_type  k  )  [inline]

Coefficient_traits::const_reference Parma_Polyhedra_Library::Row::operator[] ( dimension_type  k  )  const [inline]

Returns a constant reference to the element of the row indexed by k.

Reimplemented in Parma_Polyhedra_Library::Grid_Generator.

Definition at line 349 of file Row.inlines.hh.

References Parma_Polyhedra_Library::Row_Impl_Handler::impl.

00349                                             {
00350   assert(impl);
00351   return (*impl)[k];
00352 }

void Parma_Polyhedra_Library::Row::normalize (  ) 

Normalizes the modulo of coefficients so that they are mutually prime.

Computes the Greatest Common Divisor (GCD) among the elements of the row and normalizes them by the GCD itself.

Reimplemented in Parma_Polyhedra_Library::Congruence.

Definition at line 87 of file Row.cc.

References Parma_Polyhedra_Library::exact_div_assign(), Parma_Polyhedra_Library::gcd_assign(), Parma_Polyhedra_Library::neg_assign(), size(), and TEMP_INTEGER.

Referenced by Parma_Polyhedra_Library::Generator_System::add_corresponding_closure_points(), Parma_Polyhedra_Library::Polyhedron::add_generator(), Parma_Polyhedra_Library::Polyhedron::BHRZ03_evolving_rays(), Parma_Polyhedra_Library::Generator::is_equivalent_to(), Parma_Polyhedra_Library::Constraint::is_equivalent_to(), Parma_Polyhedra_Library::MIP_Problem::linear_combine(), Parma_Polyhedra_Library::Linear_Row::strong_normalize(), Parma_Polyhedra_Library::Congruence::strong_normalize(), Parma_Polyhedra_Library::Polyhedron::strongly_minimize_generators(), Parma_Polyhedra_Library::Polyhedron::time_elapse_assign(), and Parma_Polyhedra_Library::Polyhedron::topological_closure_assign().

00087                   {
00088   Row& x = *this;
00089   // Compute the GCD of all the coefficients.
00090   const dimension_type sz = size();
00091   dimension_type i = sz;
00092   TEMP_INTEGER(gcd);
00093   while (i > 0) {
00094     const Coefficient& x_i = x[--i];
00095     if (const int x_i_sign = sgn(x_i)) {
00096       gcd = x_i;
00097       if (x_i_sign < 0)
00098         neg_assign(gcd);
00099       goto compute_gcd;
00100     }
00101   }
00102   // We reach this point only if all the coefficients were zero.
00103   return;
00104 
00105  compute_gcd:
00106   if (gcd == 1)
00107     return;
00108   while (i > 0) {
00109     const Coefficient& x_i = x[--i];
00110     if (x_i != 0) {
00111       // Note: we use the ternary version instead of a more concise
00112       // gcd_assign(gcd, x_i) to take advantage of the fact that
00113       // `gcd' will decrease very rapidly (see D. Knuth, The Art of
00114       // Computer Programming, second edition, Section 4.5.2,
00115       // Algorithm C, and the discussion following it).  Our
00116       // implementation of gcd_assign(x, y, z) for checked numbers is
00117       // optimized for the case where `z' is smaller than `y', so that
00118       // on checked numbers we gain.  On the other hand, for the
00119       // implementation of gcd_assign(x, y, z) on GMP's unbounded
00120       // integers we cannot make any assumption, so here we draw.
00121       // Overall, we win.
00122       gcd_assign(gcd, x_i, gcd);
00123       if (gcd == 1)
00124         return;
00125     }
00126   }
00127   // Divide the coefficients by the GCD.
00128   for (dimension_type j = sz; j-- > 0; ) {
00129     Coefficient& x_j = x[j];
00130     exact_div_assign(x_j, x_j, gcd);
00131   }
00132 }

void Parma_Polyhedra_Library::Row::ascii_dump (  )  const

void Parma_Polyhedra_Library::Row::ascii_dump ( std::ostream &  s  )  const

Writes to s an ASCII representation of *this.

Reimplemented in Parma_Polyhedra_Library::Linear_Row, Parma_Polyhedra_Library::Linear_Expression, Parma_Polyhedra_Library::Constraint, Parma_Polyhedra_Library::Congruence, Parma_Polyhedra_Library::Generator, and Parma_Polyhedra_Library::Grid_Generator.

Definition at line 162 of file Row.cc.

References Parma_Polyhedra_Library::Row::Flags::ascii_dump(), flags(), and size().

00162                                       {
00163   const Row& x = *this;
00164   const dimension_type x_size = x.size();
00165   s << "size " << x_size << " ";
00166   for (dimension_type i = 0; i < x_size; ++i)
00167     s << x[i] << ' ';
00168   s << "f ";
00169   flags().ascii_dump(s);
00170   s << "\n";
00171 }

void Parma_Polyhedra_Library::Row::print (  )  const

bool Parma_Polyhedra_Library::Row::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.

Reimplemented in Parma_Polyhedra_Library::Linear_Row, Parma_Polyhedra_Library::Linear_Expression, Parma_Polyhedra_Library::Constraint, Parma_Polyhedra_Library::Congruence, Parma_Polyhedra_Library::Generator, and Parma_Polyhedra_Library::Grid_Generator.

Definition at line 176 of file Row.cc.

References Parma_Polyhedra_Library::Row::Flags::ascii_load(), flags(), shrink(), size(), and swap().

Referenced by Parma_Polyhedra_Library::MIP_Problem::ascii_load().

00176                                 {
00177   std::string str;
00178   if (!(s >> str) || str != "size")
00179     return false;
00180   dimension_type new_size;
00181   if (!(s >> new_size))
00182     return false;
00183 
00184   Row& x = *this;
00185   const dimension_type old_size = x.size();
00186   if (new_size < old_size)
00187     x.shrink(new_size);
00188   else if (new_size > old_size) {
00189     Row y(new_size, Row::Flags());
00190     x.swap(y);
00191   }
00192 
00193   for (dimension_type col = 0; col < new_size; ++col)
00194     if (!(s >> x[col]))
00195       return false;
00196   if (!(s >> str) || (str.compare("f") != 0))
00197     return false;
00198   return flags().ascii_load(s);
00199 }

memory_size_type Parma_Polyhedra_Library::Row::total_memory_in_bytes (  )  const [inline]

Returns a lower bound to the total size in bytes of the memory occupied by *this.

Reimplemented in Parma_Polyhedra_Library::Linear_Expression, Parma_Polyhedra_Library::Constraint, Parma_Polyhedra_Library::Congruence, Parma_Polyhedra_Library::Generator, and Parma_Polyhedra_Library::Grid_Generator.

Definition at line 374 of file Row.inlines.hh.

References external_memory_in_bytes().

00374                                  {
00375   return sizeof(*this) + external_memory_in_bytes();
00376 }

memory_size_type Parma_Polyhedra_Library::Row::external_memory_in_bytes (  )  const [inline]

memory_size_type Parma_Polyhedra_Library::Row::total_memory_in_bytes ( dimension_type  capacity  )  const [inline]

Returns the total size in bytes of the memory occupied by *this, provided the capacity of *this is given by capacity.

Definition at line 360 of file Row.inlines.hh.

References external_memory_in_bytes().

00360                                                         {
00361   return sizeof(*this) + external_memory_in_bytes(capacity);
00362 }

memory_size_type Parma_Polyhedra_Library::Row::external_memory_in_bytes ( dimension_type  capacity  )  const [inline]

Returns the size in bytes of the memory managed by *this, provided the capacity of *this is given by capacity.

Definition at line 355 of file Row.inlines.hh.

References Parma_Polyhedra_Library::Row_Impl_Handler::impl, and Parma_Polyhedra_Library::Row_Impl_Handler::Impl::total_memory_in_bytes().

00355                                                            {
00356   return impl->total_memory_in_bytes(capacity);
00357 }

bool Parma_Polyhedra_Library::Row::OK (  )  const

Checks if all the invariants are satisfied.

Reimplemented in Parma_Polyhedra_Library::Linear_Row, Parma_Polyhedra_Library::Linear_Expression, Parma_Polyhedra_Library::Constraint, Parma_Polyhedra_Library::Congruence, Parma_Polyhedra_Library::Generator, and Parma_Polyhedra_Library::Grid_Generator.

Definition at line 210 of file Row.cc.

References max_size(), and size().

Referenced by Parma_Polyhedra_Library::Matrix::add_recycled_row(), OK(), Parma_Polyhedra_Library::Linear_Row::OK(), and Parma_Polyhedra_Library::Congruence::OK().

00210                  {
00211 #ifndef NDEBUG
00212   using std::endl;
00213   using std::cerr;
00214 #endif
00215 
00216   bool is_broken = false;
00217 #if PPL_ROW_EXTRA_DEBUG
00218 # if !PPL_CXX_SUPPORTS_FLEXIBLE_ARRAYS
00219   if (capacity_ == 0) {
00220     cerr << "Illegal row capacity: is 0, should be at least 1"
00221          << endl;
00222     is_broken = true;
00223   }
00224   else
00225 # endif // !PPL_CXX_SUPPORTS_FLEXIBLE_ARRAYS
00226   if (capacity_ > max_size()) {
00227     cerr << "Row capacity exceeds the maximum allowed size:"
00228          << endl
00229          << "is " << capacity_
00230          << ", should be less than or equal to " << max_size() << "."
00231          << endl;
00232     is_broken = true;
00233   }
00234 #endif // PPL_ROW_EXTRA_DEBUG
00235   if (size() > max_size()) {
00236 #ifndef NDEBUG
00237     cerr << "Row size exceeds the maximum allowed size:"
00238          << endl
00239          << "is " << size()
00240          << ", should be less than or equal to " << max_size() << "."
00241          << endl;
00242 #endif
00243     is_broken = true;
00244   }
00245 #if PPL_ROW_EXTRA_DEBUG
00246   if (capacity_ < size()) {
00247 #ifndef NDEBUG
00248     cerr << "Row is completely broken: capacity is " << capacity_
00249          << ", size is " << size() << "."
00250          << endl;
00251 #endif
00252     is_broken = true;
00253   }
00254 #endif // PPL_ROW_EXTRA_DEBUG
00255   return !is_broken;
00256 }

bool Parma_Polyhedra_Library::Row::OK ( dimension_type  row_size,
dimension_type  row_capacity 
) const

Checks if all the invariants are satisfied and that the actual size and capacity match the values provided as arguments.

Reimplemented in Parma_Polyhedra_Library::Linear_Row.

Definition at line 259 of file Row.cc.

References OK(), and size().

00264                      {
00265 #ifndef NDEBUG
00266   using std::endl;
00267   using std::cerr;
00268 #endif
00269 
00270   bool is_broken = !OK();
00271 
00272 #if PPL_ROW_EXTRA_DEBUG
00273   // Check the declared capacity.
00274 # if !PPL_CXX_SUPPORTS_FLEXIBLE_ARRAYS
00275   if (capacity_ == 1 && row_capacity == 0)
00276     // This is fine.
00277     ;
00278   else
00279 # endif // !PPL_CXX_SUPPORTS_FLEXIBLE_ARRAYS
00280   if (capacity_ != row_capacity) {
00281     cerr << "Row capacity mismatch: is " << capacity_
00282          << ", should be " << row_capacity << "."
00283          << endl;
00284     is_broken = true;
00285   }
00286 #endif // PPL_ROW_EXTRA_DEBUG
00287 
00288   // Check the declared size.
00289   if (size() != row_size) {
00290 #ifndef NDEBUG
00291     cerr << "Row size mismatch: is " << size()
00292          << ", should be " << row_size << "."
00293          << endl;
00294 #endif
00295     is_broken = true;
00296   }
00297   return !is_broken;
00298 }

void Parma_Polyhedra_Library::Row::copy_construct_coefficients ( const Row y  )  [inline, private]

Exception-safe copy construction mechanism for coefficients.

Definition at line 239 of file Row.inlines.hh.

References Parma_Polyhedra_Library::Row_Impl_Handler::Impl::copy_construct_coefficients(), Parma_Polyhedra_Library::Row_Impl_Handler::impl, and size().

Referenced by Row().

00239                                              {
00240   assert(impl && y.impl);
00241 #if PPL_ROW_EXTRA_DEBUG
00242   assert(y.size() <= capacity_);
00243 #endif
00244   impl->copy_construct_coefficients(*(y.impl));
00245 }


Friends And Related Function Documentation

bool operator== ( const Row x,
const Row y 
) [related]

Returns true if and only if x and y are equal.

Definition at line 302 of file Row.cc.

References flags(), and size().

00302                                           {
00303   const dimension_type x_size = x.size();
00304   const dimension_type y_size = y.size();
00305   if (x_size != y_size)
00306     return false;
00307 
00308   if (x.flags() != y.flags())
00309     return false;
00310 
00311   for (dimension_type i = x_size; i-- > 0; )
00312     if (x[i] != y[i])
00313       return false;
00314 
00315   return true;
00316 }

bool operator!= ( const Row x,
const Row y 
) [related]

Returns true if and only if x and y are different.

Definition at line 380 of file Row.inlines.hh.

00380                                        {
00381   return !(x == y);
00382 }

void swap ( Parma_Polyhedra_Library::Row x,
Parma_Polyhedra_Library::Row y 
) [related]

Specializes std::swap.

Definition at line 391 of file Row.inlines.hh.

References swap().

00391                                                                    {
00392   x.swap(y);
00393 }

void iter_swap ( std::vector< Parma_Polyhedra_Library::Row >::iterator  x,
std::vector< Parma_Polyhedra_Library::Row >::iterator  y 
) [related]

Specializes std::iter_swap.

Definition at line 397 of file Row.inlines.hh.

References swap().

00398                                                            {
00399   swap(*x, *y);
00400 }


The documentation for this class was generated from the following files:

Generated on Sat Oct 11 10:41:05 2008 for PPL by  doxygen 1.5.6