PPL  1.2
Parma_Polyhedra_Library::Bit_Matrix Class Reference

A matrix of bits. More...

#include <Bit_Matrix_defs.hh>

Classes

struct  Bit_Row_Less_Than
 Ordering predicate (used when implementing the sort algorithm). More...
 

Public Member Functions

 Bit_Matrix ()
 Default constructor. More...
 
 Bit_Matrix (dimension_type n_rows, dimension_type n_columns)
 Construct a bit matrix with n_rows rows and n_columns columns. More...
 
 Bit_Matrix (const Bit_Matrix &y)
 Copy constructor. More...
 
 ~Bit_Matrix ()
 Destructor. More...
 
Bit_Matrixoperator= (const Bit_Matrix &y)
 Assignment operator. More...
 
void m_swap (Bit_Matrix &y)
 Swaps *this with y. More...
 
Bit_Rowoperator[] (dimension_type k)
 Subscript operator. More...
 
const Bit_Rowoperator[] (dimension_type k) const
 Constant subscript operator. More...
 
void clear ()
 Clears the matrix deallocating all its rows. More...
 
void transpose ()
 Transposes the matrix. More...
 
void transpose_assign (const Bit_Matrix &y)
 Makes *this a transposed copy of y. More...
 
dimension_type num_columns () const
 Returns the number of columns of *this. More...
 
dimension_type num_rows () const
 Returns the number of rows of *this. More...
 
void sort_rows ()
 Sorts the rows and removes duplicates. More...
 
bool sorted_contains (const Bit_Row &row) const
 Looks for row in *this, which is assumed to be sorted. More...
 
void add_recycled_row (Bit_Row &row)
 Adds row to *this. More...
 
void remove_trailing_rows (dimension_type n)
 Removes the last n rows. More...
 
void remove_trailing_columns (dimension_type n)
 Removes the last n columns. More...
 
void resize (dimension_type new_n_rows, dimension_type new_n_columns)
 Resizes the matrix copying the old contents. More...
 
bool OK () const
 Checks if all the invariants are satisfied. More...
 
void ascii_dump () const
 Writes to std::cerr an ASCII representation of *this. More...
 
void ascii_dump (std::ostream &s) const
 Writes to s an ASCII representation of *this. More...
 
void print () const
 Prints *this to std::cerr using operator<<. More...
 
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. More...
 
memory_size_type total_memory_in_bytes () const
 Returns the total size in bytes of the memory occupied by *this. More...
 
memory_size_type external_memory_in_bytes () const
 Returns the size in bytes of the memory managed by *this. More...
 
bool check_sorted () const
 Checks whether *this is sorted. It does NOT check for duplicates. More...
 

Static Public Member Functions

static dimension_type max_num_rows ()
 Returns the maximum number of rows of a Bit_Matrix. More...
 

Private Attributes

std::vector< Bit_Rowrows
 Contains the rows of the matrix. More...
 
dimension_type row_size
 Size of the initialized part of each row. More...
 

Friends

template<typename Row >
class Parma_Polyhedra_Library::Linear_System
 

Related Functions

(Note that these are not member functions.)

bool operator== (const Bit_Matrix &x, const Bit_Matrix &y)
 
void swap (Bit_Matrix &x, Bit_Matrix &y)
 Swaps x with y. More...
 
bool operator== (const Bit_Matrix &x, const Bit_Matrix &y)
 Returns true if and only if x and y are equal. More...
 
bool operator!= (const Bit_Matrix &x, const Bit_Matrix &y)
 Returns true if and only if x and y are not equal. More...
 
bool operator!= (const Bit_Matrix &x, const Bit_Matrix &y)
 
void swap (Bit_Matrix &x, Bit_Matrix &y)
 

Detailed Description

A matrix of bits.

Definition at line 47 of file Bit_Matrix_defs.hh.

Constructor & Destructor Documentation

Parma_Polyhedra_Library::Bit_Matrix::Bit_Matrix ( )
inline

Default constructor.

Definition at line 33 of file Bit_Matrix_inlines.hh.

34  : rows(),
35  row_size(0) {
36 }
dimension_type row_size
Size of the initialized part of each row.
std::vector< Bit_Row > rows
Contains the rows of the matrix.
Parma_Polyhedra_Library::Bit_Matrix::Bit_Matrix ( dimension_type  n_rows,
dimension_type  n_columns 
)
inline

