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.

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.

Classes

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


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 45 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(), OK(), row_capacity, and rows.

00036   : rows((assert(n_rows <= max_num_rows()),
00037           n_rows)),
00038     row_size(n_columns),
00039     row_capacity(compute_capacity(n_columns, max_num_columns())) {
00040   // Construct in direct order: will destroy in reverse order.
00041   for (dimension_type i = 0; i < n_rows; ++i)
00042     rows[i].construct(n_columns, row_capacity, row_flags);
00043   assert(OK());
00044 }

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

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(), 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::max_num_columns (  )  [inline, static]

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.

Referenced by Parma_Polyhedra_Library::Linear_System::assign_with_pending(), Parma_Polyhedra_Library::Linear_System::operator=(), and Parma_Polyhedra_Library::Congruence_System::operator=().

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 }

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::Grid::add_recycled_congruences_and_minimize(), Parma_Polyhedra_Library::Polyhedron::add_recycled_constraints(), Parma_Polyhedra_Library::Polyhedron::add_recycled_generators(), Parma_Polyhedra_Library::Polyhedron::add_recycled_generators_and_minimize(), Parma_Polyhedra_Library::Grid::add_recycled_grid_generators(), Parma_Polyhedra_Library::Grid::add_recycled_grid_generators_and_minimize(), 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::get_covering_box(), 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 }

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 }

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

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, rows, and Parma_Polyhedra_Library::swap().

Referenced by add_zero_rows_and_columns(), clear(), resize_no_copy(), and swap().

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::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 47 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 Parma_Polyhedra_Library::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::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().

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

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 78 of file Matrix.cc.

References Parma_Polyhedra_Library::compute_capacity(), max_num_columns(), num_columns(), num_rows(), row_capacity, row_size, rows, and Parma_Polyhedra_Library::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::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(), and Parma_Polyhedra_Library::MIP_Problem::process_pending_constraints().

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

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 105 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, swap(), and Parma_Polyhedra_Library::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().

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

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}{0}$. 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::Linear_System::add_row(), Parma_Polyhedra_Library::Grid_Generator_System::insert(), and Parma_Polyhedra_Library::Congruence_System::insert_verbatim().

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

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.
Turns the $r \times c$ matrix $M$ into the $(r+1) \times c$ matrix $\genfrac{(}{)}{0pt}{}{M}{0}$. The matrix is expanded avoiding reallocation whenever possible.

Definition at line 178 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 Parma_Polyhedra_Library::swap().

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

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

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

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 207 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, swap(), and Parma_Polyhedra_Library::swap().

Referenced by ascii_load(), Parma_Polyhedra_Library::Linear_System::resize_no_copy(), and Parma_Polyhedra_Library::Congruence_System::resize_no_copy().

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

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

Swaps the columns having indexes i and j.

Definition at line 323 of file Matrix.cc.

References num_columns(), num_rows(), rows, and Parma_Polyhedra_Library::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().

00323                                                                       {
00324   assert(i != j && i < num_columns() && j < num_columns());
00325   for (dimension_type k = num_rows(); k-- > 0; ) {
00326     Row& rows_k = rows[k];
00327     std::swap(rows_k[i], rows_k[j]);
00328   }
00329 }

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 341 of file Matrix.cc.

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

Referenced by Parma_Polyhedra_Library::Grid::map_space_dimensions(), Parma_Polyhedra_Library::MIP_Problem::merge_split_variables(), and Parma_Polyhedra_Library::Linear_System::permute_columns().

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

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::MIP_Problem::ascii_load(), 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::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::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_variables(), Parma_Polyhedra_Library::Polyhedron::minimize(), Parma_Polyhedra_Library::Grid_Generator_System::num_columns(), 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::Polyhedron::simplify(), Parma_Polyhedra_Library::Grid::simplify(), 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(), add_to_system_and_check_independence(), 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::BHRZ03_combining_constraints(), Parma_Polyhedra_Library::Polyhedron::BHRZ03_evolving_points(), Parma_Polyhedra_Library::Polyhedron::BHRZ03_evolving_rays(), Parma_Polyhedra_Library::Polyhedron::bounds(), 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::MIP_Problem::erase_artificials(), external_memory_in_bytes(), Parma_Polyhedra_Library::Polyhedron::generalized_affine_image(), 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::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::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::MIP_Problem::merge_split_variables(), Parma_Polyhedra_Library::Polyhedron::minimize(), 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::Grid_Generator_System::num_rows(), Parma_Polyhedra_Library::Polyhedron::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::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::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 }

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

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   assert(k < rows.size());
00171   return rows[k];
00172 }

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::Linear_System::clear(), and Parma_Polyhedra_Library::Congruence_System::clear().

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

