]> https://gitweb.dealii.org/ - dealii.git/commitdiff
Directly use raw pointers instead of &v[0].
authorDavid Wells <wellsd2@rpi.edu>
Sat, 7 Oct 2017 00:43:13 +0000 (20:43 -0400)
committerDavid Wells <wellsd2@rpi.edu>
Thu, 12 Oct 2017 19:57:46 +0000 (15:57 -0400)
include/deal.II/lac/read_write_vector.h
include/deal.II/lac/read_write_vector.templates.h
include/deal.II/lac/vector.h
include/deal.II/matrix_free/dof_info.h
source/distributed/grid_refinement.cc
source/grid/grid_generator.cc
source/grid/grid_reordering.cc
source/grid/grid_tools.cc
source/grid/tria.cc
source/lac/cuda_vector.cu

index 91c165a4e5488661979dfd851339b4a04e34c823..3e3049dc9e6322df42b50055010125f7556b6653 100644 (file)
@@ -756,7 +756,7 @@ namespace LinearAlgebra
   typename ReadWriteVector<Number>::iterator
   ReadWriteVector<Number>::begin ()
   {
-    return &val[0];
+    return val;
   }
 
 
@@ -766,7 +766,7 @@ namespace LinearAlgebra
   typename ReadWriteVector<Number>::const_iterator
   ReadWriteVector<Number>::begin () const
   {
-    return &val[0];
+    return val;
   }
 
 
@@ -776,7 +776,7 @@ namespace LinearAlgebra
   typename ReadWriteVector<Number>::iterator
   ReadWriteVector<Number>::end ()
   {
-    return &val[this->n_elements()];
+    return val + this->n_elements();
   }
 
 
@@ -786,7 +786,7 @@ namespace LinearAlgebra
   typename ReadWriteVector<Number>::const_iterator
   ReadWriteVector<Number>::end () const
   {
-    return &val[this->n_elements()];
+    return val + this->n_elements();
   }
 
 
index 8fd8c25999e443cc655fa88feb41ca8a942c9cc3..7ee68d7021aff2f996f0c6c5961280c4e6e941c2 100644 (file)
@@ -438,7 +438,7 @@ namespace LinearAlgebra
     const unsigned int n_elements = stored_elements.n_elements();
     if (operation == VectorOperation::insert)
       {
-        cudaError_t error_code = cudaMemcpy(&val[0], cuda_vec.get_values(),
+        cudaError_t error_code = cudaMemcpy(val, cuda_vec.get_values(),
                                             n_elements*sizeof(Number),
                                             cudaMemcpyDeviceToHost);
         AssertCuda(error_code);
index 9c6bc07716bf3f44de073001e15776d304dc412a..89ad440328e5044b182243f33430e5397cb091c2 100644 (file)
@@ -1052,7 +1052,7 @@ inline
 typename Vector<Number>::iterator
 Vector<Number>::begin ()
 {
-  return &val[0];
+  return val;
 }
 
 
@@ -1062,7 +1062,7 @@ inline
 typename Vector<Number>::const_iterator
 Vector<Number>::begin () const
 {
-  return &val[0];
+  return val;
 }
 
 
@@ -1072,7 +1072,7 @@ inline
 typename Vector<Number>::iterator
 Vector<Number>::end ()
 {
-  return &val[vec_size];
+  return val + vec_size;
 }
 
 
@@ -1082,7 +1082,7 @@ inline
 typename Vector<Number>::const_iterator
 Vector<Number>::end () const
 {
-  return &val[vec_size];
+  return val + vec_size;
 }
 
 
index ed6c65c4d3d7167a731551ecc55ecb7f8aa02b3a..ecdd2e3b8e489656f4ea326418113d43a00002a9 100644 (file)
@@ -432,7 +432,7 @@ namespace internal
       AssertIndexRange (row, row_starts.size()-1);
       const unsigned int index = row_starts[row][0];
       AssertIndexRange(index, dof_indices.size()+1);
-      return dof_indices.empty() ? nullptr : &dof_indices[0] + index;
+      return dof_indices.empty() ? nullptr : &dof_indices[index];
     }
 
 
@@ -444,7 +444,7 @@ namespace internal
       AssertIndexRange (row, row_starts.size()-1);
       const unsigned int index = row_starts[row+1][0];
       AssertIndexRange(index, dof_indices.size()+1);
-      return dof_indices.empty() ? nullptr : &dof_indices[0] + index;
+      return dof_indices.empty() ? nullptr : &dof_indices[index];
     }
 
 