Construct a bit matrix with n_rows rows and n_columns columns.

Definition at line 44 of file Bit_Matrix_inlines.hh.

46  : rows(n_rows),
47  row_size(n_columns) {
48 }
dimension_type row_size
Size of the initialized part of each row.
std::vector< Bit_Row > rows
Contains the rows of the matrix.
Parma_Polyhedra_Library::Bit_Matrix::Bit_Matrix ( const Bit_Matrix y)
inline

Copy constructor.

Definition at line 51 of file Bit_Matrix_inlines.hh.

52  : rows(y.rows),
53  row_size(y.row_size) {
54 }
dimension_type row_size
Size of the initialized part of each row.
std::vector< Bit_Row > rows
Contains the rows of the matrix.
Parma_Polyhedra_Library::Bit_Matrix::~Bit_Matrix ( )
inline

Destructor.

Definition at line 57 of file Bit_Matrix_inlines.hh.

57  {
58 }

Member Function Documentation

void Parma_Polyhedra_Library::Bit_Matrix::add_recycled_row ( Bit_Row row)

Adds row to *this.

Parameters
rowThe row whose implementation will be recycled.

The only thing that can be done with row upon return is destruction.

Definition at line 74 of file Bit_Matrix.cc.

References Parma_Polyhedra_Library::compute_capacity(), and Parma_Polyhedra_Library::swap().

Referenced by Parma_Polyhedra_Library::Polyhedron::conversion().

74  {
75  const dimension_type new_rows_size = rows.size() + 1;
76  if (rows.capacity() < new_rows_size) {
77  // Reallocation will take place.
78  std::vector<Bit_Row> new_rows;
79  new_rows.reserve(compute_capacity(new_rows_size, max_num_rows()));
80  new_rows.insert(new_rows.end(), new_rows_size, Bit_Row());
81  // Put the new row in place.
82  dimension_type i = new_rows_size-1;
83  new_rows[i].m_swap(row);
84  // Steal the old rows.
85  while (i-- > 0) {
86  new_rows[i].m_swap(rows[i]);
87  }
88  // Put the new rows into place.
89  using std::swap;
90  swap(rows, new_rows);
91  }
92  else {
93  // Reallocation will NOT take place: append an empty row
94  // and swap it with the new row.
95  rows.insert(rows.end(), Bit_Row())->m_swap(row);
96  }
97  PPL_ASSERT(OK());
98 }
void swap(CO_Tree &x, CO_Tree &y)
size_t dimension_type
An unsigned integral type for representing space dimensions.
void swap(Bit_Matrix &x, Bit_Matrix &y)
Swaps x with y.
dimension_type compute_capacity(dimension_type requested_size, dimension_type maximum_size)
Speculative allocation function.
void m_swap(Bit_Matrix &y)
Swaps *this with y.
bool OK() const
Checks if all the invariants are satisfied.
Definition: Bit_Matrix.cc:234
static dimension_type max_num_rows()
Returns the maximum number of rows of a Bit_Matrix.
std::vector< Bit_Row > rows
Contains the rows of the matrix.
void Parma_Polyhedra_Library::Bit_Matrix::ascii_dump ( ) const

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

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

Writes to s an ASCII representation of *this.

Definition at line 173 of file Bit_Matrix.cc.

References Parma_Polyhedra_Library::Implementation::BD_Shapes::separator.

173  {
174  const Bit_Matrix& x = *this;
175  const char separator = ' ';
176  s << num_rows() << separator << 'x' << separator
177  << num_columns() << "\n";
178  for (dimension_type i = 0; i < num_rows(); ++i) {
179  for (dimension_type j = 0; j < num_columns(); ++j) {
180  s << x[i][j] << separator;
181  }
182  s << "\n";
183  }
184 }
size_t dimension_type
An unsigned integral type for representing space dimensions.
dimension_type num_rows() const
Returns the number of rows of *this.
dimension_type num_columns() const
Returns the number of columns of *this.
bool Parma_Polyhedra_Library::Bit_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.

Definition at line 189 of file Bit_Matrix.cc.

References clear().

