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

A 2-dimensional matrix of coefficients. More...

#include <Matrix.defs.hh>

Inheritance diagram for Parma_Polyhedra_Library::Matrix:
Inheritance graph
[legend]

List of all members.

Classes

class  const_iterator
 An iterator over a matrix. More...

Public Member Functions

 Matrix ()
 Builds an empty matrix.
 Matrix (dimension_type n_rows, dimension_type n_columns, Row::Flags row_flags=Row::Flags())
 Builds a zero matrix with specified dimensions and flags.
 Matrix (const Matrix &y)
 Copy constructor.
 ~Matrix ()
 Destructor.
Matrixoperator= (const Matrix &y)
 Assignment operator.
bool has_no_rows () const
 Returns true if and only if *this has no rows.
const_iterator begin () const
 Returns the const_iterator pointing to the first row, if *this is not empty; otherwise, returns the past-the-end const_iterator.
const_iterator end () const
 Returns the past-the-end const_iterator.
void swap (Matrix &y)
 Swaps *this with y.
void add_zero_rows (dimension_type n, Row::Flags row_flags)
 Adds to the matrix n rows of zeroes with flags set to row_flags.
void add_zero_columns (dimension_type n)
 Adds n columns of zeroes to the matrix.
void add_zero_rows_and_columns (dimension_type n, dimension_type m, Row::Flags row_flags)
 Adds n rows and m columns of zeroes to the matrix.
void add_row (const Row &y)
 Adds a copy of the row y to the matrix.
void add_recycled_row (Row &y)
 Adds the row y to the matrix.
void remove_trailing_columns (dimension_type n)
 Makes the matrix shrink by removing its n trailing columns.
void resize_no_copy (dimension_type new_n_rows, dimension_type new_n_columns, Row::Flags row_flags)
 Resizes the matrix without worrying about the old contents.
void swap_columns (dimension_type i, dimension_type j)
 Swaps the columns having indexes i and j.
void permute_columns (const std::vector< dimension_type > &cycles)
 Permutes the columns of the matrix.
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.
void erase_to_end (dimension_type first_to_erase)
 Erases from the matrix all the rows but those having an index less than first_to_erase.
bool OK () const
 Checks if all the invariants are satisfied.
Accessors

dimension_type num_columns () const
 Returns the number of columns of the matrix (i.e., the size of the rows).
dimension_type num_rows () const
 Returns the number of rows in the matrix.
Subscript operators

Rowoperator[] (dimension_type k)
 Returns a reference to the k-th row of the matrix.