@@ -466,7 +466,7 @@ namespace internal
       AssertIndexRange (row, row_starts.size()-1);
       const unsigned int index = row_starts[row][1];
       AssertIndexRange (index, constraint_indicator.size()+1);
-      return constraint_indicator.empty() ? nullptr : &constraint_indicator[0] + index;
+      return constraint_indicator.empty() ? nullptr : &constraint_indicator[index];
     }
 
 
@@ -478,7 +478,7 @@ namespace internal
       AssertIndexRange (row, row_starts.size()-1);
       const unsigned int index = row_starts[row+1][1];
       AssertIndexRange (index, constraint_indicator.size()+1);
-      return constraint_indicator.empty() ? nullptr : &constraint_indicator[0] + index;
+      return constraint_indicator.empty() ? nullptr : &constraint_indicator[index];
     }
 
 
@@ -509,7 +509,7 @@ namespace internal
           AssertDimension (row_starts.size(), row_starts_plain_indices.size());
           const unsigned int index = row_starts_plain_indices[row];
           AssertIndexRange(index, plain_dof_indices.size()+1);
-          return plain_dof_indices.empty() ? nullptr : &plain_dof_indices[0] + index;
+          return plain_dof_indices.empty() ? nullptr : &plain_dof_indices[index];
         }
     }
 
index 3157b0d2d59ff53fbd5fd65cf650fd5f24b6b3b6..94dfc65bd0bce5bda543c4709c35c83133eee1ad 100644 (file)
@@ -274,7 +274,7 @@ namespace
 
       do
         {
-          int ierr = MPI_Bcast (&interesting_range[0], 2, MPI_DOUBLE,
+          int ierr = MPI_Bcast (interesting_range, 2, MPI_DOUBLE,
                                 master_mpi_rank, mpi_communicator);
           AssertThrowMPI(ierr);
 
@@ -371,7 +371,7 @@ namespace
 
       do
         {
-          int ierr = MPI_Bcast (&interesting_range[0], 2, MPI_DOUBLE,
+          int ierr = MPI_Bcast (interesting_range, 2, MPI_DOUBLE,
                                 master_mpi_rank, mpi_communicator);
           AssertThrowMPI(ierr);
 
index 9307cf69f51001b326af525a57c9b7de5eb0b936..9aeb0dc8ed6fba631e59c720da4f88430624ddc3 100644 (file)
@@ -2160,7 +2160,7 @@ namespace GridGenerator
         cells[i].material_id = 0;
       };
     tria.create_triangulation (
-      std::vector<Point<2> >(&vertices[0], &vertices[10]),
+      std::vector<Point<2> >(std::begin(vertices), std::end(vertices)),
       cells,
       SubCellData());       // no boundary information
 
@@ -2188,7 +2188,7 @@ namespace GridGenerator
     vertices_tmp[2] = Point<2> (-half_length, radius_0);
     vertices_tmp[3] = Point<2> (half_length, radius_1);
 
-    const std::vector<Point<2> > vertices (&vertices_tmp[0], &vertices_tmp[4]);
+    const std::vector<Point<2> > vertices (std::begin(vertices_tmp), std::end(vertices_tmp));
     unsigned int cell_vertices[1][GeometryInfo<2>::vertices_per_cell];
 
     for (unsigned int i = 0; i < GeometryInfo<2>::vertices_per_cell; ++i)
@@ -2245,7 +2245,7 @@ namespace GridGenerator
       };
 
     tria.create_triangulation (
-      std::vector<Point<2> >(&vertices[0], &vertices[8]),
+      std::vector<Point<2> >(std::begin(vertices), std::end(vertices)),
       cells,
       SubCellData());
 
@@ -2310,7 +2310,7 @@ namespace GridGenerator
       };
 
     tria.create_triangulation (
-      std::vector<Point<2> >(&vertices[0], &vertices[8]),
+      std::vector<Point<2> >(std::begin(vertices), std::end(vertices)),
       cells,
       SubCellData());       // no boundary information
   }