void Parma_Polyhedra_Library::Matrix::ascii_dump (  )  const

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 287 of file Matrix.cc.

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

00287                                          {
00288   const Matrix& x = *this;
00289   dimension_type x_num_rows = x.num_rows();
00290   dimension_type x_num_columns = x.num_columns();
00291   s << x_num_rows << " x " << x_num_columns << "\n";
00292   for (dimension_type i = 0; i < x_num_rows; ++i)
00293     x[i].ascii_dump(s);
00294 }

void Parma_Polyhedra_Library::Matrix::print (  )  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 299 of file Matrix.cc.

References OK(), and resize_no_copy().

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

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

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 }

PPL::memory_size_type Parma_Polyhedra_Library::Matrix::external_memory_in_bytes (  )  const

Returns the size in bytes of the memory managed 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 383 of file Matrix.cc.

References num_rows(), row_capacity, and rows.

Referenced by Parma_Polyhedra_Library::MIP_Problem::external_memory_in_bytes(), and total_memory_in_bytes().

00383                                           {
00384   memory_size_type n = rows.capacity() * sizeof(Row);
00385   for (dimension_type i = num_rows(); i-- > 0; )
00386     n += rows[i].external_memory_in_bytes(row_capacity);
00387   return n;
00388 }

void Parma_Polyhedra_Library::Matrix::erase_to_end ( dimension_type  first_to_erase  )  [inline]

Erases from the matrix all the rows but those having an index less than first_to_erase.

Reimplemented in Parma_Polyhedra_Library::Grid_Generator_System.

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

References rows.

Referenced by add_to_system_and_check_independence(), Parma_Polyhedra_Library::Generator_System::adjust_topology_and_space_dimension(), Parma_Polyhedra_Library::Constraint_System::adjust_topology_and_space_dimension(), Parma_Polyhedra_Library::Polyhedron::conversion(), Parma_Polyhedra_Library::MIP_Problem::erase_artificials(), Parma_Polyhedra_Library::Grid_Generator_System::erase_to_end(), Parma_Polyhedra_Library::Polyhedron::OK(), Parma_Polyhedra_Library::Polyhedron::Polyhedron(), Parma_Polyhedra_Library::Grid::remove_higher_space_dimensions(), Parma_Polyhedra_Library::Generator_System::remove_invalid_lines_and_rays(), Parma_Polyhedra_Library::Polyhedron::simplify(), Parma_Polyhedra_Library::Linear_System::simplify(), Parma_Polyhedra_Library::Grid::simplify(), Parma_Polyhedra_Library::Linear_System::sort_and_remove_with_sat(), Parma_Polyhedra_Library::Linear_System::sort_pending_and_remove_duplicates(), Parma_Polyhedra_Library::Polyhedron::strongly_minimize_constraints(), Parma_Polyhedra_Library::Polyhedron::strongly_minimize_generators(), and Parma_Polyhedra_Library::Polyhedron::time_elapse_assign().

00191                                                         {
00192   assert(first_to_erase <= rows.size());
00193   if (first_to_erase < rows.size())
00194     rows.erase(rows.begin() + first_to_erase, rows.end());
00195 }

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 391 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(), ascii_load(), Parma_Polyhedra_Library::Linear_System::ascii_load(), Parma_Polyhedra_Library::Linear_System::insert(), Parma_Polyhedra_Library::Linear_System::insert_pending(), Matrix(), 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().

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


Friends And Related Function Documentation

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 }

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

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

Definition at line 369 of file Matrix.cc.

References num_columns(), and num_rows().

00369                                                 {
00370   if (x.num_columns() != y.num_columns())
00371     return false;
00372   const dimension_type x_num_rows = x.num_rows();
00373   const dimension_type y_num_rows = y.num_rows();
00374   if (x_num_rows != y_num_rows)
00375     return false;
00376   for (dimension_type i = x_num_rows; i-- > 0; )
00377     if (x[i] != y[i])
00378       return false;
00379   return true;
00380 }

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 }


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 Sat Oct 11 10:41:05 2008 for PPL by  doxygen 1.5.6