189  {
190  Bit_Matrix& x = *this;
191  dimension_type nrows;
192  dimension_type ncols;
193  std::string str;
194  if (!(s >> nrows)) {
195  return false;
196  }
197  if (!(s >> str) || str != "x") {
198  return false;
199  }
200  if (!(s >> ncols)) {
201  return false;
202  }
203  resize(nrows, ncols);
204 
205  for (dimension_type i = 0; i < num_rows(); ++i) {
206  for (dimension_type j = 0; j < num_columns(); ++j) {
207  int bit;
208  if (!(s >> bit)) {
209  return false;
210  }
211  if (bit != 0) {
212  x[i].set(j);
213  }
214  else {
215  x[i].clear(j);
216  }
217  }
218  }
219  // Check invariants.
220  PPL_ASSERT(OK());
221  return true;
222 }
size_t dimension_type
An unsigned integral type for representing space dimensions.
void resize(dimension_type new_n_rows, dimension_type new_n_columns)
Resizes the matrix copying the old contents.
Definition: Bit_Matrix.cc:132
dimension_type num_rows() const
Returns the number of rows of *this.
bool OK() const
Checks if all the invariants are satisfied.
Definition: Bit_Matrix.cc:234
dimension_type num_columns() const
Returns the number of columns of *this.
bool Parma_Polyhedra_Library::Bit_Matrix::check_sorted ( ) const

Checks whether *this is sorted. It does NOT check for duplicates.

Definition at line 263 of file Bit_Matrix.cc.

References Parma_Polyhedra_Library::compare().

Referenced by sorted_contains().

263  {
264  const Bit_Matrix& x = *this;
265  for (dimension_type i = num_rows(); i-- > 1; ) {
266  if (compare(x[i-1], x[i]) > 0) {
267  return false;
268  }
269  }
270  return true;
271 }
size_t dimension_type
An unsigned integral type for representing space dimensions.
dimension_type num_rows() const
Returns the number of rows of *this.
int compare(const Linear_Expression &x, const Linear_Expression &y)
void Parma_Polyhedra_Library::Bit_Matrix::clear ( )
inline

Clears the matrix deallocating all its rows.

Definition at line 109 of file Bit_Matrix_inlines.hh.

References row_size, rows, and Parma_Polyhedra_Library::swap().

Referenced by ascii_load(), Parma_Polyhedra_Library::BD_Shape< T >::shortest_path_reduction_assign(), Parma_Polyhedra_Library::Polyhedron::update_sat_c(), and Parma_Polyhedra_Library::Polyhedron::update_sat_g().

109  {
110  // Clear `rows' and minimize its capacity.
111  std::vector<Bit_Row> tmp;
112  std::swap(tmp, rows);
113  row_size = 0;
114 }
void swap(CO_Tree &x, CO_Tree &y)
dimension_type row_size
Size of the initialized part of each row.
std::vector< Bit_Row > rows
Contains the rows of the matrix.
PPL::memory_size_type Parma_Polyhedra_Library::Bit_Matrix::external_memory_in_bytes ( ) const

Returns the size in bytes of the memory managed by *this.

Definition at line 225 of file Bit_Matrix.cc.

Referenced by total_memory_in_bytes().

225  {
226  memory_size_type n = rows.capacity() * sizeof(Dense_Row);
227  for (dimension_type i = num_rows(); i-- > 0; ) {
228  n += rows[i].external_memory_in_bytes();
229  }
230  return n;
231 }
size_t dimension_type
An unsigned integral type for representing space dimensions.
dimension_type num_rows() const
Returns the number of rows of *this.
std::vector< Bit_Row > rows
Contains the rows of the matrix.
size_t memory_size_type
An unsigned integral type for representing memory size in bytes.
void Parma_Polyhedra_Library::Bit_Matrix::m_swap ( Bit_Matrix y)
inline

Swaps *this with y.

Definition at line 81 of file Bit_Matrix_inlines.hh.

References row_size, rows, and Parma_Polyhedra_Library::swap().

Referenced by resize(), and swap().

81  {
82  std::swap(row_size, y.row_size);
83  std::swap(rows, y.rows);
84 }
void swap(CO_Tree &x, CO_Tree &y)
dimension_type row_size
Size of the initialized part of each row.
std::vector< Bit_Row > rows
Contains the rows of the matrix.
dimension_type Parma_Polyhedra_Library::Bit_Matrix::max_num_rows ( )
inlinestatic