@@ -2466,7 +2466,7 @@ namespace GridGenerator
       };
 
     tria.create_triangulation (
-      std::vector<Point<dim> >(&vertices[0], &vertices[7]),
+      std::vector<Point<dim> >(std::begin(vertices), std::end(vertices)),
       cells,
       SubCellData());       // no boundary information
 
@@ -2527,7 +2527,7 @@ namespace GridGenerator
       };
 
     tria.create_triangulation (
-      std::vector<Point<2> >(&vertices[0], &vertices[8]),
+      std::vector<Point<2> >(std::begin(vertices), std::end(vertices)),
       cells,
       SubCellData());       // no boundary information
 
@@ -2762,7 +2762,7 @@ namespace GridGenerator
         cells[i].material_id = 0;
       };
     tria.create_triangulation (
-      std::vector<Point<3> >(&vertices[0], &vertices[20]),
+      std::vector<Point<3> >(std::begin(vertices), std::end(vertices)),
       cells,
       SubCellData());       // no boundary information
 
@@ -2985,7 +2985,7 @@ namespace GridGenerator
       };
 
     tria.create_triangulation (
-      std::vector<Point<3> >(&vertices[0], &vertices[26]),
+      std::vector<Point<3> >(std::begin(vertices), std::end(vertices)),
       cells,
       SubCellData());       // no boundary information
 
@@ -3055,7 +3055,7 @@ namespace GridGenerator
       };
 
     tria.create_triangulation (
-      std::vector<Point<3> >(&vertices[0], &vertices[n_vertices]),
+      std::vector<Point<3> >(std::begin(vertices), std::end(vertices)),
       cells,
       SubCellData());       // no boundary information
   }
@@ -3144,7 +3144,7 @@ namespace GridGenerator
       };
 
     tria.create_triangulation (
-      std::vector<Point<3> >(&vertices[0], &vertices[24]),
+      std::vector<Point<3> >(std::begin(vertices), std::end(vertices)),
       cells,
       SubCellData());       // no boundary information
 
@@ -3236,7 +3236,7 @@ namespace GridGenerator
       };
 
     tria.create_triangulation (
-      std::vector<Point<dim> >(&vertices[0], &vertices[15]),
+      std::vector<Point<dim> >(std::begin(vertices), std::end(vertices)),
       cells,
       SubCellData());       // no boundary information
 
@@ -3337,7 +3337,7 @@ namespace GridGenerator
       };
 
     tria.create_triangulation (
-      std::vector<Point<3> >(&vertices[0], &vertices[16]),
+      std::vector<Point<3> >(std::begin(vertices), std::end(vertices)),
       cells,
       SubCellData());       // no boundary information
 
@@ -3676,7 +3676,7 @@ namespace GridGenerator
           };
 
         tria.create_triangulation (
-          std::vector<Point<3> >(&vertices[0], &vertices[16]),
+          std::vector<Point<3> >(std::begin(vertices), std::end(vertices)),
           cells,
           SubCellData());       // no boundary information
       }
