From 7c66e61374fe79a74cd64f7f29402ff3e1514d82 Mon Sep 17 00:00:00 2001 From: David Wells Date: Fri, 6 Oct 2017 20:43:13 -0400 Subject: [PATCH] Directly use raw pointers instead of &v[0]. --- include/deal.II/lac/read_write_vector.h | 8 +++--- .../deal.II/lac/read_write_vector.templates.h | 2 +- include/deal.II/lac/vector.h | 8 +++--- include/deal.II/matrix_free/dof_info.h | 10 +++---- source/distributed/grid_refinement.cc | 4 +-- source/grid/grid_generator.cc | 26 +++++++++---------- source/grid/grid_reordering.cc | 20 +++++++------- source/grid/grid_tools.cc | 4 +-- source/grid/tria.cc | 2 +- source/lac/cuda_vector.cu | 2 +- 10 files changed, 43 insertions(+), 43 deletions(-) diff --git a/include/deal.II/lac/read_write_vector.h b/include/deal.II/lac/read_write_vector.h index 91c165a4e5..3e3049dc9e 100644 --- a/include/deal.II/lac/read_write_vector.h +++ b/include/deal.II/lac/read_write_vector.h @@ -756,7 +756,7 @@ namespace LinearAlgebra typename ReadWriteVector::iterator ReadWriteVector::begin () { - return &val[0]; + return val; } @@ -766,7 +766,7 @@ namespace LinearAlgebra typename ReadWriteVector::const_iterator ReadWriteVector::begin () const { - return &val[0]; + return val; } @@ -776,7 +776,7 @@ namespace LinearAlgebra typename ReadWriteVector::iterator ReadWriteVector::end () { - return &val[this->n_elements()]; + return val + this->n_elements(); } @@ -786,7 +786,7 @@ namespace LinearAlgebra typename ReadWriteVector::const_iterator ReadWriteVector::end () const { - return &val[this->n_elements()]; + return val + this->n_elements(); } diff --git a/include/deal.II/lac/read_write_vector.templates.h b/include/deal.II/lac/read_write_vector.templates.h index 8fd8c25999..7ee68d7021 100644 --- a/include/deal.II/lac/read_write_vector.templates.h +++ b/include/deal.II/lac/read_write_vector.templates.h @@ -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); diff --git a/include/deal.II/lac/vector.h b/include/deal.II/lac/vector.h index 9c6bc07716..89ad440328 100644 --- a/include/deal.II/lac/vector.h +++ b/include/deal.II/lac/vector.h @@ -1052,7 +1052,7 @@ inline typename Vector::iterator Vector::begin () { - return &val[0]; + return val; } @@ -1062,7 +1062,7 @@ inline typename Vector::const_iterator Vector::begin () const { - return &val[0]; + return val; } @@ -1072,7 +1072,7 @@ inline typename Vector::iterator Vector::end () { - return &val[vec_size]; + return val + vec_size; } @@ -1082,7 +1082,7 @@ inline typename Vector::const_iterator Vector::end () const { - return &val[vec_size]; + return val + vec_size; } diff --git a/include/deal.II/matrix_free/dof_info.h b/include/deal.II/matrix_free/dof_info.h index ed6c65c4d3..ecdd2e3b8e 100644 --- a/include/deal.II/matrix_free/dof_info.h +++ b/include/deal.II/matrix_free/dof_info.h @@ -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]; } } diff --git a/source/distributed/grid_refinement.cc b/source/distributed/grid_refinement.cc index 3157b0d2d5..94dfc65bd0 100644 --- a/source/distributed/grid_refinement.cc +++ b/source/distributed/grid_refinement.cc @@ -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); diff --git a/source/grid/grid_generator.cc b/source/grid/grid_generator.cc index 9307cf69f5..9aeb0dc8ed 100644 --- a/source/grid/grid_generator.cc +++ b/source/grid/grid_generator.cc @@ -2160,7 +2160,7 @@ namespace GridGenerator cells[i].material_id = 0; }; tria.create_triangulation ( - std::vector >(&vertices[0], &vertices[10]), + std::vector >(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 > vertices (&vertices_tmp[0], &vertices_tmp[4]); + const std::vector > 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 >(&vertices[0], &vertices[8]), + std::vector >(std::begin(vertices), std::end(vertices)), cells, SubCellData()); @@ -2310,7 +2310,7 @@ namespace GridGenerator }; tria.create_triangulation ( - std::vector >(&vertices[0], &vertices[8]), + std::vector >(std::begin(vertices), std::end(vertices)), cells, SubCellData()); // no boundary information } @@ -2466,7 +2466,7 @@ namespace GridGenerator }; tria.create_triangulation ( - std::vector >(&vertices[0], &vertices[7]), + std::vector >(std::begin(vertices), std::end(vertices)), cells, SubCellData()); // no boundary information @@ -2527,7 +2527,7 @@ namespace GridGenerator }; tria.create_triangulation ( - std::vector >(&vertices[0], &vertices[8]), + std::vector >(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 >(&vertices[0], &vertices[20]), + std::vector >(std::begin(vertices), std::end(vertices)), cells, SubCellData()); // no boundary information @@ -2985,7 +2985,7 @@ namespace GridGenerator }; tria.create_triangulation ( - std::vector >(&vertices[0], &vertices[26]), + std::vector >(std::begin(vertices), std::end(vertices)), cells, SubCellData()); // no boundary information @@ -3055,7 +3055,7 @@ namespace GridGenerator }; tria.create_triangulation ( - std::vector >(&vertices[0], &vertices[n_vertices]), + std::vector >(std::begin(vertices), std::end(vertices)), cells, SubCellData()); // no boundary information } @@ -3144,7 +3144,7 @@ namespace GridGenerator }; tria.create_triangulation ( - std::vector >(&vertices[0], &vertices[24]), + std::vector >(std::begin(vertices), std::end(vertices)), cells, SubCellData()); // no boundary information @@ -3236,7 +3236,7 @@ namespace GridGenerator }; tria.create_triangulation ( - std::vector >(&vertices[0], &vertices[15]), + std::vector >(std::begin(vertices), std::end(vertices)), cells, SubCellData()); // no boundary information @@ -3337,7 +3337,7 @@ namespace GridGenerator }; tria.create_triangulation ( - std::vector >(&vertices[0], &vertices[16]), + std::vector >(std::begin(vertices), std::end(vertices)), cells, SubCellData()); // no boundary information @@ -3676,7 +3676,7 @@ namespace GridGenerator }; tria.create_triangulation ( - std::vector >(&vertices[0], &vertices[16]), + std::vector >(std::begin(vertices), std::end(vertices)), cells, SubCellData()); // no boundary information } diff --git a/source/grid/grid_reordering.cc b/source/grid/grid_reordering.cc index 77661f7998..f003fe1f36 100644 --- a/source/grid/grid_reordering.cc +++ b/source/grid/grid_reordering.cc @@ -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::vertices_per_cell; ++origin_vertex_of_cell) - if (std::count (&starting_vertex_of_edge[0], - &starting_vertex_of_edge[0]+GeometryInfo::lines_per_cell, + if (std::count (starting_vertex_of_edge, + starting_vertex_of_edge + GeometryInfo::lines_per_cell, cell_list[cell_index].vertex_indices[origin_vertex_of_cell]) == dim) break; diff --git a/source/grid/grid_tools.cc b/source/grid/grid_tools.cc index 51390ceb09..f71851f3a9 100644 --- a/source/grid/grid_tools.cc +++ b/source/grid/grid_tools.cc @@ -3112,8 +3112,8 @@ next_cell: const Tensor average_parent_alternating_form - = std::accumulate (&parent_alternating_forms[0], - &parent_alternating_forms[GeometryInfo::vertices_per_cell], + = std::accumulate (parent_alternating_forms, + parent_alternating_forms + GeometryInfo::vertices_per_cell, Tensor()); // now do the same diff --git a/source/grid/tria.cc b/source/grid/tria.cc index d7fdfb3687..693c574ca4 100644 --- a/source/grid/tria.cc +++ b/source/grid/tria.cc @@ -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]; diff --git a/source/lac/cuda_vector.cu b/source/lac/cuda_vector.cu index 42504b7fda..54e6afa31d 100644 --- a/source/lac/cuda_vector.cu +++ b/source/lac/cuda_vector.cu @@ -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); -- 2.39.5