Returns the maximum number of rows of a Bit_Matrix.

Definition at line 39 of file Bit_Matrix_inlines.hh.

39  {
40  return std::vector<Bit_Row>().max_size();
41 }
dimension_type Parma_Polyhedra_Library::Bit_Matrix::num_columns ( ) const
inline

Returns the number of columns of *this.

Definition at line 99 of file Bit_Matrix_inlines.hh.

References row_size.

Referenced by Parma_Polyhedra_Library::Polyhedron::add_space_dimensions(), Parma_Polyhedra_Library::Polyhedron::conversion(), operator==(), Parma_Polyhedra_Library::Polyhedron::simplify(), and transpose_assign().

99  {
100  return row_size;
101 }
dimension_type row_size
Size of the initialized part of each row.
dimension_type Parma_Polyhedra_Library::Bit_Matrix::num_rows ( ) const
inline

Returns the number of rows of *this.

Definition at line 104 of file Bit_Matrix_inlines.hh.

References rows.

Referenced by Parma_Polyhedra_Library::Polyhedron::add_space_dimensions(), Parma_Polyhedra_Library::Polyhedron::conversion(), operator==(), Parma_Polyhedra_Library::Linear_System< Row >::sort_and_remove_with_sat(), and transpose_assign().

104  {
105  return rows.size();
106 }
std::vector< Bit_Row > rows
Contains the rows of the matrix.
bool Parma_Polyhedra_Library::Bit_Matrix::OK ( ) const

Checks if all the invariants are satisfied.

Definition at line 234 of file Bit_Matrix.cc.

References Parma_Polyhedra_Library::Bit_Row::last(), and Parma_Polyhedra_Library::Bit_Row::OK().

Referenced by operator=(), remove_trailing_columns(), and remove_trailing_rows().

234  {
235 #ifndef NDEBUG
236  using std::endl;
237  using std::cerr;
238 #endif
239 
240  const Bit_Matrix& x = *this;
241  for (dimension_type i = num_rows(); i-- > 0; ) {
242  const Bit_Row& row = x[i];
243  if (!row.OK()) {
244  return false;
245  }
246  else if (row.last() != C_Integer<unsigned long>::max
247  && row.last() >= row_size) {
248 #ifndef NDEBUG
249  cerr << "Bit_Matrix[" << i << "] is a row with too many bits!"
250  << endl
251  << "(row_size == " << row_size
252  << ", row.last() == " << row.last() << ")"
253  << endl;
254 #endif
255  return false;
256  }
257  }
258  return true;
259 }
size_t dimension_type
An unsigned integral type for representing space dimensions.
dimension_type num_rows() const
Returns the number of rows of *this.
dimension_type row_size
Size of the initialized part of each row.
PPL::Bit_Matrix & Parma_Polyhedra_Library::Bit_Matrix::operator= ( const Bit_Matrix y)

Assignment operator.

Definition at line 36 of file Bit_Matrix.cc.

References OK(), row_size, and rows.

36  {
37  rows = y.rows;
38  row_size = y.row_size;
39  PPL_ASSERT(OK());
40  return *this;
41 }
bool OK() const
Checks if all the invariants are satisfied.
Definition: Bit_Matrix.cc:234
dimension_type row_size
Size of the initialized part of each row.
std::vector< Bit_Row > rows
Contains the rows of the matrix.
Bit_Row & Parma_Polyhedra_Library::Bit_Matrix::operator[] ( dimension_type  k)
inline

Subscript operator.

Definition at line 87 of file Bit_Matrix_inlines.hh.

References rows.

87  {
88  PPL_ASSERT(k < rows.size());
89  return rows[k];
90 }
std::vector< Bit_Row > rows
Contains the rows of the matrix.
const Bit_Row & Parma_Polyhedra_Library::Bit_Matrix::operator[] ( dimension_type  k) const
inline

Constant subscript operator.

Definition at line 93 of file Bit_Matrix_inlines.hh.

References rows.

93  {
94  PPL_ASSERT(k < rows.size());
95  return rows[k];
96 }
std::vector< Bit_Row > rows
Contains the rows of the matrix.
void Parma_Polyhedra_Library::Bit_Matrix::print ( ) const

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

void Parma_Polyhedra_Library::Bit_Matrix::remove_trailing_columns ( dimension_type  n)
inline

Removes the last n columns.

