24 #include "ppl-config.h"
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;
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);
76 if (rows.capacity() < new_rows_size) {
78 std::vector<Bit_Row> new_rows;
80 new_rows.insert(new_rows.end(), new_rows_size,
Bit_Row());
83 new_rows[i].m_swap(row);
86 new_rows[i].m_swap(rows[i]);
95 rows.insert(rows.end(),
Bit_Row())->m_swap(row);
107 for (
unsigned long j = x[i].last();
122 for (
unsigned long j = y[i].last();
136 if (new_n_columns < row_size) {
138 = std::min(old_num_rows, new_n_rows);
141 x[i].clear_from(new_n_columns);
144 row_size = new_n_columns;
145 if (new_n_rows > old_num_rows) {
146 if (rows.capacity() < new_n_rows) {
148 std::vector<Bit_Row> new_rows;
150 new_rows.insert(new_rows.end(), new_n_rows,
Bit_Row());
153 new_rows[i].
m_swap(rows[i]);
157 swap(rows, new_rows);
161 rows.insert(rows.end(), new_n_rows - old_num_rows,
Bit_Row());
164 else if (new_n_rows < old_num_rows) {
166 rows.resize(new_n_rows);
176 s << num_rows() << separator <<
'x' << separator
177 << num_columns() <<
"\n";
197 if (!(s >> str) || str !=
"x") {
203 resize(nrows, ncols);
228 n += rows[i].external_memory_in_bytes();
247 && row.
last() >= row_size) {
249 cerr <<
"Bit_Matrix[" << i <<
"] is a row with too many bits!"
251 <<
"(row_size == " << row_size
252 <<
", row.last() == " << row.
last() <<
")"
266 if (
compare(x[i-1], x[i]) > 0) {
bool OK() const
Checks if all the invariants are satisfied.
void swap(CO_Tree &x, CO_Tree &y)
A finite sequence of coefficients.
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.
dimension_type num_rows() const
Returns the number of rows of *this.
unsigned long last() const
Returns the index of the last set bit or ULONG_MAX if no bit is set.
The standard C++ namespace.
void add_recycled_row(Bit_Row &row)
Adds row to *this.
A row in a matrix of bits.
void transpose()
Transposes the matrix.
dimension_type compute_capacity(dimension_type requested_size, dimension_type maximum_size)
Speculative allocation function.
void clear()
Clears the matrix deallocating all its rows.
#define PPL_OUTPUT_DEFINITIONS_ASCII_ONLY(class_name)
Enable_If< Is_Native_Or_Checked< T >::value, bool >::type ascii_load(std::istream &s, T &t)
int compare(const Linear_Expression &x, const Linear_Expression &y)
memory_size_type external_memory_in_bytes() const
Returns the size in bytes of the memory managed by *this.
Bit_Matrix & operator=(const Bit_Matrix &y)
Assignment operator.
void m_swap(Bit_Matrix &y)
Swaps *this with y.
bool check_sorted() const
Checks whether *this is sorted. It does NOT check for duplicates.
bool OK() const
Checks if all the invariants are satisfied.
dimension_type num_columns() const
Returns the number of columns of *this.
The entire library is confined to this namespace.
dimension_type row_size
Size of the initialized part of each row.
void sort_rows()
Sorts the rows and removes duplicates.
std::vector< Bit_Row > rows
Contains the rows of the matrix.
bool operator==(const Box< ITV > &x, const Box< ITV > &y)
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)
size_t memory_size_type
An unsigned integral type for representing memory size in bytes.
void transpose_assign(const Bit_Matrix &y)
Makes *this a transposed copy of y.
void ascii_dump() const
Writes to std::cerr an ASCII representation of *this.