index 77661f7998cacb337c617c261a83fda81bbb515f..f003fe1f3663cbdca8f72488958dd6d65d224525 100644 (file)
@@ -230,7 +230,7 @@ namespace
      */
     const_iterator begin () const
     {
-      return &adjacent_cells[0];
+      return adjacent_cells;
     }
 
 
@@ -245,11 +245,11 @@ namespace
       // adjacent cells, and use this to point to the element past the
       // last valid one
       if (adjacent_cells[0].cell_index == numbers::invalid_unsigned_int)
-        return &adjacent_cells[0];
+        return adjacent_cells;
       else if (adjacent_cells[1].cell_index == numbers::invalid_unsigned_int)
-        return &adjacent_cells[0]+1;
+        return adjacent_cells + 1;
       else
-        return &adjacent_cells[0]+2;
+        return adjacent_cells + 2;
     }
 
   private:
@@ -464,7 +464,7 @@ namespace
      */
     const_iterator begin () const
     {
-      return &edge_indices[0];
+      return edge_indices;
     }
 
 
@@ -477,11 +477,11 @@ namespace
       // indices, and use this to point to the element past the
       // last valid one
       if (edge_indices[0] == numbers::invalid_unsigned_int)
-        return &edge_indices[0];
+        return edge_indices;
       else if (edge_indices[1] == numbers::invalid_unsigned_int)
-        return &edge_indices[0]+1;
+        return edge_indices + 1;
       else
-        return &edge_indices[0]+2;
+        return edge_indices + 2;
     }
 
   private:
@@ -825,8 +825,8 @@ namespace
         for (origin_vertex_of_cell=0;
              origin_vertex_of_cell<GeometryInfo<dim>::vertices_per_cell;
              ++origin_vertex_of_cell)
-          if (std::count (&starting_vertex_of_edge[0],
-                          &starting_vertex_of_edge[0]+GeometryInfo<dim>::lines_per_cell,
+          if (std::count (starting_vertex_of_edge,
+                          starting_vertex_of_edge + GeometryInfo<dim>::lines_per_cell,
                           cell_list[cell_index].vertex_indices[origin_vertex_of_cell])
               == dim)
             break;
index 51390ceb092c16872708a018582eb5fd2fc73d02..f71851f3a9fe0a1427755597b5bd2fff7f4e6c5a 100644 (file)
@@ -3112,8 +3112,8 @@ next_cell:
 
         const Tensor<spacedim-structdim,spacedim>
         average_parent_alternating_form
-          = std::accumulate (&parent_alternating_forms[0],
-                             &parent_alternating_forms[GeometryInfo<structdim>::vertices_per_cell],
+          = std::accumulate (parent_alternating_forms,
+                             parent_alternating_forms + GeometryInfo<structdim>::vertices_per_cell,
                              Tensor<spacedim-structdim,spacedim>());
 
         // now do the same
index d7fdfb36871d89b1276a0b148f909fcd88f1bb0e..693c574ca4faee03f0b790e08dd180c07ec0ada1 100644 (file)
@@ -6373,7 +6373,7 @@ namespace internal
                         ->line((hex->face(5)->refinement_case() == RefinementCase<2>::cut_x) ? 1 : 3)         //3
                       };
 
-                      lines = &lines_x[0];
+                      lines = lines_x;
 
                       unsigned int line_indices_x[4];
 
index 42504b7fda2e508a71d78d463aa3708ee83a00c0..54e6afa31d9b3d7d6c6d8fe49bfd5aaad997897c 100644 (file)
@@ -593,7 +593,7 @@ namespace LinearAlgebra
           AssertCuda(error_code);
 
           // Copy the vector from the host to the temporary vector on the device
-          error_code = cudaMemcpy(&tmp[0], V.begin(), n_elements*sizeof(Number),
+          error_code = cudaMemcpy(tmp, V.begin(), n_elements*sizeof(Number),
                                   cudaMemcpyHostToDevice);
           AssertCuda(error_code);
 

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.