The last n columns of the matrix are all made of zeros. If such an assumption is not met, the behavior is undefined.

Definition at line 72 of file Bit_Matrix_inlines.hh.

References OK(), and row_size.

Referenced by Parma_Polyhedra_Library::Polyhedron::conversion().

72  {
73  // The number of columns to be erased cannot be greater
74  // than the actual number of the columns of the matrix.
75  PPL_ASSERT(n <= row_size);
76  row_size -= n;
77  PPL_ASSERT(OK());
78 }
bool OK() const
Checks if all the invariants are satisfied.
Definition: Bit_Matrix.cc:234
dimension_type row_size
Size of the initialized part of each row.
void Parma_Polyhedra_Library::Bit_Matrix::remove_trailing_rows ( dimension_type  n)
inline

Removes the last n rows.

Definition at line 61 of file Bit_Matrix_inlines.hh.

References OK(), and rows.

Referenced by Parma_Polyhedra_Library::Polyhedron::conversion(), Parma_Polyhedra_Library::Polyhedron::select_H79_constraints(), Parma_Polyhedra_Library::Polyhedron::simplify(), and Parma_Polyhedra_Library::Linear_System< Row >::sort_and_remove_with_sat().

61  {
62  // The number of rows to be erased cannot be greater
63  // than the actual number of the rows of the matrix.
64  PPL_ASSERT(n <= rows.size());
65  if (n != 0) {
66  rows.resize(rows.size() - n);
67  }
68  PPL_ASSERT(OK());
69 }
bool OK() const
Checks if all the invariants are satisfied.
Definition: Bit_Matrix.cc:234
std::vector< Bit_Row > rows
Contains the rows of the matrix.
void Parma_Polyhedra_Library::Bit_Matrix::resize ( dimension_type  new_n_rows,
dimension_type  new_n_columns 
)

Resizes the matrix copying the old contents.

Definition at line 132 of file Bit_Matrix.cc.

References Parma_Polyhedra_Library::compute_capacity(), m_swap(), and Parma_Polyhedra_Library::swap().

Referenced by Parma_Polyhedra_Library::Polyhedron::add_and_minimize(), Parma_Polyhedra_Library::Polyhedron::add_space_dimensions(), Parma_Polyhedra_Library::Polyhedron::update_sat_c(), and Parma_Polyhedra_Library::Polyhedron::update_sat_g().

133  {
134  PPL_ASSERT(OK());
135  const dimension_type old_num_rows = num_rows();
136  if (new_n_columns < row_size) {
137  const dimension_type num_preserved_rows
138  = std::min(old_num_rows, new_n_rows);
139  Bit_Matrix& x = *this;
140  for (dimension_type i = num_preserved_rows; i-- > 0; ) {
141  x[i].clear_from(new_n_columns);
142  }
143  }
144  row_size = new_n_columns;
145  if (new_n_rows > old_num_rows) {
146  if (rows.capacity() < new_n_rows) {
147  // Reallocation will take place.
148  std::vector<Bit_Row> new_rows;
149  new_rows.reserve(compute_capacity(new_n_rows, max_num_rows()));
150  new_rows.insert(new_rows.end(), new_n_rows, Bit_Row());
151  // Steal the old rows.
152  for (dimension_type i = old_num_rows; i-- > 0; ) {
153  new_rows[i].m_swap(rows[i]);
154  }
155  // Put the new vector into place.
156  using std::swap;
157  swap(rows, new_rows);
158  }
159  else {
160  // Reallocation will NOT take place.
161  rows.insert(rows.end(), new_n_rows - old_num_rows, Bit_Row());
162  }
163  }
164  else if (new_n_rows < old_num_rows) {
165  // Drop some rows.
166  rows.resize(new_n_rows);
167  }
168 
169  PPL_ASSERT(OK());
170 }
void swap(CO_Tree &x, CO_Tree &y)
size_t dimension_type
An unsigned integral type for representing space dimensions.
void swap(Bit_Matrix &x, Bit_Matrix &y)
Swaps x with y.
dimension_type num_rows() const
Returns the number of rows of *this.
dimension_type compute_capacity(dimension_type requested_size, dimension_type maximum_size)
Speculative allocation function.
bool OK() const
Checks if all the invariants are satisfied.
Definition: Bit_Matrix.cc:234
static dimension_type max_num_rows()
Returns the maximum number of rows of a Bit_Matrix.
dimension_type row_size
Size of the initialized part of each row.
std::vector< Bit_Row > rows
Contains the rows of the matrix.
void Parma_Polyhedra_Library::Bit_Matrix::sort_rows ( )

