24 #ifndef PPL_DB_Matrix_templates_hh
25 #define PPL_DB_Matrix_templates_hh 1
44 : rows(y.rows.size()),
58 PPL_ASSERT(new_n_rows >= old_n_rows);
60 if (new_n_rows > old_n_rows) {
61 if (new_n_rows <= row_capacity) {
63 if (rows.capacity() < new_n_rows) {
65 std::vector<DB_Row<T> > new_rows;
67 new_rows.insert(new_rows.end(), new_n_rows,
DB_Row<T>());
70 while (i-- > old_n_rows) {
71 new_rows[i].construct(new_n_rows, row_capacity);
76 swap(new_rows[i], rows[i]);
84 rows.insert(rows.end(), new_n_rows - old_n_rows,
DB_Row<T>());
86 rows[i].construct(new_n_rows, row_capacity);
100 while (i-- > old_n_rows) {
119 if (new_n_rows > row_size) {
121 if (new_n_rows <= row_capacity) {
124 rows[i].expand_within_capacity(new_n_rows);
134 DB_Row<T> new_row(rows[i], new_n_rows, new_row_capacity);
135 swap(rows[i], new_row);
137 row_capacity = new_row_capacity;
140 row_size = new_n_rows;
144 template <
typename T>
149 if (new_n_rows > old_n_rows) {
151 if (new_n_rows <= row_capacity) {
153 if (rows.capacity() < new_n_rows) {
155 std::vector<DB_Row<T> > new_rows;
157 new_rows.insert(new_rows.end(), new_n_rows,
DB_Row<T>());
161 while (i-- > old_n_rows) {
162 new_rows[i].construct(new_n_rows, row_capacity);
167 swap(new_rows[i], rows[i]);
171 swap(rows, new_rows);
175 rows.insert(rows.end(), new_n_rows - old_n_rows,
DB_Row<T>());
179 rows[i].construct(new_n_rows, row_capacity);
190 else if (new_n_rows < old_n_rows) {
192 rows.resize(new_n_rows);
195 rows[i].shrink(new_n_rows);
197 old_n_rows = new_n_rows;
200 if (new_n_rows > row_size) {
202 if (new_n_rows <= row_capacity) {
205 rows[i].expand_within_capacity(new_n_rows);
214 DB_Row<T> new_row(new_n_rows, new_row_capacity);
215 swap(rows[i], new_row);
217 row_capacity = new_row_capacity;
221 row_size = new_n_rows;
224 template <
typename T>
230 s << nrows << separator <<
"\n";
233 using namespace IO_Operators;
242 template <typename T>
249 resize_no_copy(nrows);
265 #ifdef PPL_DOXYGEN_INCLUDE_IMPLEMENTATION_DETAILS
267 #endif // defined(PPL_DOXYGEN_INCLUDE_IMPLEMENTATION_DETAILS)
268 template <
typename T>
283 template <
typename T>
288 n += rows[i].external_memory_in_bytes(row_capacity);
293 template <
typename T>
302 if (num_rows() != row_size) {
304 cerr <<
"DB_Matrix has fewer columns than rows:\n"
305 <<
"row_size is " << row_size
306 <<
", num_rows() is " << num_rows() <<
"!"
315 if (!x[i].OK(row_size, row_capacity)) {
324 #ifdef PPL_DOXYGEN_INCLUDE_IMPLEMENTATION_DETAILS
326 #endif // defined(PPL_DOXYGEN_INCLUDE_IMPLEMENTATION_DETAILS)
327 template <
typename T>
329 IO_Operators::operator<<(std::ostream& s, const DB_Matrix<T>&
c) {
342 #endif // !defined(PPL_DB_Matrix_templates_hh)
Enable_If< Is_Native_Or_Checked< T >::value, bool >::type is_minus_infinity(const T &x)
void swap(CO_Tree &x, CO_Tree &y)
size_t dimension_type
An unsigned integral type for representing space dimensions.
memory_size_type external_memory_in_bytes() const
Returns the size in bytes of the memory managed by *this.
Result
Possible outcomes of a checked arithmetic computation.
The standard C++ namespace.
#define PPL_OUTPUT_TEMPLATE_DEFINITIONS(type_symbol, class_prefix)
std::vector< DB_Row< T > > rows
The rows of the matrix.
void grow(dimension_type new_n_rows)
Makes the matrix grow by adding more rows and more columns.
Result_Relation result_relation(Result r)
DB_Matrix()
Builds an empty matrix.
void resize_no_copy(dimension_type new_n_rows)
Resizes the matrix without worrying about the old contents.
The base class for the single rows of matrices.
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.
dimension_type row_size
Size of the initialized part of each row.
Equal. This need to be accompanied by a value.
Enable_If< Is_Native_Or_Checked< T >::value, bool >::type ascii_load(std::istream &s, T &t)
bool operator==(const DB_Matrix< T > &x, const DB_Matrix< T > &y)
dimension_type num_rows() const
Returns the number of rows in the matrix.
dimension_type row_capacity
Capacity allocated for each row, i.e., number of long objects that each row can contain.
The entire library is confined to this namespace.
size_t memory_size_type
An unsigned integral type for representing memory size in bytes.
The base class for the square matrices.
void ascii_dump() const
Writes to std::cerr an ASCII representation of *this.