24 #ifndef PPL_Matrix_templates_hh
25 #define PPL_Matrix_templates_hh 1
29 template <
typename Row>
31 : rows(n), num_columns_(n) {
38 template <
typename Row>
40 : rows(num_rows), num_columns_(num_columns) {
47 template <
typename Row>
51 rows.resize(num_rows);
52 if (old_num_rows < num_rows) {
54 rows[i].resize(num_columns);
56 if (num_columns_ != num_columns) {
57 num_columns_ = num_columns;
59 rows[i].resize(num_columns);
64 if (num_columns_ != num_columns) {
65 num_columns_ = num_columns;
67 rows[i].resize(num_columns);
73 template <
typename Row>
78 PPL_ASSERT(cycles[n - 1] == 0);
80 Row& rows_k = (*this)[k];
83 while (cycles[j] != 0) {
87 PPL_ASSERT(j - i >= 2);
90 rows_k.swap_coefficients(cycles[i], cycles[i + 1]);
94 tmp = rows_k.get(cycles[j - 1]);
96 rows_k.swap_coefficients(cycles[l-1], cycles[l]);
99 rows_k.reset(cycles[i]);
103 swap(tmp, rows_k[cycles[i]]);
110 template <
typename Row>
114 (*this)[k].swap_coefficients(i, j);
118 template <
typename Row>
122 rows[j].add_zeroes_and_shift(n, i);
128 template <
typename Row>
132 rows[j].delete_element_and_shift(i);
138 template <
typename Row>
141 s << num_rows() <<
" x ";
142 s << num_columns() <<
"\n";
150 template <typename Row>
156 if (!(s >> new_num_rows)) {
159 if (!(s >> str) || str !=
"x") {
162 if (!(s >> new_num_cols)) {
166 for (
iterator i = rows.begin(), i_end = rows.end();
171 resize(new_num_rows, new_num_cols);
184 template <
typename Row>
187 return rows.external_memory_in_bytes();
190 template <
typename Row>
193 for (
const_iterator i = begin(), i_end = end(); i != i_end; ++i) {
194 if (i->size() != num_columns_) {
202 template <
typename Row>
220 template <
typename Row>
228 #endif // !defined(PPL_Matrix_templates_hh)
memory_size_type external_memory_in_bytes() const
Returns the size in bytes of the memory managed by *this.
void swap(CO_Tree &x, CO_Tree &y)
void swap_columns(dimension_type i, dimension_type j)
Swaps the columns having indexes i and j.
size_t dimension_type
An unsigned integral type for representing space dimensions.
#define PPL_DIRTY_TEMP_COEFFICIENT(id)
Declare a local variable named id, of type Coefficient, and containing an unknown initial value...
void resize(dimension_type new_size)
Matrix(dimension_type n=0)
Constructs a square matrix with the given size, filled with unstored zeroes.
Swapping_Vector< Row >::iterator iterator
A sparse matrix of Coefficient.
The standard C++ namespace.
void permute_columns(const std::vector< dimension_type > &cycles)
Permutes the columns of the matrix.
Swapping_Vector< Row >::const_iterator const_iterator
bool operator==(const Matrix< Row > &x, const Matrix< Row > &y)
#define PPL_OUTPUT_TEMPLATE_DEFINITIONS_ASCII_ONLY(type_symbol, class_prefix)
dimension_type num_columns() const
Returns the number of columns in the matrix.
Enable_If< Is_Native_Or_Checked< T >::value, bool >::type ascii_load(std::istream &s, T &t)
void ascii_dump() const
Writes to std::cerr an ASCII representation of *this.
dimension_type num_columns_
The number of columns in this matrix.
The entire library is confined to this namespace.
Swapping_Vector< Row > rows
The vector that stores the matrix's elements.
void resize(dimension_type n)
Equivalent to resize(n, n).
bool operator!=(const Matrix< Row > &x, const Matrix< Row > &y)
size_t memory_size_type
An unsigned integral type for representing memory size in bytes.
bool OK() const
Checks if all the invariants are satisfied.
void remove_column(dimension_type i)
Removes the i-th from the matrix, shifting other columns to the left.
dimension_type size() const
void add_zero_columns(dimension_type n)
Adds n columns of zeroes to the matrix.
dimension_type num_rows() const
Returns the number of rows in the matrix.