Sorts the rows and removes duplicates.

Definition at line 44 of file Bit_Matrix.cc.

References Parma_Polyhedra_Library::Implementation::indirect_sort_and_unique().

Referenced by Parma_Polyhedra_Library::Polyhedron::select_H79_constraints().

44  {
45  const dimension_type num_elems = rows.size();
46  if (num_elems < 2) {
47  return;
48  }
49  // Build the function objects implementing indirect sort comparison,
50  // indirect unique comparison and indirect swap operation.
51  using namespace Implementation;
52  typedef std::vector<Bit_Row> Cont;
53  typedef Indirect_Sort_Compare<Cont, Bit_Row_Less_Than> Sort_Compare;
54  typedef Indirect_Unique_Compare<Cont> Unique_Compare;
55  typedef Indirect_Swapper<Cont> Swapper;
56  const dimension_type num_duplicates
57  = indirect_sort_and_unique(num_elems,
58  Sort_Compare(rows),
59  Unique_Compare(rows),
60  Swapper(rows));
61 
62  if (num_duplicates > 0) {
63  typedef Cont::iterator Iter;
64  typedef std::iterator_traits<Iter>::difference_type diff_t;
65  Iter last = rows.end();
66  Iter first = last - static_cast<diff_t>(num_duplicates);
67  rows.erase(first, last);
68  }
69 
70  PPL_ASSERT(OK());
71 }
size_t dimension_type
An unsigned integral type for representing space dimensions.
bool OK() const
Checks if all the invariants are satisfied.
Definition: Bit_Matrix.cc:234
std::vector< Bit_Row > rows
Contains the rows of the matrix.
Sort_Comparer::size_type indirect_sort_and_unique(typename Sort_Comparer::size_type num_elems, Sort_Comparer sort_cmp, Unique_Comparer unique_cmp, Swapper indirect_swap)
bool Parma_Polyhedra_Library::Bit_Matrix::sorted_contains ( const Bit_Row row) const
inline

Looks for row in *this, which is assumed to be sorted.

Returns
true if row belongs to *this, false otherwise.
Parameters
rowThe row that will be searched for in the matrix.

Given a sorted bit matrix (this ensures better efficiency), tells whether it contains the given row.

Definition at line 128 of file Bit_Matrix_inlines.hh.

References check_sorted(), and rows.

Referenced by Parma_Polyhedra_Library::Polyhedron::select_H79_constraints().

128  {
129  PPL_ASSERT(check_sorted());
130  return std::binary_search(rows.begin(), rows.end(), row,
131  Bit_Row_Less_Than());
132 }
bool check_sorted() const
Checks whether *this is sorted. It does NOT check for duplicates.
Definition: Bit_Matrix.cc:263
std::vector< Bit_Row > rows
Contains the rows of the matrix.
memory_size_type Parma_Polyhedra_Library::Bit_Matrix::total_memory_in_bytes ( ) const
inline

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

Definition at line 117 of file Bit_Matrix_inlines.hh.

References external_memory_in_bytes().

117  {
118  return sizeof(*this) + external_memory_in_bytes();
119 }
memory_size_type external_memory_in_bytes() const
Returns the size in bytes of the memory managed by *this.
Definition: Bit_Matrix.cc:225
void Parma_Polyhedra_Library::Bit_Matrix::transpose ( )

Transposes the matrix.

Definition at line 101 of file Bit_Matrix.cc.

101  {
102  const Bit_Matrix& x = *this;
103  const dimension_type nrows = num_rows();
104  const dimension_type ncols = num_columns();
105  Bit_Matrix tmp(ncols, nrows);
106  for (dimension_type i = nrows; i-- > 0; ) {
107  for (unsigned long j = x[i].last();
108  j != C_Integer<unsigned long>::max; j = x[i].prev(j)) {
109  tmp[j].set(i);
110  }
111  }
112  m_swap(tmp);
113  PPL_ASSERT(OK());
114 }
size_t dimension_type
An unsigned integral type for representing space dimensions.
dimension_type num_rows() const
Returns the number of rows of *this.
void m_swap(Bit_Matrix &y)
Swaps *this with y.
bool OK() const
Checks if all the invariants are satisfied.
Definition: Bit_Matrix.cc:234
dimension_type num_columns() const
Returns the number of columns of *this.
void Parma_Polyhedra_Library::Bit_Matrix::transpose_assign ( const Bit_Matrix y)