const Rowoperator[] (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 Matrix.
static dimension_type max_num_columns ()
 Returns the maximum number of columns of a Matrix.

Protected Attributes

std::vector< Rowrows
 Contains the rows of the matrix.
dimension_type row_size
 Size of the initialized part of each row.
dimension_type row_capacity
 Capacity allocated for each row.

Related Functions

(Note that these are not member functions.)



void swap (Parma_Polyhedra_Library::Matrix &x, Parma_Polyhedra_Library::Matrix &y)
 Specializes std::swap.
bool operator== (const Matrix &x, const Matrix &y)
 Returns true if and only if x and y are identical.
bool operator!= (const Matrix &x, const Matrix &y)
 Returns true if and only if x and y are different.

Detailed Description

A 2-dimensional matrix of coefficients.

A Matrix object is a sequence of Row objects and is characterized by the matrix dimensions (the number of rows and columns). All the rows in a matrix, besides having the same size (corresponding to the number of columns of the matrix), are also bound to have the same capacity.

Definition at line 46 of file Matrix.defs.hh.


Constructor & Destructor Documentation

Parma_Polyhedra_Library::Matrix::Matrix (  )  [inline]

Builds an empty matrix.

Rows' size and capacity are initialized to $0$.

Definition at line 122 of file Matrix.inlines.hh.

00123   : rows(),
00124     row_size(0),
00125     row_capacity(0) {
00126 }

Parma_Polyhedra_Library::Matrix::Matrix ( dimension_type  n_rows,
dimension_type  n_columns,
Row::Flags  row_flags = Row::Flags() 
)

Builds a zero matrix with specified dimensions and flags.

Parameters:
n_rows The number of rows of the matrix that will be created;
n_columns The number of columns of the matrix that will be created.
row_flags The flags used to build the rows of the matrix; by default, the rows will have all flags unset.

Definition at line 33 of file Matrix.cc.

References Parma_Polyhedra_Library::construct(), max_num_rows(), OK(), row_capacity, and rows.

00037   :
00038 #ifdef NDEBUG
00039     rows(n_rows),
00040 #else
00041     rows(n_rows <= max_num_rows() ? n_rows : 0),
00042 #endif
00043     row_size(n_columns),
00044     row_capacity(compute_capacity(n_columns, max_num_columns())) {
00045   PPL_ASSERT(n_rows <= max_num_rows());
00046   // Construct in direct order: will destroy in reverse order.
00047   for (dimension_type i = 0; i < n_rows; ++i)
00048     rows[i].construct(n_columns, row_capacity, row_flags);
00049   PPL_ASSERT(OK());
}

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

Copy constructor.

Definition at line 129 of file Matrix.inlines.hh.

00130   : rows(y.rows),
00131     row_size(y.row_size),
00132     row_capacity(compute_capacity(y.row_size, max_num_columns())) {
00133 }

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

Destructor.

Definition at line 136 of file Matrix.inlines.hh.

00136                 {
00137 }


Member Function Documentation

void Parma_Polyhedra_Library::Matrix::add_recycled_row ( Row y  ) 

Adds the row y to the matrix.

Parameters:
y The row to be added: it must have the same size and capacity as *this. It is not declared const because its data-structures will recycled to build the new matrix row.

Turns the $r \times c$ matrix $M$ into the $(r+1) \times c$ matrix $\genfrac{(}{)}{0pt}{}{M}{y}$. The matrix is expanded avoiding reallocation whenever possible.

Definition at line 183 of file Matrix.cc.

References Parma_Polyhedra_Library::compute_capacity(), max_num_rows(), OK(), Parma_Polyhedra_Library::Row::OK(), row_capacity, row_size, rows, and swap().

Referenced by add_row(), Parma_Polyhedra_Library::Congruence_System::insert(), and Parma_Polyhedra_Library::Congruence_System::insert_verbatim().

00183                                   {
00184   // The added row must have the same size and capacity as the
00185   // existing rows of the system.
00186   PPL_ASSERT(y.OK(row_size, row_capacity));
00187   const dimension_type new_rows_size = rows.size() + 1;
00188   if (rows.capacity() < new_rows_size) {
00189     // Reallocation will take place.
00190     std::vector<Row> new_rows;
00191     new_rows.reserve(compute_capacity(new_rows_size, max_num_rows()));
00192     new_rows.insert(new_rows.end(), new_rows_size, Row());
00193     // Put the new row in place.
00194     dimension_type i = new_rows_size-1;
00195     std::swap(new_rows[i], y);
00196     // Steal the old rows.
00197     while (i-- > 0)
00198       new_rows[i].swap(rows[i]);
00199     // Put the new rows into place.
00200     std::swap(rows, new_rows);
00201   }
00202   else
00203     // Reallocation will NOT take place.
00204     // Inserts a new empty row at the end,
00205     // then substitutes it with a copy of the given row.
00206     std::swap(*rows.insert(rows.end(), Row()), y);
00207 
00208   PPL_ASSERT(OK());
00209 }

void Parma_Polyhedra_Library::Matrix::add_row ( const Row y  )  [inline]

Adds a copy of the row y to the matrix.

Parameters:
y The row to be copied: it must have the same number of columns as the matrix.

Turns the $r \times c$ matrix $M$ into the $(r+1) \times c$ matrix $\genfrac{(}{)}{0pt}{}{M}{y}$. The matrix is expanded avoiding reallocation whenever possible.

Definition at line 157 of file Matrix.inlines.hh.

References add_recycled_row(), and row_capacity.

Referenced by Parma_Polyhedra_Library::PIP_Tree_Node::compatibility_check(), Parma_Polyhedra_Library::Congruence_System::insert_verbatim(), Parma_Polyhedra_Library::PIP_Solution_Node::solve(), and Parma_Polyhedra_Library::PIP_Problem::solve().

00157                             {
00158   Row new_row(y, row_capacity);
00159   add_recycled_row(new_row);
00160 }

void Parma_Polyhedra_Library::Matrix::add_zero_columns ( dimension_type  n  ) 

Adds n columns of zeroes to the matrix.

Parameters:
n The number of columns to be added: must be strictly positive.

Turns the $r \times c$ matrix $M$ into the $r \times (c+n)$ matrix $(M \, 0)$. The matrix is expanded avoiding reallocation whenever possible.

Definition at line 83 of file Matrix.cc.

References Parma_Polyhedra_Library::compute_capacity(), max_num_columns(), num_columns(), num_rows(), row_capacity, row_size, rows, and swap().

Referenced by Parma_Polyhedra_Library::Polyhedron::add_space_dimensions(), Parma_Polyhedra_Library::Grid::add_space_dimensions(), Parma_Polyhedra_Library::Polyhedron::add_space_dimensions_and_embed(), Parma_Polyhedra_Library::Grid::add_space_dimensions_and_embed(), Parma_Polyhedra_Library::Polyhedron::add_space_dimensions_and_project(), Parma_Polyhedra_Library::Generator_System::adjust_topology_and_space_dimension(), Parma_Polyhedra_Library::Constraint_System::adjust_topology_and_space_dimension(), Parma_Polyhedra_Library::Grid_Generator_System::clear(), Parma_Polyhedra_Library::Congruence_System::clear(), Parma_Polyhedra_Library::PIP_Solution_Node::generate_cut(), Parma_Polyhedra_Library::Congruence_System::increase_space_dimension(), Parma_Polyhedra_Library::Linear_System::insert(), Parma_Polyhedra_Library::Grid_Generator_System::insert(), Parma_Polyhedra_Library::Generator_System::insert(), Parma_Polyhedra_Library::Constraint_System::insert(), Parma_Polyhedra_Library::Congruence_System::insert(), Parma_Polyhedra_Library::Linear_System::insert_pending(), Parma_Polyhedra_Library::Generator_System::insert_pending(), Parma_Polyhedra_Library::Constraint_System::insert_pending(), Parma_Polyhedra_Library::Congruence_System::insert_verbatim(), Parma_Polyhedra_Library::MIP_Problem::is_lp_satisfiable(), Parma_Polyhedra_Library::MIP_Problem::process_pending_constraints(), and Parma_Polyhedra_Library::PIP_Problem::solve().

00083                                                   {
00084   PPL_ASSERT(n > 0);
00085   PPL_ASSERT(n <= max_num_columns() - num_columns());
00086   const dimension_type num_rows = rows.size();
00087   const dimension_type new_num_columns = row_size + n;
00088 
00089   if (new_num_columns <= row_capacity)
00090     // We have enough capacity: we resize existing rows.
00091     for (dimension_type i = num_rows; i-- > 0; )
00092       rows[i].expand_within_capacity(new_num_columns);
00093   else {
00094     // Capacity exhausted: we must reallocate the rows and
00095     // make sure all the rows have the same capacity.
00096     const dimension_type new_row_capacity
00097       = compute_capacity(new_num_columns, max_num_columns());
00098     PPL_ASSERT(new_row_capacity <= max_num_columns());
00099     for (dimension_type i = num_rows; i-- > 0; ) {
00100       Row new_row(rows[i], new_num_columns, new_row_capacity);
00101       std::swap(rows[i], new_row);
00102     }
00103     row_capacity = new_row_capacity;
00104   }
00105   // Rows have been expanded.
00106   row_size = new_num_columns;
00107 }

void Parma_Polyhedra_Library::Matrix::add_zero_rows ( dimension_type  n,
Row::Flags  row_flags 
)

Adds to the matrix n rows of zeroes with flags set to row_flags.

Parameters:
n The number of rows to be added: must be strictly positive.
row_flags Flags for the newly added rows.

Turns the $r \times c$ matrix $M$ into the $(r+n) \times c$ matrix $\genfrac{(}{)}{0pt}{}{M}{0}$. The matrix is expanded avoiding reallocation whenever possible.

Definition at line 52 of file Matrix.cc.

References Parma_Polyhedra_Library::compute_capacity(), Parma_Polyhedra_Library::construct(), max_num_rows(), num_rows(), row_capacity, row_size, rows, and swap().

Referenced by Parma_Polyhedra_Library::Linear_System::add_pending_rows(), Parma_Polyhedra_Library::Polyhedron::add_recycled_constraints(), Parma_Polyhedra_Library::Polyhedron::add_recycled_generators(), Parma_Polyhedra_Library::PIP_Tree_Node::compatibility_check(), Parma_Polyhedra_Library::PIP_Solution_Node::generate_cut(), Parma_Polyhedra_Library::Congruence_System::insert(), Parma_Polyhedra_Library::MIP_Problem::process_pending_constraints(), Parma_Polyhedra_Library::Grid_Generator_System::recycling_insert(), Parma_Polyhedra_Library::Congruence_System::recycling_insert(), and Parma_Polyhedra_Library::Grid::simplify().

00052                                                                    {
00053   PPL_ASSERT(n > 0);
00054   PPL_ASSERT(n <= max_num_rows() - num_rows());
00055   const dimension_type old_num_rows = rows.size();
00056   const dimension_type new_num_rows = old_num_rows + n;
00057 
00058   if (rows.capacity() < new_num_rows) {
00059     // Reallocation will take place.
00060     std::vector<Row> new_rows;
00061     new_rows.reserve(compute_capacity(new_num_rows, max_num_rows()));
00062     new_rows.insert(new_rows.end(), new_num_rows, Row());
00063     // Construct the new rows.
00064     dimension_type i = new_num_rows;
00065     while (i-- > old_num_rows)
00066       new_rows[i].construct(row_size, row_capacity, row_flags);
00067     // Steal the old rows.
00068     ++i;
00069     while (i-- > 0)
00070       new_rows[i].swap(rows[i]);
00071     // Put the new vector into place.
00072     std::swap(rows, new_rows);
00073   }
00074   else {
00075     // Reallocation will NOT take place.
00076     rows.insert(rows.end(), n, Row());
00077     for (dimension_type i = new_num_rows; i-- > old_num_rows; )
00078       rows[i].construct(row_size, row_capacity, row_flags);
00079   }
00080 }

void Parma_Polyhedra_Library::Matrix::add_zero_rows_and_columns ( dimension_type  n,
dimension_type  m,
Row::Flags  row_flags 
)

Adds n rows and m columns of zeroes to the matrix.

Parameters:
n The number of rows to be added: must be strictly positive.
m The number of columns to be added: must be strictly positive.
row_flags Flags for the newly added rows.

Turns the $r \times c$ matrix $M$ into the $(r+n) \times (c+m)$ matrix $\bigl(\genfrac{}{}{0pt}{}{M}{0} \genfrac{}{}{0pt}{}{0}{0}\bigr)$. The matrix is expanded avoiding reallocation whenever possible.

Definition at line 110 of file Matrix.cc.

References Parma_Polyhedra_Library::compute_capacity(), max_num_columns(), max_num_rows(), num_columns(), num_rows(), row_capacity, row_size, rows, and swap().

Referenced by Parma_Polyhedra_Library::Linear_System::add_rows_and_columns(), Parma_Polyhedra_Library::Congruence_System::add_unit_rows_and_columns(), Parma_Polyhedra_Library::Grid_Generator_System::add_universe_rows_and_columns(), Parma_Polyhedra_Library::Congruence_System::concatenate(), Parma_Polyhedra_Library::Polyhedron::concatenate_assign(), Parma_Polyhedra_Library::Congruence_System::insert(), Parma_Polyhedra_Library::Grid_Generator_System::recycling_insert(), and Parma_Polyhedra_Library::Congruence_System::recycling_insert().

00112                                                            {
00113   PPL_ASSERT(n > 0);
00114   PPL_ASSERT(n <= max_num_rows() - num_rows());
00115   PPL_ASSERT(m > 0);
00116   PPL_ASSERT(m <= max_num_columns() - num_columns());
00117   const dimension_type old_num_rows = rows.size();
00118   const dimension_type new_num_rows = old_num_rows + n;
00119   const dimension_type new_num_columns = row_size + m;
00120 
00121   if (new_num_columns <= row_capacity) {
00122     // We can recycle the old rows.
00123     if (rows.capacity() < new_num_rows) {
00124       // Reallocation will take place.
00125       std::vector<Row> new_rows;
00126       new_rows.reserve(compute_capacity(new_num_rows, max_num_rows()));
00127       new_rows.insert(new_rows.end(), new_num_rows, Row());
00128       // Construct the new rows.
00129       dimension_type i = new_num_rows;
00130       while (i-- > old_num_rows)
00131         new_rows[i].construct(new_num_columns, row_capacity, row_flags);
00132       // Expand and steal the old rows.
00133       ++i;
00134       while (i-- > 0) {
00135         rows[i].expand_within_capacity(new_num_columns);
00136         new_rows[i].swap(rows[i]);
00137       }
00138       // Put the new vector into place.
00139       std::swap(rows, new_rows);
00140     }
00141     else {
00142       // Reallocation will NOT take place.
00143       rows.insert(rows.end(), n, Row());
00144       // Construct the new rows.
00145       dimension_type i = new_num_rows;
00146       while (i-- > old_num_rows)
00147         rows[i].construct(new_num_columns, row_capacity, row_flags);
00148       // Expand the old rows.
00149       ++i;
00150       while (i-- > 0)
00151         rows[i].expand_within_capacity(new_num_columns);
00152     }
00153     row_size = new_num_columns;
00154   }
00155   else {
00156     // We cannot even recycle the old rows.
00157     Matrix new_matrix;
00158     new_matrix.rows.reserve(compute_capacity(new_num_rows, max_num_rows()));
00159     new_matrix.rows.insert(new_matrix.rows.end(), new_num_rows, Row());
00160     // Construct the new rows.
00161     new_matrix.row_size = new_num_columns;
00162     new_matrix.row_capacity = compute_capacity(new_num_columns,
00163                                                max_num_columns());
00164     dimension_type i = new_num_rows;
00165     while (i-- > old_num_rows)
00166       new_matrix.rows[i].construct(new_matrix.row_size,
00167                                    new_matrix.row_capacity,
00168                                    row_flags);
00169     // Copy the old rows.
00170     ++i;
00171     while (i-- > 0) {
00172       Row new_row(rows[i],
00173                   new_matrix.row_size,
00174                   new_matrix.row_capacity);
00175       std::swap(new_matrix.rows[i], new_row);
00176     }
00177     // Put the new vector into place.
00178     swap(new_matrix);
00179   }
00180 }

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

Writes to s an ASCII representation of *this.

Reimplemented in Parma_Polyhedra_Library::Linear_System, Parma_Polyhedra_Library::Constraint_System, Parma_Polyhedra_Library::Congruence_System, Parma_Polyhedra_Library::Generator_System, and Parma_Polyhedra_Library::Grid_Generator_System.

Definition at line 292 of file Matrix.cc.

References ascii_dump(), num_columns(), and num_rows().

00292                                          {
00293   const Matrix& x = *this;
00294   dimension_type x_num_rows = x.num_rows();
00295   dimension_type x_num_columns = x.num_columns();
00296   s << x_num_rows << " x " << x_num_columns << "\n";
00297   for (dimension_type i = 0; i < x_num_rows; ++i)
00298     x[i].ascii_dump(s);
00299 }

void Parma_Polyhedra_Library::Matrix::ascii_dump (  )  const
bool Parma_Polyhedra_Library::Matrix::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_System, Parma_Polyhedra_Library::Constraint_System, Parma_Polyhedra_Library::Congruence_System, Parma_Polyhedra_Library::Generator_System, and Parma_Polyhedra_Library::Grid_Generator_System.

Definition at line 304 of file Matrix.cc.

References Parma_Polyhedra_Library::ascii_load().

Referenced by Parma_Polyhedra_Library::PIP_Solution_Node::Tableau::ascii_load().

00304                                    {
00305   Matrix& x = *this;
00306   std::string str;
00307   dimension_type x_num_rows;
00308   dimension_type x_num_cols;
00309   if (!(s >> x_num_rows))
00310     return false;
00311   if (!(s >> str) || str != "x")
00312     return false;
00313   if (!(s >> x_num_cols))
00314     return false;
00315 
00316   resize_no_copy(x_num_rows, x_num_cols, Row::Flags());
00317 
00318   for (dimension_type row = 0; row < x_num_rows; ++row)
00319     if (!x[row].ascii_load(s))
00320       return false;
00321 
00322   // Check invariants.
00323   PPL_ASSERT(OK());
00324   return true;
00325 }

Matrix::const_iterator Parma_Polyhedra_Library::Matrix::begin (  )  const [inline]

Returns the const_iterator pointing to the first row, if *this is not empty; otherwise, returns the past-the-end const_iterator.

Reimplemented in Parma_Polyhedra_Library::Constraint_System, Parma_Polyhedra_Library::Congruence_System, Parma_Polyhedra_Library::Generator_System, and Parma_Polyhedra_Library::Grid_Generator_System.

Definition at line 105 of file Matrix.inlines.hh.

References rows.

Referenced by Parma_Polyhedra_Library::Generator_System::begin(), Parma_Polyhedra_Library::Constraint_System::begin(), and Parma_Polyhedra_Library::Congruence_System::begin().

00105                     {
00106   return const_iterator(rows.begin());
00107 }

void Parma_Polyhedra_Library::Matrix::clear (  )  [inline]

Clears the matrix deallocating all its rows.

Reimplemented in Parma_Polyhedra_Library::Linear_System, Parma_Polyhedra_Library::Constraint_System, Parma_Polyhedra_Library::Congruence_System, Parma_Polyhedra_Library::Generator_System, and Parma_Polyhedra_Library::Grid_Generator_System.

Definition at line 198 of file Matrix.inlines.hh.

References row_capacity, row_size, rows, and swap().

Referenced by Parma_Polyhedra_Library::PIP_Problem::clear().

00198               {
00199   // Clear `rows' and minimize its capacity.
00200   std::vector<Row>().swap(rows);
00201   row_size = 0;
00202   row_capacity = 0;
00203 }

Matrix::const_iterator Parma_Polyhedra_Library::Matrix::end (  )  const [inline]
void Parma_Polyhedra_Library::Matrix::erase_to_end ( dimension_type  first_to_erase  )  [inline]
PPL::memory_size_type Parma_Polyhedra_Library::Matrix::external_memory_in_bytes (  )  const
bool Parma_Polyhedra_Library::Matrix::has_no_rows (  )  const [inline]

Returns true if and only if *this has no rows.

Note:
The unusual naming for this method is intentional: we do not want it to be named empty because this would cause an error prone name clash with the corresponding methods in derived classes Constraint_System and Congruence_System (which have a different semantics).

Definition at line 100 of file Matrix.inlines.hh.

References rows.

Referenced by Parma_Polyhedra_Library::Polyhedron::add_and_minimize(), Parma_Polyhedra_Library::Grid::add_recycled_congruences(), Parma_Polyhedra_Library::Polyhedron::add_recycled_constraints(), Parma_Polyhedra_Library::Polyhedron::add_recycled_generators(), Parma_Polyhedra_Library::Grid::add_recycled_grid_generators(), Parma_Polyhedra_Library::Linear_System::add_rows(), Parma_Polyhedra_Library::Polyhedron::add_space_dimensions_and_project(), Parma_Polyhedra_Library::Generator_System::adjust_topology_and_space_dimension(), Parma_Polyhedra_Library::Polyhedron::BHRZ03_evolving_rays(), Parma_Polyhedra_Library::Polyhedron::BHRZ03_widening_assign(), Parma_Polyhedra_Library::Polyhedron::constraints(), Parma_Polyhedra_Library::Grid::construct(), Parma_Polyhedra_Library::Generator_System::empty(), Parma_Polyhedra_Library::Grid::generator_widening_assign(), Parma_Polyhedra_Library::Polyhedron::generators(), Parma_Polyhedra_Library::Grid::grid_generators(), Parma_Polyhedra_Library::Polyhedron::H79_widening_assign(), Parma_Polyhedra_Library::Congruence_System::insert(), Parma_Polyhedra_Library::Congruence_System::insert_verbatim(), Parma_Polyhedra_Library::Grid::intersection_assign(), Parma_Polyhedra_Library::Polyhedron::map_space_dimensions(), Parma_Polyhedra_Library::Grid::map_space_dimensions(), Parma_Polyhedra_Library::Polyhedron::minimize(), Parma_Polyhedra_Library::Grid::minimized_grid_generators(), Parma_Polyhedra_Library::Polyhedron::OK(), Parma_Polyhedra_Library::Linear_System::OK(), Parma_Polyhedra_Library::Grid::OK(), Parma_Polyhedra_Library::Polyhedron::Polyhedron(), Parma_Polyhedra_Library::Polyhedron::refine_with_constraints(), Parma_Polyhedra_Library::Linear_System::set_necessarily_closed(), Parma_Polyhedra_Library::Linear_System::set_not_necessarily_closed(), Parma_Polyhedra_Library::Grid::simplify(), and Parma_Polyhedra_Library::Grid::update_congruences().

00100                           {
00101   return rows.empty();
00102 }

dimension_type Parma_Polyhedra_Library::Matrix::max_num_columns (  )  [inline, static]
dimension_type Parma_Polyhedra_Library::Matrix::max_num_rows (  )  [inline, static]

Returns the maximum number of rows of a Matrix.

Definition at line 33 of file Matrix.inlines.hh.

Referenced by Parma_Polyhedra_Library::Linear_System::add_pending_row(), add_recycled_row(), add_zero_rows(), add_zero_rows_and_columns(), Matrix(), Parma_Polyhedra_Library::Linear_System::merge_rows_assign(), and resize_no_copy().

00033                      {
00034   return std::vector<Row>().max_size();
00035 }

dimension_type Parma_Polyhedra_Library::Matrix::num_columns (  )  const [inline]

Returns the number of columns of the matrix (i.e., the size of the rows).

Reimplemented in Parma_Polyhedra_Library::Grid_Generator_System.

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

References row_size.

Referenced by Parma_Polyhedra_Library::Polyhedron::add_and_minimize(), Parma_Polyhedra_Library::Generator_System::add_corresponding_closure_points(), Parma_Polyhedra_Library::Generator_System::add_corresponding_points(), Parma_Polyhedra_Library::Polyhedron::add_recycled_constraints(), Parma_Polyhedra_Library::Polyhedron::add_recycled_generators(), Parma_Polyhedra_Library::Linear_System::add_rows_and_columns(), Parma_Polyhedra_Library::Polyhedron::add_space_dimensions(), Parma_Polyhedra_Library::Grid::add_space_dimensions(), Parma_Polyhedra_Library::Grid::add_space_dimensions_and_embed(), Parma_Polyhedra_Library::Grid::add_space_dimensions_and_project(), Parma_Polyhedra_Library::Congruence_System::add_unit_rows_and_columns(), add_zero_columns(), add_zero_rows_and_columns(), Parma_Polyhedra_Library::Generator_System::adjust_topology_and_space_dimension(), Parma_Polyhedra_Library::Constraint_System::adjust_topology_and_space_dimension(), Parma_Polyhedra_Library::Generator_System::affine_image(), Parma_Polyhedra_Library::Constraint_System::affine_preimage(), Parma_Polyhedra_Library::Congruence_System::affine_preimage(), ascii_dump(), Parma_Polyhedra_Library::Linear_System::ascii_dump(), Parma_Polyhedra_Library::Generator_System::ascii_dump(), Parma_Polyhedra_Library::Constraint_System::ascii_dump(), Parma_Polyhedra_Library::Congruence_System::ascii_dump(), Parma_Polyhedra_Library::Generator_System::ascii_load(), Parma_Polyhedra_Library::Constraint_System::ascii_load(), Parma_Polyhedra_Library::Linear_System::back_substitute(), Parma_Polyhedra_Library::PIP_Tree_Node::compatibility_check(), 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_System::concatenate(), Parma_Polyhedra_Library::Polyhedron::concatenate_assign(), Parma_Polyhedra_Library::Grid::congruences(), Parma_Polyhedra_Library::Polyhedron::constraints(), Parma_Polyhedra_Library::Grid::construct(), Parma_Polyhedra_Library::Grid::conversion(), Parma_Polyhedra_Library::Polyhedron::conversion(), Parma_Polyhedra_Library::MIP_Problem::erase_artificials(), Parma_Polyhedra_Library::Linear_System::gauss(), Parma_Polyhedra_Library::Polyhedron::generators(), Parma_Polyhedra_Library::Congruence_System::has_linear_equalities(), Parma_Polyhedra_Library::Generator_System::has_points(), Parma_Polyhedra_Library::Constraint_System::has_strict_inequalities(), Parma_Polyhedra_Library::Congruence_System::increase_space_dimension(), Parma_Polyhedra_Library::Linear_System::insert(), Parma_Polyhedra_Library::Generator_System::insert(), Parma_Polyhedra_Library::Congruence_System::insert(), Parma_Polyhedra_Library::Linear_System::insert_pending(), Parma_Polyhedra_Library::Generator_System::insert_pending(), Parma_Polyhedra_Library::Congruence_System::insert_verbatim(), Parma_Polyhedra_Library::PIP_Solution_Node::Tableau::is_better_pivot(), Parma_Polyhedra_Library::Congruence_System::is_equal_to(), Parma_Polyhedra_Library::MIP_Problem::is_lp_satisfiable(), Parma_Polyhedra_Library::Polyhedron::is_universe(), Parma_Polyhedra_Library::Grid::lower_triangular(), Parma_Polyhedra_Library::MIP_Problem::merge_split_variable(), Parma_Polyhedra_Library::Polyhedron::minimize(), Parma_Polyhedra_Library::PIP_Solution_Node::Tableau::normalize(), Parma_Polyhedra_Library::Polyhedron::OK(), Parma_Polyhedra_Library::MIP_Problem::OK(), Parma_Polyhedra_Library::Linear_System::OK(), Parma_Polyhedra_Library::Grid::OK(), Parma_Polyhedra_Library::Congruence_System::OK(), operator==(), Parma_Polyhedra_Library::Linear_System::operator==(), Parma_Polyhedra_Library::Polyhedron::Polyhedron(), Parma_Polyhedra_Library::MIP_Problem::process_pending_constraints(), Parma_Polyhedra_Library::Congruence_System::recycling_insert(), Parma_Polyhedra_Library::Grid::reduce_congruence_with_equality(), Parma_Polyhedra_Library::Polyhedron::remove_higher_space_dimensions(), Parma_Polyhedra_Library::Polyhedron::remove_space_dimensions(), Parma_Polyhedra_Library::PIP_Solution_Node::Tableau::scale(), Parma_Polyhedra_Library::Polyhedron::simplify(), Parma_Polyhedra_Library::Grid::simplify(), Parma_Polyhedra_Library::PIP_Problem::solve(), Parma_Polyhedra_Library::Linear_System::space_dimension(), Parma_Polyhedra_Library::Congruence_System::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::Polyhedron::strongly_minimize_constraints(), Parma_Polyhedra_Library::Polyhedron::strongly_minimize_generators(), and swap_columns().

00180                           {
00181   return row_size;
00182 }

dimension_type Parma_Polyhedra_Library::Matrix::num_rows (  )  const [inline]

Returns the number of rows in the matrix.

Reimplemented in Parma_Polyhedra_Library::Grid_Generator_System.

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

References rows.

Referenced by Parma_Polyhedra_Library::Polyhedron::add_and_minimize(), Parma_Polyhedra_Library::Generator_System::add_corresponding_closure_points(), Parma_Polyhedra_Library::Generator_System::add_corresponding_points(), Parma_Polyhedra_Library::Polyhedron::add_generator(), Parma_Polyhedra_Library::Linear_System::add_pending_rows(), Parma_Polyhedra_Library::Polyhedron::add_recycled_constraints(), Parma_Polyhedra_Library::Polyhedron::add_recycled_generators(), Parma_Polyhedra_Library::Linear_System::add_row(), Parma_Polyhedra_Library::Linear_System::add_rows(), Parma_Polyhedra_Library::Linear_System::add_rows_and_columns(), Parma_Polyhedra_Library::Polyhedron::add_space_dimensions(), Parma_Polyhedra_Library::Polyhedron::add_space_dimensions_and_embed(), Parma_Polyhedra_Library::Polyhedron::add_space_dimensions_and_project(), Parma_Polyhedra_Library::Congruence_System::add_unit_rows_and_columns(), add_zero_columns(), add_zero_rows(), add_zero_rows_and_columns(), Parma_Polyhedra_Library::Generator_System::adjust_topology_and_space_dimension(), Parma_Polyhedra_Library::Constraint_System::adjust_topology_and_space_dimension(), Parma_Polyhedra_Library::Grid::affine_dimension(), Parma_Polyhedra_Library::Generator_System::affine_image(), Parma_Polyhedra_Library::Constraint_System::affine_preimage(), Parma_Polyhedra_Library::Congruence_System::affine_preimage(), ascii_dump(), Parma_Polyhedra_Library::Linear_System::ascii_dump(), Parma_Polyhedra_Library::Generator_System::ascii_dump(), Parma_Polyhedra_Library::Constraint_System::ascii_dump(), Parma_Polyhedra_Library::Congruence_System::ascii_dump(), Parma_Polyhedra_Library::Generator_System::ascii_load(), Parma_Polyhedra_Library::Constraint_System::ascii_load(), Parma_Polyhedra_Library::Congruence_System::ascii_load(), Parma_Polyhedra_Library::Linear_System::back_substitute(), Parma_Polyhedra_Library::Polyhedron::BFT00_poly_hull_assign_if_exact(), Parma_Polyhedra_Library::Polyhedron::BHRZ03_combining_constraints(), Parma_Polyhedra_Library::Polyhedron::BHRZ03_evolving_points(), Parma_Polyhedra_Library::Polyhedron::BHRZ03_evolving_rays(), Parma_Polyhedra_Library::Polyhedron::BHZ09_C_poly_hull_assign_if_exact(), Parma_Polyhedra_Library::Polyhedron::BHZ09_NNC_poly_hull_assign_if_exact(), Parma_Polyhedra_Library::Polyhedron::bounds(), Parma_Polyhedra_Library::PIP_Tree_Node::compatibility_check(), 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_System::concatenate(), Parma_Polyhedra_Library::Polyhedron::concatenate_assign(), Parma_Polyhedra_Library::Grid::congruence_widening_assign(), Parma_Polyhedra_Library::Grid::congruences(), Parma_Polyhedra_Library::Polyhedron::constrains(), Parma_Polyhedra_Library::Grid::constrains(), Parma_Polyhedra_Library::Polyhedron::constraints(), Parma_Polyhedra_Library::Grid::construct(), Parma_Polyhedra_Library::Polyhedron::contains_integer_point(), Parma_Polyhedra_Library::Polyhedron::conversion(), Parma_Polyhedra_Library::Polyhedron::drop_some_non_integer_points(), Parma_Polyhedra_Library::MIP_Problem::erase_artificials(), external_memory_in_bytes(), Parma_Polyhedra_Library::Polyhedron::frequency(), Parma_Polyhedra_Library::Polyhedron::generalized_affine_image(), Parma_Polyhedra_Library::PIP_Solution_Node::generate_cut(), Parma_Polyhedra_Library::Polyhedron::generators(), Parma_Polyhedra_Library::MIP_Problem::get_exiting_base_index(), Parma_Polyhedra_Library::Polyhedron::H79_widening_assign(), Parma_Polyhedra_Library::Congruence_System::has_a_free_dimension(), Parma_Polyhedra_Library::Constraint_System::has_equalities(), Parma_Polyhedra_Library::Congruence_System::has_linear_equalities(), Parma_Polyhedra_Library::Generator_System::has_points(), Parma_Polyhedra_Library::Constraint_System::has_strict_inequalities(), Parma_Polyhedra_Library::Congruence_System::increase_space_dimension(), Parma_Polyhedra_Library::Linear_System::insert(), Parma_Polyhedra_Library::Generator_System::insert(), Parma_Polyhedra_Library::Congruence_System::insert(), Parma_Polyhedra_Library::Linear_System::insert_pending(), Parma_Polyhedra_Library::Generator_System::insert_pending(), Parma_Polyhedra_Library::PIP_Solution_Node::Tableau::is_better_pivot(), Parma_Polyhedra_Library::Polyhedron::is_bounded(), Parma_Polyhedra_Library::Congruence_System::is_equal_to(), Parma_Polyhedra_Library::Polyhedron::is_included_in(), Parma_Polyhedra_Library::Polyhedron::is_topologically_closed(), Parma_Polyhedra_Library::Polyhedron::is_universe(), Parma_Polyhedra_Library::Grid::is_universe(), Parma_Polyhedra_Library::Polyhedron::limited_BHRZ03_extrapolation_assign(), Parma_Polyhedra_Library::Grid::limited_congruence_extrapolation_assign(), Parma_Polyhedra_Library::Grid::limited_extrapolation_assign(), Parma_Polyhedra_Library::Grid::limited_generator_extrapolation_assign(), Parma_Polyhedra_Library::Polyhedron::limited_H79_extrapolation_assign(), Parma_Polyhedra_Library::Grid::lower_triangular(), Parma_Polyhedra_Library::Polyhedron::max_min(), Parma_Polyhedra_Library::Linear_System::merge_rows_assign(), Parma_Polyhedra_Library::Polyhedron::minimize(), Parma_Polyhedra_Library::PIP_Solution_Node::Tableau::normalize(), Parma_Polyhedra_Library::Linear_System::normalize(), Parma_Polyhedra_Library::Congruence_System::normalize_moduli(), Parma_Polyhedra_Library::Constraint_System::num_equalities(), Parma_Polyhedra_Library::Congruence_System::num_equalities(), Parma_Polyhedra_Library::Constraint_System::num_inequalities(), Parma_Polyhedra_Library::Generator_System::num_lines(), Parma_Polyhedra_Library::Linear_System::num_lines_or_equalities(), Parma_Polyhedra_Library::Linear_System::num_pending_rows(), Parma_Polyhedra_Library::Congruence_System::num_proper_congruences(), Parma_Polyhedra_Library::Generator_System::num_rays(), Parma_Polyhedra_Library::Polyhedron::OK(), Parma_Polyhedra_Library::PIP_Solution_Node::Tableau::OK(), Parma_Polyhedra_Library::MIP_Problem::OK(), OK(), Parma_Polyhedra_Library::Linear_System::OK(), Parma_Polyhedra_Library::Generator_System::OK(), Parma_Polyhedra_Library::Constraint_System::OK(), Parma_Polyhedra_Library::Congruence_System::OK(), operator==(), Parma_Polyhedra_Library::Linear_System::operator==(), permute_columns(), Parma_Polyhedra_Library::MIP_Problem::pivot(), Parma_Polyhedra_Library::Polyhedron::Polyhedron(), Parma_Polyhedra_Library::MIP_Problem::process_pending_constraints(), Parma_Polyhedra_Library::Polyhedron::quick_equivalence_test(), Parma_Polyhedra_Library::Grid::quick_equivalence_test(), Parma_Polyhedra_Library::Congruence_System::recycling_insert(), Parma_Polyhedra_Library::Grid::reduce_congruence_with_equality(), Parma_Polyhedra_Library::Polyhedron::refine_with_constraints(), Parma_Polyhedra_Library::Generator_System::relation_with(), Parma_Polyhedra_Library::Grid::remove_higher_space_dimensions(), Parma_Polyhedra_Library::Generator_System::remove_invalid_lines_and_rays(), remove_trailing_columns(), Parma_Polyhedra_Library::Generator_System::satisfied_by_all_generators(), Parma_Polyhedra_Library::Constraint_System::satisfies_all_constraints(), Parma_Polyhedra_Library::PIP_Solution_Node::Tableau::scale(), Parma_Polyhedra_Library::MIP_Problem::second_phase(), Parma_Polyhedra_Library::Polyhedron::select_CH78_constraints(), Parma_Polyhedra_Library::Polyhedron::select_H79_constraints(), Parma_Polyhedra_Library::Linear_System::set_rows_topology(), Parma_Polyhedra_Library::Linear_System::sign_normalize(), Parma_Polyhedra_Library::Polyhedron::simplify(), Parma_Polyhedra_Library::Linear_System::simplify(), Parma_Polyhedra_Library::Grid::simplify(), Parma_Polyhedra_Library::Polyhedron::simplify_using_context_assign(), Parma_Polyhedra_Library::Grid::simplify_using_context_assign(), Parma_Polyhedra_Library::PIP_Solution_Node::solve(), Parma_Polyhedra_Library::PIP_Decision_Node::solve(), Parma_Polyhedra_Library::Linear_System::sort_and_remove_with_sat(), Parma_Polyhedra_Library::Linear_System::sort_pending_and_remove_duplicates(), Parma_Polyhedra_Library::Linear_System::sort_rows(), Parma_Polyhedra_Library::MIP_Problem::steepest_edge_exact_entering_index(), Parma_Polyhedra_Library::MIP_Problem::steepest_edge_float_entering_index(), Parma_Polyhedra_Library::Linear_System::strong_normalize(), Parma_Polyhedra_Library::Polyhedron::strongly_minimize_constraints(), Parma_Polyhedra_Library::Polyhedron::strongly_minimize_generators(), swap_columns(), Parma_Polyhedra_Library::Polyhedron::time_elapse_assign(), Parma_Polyhedra_Library::Polyhedron::topological_closure_assign(), and Parma_Polyhedra_Library::Linear_System::unset_pending_rows().

00175                        {
00176   return rows.size();
00177 }

bool Parma_Polyhedra_Library::Matrix::OK (  )  const

Checks if all the invariants are satisfied.

Reimplemented in Parma_Polyhedra_Library::Constraint_System, Parma_Polyhedra_Library::Congruence_System, Parma_Polyhedra_Library::Generator_System, and Parma_Polyhedra_Library::Grid_Generator_System.

Definition at line 396 of file Matrix.cc.

References num_rows(), row_capacity, and row_size.

Referenced by Parma_Polyhedra_Library::Linear_System::add_pending_row(), Parma_Polyhedra_Library::Linear_System::add_pending_rows(), add_recycled_row(), Parma_Polyhedra_Library::Linear_System::add_row(), Parma_Polyhedra_Library::Linear_System::add_rows(), Parma_Polyhedra_Library::Linear_System::add_rows_and_columns(), Parma_Polyhedra_Library::PIP_Tree_Node::compatibility_check(), Parma_Polyhedra_Library::Linear_System::insert(), Parma_Polyhedra_Library::Linear_System::insert_pending(), Matrix(), Parma_Polyhedra_Library::PIP_Solution_Node::Tableau::OK(), Parma_Polyhedra_Library::PIP_Problem::OK(), Parma_Polyhedra_Library::MIP_Problem::OK(), Parma_Polyhedra_Library::Linear_System::OK(), Parma_Polyhedra_Library::Grid_Generator_System::OK(), Parma_Polyhedra_Library::Generator_System::OK(), Parma_Polyhedra_Library::Constraint_System::OK(), Parma_Polyhedra_Library::Congruence_System::OK(), Parma_Polyhedra_Library::Linear_System::sort_pending_and_remove_duplicates(), and Parma_Polyhedra_Library::Linear_System::sort_rows().

00396                     {
00397   if (row_size > row_capacity) {
00398 #ifndef NDEBUG
00399     std::cerr << "Matrix completely broken: "
00400               << "row_capacity is " << row_capacity
00401               << ", row_size is " << row_size
00402               << std::endl;
00403 #endif
00404     return false;
00405   }
00406 
00407   const Matrix& x = *this;
00408   for (dimension_type i = 0, n_rows = num_rows(); i < n_rows; ++i)
00409     if (!x[i].OK(row_size, row_capacity))
00410       return false;
00411 
00412   // All checks passed.
00413   return true;
00414 }

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

Assignment operator.

Definition at line 140 of file Matrix.inlines.hh.

References Parma_Polyhedra_Library::compute_capacity(), max_num_columns(), row_capacity, row_size, and rows.

00140                                  {
00141   // Without the following guard against auto-assignments we would
00142   // recompute the row capacity based on row size, possibly without
00143   // actually increasing the capacity of the rows.  This would lead to
00144   // an inconsistent state.
00145   if (this != &y) {
00146     // The following assignment may do nothing on auto-assignments...
00147     rows = y.rows;
00148     row_size = y.row_size;
00149     // ... hence the following assignment must not be done on
00150     // auto-assignments.
00151     row_capacity = compute_capacity(y.row_size, max_num_columns());
00152   }
00153   return *this;
00154 }

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

Returns a constant reference to the k-th row of the matrix.

Reimplemented in Parma_Polyhedra_Library::Linear_System, Parma_Polyhedra_Library::Constraint_System, Parma_Polyhedra_Library::Congruence_System, Parma_Polyhedra_Library::Generator_System, and Parma_Polyhedra_Library::Grid_Generator_System.

Definition at line 169 of file Matrix.inlines.hh.

References rows.

00169                                                {
00170   PPL_ASSERT(k < rows.size());
00171   return rows[k];
00172 }

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

Returns a reference to the k-th row of the matrix.

Reimplemented in Parma_Polyhedra_Library::Linear_System, Parma_Polyhedra_Library::Constraint_System, Parma_Polyhedra_Library::Congruence_System, Parma_Polyhedra_Library::Generator_System, and Parma_Polyhedra_Library::Grid_Generator_System.

Definition at line 163 of file Matrix.inlines.hh.

References rows.

00163                                          {
00164   PPL_ASSERT(k < rows.size());
00165   return rows[k];
00166 }

void Parma_Polyhedra_Library::Matrix::permute_columns ( const std::vector< dimension_type > &  cycles  ) 

Permutes the columns of the matrix.

Reimplemented in Parma_Polyhedra_Library::Linear_System, and Parma_Polyhedra_Library::Grid_Generator_System.

Definition at line 346 of file Matrix.cc.

References num_rows(), PPL_DIRTY_TEMP_COEFFICIENT, rows, Parma_Polyhedra_Library::swap(), and swap().

Referenced by Parma_Polyhedra_Library::Grid::map_space_dimensions(), and Parma_Polyhedra_Library::MIP_Problem::merge_split_variable().

00346                                                                   {
00347   PPL_DIRTY_TEMP_COEFFICIENT(tmp);
00348   const dimension_type n = cycles.size();
00349   PPL_ASSERT(cycles[n - 1] == 0);
00350   for (dimension_type k = num_rows(); k-- > 0; ) {
00351     Row& rows_k = rows[k];
00352     for (dimension_type i = 0, j = 0; i < n; i = ++j) {
00353       // Make `j' be the index of the next cycle terminator.
00354       while (cycles[j] != 0)
00355         ++j;
00356       // Cycles of length less than 2 are not allowed.
00357       PPL_ASSERT(j - i >= 2);
00358       if (j - i == 2)
00359         // For cycles of length 2 no temporary is needed, just a swap.
00360         std::swap(rows_k[cycles[i]], rows_k[cycles[i+1]]);
00361       else {
00362         // Longer cycles need a temporary.
00363         std::swap(rows_k[cycles[j-1]], tmp);
00364         for (dimension_type l = j-1; l > i; --l)
00365           std::swap(rows_k[cycles[l-1]], rows_k[cycles[l]]);
00366         std::swap(tmp, rows_k[cycles[i]]);
00367       }
00368     }
00369   }
00370 }

void Parma_Polyhedra_Library::Matrix::print (  )  const
void Parma_Polyhedra_Library::Matrix::remove_trailing_columns ( dimension_type  n  ) 

Makes the matrix shrink by removing its n trailing columns.

Reimplemented in Parma_Polyhedra_Library::Linear_System.

Definition at line 337 of file Matrix.cc.

References num_rows(), row_size, and rows.

Referenced by Parma_Polyhedra_Library::MIP_Problem::erase_artificials(), Parma_Polyhedra_Library::MIP_Problem::merge_split_variable(), and Parma_Polyhedra_Library::Congruence_System::remove_higher_space_dimensions().

00337                                                          {
00338   PPL_ASSERT(n > 0);
00339   PPL_ASSERT(n <= row_size);
00340   row_size -= n;
00341   for (dimension_type i = num_rows(); i-- > 0; )
00342     rows[i].shrink(row_size);
00343 }

void Parma_Polyhedra_Library::Matrix::resize_no_copy ( dimension_type  new_n_rows,
dimension_type  new_n_columns,
Row::Flags  row_flags 
)

Resizes the matrix without worrying about the old contents.

Parameters:
new_n_rows The number of rows of the resized matrix;
new_n_columns The number of columns of the resized matrix.
row_flags The flags of the rows eventually added to the matrix.

The matrix is expanded to the specified dimensions avoiding reallocation whenever possible. The contents of the original matrix is lost.

Definition at line 212 of file Matrix.cc.

References Parma_Polyhedra_Library::compute_capacity(), Parma_Polyhedra_Library::construct(), max_num_columns(), max_num_rows(), row_capacity, row_size, rows, and swap().

00214                                                 {
00215   dimension_type old_n_rows = rows.size();
00216   // Note that, if we have `new_n_rows <= old_n_rows' and
00217   // `new_n_columns >= row_size', the matrix will keep its sortedness.
00218   // This is obvious if `new_n_columns == row_size'.
00219   // If `new_n_columns > row_size', then sortedness is maintained
00220   // because trailing zeroes will be added to all rows.
00221   if (new_n_rows > old_n_rows) {
00222     if (new_n_columns <= row_capacity) {
00223       // We can recycle the old rows.
00224       if (rows.capacity() < new_n_rows) {
00225         // Reallocation (of vector `rows') will take place.
00226         std::vector<Row> new_rows;
00227         new_rows.reserve(compute_capacity(new_n_rows, max_num_rows()));
00228         new_rows.insert(new_rows.end(), new_n_rows, Row());
00229         // Construct the new rows (be careful: each new row must have
00230         // the same capacity as each one of the old rows).
00231         dimension_type i = new_n_rows;
00232         while (i-- > old_n_rows)
00233           new_rows[i].construct(new_n_columns, row_capacity, row_flags);
00234         // Steal the old rows.
00235         ++i;
00236         while (i-- > 0)
00237           new_rows[i].swap(rows[i]);
00238         // Put the new vector into place.
00239         std::swap(rows, new_rows);
00240       }
00241       else {
00242         // Reallocation (of vector `rows') will NOT take place.
00243         rows.insert(rows.end(), new_n_rows - old_n_rows, Row());
00244         // Be careful: each new row must have
00245         // the same capacity as each one of the old rows.
00246         for (dimension_type i = new_n_rows; i-- > old_n_rows; )
00247           rows[i].construct(new_n_columns, row_capacity, row_flags);
00248       }
00249     }
00250     else {
00251       // We cannot even recycle the old rows: allocate a new matrix and swap.
00252       Matrix new_matrix(new_n_rows, new_n_columns, row_flags);
00253       swap(new_matrix);
00254       return;
00255     }
00256   }
00257   else if (new_n_rows < old_n_rows) {
00258     // Drop some rows.
00259     rows.erase(rows.begin() + new_n_rows, rows.end());
00260     old_n_rows = new_n_rows;
00261   }
00262   // Here we have the right number of rows.
00263   if (new_n_columns != row_size) {
00264     if (new_n_columns < row_size) {
00265       // Shrink the existing rows.
00266       for (dimension_type i = old_n_rows; i-- > 0; )
00267         rows[i].shrink(new_n_columns);
00268     }
00269     else
00270       // We need more columns.
00271       if (new_n_columns <= row_capacity)
00272         // But we have enough capacity: we resize existing rows.
00273         for (dimension_type i = old_n_rows; i-- > 0; )
00274           rows[i].expand_within_capacity(new_n_columns);
00275       else {
00276         // Capacity exhausted: we must reallocate the rows and
00277         // make sure all the rows have the same capacity.
00278         const dimension_type new_row_capacity
00279           = compute_capacity(new_n_columns, max_num_columns());
00280         for (dimension_type i = old_n_rows; i-- > 0; ) {
00281           Row new_row(new_n_columns, new_row_capacity, row_flags);
00282           std::swap(rows[i], new_row);
00283         }
00284         row_capacity = new_row_capacity;
00285       }
00286     // Rows have grown or shrunk.
00287     row_size = new_n_columns;
00288   }
00289 }

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

Swaps *this with y.

Definition at line 115 of file Matrix.inlines.hh.

References row_capacity, row_size, and rows.

Referenced by add_recycled_row(), add_zero_columns(), add_zero_rows(), add_zero_rows_and_columns(), clear(), permute_columns(), resize_no_copy(), swap(), and swap_columns().

00115                       {
00116   std::swap(rows, y.rows);
00117   std::swap(row_size, y.row_size);
00118   std::swap(row_capacity, y.row_capacity);
00119 }

void Parma_Polyhedra_Library::Matrix::swap_columns ( dimension_type  i,
dimension_type  j 
)

Swaps the columns having indexes i and j.

Definition at line 328 of file Matrix.cc.

References num_columns(), num_rows(), rows, and swap().

Referenced by Parma_Polyhedra_Library::Polyhedron::add_space_dimensions(), Parma_Polyhedra_Library::Grid::add_space_dimensions(), Parma_Polyhedra_Library::Polyhedron::add_space_dimensions_and_embed(), Parma_Polyhedra_Library::Grid::add_space_dimensions_and_embed(), Parma_Polyhedra_Library::Polyhedron::add_space_dimensions_and_project(), Parma_Polyhedra_Library::Congruence_System::add_unit_rows_and_columns(), Parma_Polyhedra_Library::Grid_Generator_System::add_universe_rows_and_columns(), Parma_Polyhedra_Library::Generator_System::adjust_topology_and_space_dimension(), Parma_Polyhedra_Library::Constraint_System::adjust_topology_and_space_dimension(), Parma_Polyhedra_Library::Polyhedron::concatenate_assign(), Parma_Polyhedra_Library::Congruence_System::increase_space_dimension(), Parma_Polyhedra_Library::Linear_System::insert(), Parma_Polyhedra_Library::Grid_Generator_System::insert(), Parma_Polyhedra_Library::Congruence_System::insert(), Parma_Polyhedra_Library::Linear_System::insert_pending(), Parma_Polyhedra_Library::Congruence_System::insert_verbatim(), Parma_Polyhedra_Library::Grid_Generator_System::recycling_insert(), Parma_Polyhedra_Library::Congruence_System::recycling_insert(), Parma_Polyhedra_Library::Polyhedron::remove_higher_space_dimensions(), Parma_Polyhedra_Library::Grid_Generator_System::remove_higher_space_dimensions(), Parma_Polyhedra_Library::Congruence_System::remove_higher_space_dimensions(), and Parma_Polyhedra_Library::Grid_Generator_System::remove_space_dimensions().

00328                                                                       {
00329   PPL_ASSERT(i != j && i < num_columns() && j < num_columns());
00330   for (dimension_type k = num_rows(); k-- > 0; ) {
00331     Row& rows_k = rows[k];
00332     std::swap(rows_k[i], rows_k[j]);
00333   }
00334 }

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

Returns the total size in bytes of the memory occupied by *this.

Reimplemented in Parma_Polyhedra_Library::Linear_System, Parma_Polyhedra_Library::Constraint_System, Parma_Polyhedra_Library::Congruence_System, Parma_Polyhedra_Library::Generator_System, and Parma_Polyhedra_Library::Grid_Generator_System.

Definition at line 43 of file Matrix.inlines.hh.

References external_memory_in_bytes().

00043                                     {
00044   return sizeof(*this) + external_memory_in_bytes();
00045 }


Friends And Related Function Documentation

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

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

Definition at line 186 of file Matrix.inlines.hh.

00186                                              {
00187   return !(x == y);
00188 }

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

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

Definition at line 374 of file Matrix.cc.

References num_columns(), and num_rows().

00374                                                 {
00375   if (x.num_columns() != y.num_columns())
00376     return false;
00377   const dimension_type x_num_rows = x.num_rows();
00378   const dimension_type y_num_rows = y.num_rows();
00379   if (x_num_rows != y_num_rows)
00380     return false;
00381   for (dimension_type i = x_num_rows; i-- > 0; )
00382     if (x[i] != y[i])
00383       return false;
00384   return true;
00385 }

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

Specializes std::swap.

Definition at line 211 of file Matrix.inlines.hh.

References swap().

00212                                        {
00213   x.swap(y);
00214 }


Member Data Documentation

std::vector<Row> Parma_Polyhedra_Library::Matrix::rows [protected]

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