From: Daniel Arndt Date: Thu, 7 Feb 2019 09:43:15 +0000 (+0100) Subject: Replace all unsigned int by size_type in ChunkSparsityPattern X-Git-Tag: v9.1.0-rc1~348^2~1 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=b163e04e589737eba7702e93f648073022b3afc1;p=dealii.git Replace all unsigned int by size_type in ChunkSparsityPattern --- diff --git a/include/deal.II/lac/chunk_sparsity_pattern.h b/include/deal.II/lac/chunk_sparsity_pattern.h index a43a3f9558..cc0d6969c6 100644 --- a/include/deal.II/lac/chunk_sparsity_pattern.h +++ b/include/deal.II/lac/chunk_sparsity_pattern.h @@ -83,7 +83,7 @@ namespace ChunkSparsityPatternIterators * Row number of the element represented by this object. This function can * only be called for entries for which is_valid_entry() is true. */ - unsigned int + size_type row() const; /** @@ -96,7 +96,7 @@ namespace ChunkSparsityPatternIterators * Column number of the element represented by this object. This function * can only be called for entries for which is_valid_entry() is true. */ - unsigned int + size_type column() const; /** @@ -143,12 +143,12 @@ namespace ChunkSparsityPatternIterators /** * Current chunk row number. */ - unsigned int chunk_row; + size_type chunk_row; /** * Current chunk col number. */ - unsigned int chunk_col; + size_type chunk_col; /** * Move the accessor to the next nonzero entry in the matrix. @@ -443,13 +443,12 @@ public: * these iterators) must be a container itself that provides functions * begin and end designating a range of iterators that * describe the contents of one line. Dereferencing these inner iterators - * must either yield a pair of an unsigned integer as column index and a + * must either yield a pair of a scalar as column index and a * value of arbitrary type (such a type would be used if we wanted to - * describe a sparse matrix with one such object), or simply an unsigned - * integer (of we only wanted to describe a sparsity pattern). The function - * is able to determine itself whether an unsigned integer or a pair is what - * we get after dereferencing the inner iterators, through some template - * magic. + * describe a sparse matrix with one such object), or simply a scalar (if we + * only wanted to describe a sparsity pattern). The function is able to + * determine itself whether a scalar or a pair is what we get after + * dereferencing the inner iterators, through some template magic. * * While the order of the outer iterators denotes the different rows of the * matrix, the order of the inner iterator denoting the columns does not @@ -471,7 +470,7 @@ public: * Note that this example works since the iterators dereferenced yield * containers with functions begin and end (namely * std::vectors), and the inner iterators dereferenced yield - * unsigned integers as column indices. Note that we could have replaced + * scalars as column indices. Note that we could have replaced * each of the two std::vector occurrences by std::list, * and the inner one by std::set as well. * @@ -493,12 +492,12 @@ public: * @endcode * * This example works because dereferencing iterators of the inner type - * yields a pair of unsigned integers and a value, the first of which we + * yields a pair of scalars and a value, the first of which we * take as column index. As previously, the outer std::vector could - * be replaced by std::list, and the inner std::map could be replaced by std::vector >, or a list or set of such pairs, as they all return - * iterators that point to such pairs. + * be replaced by std::list, and the inner + * std::map could be replaced by + * std::vector >, or a list or set of + * such pairs, as they all return iterators that point to such pairs. */ template void @@ -547,11 +546,11 @@ public: */ template void - create_from(const unsigned int m, - const unsigned int n, - const Sparsity & sparsity_pattern_for_chunks, - const unsigned int chunk_size, - const bool optimize_diagonal = true); + create_from(const size_type m, + const size_type n, + const Sparsity &sparsity_pattern_for_chunks, + const size_type chunk_size, + const bool optimize_diagonal = true); /** * Return whether the object is empty. It is empty if no memory is @@ -683,7 +682,7 @@ public: * that case. */ iterator - begin(const unsigned int r) const; + begin(const size_type r) const; /** * Final iterator of row r. It points to the first element past the @@ -694,7 +693,7 @@ public: * matrix. */ iterator - end(const unsigned int r) const; + end(const size_type r) const; /** * Write the data of this object en bloc to a file. This is done in a binary @@ -764,22 +763,22 @@ public: * Exception */ DeclException1(ExcInvalidNumber, - int, + size_type, << "The provided number is invalid here: " << arg1); /** * Exception */ DeclException2(ExcInvalidIndex, - int, - int, + size_type, + size_type, << "The given index " << arg1 << " should be less than " << arg2 << "."); /** * Exception */ DeclException2(ExcNotEnoughSpace, - int, - int, + size_type, + size_type, << "Upon entering a new entry to row " << arg1 << ": there was no free entry any more. " << std::endl << "(Maximum number of entries for this row: " << arg2 @@ -808,8 +807,8 @@ public: * Exception */ DeclException2(ExcIteratorRange, - int, - int, + size_type, + size_type, << "The iterators denote a range of " << arg1 << " elements, but the given number of rows was " << arg2); /** @@ -820,15 +819,15 @@ public: * Exception */ DeclException1(ExcInvalidNumberOfPartitions, - int, + size_type, << "The number of partitions you gave is " << arg1 << ", but must be greater than zero."); /** * Exception */ DeclException2(ExcInvalidArraySize, - int, - int, + size_type, + size_type, << "The array has size " << arg1 << " but should have size " << arg2); //@} @@ -912,7 +911,7 @@ namespace ChunkSparsityPatternIterators - inline unsigned int + inline Accessor::size_type Accessor::row() const { Assert(is_valid_entry() == true, ExcInvalidIterator()); @@ -923,7 +922,7 @@ namespace ChunkSparsityPatternIterators - inline unsigned int + inline Accessor::size_type Accessor::column() const { Assert(is_valid_entry() == true, ExcInvalidIterator()); @@ -970,13 +969,12 @@ namespace ChunkSparsityPatternIterators reduced_accessor.container->n_nonzero_elements()) return true; - const unsigned int global_row = sparsity_pattern->get_chunk_size() * - reduced_accessor.row() + - chunk_row, - other_global_row = - sparsity_pattern->get_chunk_size() * - other.reduced_accessor.row() + - other.chunk_row; + const auto global_row = sparsity_pattern->get_chunk_size() * + reduced_accessor.row() + + chunk_row, + other_global_row = sparsity_pattern->get_chunk_size() * + other.reduced_accessor.row() + + other.chunk_row; if (global_row < other_global_row) return true; else if (global_row > other_global_row) @@ -993,7 +991,7 @@ namespace ChunkSparsityPatternIterators inline void Accessor::advance() { - const unsigned int chunk_size = sparsity_pattern->get_chunk_size(); + const auto chunk_size = sparsity_pattern->get_chunk_size(); Assert(chunk_row < chunk_size && chunk_col < chunk_size, ExcIteratorPastEnd()); Assert(reduced_accessor.row() * chunk_size + chunk_row < @@ -1014,7 +1012,7 @@ namespace ChunkSparsityPatternIterators reduced_accessor.column() * chunk_size + chunk_col == sparsity_pattern->n_cols()) { - const unsigned int reduced_row = reduced_accessor.row(); + const auto reduced_row = reduced_accessor.row(); // end of row if (reduced_accessor.linear_index + 1 == reduced_accessor.container->rowstart[reduced_row + 1]) @@ -1128,7 +1126,7 @@ ChunkSparsityPattern::end() const inline ChunkSparsityPattern::iterator -ChunkSparsityPattern::begin(const unsigned int r) const +ChunkSparsityPattern::begin(const size_type r) const { Assert(r < n_rows(), ExcIndexRange(r, 0, n_rows())); return {this, r}; @@ -1137,7 +1135,7 @@ ChunkSparsityPattern::begin(const unsigned int r) const inline ChunkSparsityPattern::iterator -ChunkSparsityPattern::end(const unsigned int r) const +ChunkSparsityPattern::end(const size_type r) const { Assert(r < n_rows(), ExcIndexRange(r, 0, n_rows())); return {this, r + 1}; diff --git a/source/lac/chunk_sparsity_pattern.cc b/source/lac/chunk_sparsity_pattern.cc index 60b4167a53..db9cc4bbe4 100644 --- a/source/lac/chunk_sparsity_pattern.cc +++ b/source/lac/chunk_sparsity_pattern.cc @@ -292,10 +292,10 @@ namespace internal template void -ChunkSparsityPattern::create_from(const unsigned int m, - const unsigned int n, +ChunkSparsityPattern::create_from(const size_type m, + const size_type n, const Sparsity &sparsity_pattern_for_chunks, - const unsigned int chunk_size_in, + const size_type chunk_size_in, const bool) { Assert(m > (sparsity_pattern_for_chunks.n_rows() - 1) * chunk_size_in && @@ -598,17 +598,17 @@ ChunkSparsityPattern::copy_from( const DynamicSparsityPattern &, const size_type); template void -ChunkSparsityPattern::create_from(const unsigned int, - const unsigned int, +ChunkSparsityPattern::create_from(const size_type, + const size_type, const SparsityPattern &, - const unsigned int, + const size_type, const bool); template void ChunkSparsityPattern::create_from( - const unsigned int, - const unsigned int, + const size_type, + const size_type, const DynamicSparsityPattern &, - const unsigned int, + const size_type, const bool); template void ChunkSparsityPattern::copy_from(const FullMatrix &,