Makes *this a transposed copy of y.

Definition at line 117 of file Bit_Matrix.cc.

References num_columns(), and num_rows().

Referenced by Parma_Polyhedra_Library::Polyhedron::add_space_dimensions(), Parma_Polyhedra_Library::Polyhedron::minimize(), Parma_Polyhedra_Library::Polyhedron::obtain_sorted_constraints(), Parma_Polyhedra_Library::Polyhedron::obtain_sorted_constraints_with_sat_c(), Parma_Polyhedra_Library::Polyhedron::obtain_sorted_generators(), Parma_Polyhedra_Library::Polyhedron::obtain_sorted_generators_with_sat_g(), Parma_Polyhedra_Library::Polyhedron::process_pending_constraints(), Parma_Polyhedra_Library::Polyhedron::process_pending_generators(), Parma_Polyhedra_Library::Polyhedron::strongly_minimize_constraints(), and Parma_Polyhedra_Library::Polyhedron::strongly_minimize_generators().

117  {
118  const dimension_type y_num_rows = y.num_rows();
119  const dimension_type y_num_columns = y.num_columns();
120  Bit_Matrix tmp(y_num_columns, y_num_rows);
121  for (dimension_type i = y_num_rows; i-- > 0; ) {
122  for (unsigned long j = y[i].last();
123  j != C_Integer<unsigned long>::max; j = y[i].prev(j)) {
124  tmp[j].set(i);
125  }
126  }
127  m_swap(tmp);
128  PPL_ASSERT(OK());
129 }
size_t dimension_type
An unsigned integral type for representing space dimensions.
void m_swap(Bit_Matrix &y)
Swaps *this with y.
bool OK() const
Checks if all the invariants are satisfied.
Definition: Bit_Matrix.cc:234

Friends And Related Function Documentation

bool operator!= ( const Bit_Matrix x,
const Bit_Matrix y 
)
related

Definition at line 136 of file Bit_Matrix_inlines.hh.

136  {
137  return !(x == y);
138 }
bool operator!= ( const Bit_Matrix x,
const Bit_Matrix y 
)
related

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

bool operator== ( const Bit_Matrix x,
const Bit_Matrix y 
)
related

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

bool operator== ( const Bit_Matrix x,
const Bit_Matrix y 
)
related

Definition at line 276 of file Bit_Matrix.cc.

References num_columns(), and num_rows().

276  {
277  const dimension_type x_num_rows = x.num_rows();
278  if (x_num_rows != y.num_rows()
279  || x.num_columns() != y.num_columns()) {
280  return false;
281  }
282  for (dimension_type i = x_num_rows; i-- > 0; ) {
283  if (x[i] != y[i]) {
284  return false;
285  }
286  }
287  return true;
288 }
size_t dimension_type
An unsigned integral type for representing space dimensions.
template<typename Row >
friend class Parma_Polyhedra_Library::Linear_System
friend

Definition at line 166 of file Bit_Matrix_defs.hh.

void swap ( Bit_Matrix x,
Bit_Matrix y 
)
related

Swaps x with y.

void swap ( Bit_Matrix x,
Bit_Matrix y 
)
related

Definition at line 142 of file Bit_Matrix_inlines.hh.

References m_swap().

142  {
143  x.m_swap(y);
144 }

Member Data Documentation

dimension_type Parma_Polyhedra_Library::Bit_Matrix::row_size
private

Size of the initialized part of each row.

Definition at line 157 of file Bit_Matrix_defs.hh.

Referenced by clear(), m_swap(), num_columns(), operator=(), and remove_trailing_columns().

std::vector<Bit_Row> Parma_Polyhedra_Library::Bit_Matrix::rows
private

Contains the rows of the matrix.

Definition at line 154 of file Bit_Matrix_defs.hh.

Referenced by clear(), m_swap(), num_rows(), operator=(), operator[](), remove_trailing_rows(), and sorted_contains().


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