]> https://gitweb.dealii.org/ - dealii.git/commitdiff
Replace all unsigned int by size_type in ChunkSparsityPattern
authorDaniel Arndt <daniel.arndt@iwr.uni-heidelberg.de>
Thu, 7 Feb 2019 09:43:15 +0000 (10:43 +0100)
committerDaniel Arndt <daniel.arndt@iwr.uni-heidelberg.de>
Thu, 7 Feb 2019 09:43:15 +0000 (10:43 +0100)
include/deal.II/lac/chunk_sparsity_pattern.h
source/lac/chunk_sparsity_pattern.cc

index a43a3f9558d60beeead8bc1920eb1785211e68a4..cc0d6969c674921573d90d7468959d1154781350 100644 (file)
@@ -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
    * <tt>begin</tt> and <tt>end</tt> 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 <tt>begin</tt> and <tt>end</tt> (namely
    * <tt>std::vector</tt>s), 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 <tt>std::vector</tt> occurrences by <tt>std::list</tt>,
    * and the inner one by <tt>std::set</tt> 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 <tt>std::vector</tt> could
-   * be replaced by <tt>std::list</tt>, and the inner <tt>std::map<unsigned
-   * int,double></tt> could be replaced by <tt>std::vector<std::pair<unsigned
-   * int,double> ></tt>, or a list or set of such pairs, as they all return
-   * iterators that point to such pairs.
+   * be replaced by <tt>std::list</tt>, and the inner
+   * <tt>std::map<size_type,double></tt> could be replaced by
+   * <tt>std::vector<std::pair<size_type,double> ></tt>, or a list or set of
+   * such pairs, as they all return iterators that point to such pairs.
    */
   template <typename ForwardIterator>
   void
@@ -547,11 +546,11 @@ public:
    */
   template <typename Sparsity>
   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 <tt>r</tt>. 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};
index 60b4167a539960148547122365f5a7b9f6e46335..db9cc4bbe47bc9531ea1c114d6fba919bbb14a82 100644 (file)
@@ -292,10 +292,10 @@ namespace internal
 
 template <typename Sparsity>
 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<DynamicSparsityPattern>(
   const DynamicSparsityPattern &,
   const size_type);
 template void
-ChunkSparsityPattern::create_from<SparsityPattern>(const unsigned int,
-                                                   const unsigned int,
+ChunkSparsityPattern::create_from<SparsityPattern>(const size_type,
+                                                   const size_type,
                                                    const SparsityPattern &,
-                                                   const unsigned int,
+                                                   const size_type,
                                                    const bool);
 template void
 ChunkSparsityPattern::create_from<DynamicSparsityPattern>(
-  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<float>(const FullMatrix<float> &,

In the beginning the Universe was created. This has made a lot of people very angry and has been widely regarded as a bad move.

Douglas Adams


Typeset in Trocchi and Trocchi Bold Sans Serif.