From c8379ab541a6f53ba5f61f07518d245baba82424 Mon Sep 17 00:00:00 2001 From: wolf Date: Wed, 12 May 2004 15:05:22 +0000 Subject: [PATCH] Rename the Table::clear function to Table::reset_entries to make its intent clearer. git-svn-id: https://svn.dealii.org/trunk@9238 0785d39b-7218-0410-832d-ea1e28bc413d --- deal.II/base/include/base/table.h | 27 ++++++++++++++----- .../lac/block_sparse_matrix.templates.h | 6 ++--- deal.II/lac/include/lac/full_matrix.h | 3 --- deal.II/lac/source/block_sparsity_pattern.cc | 8 +++--- 4 files changed, 28 insertions(+), 16 deletions(-) diff --git a/deal.II/base/include/base/table.h b/deal.II/base/include/base/table.h index eb4ae087e0..b1a17c19cf 100644 --- a/deal.II/base/include/base/table.h +++ b/deal.II/base/include/base/table.h @@ -773,9 +773,10 @@ class TableBase : public Subscriptor * Set all entries to their * default value (i.e. copy them * over with default constructed - * objects). + * objects). Do not change the + * size of the table, though. */ - void clear (); + void reset_values (); /** * Set the dimensions of this @@ -1960,7 +1961,7 @@ TableBase::operator = (const TableBase& m) template inline void -TableBase::clear () +TableBase::reset_values () { if (n_elements() != 0) std::fill_n (val, n_elements(), T()); @@ -1993,7 +1994,7 @@ TableBase::reinit (const TableIndices &new_sizes) table_size = TableIndices(); return; - }; + } // if new size is nonzero: // if necessary allocate @@ -2005,11 +2006,23 @@ TableBase::reinit (const TableIndices &new_sizes) val_size = new_size; val = new T[val_size]; - }; + } // reinitialize contents of old or - // new memory. - clear (); + // new memory. note that we + // actually need to do this here, + // even in the case that we + // reallocated memory, since per + // C++ standard, clause 5.3.4/15 + // the newly allocated objects are + // only default initialized by + // operator new[] if they are + // non-POD type. In other words, if + // we have a table of doubles, then + // their values after calling 'new + // double[val_size]' is + // indetermined. + reset_values (); } diff --git a/deal.II/lac/include/lac/block_sparse_matrix.templates.h b/deal.II/lac/include/lac/block_sparse_matrix.templates.h index 73b80067ac..50bec5d1aa 100644 --- a/deal.II/lac/include/lac/block_sparse_matrix.templates.h +++ b/deal.II/lac/include/lac/block_sparse_matrix.templates.h @@ -95,7 +95,8 @@ BlockSparseMatrix:: reinit (const BlockSparsityPattern &sparsity) { // first delete previous content of - // the subobjects array + // the subobjects array and delete + // the table completely for (unsigned int r=0; r DeclException0 (ExcSourceEqualsDestination); friend class Accessor; - - private: - void clear (); }; /*@}*/ diff --git a/deal.II/lac/source/block_sparsity_pattern.cc b/deal.II/lac/source/block_sparsity_pattern.cc index 092d1ca3c5..18667288b2 100644 --- a/deal.II/lac/source/block_sparsity_pattern.cc +++ b/deal.II/lac/source/block_sparsity_pattern.cc @@ -68,7 +68,9 @@ BlockSparsityPatternBase:: reinit (const unsigned int n_block_rows, const unsigned int n_block_columns) { - // delete previous content + // delete previous content and + // clean the sub_objects array + // completely for (unsigned int i=0; i