From: David Wells Date: Sat, 7 Oct 2017 00:42:55 +0000 (-0400) Subject: Prefer v.data() to &v[0]. X-Git-Tag: v9.0.0-rc1~954^2~5 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=4349a652a0b5c6d1c28f9100a5d371423d0b2fcb;p=dealii.git Prefer v.data() to &v[0]. --- diff --git a/include/deal.II/base/array_view.h b/include/deal.II/base/array_view.h index 7086d56d33..dbeb9569b6 100644 --- a/include/deal.II/base/array_view.h +++ b/include/deal.II/base/array_view.h @@ -431,7 +431,7 @@ inline ArrayView make_array_view (std::vector &vector) { - return ArrayView (&vector[0], vector.size()); + return ArrayView (vector.data(), vector.size()); } @@ -455,7 +455,7 @@ inline ArrayView make_array_view (const std::vector &vector) { - return ArrayView (&vector[0], vector.size()); + return ArrayView (vector.data(), vector.size()); } diff --git a/include/deal.II/distributed/grid_tools.h b/include/deal.II/distributed/grid_tools.h index 769dae436a..5e3a0203e3 100644 --- a/include/deal.II/distributed/grid_tools.h +++ b/include/deal.II/distributed/grid_tools.h @@ -243,7 +243,7 @@ namespace parallel decompressing_stream.push(boost::iostreams::gzip_decompressor()); decompressing_stream.push(boost::iostreams::back_inserter(decompressed_buffer)); - decompressing_stream.write (&buffer[0], buffer.size()); + decompressing_stream.write (buffer.data(), buffer.size()); } // then restore the object from the buffer @@ -372,7 +372,7 @@ namespace parallel receive.resize(len); - char *ptr = &receive[0]; + char *ptr = receive.data(); ierr = MPI_Recv(ptr, len, MPI_BYTE, status.MPI_SOURCE, status.MPI_TAG, tria->get_communicator(), &status); AssertThrowMPI(ierr); @@ -397,7 +397,7 @@ namespace parallel // when we leave this function. if (requests.size()) { - const int ierr = MPI_Waitall(requests.size(), &requests[0], MPI_STATUSES_IGNORE); + const int ierr = MPI_Waitall(requests.size(), requests.data(), MPI_STATUSES_IGNORE); AssertThrowMPI(ierr); } #endif // DEAL_II_WITH_MPI diff --git a/include/deal.II/fe/fe_tools_extrapolate.templates.h b/include/deal.II/fe/fe_tools_extrapolate.templates.h index d788c7421d..5ccfb75738 100644 --- a/include/deal.II/fe/fe_tools_extrapolate.templates.h +++ b/include/deal.II/fe/fe_tools_extrapolate.templates.h @@ -144,7 +144,7 @@ namespace FETools { buffer.resize(bytes_for_buffer()); - char *ptr = &buffer[0]; + char *ptr = buffer.data(); unsigned int n_dofs = dof_values.size (); std::memcpy(ptr, &n_dofs, sizeof(unsigned int)); @@ -159,13 +159,13 @@ namespace FETools std::memcpy(ptr,&quadrant,sizeof(typename dealii::internal::p4est::types::quadrant)); ptr += sizeof(typename dealii::internal::p4est::types::quadrant); - Assert (ptr == &buffer[0]+buffer.size(), + Assert (ptr == buffer.data()+buffer.size(), ExcInternalError()); } void unpack_data (const std::vector &buffer) { - const char *ptr = &buffer[0]; + const char *ptr = buffer.data(); unsigned int n_dofs; memcpy(&n_dofs, ptr, sizeof(unsigned int)); ptr += sizeof(unsigned int); @@ -180,7 +180,7 @@ namespace FETools std::memcpy(&quadrant,ptr,sizeof(typename dealii::internal::p4est::types::quadrant)); ptr += sizeof(typename dealii::internal::p4est::types::quadrant); - Assert (ptr == &buffer[0]+buffer.size(), + Assert (ptr == buffer.data()+buffer.size(), ExcInternalError()); } }; @@ -1100,7 +1100,7 @@ namespace FETools AssertThrowMPI(ierr); receive.resize (len); - char *buf = &receive[0]; + char *buf = receive.data(); ierr = MPI_Recv (buf, len, MPI_BYTE, status.MPI_SOURCE, status.MPI_TAG, communicator, &status); AssertThrowMPI(ierr); @@ -1116,7 +1116,7 @@ namespace FETools if (requests.size () > 0) { - const int ierr = MPI_Waitall(requests.size(), &requests[0], MPI_STATUSES_IGNORE); + const int ierr = MPI_Waitall(requests.size(), requests.data(), MPI_STATUSES_IGNORE); AssertThrowMPI(ierr); } diff --git a/include/deal.II/lac/arpack_solver.h b/include/deal.II/lac/arpack_solver.h index 6bf57a3583..a1409565b4 100644 --- a/include/deal.II/lac/arpack_solver.h +++ b/include/deal.II/lac/arpack_solver.h @@ -550,12 +550,12 @@ void ArpackSolver::solve (const MatrixType1 &/*system_matrix*/, // call of ARPACK dsaupd/dnaupd routine if (additional_data.symmetric) dsaupd_(&ido, bmat, &n, which, &nev, &tol, - &resid[0], &ncv, &v[0], &ldv, &iparam[0], &ipntr[0], - &workd[0], &workl[0], &lworkl, &info); + resid.data(), &ncv, v.data(), &ldv, iparam.data(), ipntr.data(), + workd.data(), workl.data(), &lworkl, &info); else dnaupd_(&ido, bmat, &n, which, &nev, &tol, - &resid[0], &ncv, &v[0], &ldv, &iparam[0], &ipntr[0], - &workd[0], &workl[0], &lworkl, &info); + resid.data(), &ncv, v.data(), &ldv, iparam.data(), ipntr.data(), + workd.data(), workl.data(), &lworkl, &info); if (ido == 99) break; @@ -671,19 +671,19 @@ void ArpackSolver::solve (const MatrixType1 &/*system_matrix*/, if (additional_data.symmetric) { std::vector z (ldz*nev, 0.); - dseupd_(&rvec, &howmany, &select[0], &eigenvalues_real[0], - &z[0], &ldz, &sigmar, bmat, &n, which, &nev, &tol, - &resid[0], &ncv, &v[0], &ldv, - &iparam[0], &ipntr[0], &workd[0], &workl[0], &lworkl, &info); + dseupd_(&rvec, &howmany, select.data(), eigenvalues_real.data(), + z.data(), &ldz, &sigmar, bmat, &n, which, &nev, &tol, + resid.data(), &ncv, v.data(), &ldv, + iparam.data(), ipntr.data(), workd.data(), workl.data(), &lworkl, &info); } else { std::vector workev (3*ncv, 0.); - dneupd_(&rvec, &howmany, &select[0], &eigenvalues_real[0], - &eigenvalues_im[0], &v[0], &ldz, &sigmar, &sigmai, - &workev[0], bmat, &n, which, &nev, &tol, - &resid[0], &ncv, &v[0], &ldv, - &iparam[0], &ipntr[0], &workd[0], &workl[0], &lworkl, &info); + dneupd_(&rvec, &howmany, select.data(), eigenvalues_real.data(), + eigenvalues_im.data(), v.data(), &ldz, &sigmar, &sigmai, + workev.data(), bmat, &n, which, &nev, &tol, + resid.data(), &ncv, v.data(), &ldv, + iparam.data(), ipntr.data(), workd.data(), workl.data(), &lworkl, &info); } if (info == 1) diff --git a/include/deal.II/lac/block_matrix_base.h b/include/deal.II/lac/block_matrix_base.h index fe42bb20a4..80fb3ffc0f 100644 --- a/include/deal.II/lac/block_matrix_base.h +++ b/include/deal.II/lac/block_matrix_base.h @@ -1668,7 +1668,7 @@ BlockMatrixBase::set (const std::vector &row_indices, ExcDimensionMismatch(col_indices.size(), values.n())); for (size_type i=0; i::set (const std::vector &indices, Assert (values.n() == values.m(), ExcNotQuadratic()); for (size_type i=0; i::set (const size_type row, Assert (col_indices.size() == values.size(), ExcDimensionMismatch(col_indices.size(), values.size())); - set (row, col_indices.size(), &col_indices[0], &values[0], + set (row, col_indices.size(), col_indices.data(), values.data(), elide_zero_values); } @@ -1865,7 +1865,7 @@ BlockMatrixBase::add (const std::vector &row_indices, ExcDimensionMismatch(col_indices.size(), values.n())); for (size_type i=0; i::add (const std::vector &indices, Assert (values.n() == values.m(), ExcNotQuadratic()); for (size_type i=0; i::add (const size_type row, Assert (col_indices.size() == values.size(), ExcDimensionMismatch(col_indices.size(), values.size())); - add (row, col_indices.size(), &col_indices[0], &values[0], + add (row, col_indices.size(), col_indices.data(), values.data(), elide_zero_values); } diff --git a/include/deal.II/lac/block_vector_base.h b/include/deal.II/lac/block_vector_base.h index 744996373c..331fbfb2f2 100644 --- a/include/deal.II/lac/block_vector_base.h +++ b/include/deal.II/lac/block_vector_base.h @@ -1797,7 +1797,7 @@ BlockVectorBase::add (const std::vector &indices, { Assert (indices.size() == values.size(), ExcDimensionMismatch(indices.size(), values.size())); - add (indices.size(), &indices[0], &values[0]); + add (indices.size(), indices.data(), values.data()); } diff --git a/include/deal.II/lac/chunk_sparse_matrix.templates.h b/include/deal.II/lac/chunk_sparse_matrix.templates.h index 30269cae4f..18c83e1754 100644 --- a/include/deal.II/lac/chunk_sparse_matrix.templates.h +++ b/include/deal.II/lac/chunk_sparse_matrix.templates.h @@ -271,9 +271,9 @@ namespace internal val_ptr += chunk_size * chunk_size; } } - Assert(std::size_t(colnum_ptr-&colnums[0]) == rowstart[end_row], + Assert(std::size_t(colnum_ptr-colnums) == rowstart[end_row], ExcInternalError()); - Assert(std::size_t(val_ptr-&values[0]) == + Assert(std::size_t(val_ptr - values) == rowstart[end_row] * chunk_size * chunk_size, ExcInternalError()); } @@ -411,7 +411,7 @@ ChunkSparseMatrix::operator = (const double d) val.get()), grain_size); else if (matrix_size > 0) - std::memset (&val[0], 0, matrix_size*sizeof(number)); + std::memset (val.get(), 0, matrix_size*sizeof(number)); return *this; } @@ -512,9 +512,9 @@ ChunkSparseMatrix::n_actually_nonzero_elements () const // around the matrix. since we have the invariant that padding elements are // zero, nothing bad can happen here const size_type chunk_size = cols->get_chunk_size(); - return std::count_if(&val[0], - &val[cols->sparsity_pattern.n_nonzero_elements () * - chunk_size * chunk_size], + return std::count_if(val.get(), + val.get() + cols->sparsity_pattern.n_nonzero_elements () + * chunk_size * chunk_size, std::bind(std::not_equal_to(), std::placeholders::_1, 0)); } @@ -543,10 +543,10 @@ ChunkSparseMatrix::copy_from (const ChunkSparseMatrix &matri // copy everything, including padding elements const size_type chunk_size = cols->get_chunk_size(); - std::copy (&matrix.val[0], - &matrix.val[cols->sparsity_pattern.n_nonzero_elements() - * chunk_size * chunk_size], - &val[0]); + std::copy (matrix.val.get(), + matrix.val.get() + cols->sparsity_pattern.n_nonzero_elements() + * chunk_size * chunk_size, + val.get()); return *this; } @@ -582,10 +582,10 @@ ChunkSparseMatrix::add (const number factor, // add everything, including padding elements const size_type chunk_size = cols->get_chunk_size(); - number *val_ptr = &val[0]; + number *val_ptr = val.get(); const somenumber *matrix_ptr = &matrix.val[0]; - const number *const end_ptr = &val[cols->sparsity_pattern.n_nonzero_elements() - * chunk_size * chunk_size]; + const number *const end_ptr = val.get() + cols->sparsity_pattern.n_nonzero_elements() + * chunk_size * chunk_size; while (val_ptr != end_ptr) *val_ptr++ += factor **matrix_ptr++; @@ -1110,7 +1110,7 @@ ChunkSparseMatrix::frobenius_norm () const // // padding elements are zero, so we can add them up as well real_type norm_sqr = 0; - for (const number *ptr = &val[0]; ptr != &val[max_len]; ++ptr) + for (const number *ptr = val.get(); ptr != val.get() + max_len; ++ptr) norm_sqr += numbers::NumberTraits::abs_square(*ptr); return std::sqrt (norm_sqr); diff --git a/include/deal.II/lac/full_matrix.templates.h b/include/deal.II/lac/full_matrix.templates.h index a12020cf4b..38ec19d056 100644 --- a/include/deal.II/lac/full_matrix.templates.h +++ b/include/deal.II/lac/full_matrix.templates.h @@ -1794,7 +1794,7 @@ FullMatrix::gauss_jordan () // Use the LAPACK function getrf for // calculating the LU factorization. - getrf(&nn, &nn, &this->values[0], &nn, &ipiv[0], &info); + getrf(&nn, &nn, &this->values[0], &nn, ipiv.data(), &info); Assert(info >= 0, ExcInternalError()); Assert(info == 0, LACExceptions::ExcSingular()); @@ -1805,7 +1805,7 @@ FullMatrix::gauss_jordan () // Use the LAPACK function getri for // calculating the actual inverse using // the LU factorization. - getri(&nn, &this->values[0], &nn, &ipiv[0], &inv_work[0], &nn, &info); + getri(&nn, &this->values[0], &nn, ipiv.data(), inv_work.data(), &nn, &info); Assert(info >= 0, ExcInternalError()); Assert(info == 0, LACExceptions::ExcSingular()); diff --git a/include/deal.II/lac/la_parallel_vector.templates.h b/include/deal.II/lac/la_parallel_vector.templates.h index c98916c8d8..3128f13299 100644 --- a/include/deal.II/lac/la_parallel_vector.templates.h +++ b/include/deal.II/lac/la_parallel_vector.templates.h @@ -656,7 +656,7 @@ namespace LinearAlgebra // first wait for the receive to complete if (compress_requests.size() > 0 && n_import_targets > 0) { - const int ierr = MPI_Waitall (n_import_targets, &compress_requests[0], + const int ierr = MPI_Waitall (n_import_targets, compress_requests.data(), MPI_STATUSES_IGNORE); AssertThrowMPI(ierr); @@ -814,7 +814,7 @@ namespace LinearAlgebra Threads::Mutex::ScopedLock lock (mutex); const int ierr = MPI_Waitall (update_ghost_values_requests.size(), - &update_ghost_values_requests[0], + update_ghost_values_requests.data(), MPI_STATUSES_IGNORE); AssertThrowMPI (ierr); } @@ -893,7 +893,7 @@ namespace LinearAlgebra if (update_ghost_values_requests.size()>0) { const int ierr = MPI_Testall (update_ghost_values_requests.size(), - &update_ghost_values_requests[0], + update_ghost_values_requests.data(), &flag, MPI_STATUSES_IGNORE); AssertThrowMPI (ierr); Assert (flag == 1, @@ -902,7 +902,7 @@ namespace LinearAlgebra } if (compress_requests.size()>0) { - const int ierr = MPI_Testall (compress_requests.size(), &compress_requests[0], + const int ierr = MPI_Testall (compress_requests.size(), compress_requests.data(), &flag, MPI_STATUSES_IGNORE); AssertThrowMPI (ierr); Assert (flag == 1, diff --git a/include/deal.II/lac/matrix_block.h b/include/deal.II/lac/matrix_block.h index 96da584c15..5a39168851 100644 --- a/include/deal.II/lac/matrix_block.h +++ b/include/deal.II/lac/matrix_block.h @@ -682,7 +682,7 @@ MatrixBlock::add (const std::vector &r_indices, AssertDimension (c_indices.size(), values.n()); for (size_type i=0; i::add (const std::vector &indices, Assert (values.n() == values.m(), ExcNotQuadratic()); for (size_type i=0; i::add (const size_type row, Assert(column_indices.size() != 0, ExcNotInitialized()); AssertDimension (col_indices.size(), values.size()); - add (row, col_indices.size(), &col_indices[0], &values[0], + add (row, col_indices.size(), col_indices.data(), values.data(), elide_zero_values); } diff --git a/include/deal.II/lac/parpack_solver.h b/include/deal.II/lac/parpack_solver.h index 2cb2bbc652..019baf364e 100644 --- a/include/deal.II/lac/parpack_solver.h +++ b/include/deal.II/lac/parpack_solver.h @@ -636,7 +636,7 @@ set_initial_vector(const VectorType &vec) ExcDimensionMismatch(resid.size(),local_indices.size())); vec.extract_subvector_to (local_indices.begin(), local_indices.end(), - &resid[0]); + resid.data()); } @@ -876,12 +876,12 @@ void PArpackSolver::solve // call of ARPACK pdnaupd routine if (additional_data.symmetric) pdsaupd_(&mpi_communicator_fortran,&ido, bmat, &n_inside_arpack, which, &nev, &tol, - &resid[0], &ncv, &v[0], &ldv, &iparam[0], &ipntr[0], - &workd[0], &workl[0], &lworkl, &info); + resid.data(), &ncv, v.data(), &ldv, iparam.data(), ipntr.data(), + workd.data(), workl.data(), &lworkl, &info); else pdnaupd_(&mpi_communicator_fortran,&ido, bmat, &n_inside_arpack, which, &nev, &tol, - &resid[0], &ncv, &v[0], &ldv, &iparam[0], &ipntr[0], - &workd[0], &workl[0], &lworkl, &info); + resid.data(), &ncv, v.data(), &ldv, iparam.data(), ipntr.data(), + workd.data(), workl.data(), &lworkl, &info); AssertThrow (info == 0, PArpackExcInfoPdnaupd(info)); @@ -906,8 +906,8 @@ void PArpackSolver::solve // compute Y = OP * X { src.add (nloc, - &local_indices[0], - &workd[0]+shift_x ); + local_indices.data(), + workd.data()+shift_x ); src.compress (VectorOperation::add); if (mode == 3) @@ -923,7 +923,7 @@ void PArpackSolver::solve // store M*X in X tmp.extract_subvector_to (local_indices.begin(), local_indices.end(), - &workd[0]+shift_x); + workd.data()+shift_x); inverse.vmult(dst,tmp); } else if (mode == 1) @@ -944,8 +944,8 @@ void PArpackSolver::solve // B*X src.add (nloc, - &local_indices[0], - &workd[0]+shift_b_x ); + local_indices.data(), + workd.data()+shift_b_x ); src.compress (VectorOperation::add); // solving linear system @@ -956,8 +956,8 @@ void PArpackSolver::solve // compute Y = B * X { src.add (nloc, - &local_indices[0], - &workd[0]+shift_x ); + local_indices.data(), + workd.data()+shift_x ); src.compress (VectorOperation::add); // Multiplication with mass matrix M @@ -979,7 +979,7 @@ void PArpackSolver::solve // store the result dst.extract_subvector_to (local_indices.begin(), local_indices.end(), - &workd[0]+shift_y); + workd.data()+shift_y); } // end of pd*aupd_ loop // 1 - compute eigenvectors, @@ -994,17 +994,17 @@ void PArpackSolver::solve // call of ARPACK pdneupd routine if (additional_data.symmetric) - pdseupd_(&mpi_communicator_fortran, &rvec, howmany, &select[0], &eigenvalues_real[0], - &z[0], &ldz, &sigmar, + pdseupd_(&mpi_communicator_fortran, &rvec, howmany, select.data(), eigenvalues_real.data(), + z.data(), &ldz, &sigmar, bmat, &n_inside_arpack, which, &nev, &tol, - &resid[0], &ncv, &v[0], &ldv, - &iparam[0], &ipntr[0], &workd[0], &workl[0], &lworkl, &info); + resid.data(), &ncv, v.data(), &ldv, + iparam.data(), ipntr.data(), workd.data(), workl.data(), &lworkl, &info); else - pdneupd_(&mpi_communicator_fortran, &rvec, howmany, &select[0], &eigenvalues_real[0], - &eigenvalues_im[0], &v[0], &ldz, &sigmar, &sigmai, - &workev[0], bmat, &n_inside_arpack, which, &nev, &tol, - &resid[0], &ncv, &v[0], &ldv, - &iparam[0], &ipntr[0], &workd[0], &workl[0], &lworkl, &info); + pdneupd_(&mpi_communicator_fortran, &rvec, howmany, select.data(), eigenvalues_real.data(), + eigenvalues_im.data(), v.data(), &ldz, &sigmar, &sigmai, + workev.data(), bmat, &n_inside_arpack, which, &nev, &tol, + resid.data(), &ncv, v.data(), &ldv, + iparam.data(), ipntr.data(), workd.data(), workl.data(), &lworkl, &info); if (info == 1) { @@ -1025,7 +1025,7 @@ void PArpackSolver::solve Assert (i*nloc + nloc <= (int)v.size(), dealii::ExcInternalError() ); eigenvectors[i]->add (nloc, - &local_indices[0], + local_indices.data(), &v[i*nloc] ); eigenvectors[i]->compress (VectorOperation::add); } @@ -1046,8 +1046,8 @@ void PArpackSolver::solve tmp = 0.0; tmp.add (nloc, - &local_indices[0], - &resid[0]); + local_indices.data(), + resid.data()); solver_control.check ( iparam[2], tmp.l2_norm() ); } diff --git a/include/deal.II/lac/petsc_matrix_base.h b/include/deal.II/lac/petsc_matrix_base.h index 1a515ac24d..c4a8c9e202 100644 --- a/include/deal.II/lac/petsc_matrix_base.h +++ b/include/deal.II/lac/petsc_matrix_base.h @@ -1156,7 +1156,7 @@ namespace PETScWrappers Assert (values.m() == values.n(), ExcNotQuadratic()); for (size_type i=0; i &values) { AssertDimension (indices.size(), values.size()); - add (indices.size(), &indices[0], &values[0]); + add (indices.size(), indices.data(), values.data()); } diff --git a/include/deal.II/lac/read_write_vector.templates.h b/include/deal.II/lac/read_write_vector.templates.h index 80037c4139..8fd8c25999 100644 --- a/include/deal.II/lac/read_write_vector.templates.h +++ b/include/deal.II/lac/read_write_vector.templates.h @@ -447,7 +447,7 @@ namespace LinearAlgebra { // Copy the vector from the device to a temporary vector on the host std::vector tmp(n_elements); - cudaError_t error_code = cudaMemcpy(&tmp[0], cuda_vec.get_values(), + cudaError_t error_code = cudaMemcpy(tmp.data(), cuda_vec.get_values(), n_elements*sizeof(Number), cudaMemcpyDeviceToHost); AssertCuda(error_code); diff --git a/include/deal.II/lac/slepc_solver.h b/include/deal.II/lac/slepc_solver.h index e69b6f6eb1..04707d046d 100644 --- a/include/deal.II/lac/slepc_solver.h +++ b/include/deal.II/lac/slepc_solver.h @@ -803,7 +803,7 @@ namespace SLEPcWrappers // One could still build a vector that is rich in the directions of all guesses, // by taking a linear combination of them. (TODO: make function virtual?) - const PetscErrorCode ierr = EPSSetInitialSpace (eps, vecs.size(), &vecs[0]); + const PetscErrorCode ierr = EPSSetInitialSpace (eps, vecs.size(), vecs.data()); AssertThrow (ierr == 0, ExcSLEPcError(ierr)); } diff --git a/include/deal.II/lac/sparse_matrix.h b/include/deal.II/lac/sparse_matrix.h index 313a1444e2..0e764fa4e1 100644 --- a/include/deal.II/lac/sparse_matrix.h +++ b/include/deal.II/lac/sparse_matrix.h @@ -1692,7 +1692,7 @@ SparseMatrix::set (const std::vector &indices, Assert (values.m() == values.n(), ExcNotQuadratic()); for (size_type i=0; i::set (const std::vector &row_indices, ExcDimensionMismatch(col_indices.size(), values.n())); for (size_type i=0; i::set (const size_type row, Assert (col_indices.size() == values.size(), ExcDimensionMismatch(col_indices.size(), values.size())); - set (row, col_indices.size(), &col_indices[0], &values[0], + set (row, col_indices.size(), col_indices.data(), values.data(), elide_zero_values); } @@ -1779,7 +1779,7 @@ SparseMatrix::add (const std::vector &indices, Assert (values.m() == values.n(), ExcNotQuadratic()); for (size_type i=0; i::add (const std::vector &row_indices, ExcDimensionMismatch(col_indices.size(), values.n())); for (size_type i=0; i::add (const size_type row, Assert (col_indices.size() == values.size(), ExcDimensionMismatch(col_indices.size(), values.size())); - add (row, col_indices.size(), &col_indices[0], &values[0], + add (row, col_indices.size(), col_indices.data(), values.data(), elide_zero_values); } @@ -1832,8 +1832,8 @@ SparseMatrix::operator *= (const number factor) Assert (cols != nullptr, ExcNotInitialized()); Assert (val != nullptr, ExcNotInitialized()); - number *val_ptr = &val[0]; - const number *const end_ptr = &val[cols->n_nonzero_elements()]; + number *val_ptr = val.get(); + const number *const end_ptr = val.get() + cols->n_nonzero_elements(); while (val_ptr != end_ptr) *val_ptr++ *= factor; @@ -1854,8 +1854,8 @@ SparseMatrix::operator /= (const number factor) const number factor_inv = number(1.) / factor; - number *val_ptr = &val[0]; - const number *const end_ptr = &val[cols->n_nonzero_elements()]; + number *val_ptr = val.get(); + const number *const end_ptr = val.get() + cols->n_nonzero_elements(); while (val_ptr != end_ptr) *val_ptr++ *= factor_inv; diff --git a/include/deal.II/lac/sparse_matrix.templates.h b/include/deal.II/lac/sparse_matrix.templates.h index 917d69584c..f3969d8d7d 100644 --- a/include/deal.II/lac/sparse_matrix.templates.h +++ b/include/deal.II/lac/sparse_matrix.templates.h @@ -205,7 +205,7 @@ SparseMatrix::operator = (const double d) val.get()), grain_size); else if (matrix_size > 0) - std::memset (&val[0], 0, matrix_size*sizeof(number)); + std::memset (val.get(), 0, matrix_size*sizeof(number)); return *this; } @@ -363,8 +363,8 @@ SparseMatrix::copy_from (const SparseMatrix &matrix) Assert (val != nullptr, ExcNotInitialized()); Assert (cols == matrix.cols, ExcDifferentSparsityPatterns()); - std::copy (&matrix.val[0], &matrix.val[cols->n_nonzero_elements()], - &val[0]); + std::copy (matrix.val.get(), matrix.val.get() + cols->n_nonzero_elements(), + val.get()); return *this; } @@ -445,9 +445,9 @@ SparseMatrix::add (const number factor, Assert (val != nullptr, ExcNotInitialized()); Assert (cols == matrix.cols, ExcDifferentSparsityPatterns()); - number *val_ptr = &val[0]; - const somenumber *matrix_ptr = &matrix.val[0]; - const number *const end_ptr = &val[cols->n_nonzero_elements()]; + number *val_ptr = val.get(); + const somenumber *matrix_ptr = matrix.val.get(); + const number *const end_ptr = val.get() + cols->n_nonzero_elements(); while (val_ptr != end_ptr) *val_ptr++ += factor * number(*matrix_ptr++); @@ -1084,14 +1084,14 @@ SparseMatrix::mmult (SparseMatrix &C, // now the innermost loop that goes over all the elements in row // 'col' of matrix B. Cache the elements, and then write them into C // at once - numberC *new_ptr = &new_entries[0]; + numberC *new_ptr = new_entries.data(); const numberB *B_val_ptr = &B.val[new_cols-&sp_B.colnums[sp_B.rowstart[0]]]; const numberB *const end_cols = &B.val[sp_B.rowstart[col+1]]; for (; B_val_ptr != end_cols; ++B_val_ptr) *new_ptr++ = numberC(A_val) * numberC(*B_val_ptr) * numberC(use_vector ? V(col) : 1); - C.add (i, new_ptr-&new_entries[0], new_cols, &new_entries[0], + C.add (i, new_ptr-new_entries.data(), new_cols, new_entries.data(), false, true); } } @@ -1215,13 +1215,13 @@ SparseMatrix::Tmmult (SparseMatrix &C, // now the innermost loop that goes over all the elements in row // 'col' of matrix B. Cache the elements, and then write them into C // at once - numberC *new_ptr = &new_entries[0]; + numberC *new_ptr = new_entries.data(); const numberB *B_val_ptr = &B.val[new_cols-&sp_B.colnums[sp_B.rowstart[0]]]; for (; B_val_ptr != end_cols; ++B_val_ptr) *new_ptr++ = numberC(A_val) * numberC(*B_val_ptr) * numberC(use_vector ? V(i) : 1); - C.add (row, new_ptr-&new_entries[0], new_cols, &new_entries[0], + C.add (row, new_ptr-new_entries.data(), new_cols, new_entries.data(), false, true); } } @@ -1281,8 +1281,8 @@ SparseMatrix::frobenius_norm () const // reference to rows or columns real_type norm_sqr = 0; const size_type n_rows = m(); - for (const number *ptr = &val[0]; - ptr != &val[cols->rowstart[n_rows]]; ++ptr) + for (const number *ptr = val.get(); + ptr != val.get() + cols->rowstart[n_rows]; ++ptr) norm_sqr += numbers::NumberTraits::abs_square(*ptr); return std::sqrt (norm_sqr); @@ -1974,9 +1974,9 @@ SparseMatrix::block_write (std::ostream &out) const // bracketed in [...] out << '[' << max_len << "]["; // then write out real data - out.write (reinterpret_cast(&val[0]), - reinterpret_cast(&val[max_len]) - - reinterpret_cast(&val[0])); + out.write (reinterpret_cast(val.get()), + reinterpret_cast(val.get() + max_len) + - reinterpret_cast(val.get())); out << ']'; AssertThrow (out, ExcIO()); @@ -2006,9 +2006,9 @@ SparseMatrix::block_read (std::istream &in) val.reset (new number[max_len]); // then read data - in.read (reinterpret_cast(&val[0]), - reinterpret_cast(&val[max_len]) - - reinterpret_cast(&val[0])); + in.read (reinterpret_cast(val.get()), + reinterpret_cast(val.get() + max_len) + - reinterpret_cast(val.get())); in >> c; AssertThrow (c == ']', ExcIO()); } diff --git a/include/deal.II/lac/sparse_matrix_ez.templates.h b/include/deal.II/lac/sparse_matrix_ez.templates.h index 6a6f3623bb..92ea656afc 100644 --- a/include/deal.II/lac/sparse_matrix_ez.templates.h +++ b/include/deal.II/lac/sparse_matrix_ez.templates.h @@ -599,13 +599,13 @@ SparseMatrixEZ::block_read (std::istream &in) DEAL_II_CHECK_INPUT(in,'[',c); // then read data - in.read(reinterpret_cast(&row_info[0]), + in.read(reinterpret_cast(row_info.data()), sizeof(RowInfo) * row_info.size()); DEAL_II_CHECK_INPUT(in,']',c); DEAL_II_CHECK_INPUT(in,'[',c); - in.read(reinterpret_cast(&data[0]), + in.read(reinterpret_cast(data.data()), sizeof(Entry) * data.size()); DEAL_II_CHECK_INPUT(in,']',c); diff --git a/include/deal.II/lac/trilinos_sparse_matrix.h b/include/deal.II/lac/trilinos_sparse_matrix.h index 263d3feab2..3e79ca4a02 100644 --- a/include/deal.II/lac/trilinos_sparse_matrix.h +++ b/include/deal.II/lac/trilinos_sparse_matrix.h @@ -2962,7 +2962,7 @@ namespace TrilinosWrappers Assert (values.m() == values.n(), ExcNotQuadratic()); for (size_type i=0; i old(array_host.size()); old.swap(array_host); - transpose(n, m, &old[0], &array_host[0]); + transpose(n, m, old.data(), array_host.data()); } @@ -88,7 +88,7 @@ namespace CUDAWrappers cudaError_t error_code = cudaMalloc(array_device, n*sizeof(Number1)); AssertCuda(error_code); - error_code = cudaMemcpy(*array_device, &array_host[0], n*sizeof(Number1), + error_code = cudaMemcpy(*array_device, array_host.data(), n*sizeof(Number1), cudaMemcpyHostToDevice); AssertCuda(error_code); } @@ -246,7 +246,7 @@ namespace CUDAWrappers for (unsigned int i=0; i> &q_points = fe_values.get_quadrature_points(); - memcpy(&q_points_host[cell_id*padding_length], &q_points[0], + memcpy(&q_points_host[cell_id*padding_length], q_points.data(), q_points_per_cell*sizeof(Point)); } @@ -271,7 +271,7 @@ namespace CUDAWrappers { const std::vector> &inv_jacobians = fe_values.get_inverse_jacobians(); - memcpy(&inv_jacobian_host[cell_id*padding_length*dim*dim], &inv_jacobians[0], + memcpy(&inv_jacobian_host[cell_id*padding_length*dim*dim], inv_jacobians.data(), q_points_per_cell*sizeof(DerivativeForm<1,dim,dim>)); } } @@ -548,7 +548,7 @@ namespace CUDAWrappers sizeof(dealii::types::global_dof_index)); AssertCuda(cuda_error); - cuda_error = cudaMemcpy(constrained_dofs, &constrained_dofs_host[0], + cuda_error = cudaMemcpy(constrained_dofs, constrained_dofs_host.data(), n_constrained_dofs * sizeof(dealii::types::global_dof_index), cudaMemcpyHostToDevice); AssertCuda(cuda_error); diff --git a/include/deal.II/matrix_free/matrix_free.h b/include/deal.II/matrix_free/matrix_free.h index 84e28635f8..dcd631309d 100644 --- a/include/deal.II/matrix_free/matrix_free.h +++ b/include/deal.II/matrix_free/matrix_free.h @@ -1164,7 +1164,7 @@ MatrixFree::constraint_pool_begin (const unsigned int row) const { AssertIndexRange (row, constraint_pool_row_index.size()-1); return constraint_pool_data.empty() ? nullptr : - &constraint_pool_data[0] + constraint_pool_row_index[row]; + constraint_pool_data.data() + constraint_pool_row_index[row]; } @@ -1176,7 +1176,7 @@ MatrixFree::constraint_pool_end (const unsigned int row) const { AssertIndexRange (row, constraint_pool_row_index.size()-1); return constraint_pool_data.empty() ? nullptr : - &constraint_pool_data[0] + constraint_pool_row_index[row+1]; + constraint_pool_data.data() + constraint_pool_row_index[row+1]; } @@ -1235,13 +1235,13 @@ MatrixFree::create_cell_subrange_hp_by_index #endif std::pair return_range; return_range.first = - std::lower_bound(&fe_indices[0] + range.first, - &fe_indices[0] + range.second, fe_index) - -&fe_indices[0] ; + std::lower_bound(fe_indices.data() + range.first, + fe_indices.data() + range.second, fe_index) + -fe_indices.data() ; return_range.second = - std::lower_bound(&fe_indices[0] + return_range.first, - &fe_indices[0] + range.second, - fe_index + 1)-&fe_indices[0]; + std::lower_bound(fe_indices.data() + return_range.first, + fe_indices.data() + range.second, + fe_index + 1)-fe_indices.data(); Assert(return_range.first >= range.first && return_range.second <= range.second, ExcInternalError()); return return_range; diff --git a/source/base/data_out_base.cc b/source/base/data_out_base.cc index 5e808e2171..e2005c9bf2 100644 --- a/source/base/data_out_base.cc +++ b/source/base/data_out_base.cc @@ -271,7 +271,7 @@ namespace char *compressed_data = new char[compressed_data_length]; int err = compress2 ((Bytef *) compressed_data, &compressed_data_length, - (const Bytef *) &data[0], + (const Bytef *) data.data(), data.size() * sizeof(T), get_zlib_compression_level(flags.compression_level)); (void)err; @@ -1154,7 +1154,7 @@ namespace { if (flags.data_binary) { - stream.write(reinterpret_cast(&values[0]), + stream.write(reinterpret_cast(values.data()), values.size()*sizeof(data)); } else @@ -7010,13 +7010,13 @@ void DataOutBase::write_hdf5_parallel (const std::vector > & // And finally, write the node data data_filter.fill_node_data(node_data_vec); - status = H5Dwrite(node_dataset, H5T_NATIVE_DOUBLE, node_memory_dataspace, node_file_dataspace, plist_id, &node_data_vec[0]); + status = H5Dwrite(node_dataset, H5T_NATIVE_DOUBLE, node_memory_dataspace, node_file_dataspace, plist_id, node_data_vec.data()); AssertThrow(status >= 0, ExcIO()); node_data_vec.clear(); // And the cell data data_filter.fill_cell_data(global_node_cell_offsets[0], cell_data_vec); - status = H5Dwrite(cell_dataset, H5T_NATIVE_UINT, cell_memory_dataspace, cell_file_dataspace, plist_id, &cell_data_vec[0]); + status = H5Dwrite(cell_dataset, H5T_NATIVE_UINT, cell_memory_dataspace, cell_file_dataspace, plist_id, cell_data_vec.data()); AssertThrow(status >= 0, ExcIO()); cell_data_vec.clear(); diff --git a/source/base/function_cspline.cc b/source/base/function_cspline.cc index 72ccbf54c5..eebf42e11e 100644 --- a/source/base/function_cspline.cc +++ b/source/base/function_cspline.cc @@ -46,7 +46,7 @@ namespace Functions const unsigned int n = interpolation_points.size(); cspline = gsl_spline_alloc (gsl_interp_cspline, n); // gsl_spline_init returns something but it seems nobody knows what - gsl_spline_init (cspline, &interpolation_points[0], &interpolation_values[0], n); + gsl_spline_init (cspline, interpolation_points.data(), interpolation_values.data(), n); } diff --git a/source/base/index_set.cc b/source/base/index_set.cc index 9543531e65..306866634c 100644 --- a/source/base/index_set.cc +++ b/source/base/index_set.cc @@ -598,7 +598,7 @@ IndexSet::make_trilinos_map (const MPI_Comm &communicator, TrilinosWrappers::types::int_type(n_elements()), (n_elements() > 0 ? - reinterpret_cast(&indices[0]) + reinterpret_cast(indices.data()) : nullptr), 0, diff --git a/source/base/mpi.cc b/source/base/mpi.cc index aa42b950fc..f829c0d5fb 100644 --- a/source/base/mpi.cc +++ b/source/base/mpi.cc @@ -125,8 +125,8 @@ namespace Utilities // processors in this case, which is more expensive than the reduction // operation above in MPI_Allreduce) std::vector all_destinations (max_n_destinations * n_procs); - const int ierr = MPI_Allgather (&my_destinations[0], max_n_destinations, MPI_UNSIGNED, - &all_destinations[0], max_n_destinations, MPI_UNSIGNED, + const int ierr = MPI_Allgather (my_destinations.data(), max_n_destinations, MPI_UNSIGNED, + all_destinations.data(), max_n_destinations, MPI_UNSIGNED, mpi_comm); AssertThrowMPI(ierr); @@ -388,8 +388,8 @@ namespace Utilities std::vector all_hostnames(max_hostname_size * MPI::n_mpi_processes(MPI_COMM_WORLD)); - const int ierr = MPI_Allgather (&hostname_array[0], max_hostname_size, MPI_CHAR, - &all_hostnames[0], max_hostname_size, MPI_CHAR, + const int ierr = MPI_Allgather (hostname_array.data(), max_hostname_size, MPI_CHAR, + all_hostnames.data(), max_hostname_size, MPI_CHAR, MPI_COMM_WORLD); AssertThrowMPI(ierr); @@ -398,7 +398,7 @@ namespace Utilities unsigned int n_local_processes=0; unsigned int nth_process_on_host = 0; for (unsigned int i=0; i0) { const int ierr = MPI_Waitall (import_requests.size(), - &import_requests[0], + import_requests.data(), MPI_STATUSES_IGNORE); AssertThrowMPI(ierr); } diff --git a/source/base/polynomial.cc b/source/base/polynomial.cc index ee259b9743..b82971ed1f 100644 --- a/source/base/polynomial.cc +++ b/source/base/polynomial.cc @@ -104,7 +104,7 @@ namespace Polynomials { Assert (values.size() > 0, ExcZero()); - value(x,values.size()-1,&values[0]); + value(x,values.size()-1,values.data()); } diff --git a/source/base/polynomials_piecewise.cc b/source/base/polynomials_piecewise.cc index bf574b0887..b6c8d159a9 100644 --- a/source/base/polynomials_piecewise.cc +++ b/source/base/polynomials_piecewise.cc @@ -47,7 +47,7 @@ namespace Polynomials { Assert (values.size() > 0, ExcZero()); - value(x,values.size()-1,&values[0]); + value(x,values.size()-1,values.data()); } diff --git a/source/distributed/tria.cc b/source/distributed/tria.cc index 3e45432cf0..ec3a462211 100644 --- a/source/distributed/tria.cc +++ b/source/distributed/tria.cc @@ -1403,52 +1403,52 @@ namespace parallel { buffer.resize(bytes_for_buffer()); - char *ptr = &buffer[0]; + char *ptr = buffer.data(); const unsigned int num_cells = tree_index.size(); std::memcpy(ptr, &num_cells, sizeof(unsigned int)); ptr += sizeof(unsigned int); std::memcpy(ptr, - &tree_index[0], + tree_index.data(), num_cells*sizeof(unsigned int)); ptr += num_cells*sizeof(unsigned int); std::memcpy(ptr, - &quadrants[0], + quadrants.data(), num_cells * sizeof(typename dealii::internal::p4est:: types::quadrant)); ptr += num_cells*sizeof(typename dealii::internal::p4est::types:: quadrant); std::memcpy(ptr, - &vertex_indices[0], + vertex_indices.data(), vertex_indices.size() * sizeof(unsigned int)); ptr += vertex_indices.size() * sizeof(unsigned int); std::memcpy(ptr, - &vertices[0], + vertices.data(), vertices.size() * sizeof(dealii::Point)); ptr += vertices.size() * sizeof(dealii::Point); - Assert (ptr == &buffer[0]+buffer.size(), + Assert (ptr == buffer.data()+buffer.size(), ExcInternalError()); } void unpack_data (const std::vector &buffer) { - const char *ptr = &buffer[0]; + const char *ptr = buffer.data(); unsigned int cells; memcpy(&cells, ptr, sizeof(unsigned int)); ptr += sizeof(unsigned int); tree_index.resize(cells); - memcpy(&tree_index[0],ptr,sizeof(unsigned int)*cells); + memcpy(tree_index.data(),ptr,sizeof(unsigned int)*cells); ptr += sizeof(unsigned int)*cells; quadrants.resize(cells); - memcpy(&quadrants[0],ptr, + memcpy(quadrants.data(),ptr, sizeof(typename dealii::internal::p4est::types::quadrant)*cells); ptr += sizeof(typename dealii::internal::p4est::types::quadrant)*cells; @@ -1494,7 +1494,7 @@ namespace parallel for (unsigned int c=0; cget_communicator(), &status); AssertThrowMPI(ierr); @@ -3173,7 +3173,7 @@ namespace parallel // safely destroy the buffers. if (requests.size() > 0) { - const int ierr = MPI_Waitall(requests.size(), &requests[0], MPI_STATUSES_IGNORE); + const int ierr = MPI_Waitall(requests.size(), requests.data(), MPI_STATUSES_IGNORE); AssertThrowMPI(ierr); } diff --git a/source/distributed/tria_base.cc b/source/distributed/tria_base.cc index 222b32d898..c9e3d92011 100644 --- a/source/distributed/tria_base.cc +++ b/source/distributed/tria_base.cc @@ -202,7 +202,7 @@ namespace parallel const int ierr = MPI_Allgather (&send_value, 1, MPI_UNSIGNED, - &number_cache.n_locally_owned_active_cells[0], + number_cache.n_locally_owned_active_cells.data(), 1, MPI_UNSIGNED, this->mpi_communicator); @@ -276,7 +276,7 @@ namespace parallel if (requests.size() > 0) { - ierr = MPI_Waitall(requests.size(), &requests[0], MPI_STATUSES_IGNORE); + ierr = MPI_Waitall(requests.size(), requests.data(), MPI_STATUSES_IGNORE); AssertThrowMPI(ierr); } diff --git a/source/dofs/dof_handler_policy.cc b/source/dofs/dof_handler_policy.cc index fd78e7cd92..d8b397fe31 100644 --- a/source/dofs/dof_handler_policy.cc +++ b/source/dofs/dof_handler_policy.cc @@ -2872,7 +2872,7 @@ namespace internal // set rcounts based on new_numbers: int cur_count = new_numbers_copy.size (); int ierr = MPI_Allgather (&cur_count, 1, MPI_INT, - &rcounts[0], 1, MPI_INT, + rcounts.data(), 1, MPI_INT, tr->get_communicator ()); AssertThrowMPI(ierr); @@ -2887,10 +2887,10 @@ namespace internal Assert(((int)new_numbers_copy.size()) == rcounts[Utilities::MPI::this_mpi_process (tr->get_communicator ())], ExcInternalError()); - ierr = MPI_Allgatherv (&new_numbers_copy[0], new_numbers_copy.size (), + ierr = MPI_Allgatherv (new_numbers_copy.data(), new_numbers_copy.size (), DEAL_II_DOF_INDEX_MPI_TYPE, - &gathered_new_numbers[0], &rcounts[0], - &displacements[0], + gathered_new_numbers.data(), rcounts.data(), + displacements.data(), DEAL_II_DOF_INDEX_MPI_TYPE, tr->get_communicator ()); AssertThrowMPI(ierr); @@ -3008,8 +3008,8 @@ namespace internal // know how to serialize itself. consequently, first copy it over // to an array of bytes, and then serialize that std::vector quadrants_as_chars (sizeof(quadrants[0]) * quadrants.size()); - std::memcpy(&quadrants_as_chars[0], - &quadrants[0], + std::memcpy(quadrants_as_chars.data(), + quadrants.data(), quadrants_as_chars.size()); // now serialize everything @@ -3033,8 +3033,8 @@ namespace internal &dof_numbers_and_indices; quadrants.resize (quadrants_as_chars.size() / sizeof(quadrants[0])); - std::memcpy(&quadrants[0], - &quadrants_as_chars[0], + std::memcpy(quadrants.data(), + quadrants_as_chars.data(), quadrants_as_chars.size()); } @@ -3083,7 +3083,7 @@ namespace internal decompressing_stream.push(boost::iostreams::gzip_decompressor()); decompressing_stream.push(boost::iostreams::back_inserter(decompressed_buffer)); - decompressing_stream.write (&buffer[0], buffer.size()); + decompressing_stream.write (buffer.data(), buffer.size()); } // then restore the object from the buffer @@ -3307,7 +3307,7 @@ namespace internal AssertThrowMPI(ierr); receive.resize(len); - char *ptr = &receive[0]; + char *ptr = receive.data(); ierr = MPI_Recv(ptr, len, MPI_BYTE, status.MPI_SOURCE, status.MPI_TAG, tria.get_communicator(), &status); AssertThrowMPI(ierr); @@ -3355,7 +3355,7 @@ namespace internal AssertThrowMPI(ierr); receive.resize(len); - char *ptr = &receive[0]; + char *ptr = receive.data(); ierr = MPI_Recv(ptr, len, MPI_BYTE, status.MPI_SOURCE, status.MPI_TAG, tria.get_communicator(), &status); AssertThrowMPI(ierr); @@ -3391,12 +3391,12 @@ namespace internal // buffers. if (requests.size() > 0) { - const int ierr = MPI_Waitall(requests.size(), &requests[0], MPI_STATUSES_IGNORE); + const int ierr = MPI_Waitall(requests.size(), requests.data(), MPI_STATUSES_IGNORE); AssertThrowMPI(ierr); } if (reply_requests.size() > 0) { - const int ierr = MPI_Waitall(reply_requests.size(), &reply_requests[0], MPI_STATUSES_IGNORE); + const int ierr = MPI_Waitall(reply_requests.size(), reply_requests.data(), MPI_STATUSES_IGNORE); AssertThrowMPI(ierr); } } @@ -3739,7 +3739,7 @@ namespace internal const int ierr = MPI_Allgather ( &n_locally_owned_dofs, 1, DEAL_II_DOF_INDEX_MPI_TYPE, - &n_locally_owned_dofs_per_processor[0], + n_locally_owned_dofs_per_processor.data(), 1, DEAL_II_DOF_INDEX_MPI_TYPE, triangulation->get_communicator()); AssertThrowMPI(ierr); @@ -4318,8 +4318,8 @@ namespace internal my_data.resize(max_size); std::vector buffer(max_size*n_cpus); - const int ierr = MPI_Allgather(&my_data[0], max_size, MPI_BYTE, - &buffer[0], max_size, MPI_BYTE, + const int ierr = MPI_Allgather(my_data.data(), max_size, MPI_BYTE, + buffer.data(), max_size, MPI_BYTE, triangulation->get_communicator()); AssertThrowMPI(ierr); diff --git a/source/dofs/dof_renumbering.cc b/source/dofs/dof_renumbering.cc index 702bde7415..fee4acbd90 100644 --- a/source/dofs/dof_renumbering.cc +++ b/source/dofs/dof_renumbering.cc @@ -315,10 +315,10 @@ namespace DoFRenumbering minimum_degree_ordering (G, - make_iterator_property_map(°ree[0], id, degree[0]), - &inverse_perm[0], - &perm[0], - make_iterator_property_map(&supernode_sizes[0], id, supernode_sizes[0]), + make_iterator_property_map(degree.begin(), id, degree[0]), + inverse_perm.data(), + perm.data(), + make_iterator_property_map(supernode_sizes.begin(), id, supernode_sizes[0]), delta, id); @@ -733,9 +733,9 @@ namespace DoFRenumbering all_dof_counts(fe_collection.n_components() * Utilities::MPI::n_mpi_processes (tria->get_communicator())); - const int ierr = MPI_Allgather ( &local_dof_count[0], + const int ierr = MPI_Allgather ( local_dof_count.data(), n_buckets, DEAL_II_DOF_INDEX_MPI_TYPE, - &all_dof_counts[0], + all_dof_counts.data(), n_buckets, DEAL_II_DOF_INDEX_MPI_TYPE, tria->get_communicator()); AssertThrowMPI(ierr); @@ -1021,9 +1021,9 @@ namespace DoFRenumbering all_dof_counts(fe_collection.n_components() * Utilities::MPI::n_mpi_processes (tria->get_communicator())); - const int ierr = MPI_Allgather ( &local_dof_count[0], + const int ierr = MPI_Allgather ( local_dof_count.data(), n_buckets, DEAL_II_DOF_INDEX_MPI_TYPE, - &all_dof_counts[0], + all_dof_counts.data(), n_buckets, DEAL_II_DOF_INDEX_MPI_TYPE, tria->get_communicator()); AssertThrowMPI(ierr); diff --git a/source/dofs/dof_tools.cc b/source/dofs/dof_tools.cc index d17ec89caa..ab956ffcb8 100644 --- a/source/dofs/dof_tools.cc +++ b/source/dofs/dof_tools.cc @@ -1806,7 +1806,7 @@ namespace DoFTools { std::vector local_dof_count = dofs_per_component; - const int ierr = MPI_Allreduce (&local_dof_count[0], &dofs_per_component[0], n_target_components, + const int ierr = MPI_Allreduce (local_dof_count.data(), dofs_per_component.data(), n_target_components, DEAL_II_DOF_INDEX_MPI_TYPE, MPI_SUM, tria->get_communicator()); AssertThrowMPI (ierr); @@ -1884,7 +1884,7 @@ namespace DoFTools (&dof_handler.get_triangulation()))) { std::vector local_dof_count = dofs_per_block; - const int ierr = MPI_Allreduce (&local_dof_count[0], &dofs_per_block[0], + const int ierr = MPI_Allreduce (local_dof_count.data(), dofs_per_block.data(), n_target_blocks, DEAL_II_DOF_INDEX_MPI_TYPE, MPI_SUM, tria->get_communicator()); diff --git a/source/fe/fe_abf.cc b/source/fe/fe_abf.cc index fa31e097ac..094700373c 100644 --- a/source/fe/fe_abf.cc +++ b/source/fe/fe_abf.cc @@ -92,7 +92,7 @@ FE_ABF::FE_ABF (const unsigned int deg) this->dofs_per_face)); // TODO: Something goes wrong there. The error of the least squares fit // is to large ... - // FETools::compute_face_embedding_matrices(*this, &face_embeddings[0], 0, 0); + // FETools::compute_face_embedding_matrices(*this, face_embeddings.data(), 0, 0); this->interface_constraints.reinit((1<<(dim-1)) * this->dofs_per_face, this->dofs_per_face); unsigned int target_row=0; diff --git a/source/grid/grid_tools.cc b/source/grid/grid_tools.cc index 2437f006a0..51390ceb09 100644 --- a/source/grid/grid_tools.cc +++ b/source/grid/grid_tools.cc @@ -2332,7 +2332,7 @@ next_cell: // processors and shifting the indices accordingly const unsigned int n_cpu = Utilities::MPI::n_mpi_processes(triangulation.get_communicator()); std::vector indices(n_cpu); - int ierr = MPI_Allgather(&next_index, 1, DEAL_II_DOF_INDEX_MPI_TYPE, &indices[0], + int ierr = MPI_Allgather(&next_index, 1, DEAL_II_DOF_INDEX_MPI_TYPE, indices.data(), indices.size(), DEAL_II_DOF_INDEX_MPI_TYPE, triangulation.get_communicator()); AssertThrowMPI(ierr); const types::global_vertex_index shift = std::accumulate(&indices[0], diff --git a/source/grid/manifold.cc b/source/grid/manifold.cc index 5b9c0abe33..1866193aae 100644 --- a/source/grid/manifold.cc +++ b/source/grid/manifold.cc @@ -612,7 +612,7 @@ get_new_points (const ArrayView> &surrounding_points, for (unsigned int i=0; i periodicity[d]/2.0) modified_points[i][d] -= periodicity[d]; - surrounding_points_start = &modified_points[0]; + surrounding_points_start = modified_points.data(); } // Now perform the interpolation diff --git a/source/lac/lapack_full_matrix.cc b/source/lac/lapack_full_matrix.cc index e298960064..6be51ecfa3 100644 --- a/source/lac/lapack_full_matrix.cc +++ b/source/lac/lapack_full_matrix.cc @@ -202,12 +202,12 @@ LAPACKFullMatrix::vmult ( AssertDimension(w.size(), this->n_rows()); // Compute V^T v work.resize(std::max(mm,nn)); - gemv("N", &nn, &nn, &alpha, &svd_vt->values[0], &nn, v.val, &one, &null, &work[0], &one); + gemv("N", &nn, &nn, &alpha, &svd_vt->values[0], &nn, v.val, &one, &null, work.data(), &one); // Multiply by singular values for (size_type i=0; ivalues[0], &mm, &work[0], &one, &beta, w.val, &one); + gemv("N", &mm, &mm, &alpha, &svd_u->values[0], &mm, work.data(), &one, &beta, w.val, &one); break; } case inverse_svd: @@ -217,12 +217,12 @@ LAPACKFullMatrix::vmult ( AssertDimension(v.size(), this->n_rows()); // Compute U^T v work.resize(std::max(mm,nn)); - gemv("T", &mm, &mm, &alpha, &svd_u->values[0], &mm, v.val, &one, &null, &work[0], &one); + gemv("T", &mm, &mm, &alpha, &svd_u->values[0], &mm, v.val, &one, &null, work.data(), &one); // Multiply by singular values for (size_type i=0; ivalues[0], &nn, &work[0], &one, &beta, w.val, &one); + gemv("T", &nn, &nn, &alpha, &svd_vt->values[0], &nn, work.data(), &one, &beta, w.val, &one); break; } default: @@ -263,12 +263,12 @@ LAPACKFullMatrix::Tvmult ( // Compute U^T v work.resize(std::max(mm,nn)); - gemv("T", &mm, &mm, &alpha, &svd_u->values[0], &mm, v.val, &one, &null, &work[0], &one); + gemv("T", &mm, &mm, &alpha, &svd_u->values[0], &mm, v.val, &one, &null, work.data(), &one); // Multiply by singular values for (size_type i=0; ivalues[0], &nn, &work[0], &one, &beta, w.val, &one); + gemv("T", &nn, &nn, &alpha, &svd_vt->values[0], &nn, work.data(), &one, &beta, w.val, &one); break; } case inverse_svd: @@ -279,12 +279,12 @@ LAPACKFullMatrix::Tvmult ( // Compute V^T v work.resize(std::max(mm,nn)); - gemv("N", &nn, &nn, &alpha, &svd_vt->values[0], &nn, v.val, &one, &null, &work[0], &one); + gemv("N", &nn, &nn, &alpha, &svd_vt->values[0], &nn, v.val, &one, &null, work.data(), &one); // Multiply by singular values for (size_type i=0; ivalues[0], &mm, &work[0], &one, &beta, w.val, &one); + gemv("N", &mm, &mm, &alpha, &svd_u->values[0], &mm, work.data(), &one, &beta, w.val, &one); break; } default: @@ -513,7 +513,7 @@ LAPACKFullMatrix::compute_lu_factorization() number *values = const_cast (&this->values[0]); ipiv.resize(mm); int info = 0; - getrf(&mm, &nn, values, &mm, &ipiv[0], &info); + getrf(&mm, &nn, values, &mm, ipiv.data(), &info); Assert(info >= 0, ExcInternalError()); @@ -580,7 +580,7 @@ number LAPACKFullMatrix::norm(const char type) const std::max(1,N) : 0; work.resize(lwork); - return lansy (&type, &LAPACKSupport::L, &N, values, &lda, &work[0]); + return lansy (&type, &LAPACKSupport::L, &N, values, &lda, work.data()); } else { @@ -589,7 +589,7 @@ number LAPACKFullMatrix::norm(const char type) const std::max(1,M) : 0; work.resize(lwork); - return lange (&type, &M, &N, values, &lda, &work[0]); + return lange (&type, &M, &N, values, &lda, work.data()); } } @@ -658,7 +658,7 @@ LAPACKFullMatrix::reciprocal_condition_number(const number a_norm) const // use the same uplo as in Cholesky pocon (&LAPACKSupport::L, &N, values, &lda, &a_norm, &rcond, - &work[0], &iwork[0], &info); + work.data(), iwork.data(), &info); Assert(info >= 0, ExcInternalError()); @@ -691,8 +691,8 @@ LAPACKFullMatrix::compute_svd() work.resize(1); int lwork = -1; gesdd(&LAPACKSupport::A, &mm, &nn, values, &mm, - &wr[0], mu, &mm, mvt, &nn, - &work[0], &lwork, &ipiv[0], &info); + wr.data(), mu, &mm, mvt, &nn, + work.data(), &lwork, ipiv.data(), &info); AssertThrow (info==0, LAPACKSupport::ExcErrorCode("gesdd", info)); // Resize the work array. Add one to the size computed by LAPACK to be on // the safe side. @@ -701,8 +701,8 @@ LAPACKFullMatrix::compute_svd() work.resize(lwork); // Do the actual SVD. gesdd(&LAPACKSupport::A, &mm, &nn, values, &mm, - &wr[0], mu, &mm, mvt, &nn, - &work[0], &lwork, &ipiv[0], &info); + wr.data(), mu, &mm, mvt, &nn, + work.data(), &lwork, ipiv.data(), &info); AssertThrow (info==0, LAPACKSupport::ExcErrorCode("gesdd", info)); work.resize(0); @@ -753,7 +753,7 @@ LAPACKFullMatrix::invert() ipiv.resize(mm); inv_work.resize (mm); - getri(&mm, values, &mm, &ipiv[0], &inv_work[0], &mm, &info); + getri(&mm, values, &mm, ipiv.data(), inv_work.data(), &mm, &info); } else { @@ -790,7 +790,7 @@ LAPACKFullMatrix::apply_lu_factorization(Vector &v, const number *values = &this->values[0]; int info = 0; - getrs(trans, &nn, &one, values, &nn, &ipiv[0], + getrs(trans, &nn, &one, values, &nn, ipiv.data(), v.begin(), &nn, &info); Assert(info == 0, ExcInternalError()); @@ -813,7 +813,7 @@ LAPACKFullMatrix::apply_lu_factorization(LAPACKFullMatrix &B, const number *values = &this->values[0]; int info = 0; - getrs(trans, &nn, &kk, values, &nn, &ipiv[0], &B.values[0], &nn, &info); + getrs(trans, &nn, &kk, values, &nn, ipiv.data(), &B.values[0], &nn, &info); Assert(info == 0, ExcInternalError()); } @@ -881,9 +881,9 @@ LAPACKFullMatrix::compute_eigenvalues(const bool right, work.resize(1); geev(jobvl, jobvr, &nn, values, &nn, - &wr[0], &wi[0], - &vl[0], &nn, &vr[0], &nn, - &work[0], &lwork, &info); + wr.data(), wi.data(), + vl.data(), &nn, vr.data(), &nn, + work.data(), &lwork, &info); // geev returns info=0 on success. Since we only queried the optimal size // for work, everything else would not be acceptable. Assert (info == 0, ExcInternalError()); @@ -896,9 +896,9 @@ LAPACKFullMatrix::compute_eigenvalues(const bool right, // Finally compute the eigenvalues. geev(jobvl, jobvr, &nn, values, &nn, - &wr[0], &wi[0], - &vl[0], &nn, &vr[0], &nn, - &work[0], &lwork, &info); + wr.data(), wi.data(), + vl.data(), &nn, vr.data(), &nn, + work.data(), &lwork, &info); // Negative return value implies a wrong argument. This should be internal. Assert (info >=0, ExcInternalError()); @@ -954,9 +954,9 @@ LAPACKFullMatrix::compute_eigenvalues_symmetric(const number lowe uplo, &nn, values_A, &nn, &lower_bound, &upper_bound, dummy, dummy, &abs_accuracy, - &n_eigenpairs, &wr[0], values_eigenvectors, - &nn, &work[0], &lwork, &iwork[0], - &ifail[0], &info); + &n_eigenpairs, wr.data(), values_eigenvectors, + &nn, work.data(), &lwork, iwork.data(), + ifail.data(), &info); // syevx returns info=0 on success. Since we only queried the optimal size // for work, everything else would not be acceptable. Assert (info == 0, ExcInternalError()); @@ -970,9 +970,9 @@ LAPACKFullMatrix::compute_eigenvalues_symmetric(const number lowe uplo, &nn, values_A, &nn, &lower_bound, &upper_bound, dummy, dummy, &abs_accuracy, - &n_eigenpairs, &wr[0], values_eigenvectors, - &nn, &work[0], &lwork, &iwork[0], - &ifail[0], &info); + &n_eigenpairs, wr.data(), values_eigenvectors, + &nn, work.data(), &lwork, iwork.data(), + ifail.data(), &info); // Negative return value implies a wrong argument. This should be internal. Assert (info >=0, ExcInternalError()); @@ -1046,8 +1046,8 @@ LAPACKFullMatrix::compute_generalized_eigenvalues_symmetric( sygvx (&itype, jobz, range, uplo, &nn, values_A, &nn, values_B, &nn, &lower_bound, &upper_bound, dummy, dummy, &abs_accuracy, &n_eigenpairs, - &wr[0], values_eigenvectors, &nn, &work[0], - &lwork, &iwork[0], &ifail[0], &info); + wr.data(), values_eigenvectors, &nn, work.data(), + &lwork, iwork.data(), ifail.data(), &info); // sygvx returns info=0 on success. Since we only queried the optimal size // for work, everything else would not be acceptable. Assert (info == 0, ExcInternalError()); @@ -1062,8 +1062,8 @@ LAPACKFullMatrix::compute_generalized_eigenvalues_symmetric( sygvx (&itype, jobz, range, uplo, &nn, values_A, &nn, values_B, &nn, &lower_bound, &upper_bound, dummy, dummy, &abs_accuracy, &n_eigenpairs, - &wr[0], values_eigenvectors, &nn, &work[0], - &lwork, &iwork[0], &ifail[0], &info); + wr.data(), values_eigenvectors, &nn, work.data(), + &lwork, iwork.data(), ifail.data(), &info); // Negative return value implies a wrong argument. This should be internal. Assert (info >=0, ExcInternalError()); @@ -1129,7 +1129,7 @@ LAPACKFullMatrix::compute_generalized_eigenvalues_symmetric ( sygv (&itype, jobz, uplo, &nn, values_A, &nn, values_B, &nn, - &wr[0], &work[0], &lwork, &info); + wr.data(), work.data(), &lwork, &info); // sygv returns info=0 on success. Since we only queried the optimal size // for work, everything else would not be acceptable. Assert (info == 0, ExcInternalError()); @@ -1143,7 +1143,7 @@ LAPACKFullMatrix::compute_generalized_eigenvalues_symmetric ( // Finally compute the generalized eigenvalues. sygv (&itype, jobz, uplo, &nn, values_A, &nn, values_B, &nn, - &wr[0], &work[0], &lwork, &info); + wr.data(), work.data(), &lwork, &info); // Negative return value implies a wrong argument. This should be internal. Assert (info >=0, ExcInternalError()); diff --git a/source/lac/petsc_matrix_base.cc b/source/lac/petsc_matrix_base.cc index 012286016e..efc57ad532 100644 --- a/source/lac/petsc_matrix_base.cc +++ b/source/lac/petsc_matrix_base.cc @@ -150,7 +150,7 @@ namespace PETScWrappers IS index_set; ISCreateGeneral (get_mpi_communicator(), rows.size(), - &petsc_rows[0], PETSC_COPY_VALUES, &index_set); + petsc_rows.data(), PETSC_COPY_VALUES, &index_set); const PetscErrorCode ierr = MatZeroRowsIS(matrix, index_set, new_diag_value, nullptr, nullptr); diff --git a/source/lac/petsc_parallel_sparse_matrix.cc b/source/lac/petsc_parallel_sparse_matrix.cc index d922448588..65461a0e6b 100644 --- a/source/lac/petsc_parallel_sparse_matrix.cc +++ b/source/lac/petsc_parallel_sparse_matrix.cc @@ -298,9 +298,9 @@ namespace PETScWrappers (communicator, local_rows, local_columns, m, n, - 0, &int_row_lengths[0], + 0, int_row_lengths.data(), 0, - offdiag_row_lengths.size() ? &int_offdiag_row_lengths[0] : nullptr, + offdiag_row_lengths.size() ? int_offdiag_row_lengths.data() : nullptr, &matrix); //TODO: Sometimes the actual number of nonzero entries allocated is greater than the number of nonzero entries, which petsc will complain about unless explicitly disabled with MatSetOption. There is probably a way to prevent a different number nonzero elements being allocated in the first place. (See also previous TODO). @@ -429,8 +429,8 @@ namespace PETScWrappers // that summarily allocates these // entries: ierr = MatMPIAIJSetPreallocationCSR (matrix, - &rowstart_in_window[0], - &colnums_in_window[0], + rowstart_in_window.data(), + colnums_in_window.data(), nullptr); AssertThrow (ierr == 0, ExcPETScError(ierr)); } @@ -558,8 +558,8 @@ namespace PETScWrappers // that summarily allocates these // entries: ierr = MatMPIAIJSetPreallocationCSR (matrix, - &rowstart_in_window[0], - &colnums_in_window[0], + rowstart_in_window.data(), + colnums_in_window.data(), nullptr); AssertThrow (ierr == 0, ExcPETScError(ierr)); diff --git a/source/lac/petsc_sparse_matrix.cc b/source/lac/petsc_sparse_matrix.cc index e71099b712..0e2215ed76 100644 --- a/source/lac/petsc_sparse_matrix.cc +++ b/source/lac/petsc_sparse_matrix.cc @@ -180,7 +180,7 @@ namespace PETScWrappers int_row_lengths (row_lengths.begin(), row_lengths.end()); const PetscErrorCode ierr = MatCreateSeqAIJ(PETSC_COMM_SELF, m, n, 0, - &int_row_lengths[0], &matrix); + int_row_lengths.data(), &matrix); AssertThrow (ierr == 0, ExcPETScError(ierr)); // set symmetric flag, if so requested @@ -231,8 +231,8 @@ namespace PETScWrappers const PetscInt int_row = i; const PetscErrorCode ierr = MatSetValues (matrix, 1, &int_row, - row_lengths[i], &row_entries[0], - &row_values[0], INSERT_VALUES); + row_lengths[i], row_entries.data(), + row_values.data(), INSERT_VALUES); AssertThrow (ierr == 0, ExcPETScError(ierr)); } compress (VectorOperation::insert); diff --git a/source/lac/petsc_vector_base.cc b/source/lac/petsc_vector_base.cc index 6f5dc4177b..763e6adf7e 100644 --- a/source/lac/petsc_vector_base.cc +++ b/source/lac/petsc_vector_base.cc @@ -289,7 +289,7 @@ namespace PETScWrappers { Assert (indices.size() == values.size(), ExcMessage ("Function called with arguments of different sizes")); - do_set_add_operation(indices.size(), &indices[0], &values[0], false); + do_set_add_operation(indices.size(), indices.data(), values.data(), false); } @@ -300,7 +300,7 @@ namespace PETScWrappers { Assert (indices.size() == values.size(), ExcMessage ("Function called with arguments of different sizes")); - do_set_add_operation(indices.size(), &indices[0], &values[0], true); + do_set_add_operation(indices.size(), indices.data(), values.data(), true); } @@ -311,7 +311,7 @@ namespace PETScWrappers { Assert (indices.size() == values.size(), ExcMessage ("Function called with arguments of different sizes")); - do_set_add_operation(indices.size(), &indices[0], values.begin(), true); + do_set_add_operation(indices.size(), indices.data(), values.begin(), true); } diff --git a/source/lac/sparse_direct.cc b/source/lac/sparse_direct.cc index b7c51851ad..7956a3e91f 100644 --- a/source/lac/sparse_direct.cc +++ b/source/lac/sparse_direct.cc @@ -59,7 +59,7 @@ SparseDirectUMFPACK::SparseDirectUMFPACK () numeric_decomposition (nullptr), control (UMFPACK_CONTROL) { - umfpack_dl_defaults (&control[0]); + umfpack_dl_defaults (control.data()); } @@ -95,7 +95,7 @@ SparseDirectUMFPACK::clear () tmp.swap (Ax); } - umfpack_dl_defaults (&control[0]); + umfpack_dl_defaults (control.data()); } @@ -279,16 +279,16 @@ factorize (const Matrix &matrix) int status; status = umfpack_dl_symbolic (N, N, - &Ap[0], &Ai[0], &Ax[0], + Ap.data(), Ai.data(), Ax.data(), &symbolic_decomposition, - &control[0], nullptr); + control.data(), nullptr); AssertThrow (status == UMFPACK_OK, ExcUMFPACKError("umfpack_dl_symbolic", status)); - status = umfpack_dl_numeric (&Ap[0], &Ai[0], &Ax[0], + status = umfpack_dl_numeric (Ap.data(), Ai.data(), Ax.data(), symbolic_decomposition, &numeric_decomposition, - &control[0], nullptr); + control.data(), nullptr); AssertThrow (status == UMFPACK_OK, ExcUMFPACKError("umfpack_dl_numeric", status)); @@ -317,10 +317,10 @@ SparseDirectUMFPACK::solve (Vector &rhs_and_solution, // instead. const int status = umfpack_dl_solve (transpose ? UMFPACK_A : UMFPACK_At, - &Ap[0], &Ai[0], &Ax[0], + Ap.data(), Ai.data(), Ax.data(), rhs_and_solution.begin(), rhs.begin(), numeric_decomposition, - &control[0], nullptr); + control.data(), nullptr); AssertThrow (status == UMFPACK_OK, ExcUMFPACKError("umfpack_dl_solve", status)); } diff --git a/source/lac/sparsity_tools.cc b/source/lac/sparsity_tools.cc index ef32909eaa..1d8c3365f5 100644 --- a/source/lac/sparsity_tools.cc +++ b/source/lac/sparsity_tools.cc @@ -119,17 +119,17 @@ namespace SparsityTools // Use recursive if the number of partitions is less than or equal to 8 if (nparts <= 8) - ierr = METIS_PartGraphRecursive(&n, &ncon, &int_rowstart[0], &int_colnums[0], + ierr = METIS_PartGraphRecursive(&n, &ncon, int_rowstart.data(), int_colnums.data(), nullptr, nullptr, nullptr, - &nparts,nullptr,nullptr,&options[0], - &dummy,&int_partition_indices[0]); + &nparts,nullptr,nullptr,options, + &dummy,int_partition_indices.data()); // Otherwise use kway else - ierr = METIS_PartGraphKway(&n, &ncon, &int_rowstart[0], &int_colnums[0], + ierr = METIS_PartGraphKway(&n, &ncon, int_rowstart.data(), int_colnums.data(), nullptr, nullptr, nullptr, - &nparts,nullptr,nullptr,&options[0], - &dummy,&int_partition_indices[0]); + &nparts,nullptr,nullptr,options, + &dummy,int_partition_indices.data()); // If metis returns normally, an error code METIS_OK=1 is returned from // the above functions (see metish.h) @@ -604,7 +604,7 @@ namespace SparsityTools ierr = MPI_Get_count(&status, DEAL_II_DOF_INDEX_MPI_TYPE, &len); AssertThrowMPI(ierr); recv_buf.resize(len); - ierr = MPI_Recv(&recv_buf[0], len, DEAL_II_DOF_INDEX_MPI_TYPE, status.MPI_SOURCE, + ierr = MPI_Recv(recv_buf.data(), len, DEAL_II_DOF_INDEX_MPI_TYPE, status.MPI_SOURCE, status.MPI_TAG, mpi_comm, &status); AssertThrowMPI(ierr); @@ -629,7 +629,7 @@ namespace SparsityTools // complete all sends, so that we can safely destroy the buffers. if (requests.size()) { - const int ierr = MPI_Waitall(requests.size(), &requests[0], MPI_STATUSES_IGNORE); + const int ierr = MPI_Waitall(requests.size(), requests.data(), MPI_STATUSES_IGNORE); AssertThrowMPI(ierr); } @@ -735,7 +735,7 @@ namespace SparsityTools ierr = MPI_Get_count(&status, DEAL_II_DOF_INDEX_MPI_TYPE, &len); AssertThrowMPI(ierr); recv_buf.resize(len); - ierr = MPI_Recv(&recv_buf[0], len, DEAL_II_DOF_INDEX_MPI_TYPE, status.MPI_SOURCE, + ierr = MPI_Recv(recv_buf.data(), len, DEAL_II_DOF_INDEX_MPI_TYPE, status.MPI_SOURCE, status.MPI_TAG, mpi_comm, &status); AssertThrowMPI(ierr); @@ -760,7 +760,7 @@ namespace SparsityTools // complete all sends, so that we can safely destroy the buffers. if (requests.size()) { - const int ierr = MPI_Waitall(requests.size(), &requests[0], MPI_STATUSES_IGNORE); + const int ierr = MPI_Waitall(requests.size(), requests.data(), MPI_STATUSES_IGNORE); AssertThrowMPI(ierr); } } diff --git a/source/lac/trilinos_precondition_ml.cc b/source/lac/trilinos_precondition_ml.cc index 3912e39480..16fb391023 100644 --- a/source/lac/trilinos_precondition_ml.cc +++ b/source/lac/trilinos_precondition_ml.cc @@ -191,7 +191,7 @@ namespace TrilinosWrappers // the current processor. Therefore, pass a dummy in that case else parameter_list.set("null space: vectors", - &dummy[0]); + dummy.data()); } initialize (matrix, parameter_list); diff --git a/source/lac/trilinos_precondition_muelu.cc b/source/lac/trilinos_precondition_muelu.cc index c70281cec2..b10c04d462 100644 --- a/source/lac/trilinos_precondition_muelu.cc +++ b/source/lac/trilinos_precondition_muelu.cc @@ -184,7 +184,7 @@ namespace TrilinosWrappers // the current processor. Therefore, pass a dummy in that case else parameter_list.set("null space: vectors", - &dummy[0]); + dummy.data()); } initialize (matrix, parameter_list); diff --git a/source/lac/trilinos_sparse_matrix.cc b/source/lac/trilinos_sparse_matrix.cc index af8c0d3aae..b4730994b2 100644 --- a/source/lac/trilinos_sparse_matrix.cc +++ b/source/lac/trilinos_sparse_matrix.cc @@ -498,10 +498,10 @@ namespace TrilinosWrappers std::shared_ptr graph; if (input_row_map.Comm().NumProc() > 1) graph.reset (new Epetra_CrsGraph (Copy, input_row_map, - &n_entries_per_row[0], true)); + n_entries_per_row.data(), true)); else graph.reset (new Epetra_CrsGraph (Copy, input_row_map, input_col_map, - &n_entries_per_row[0], true)); + n_entries_per_row.data(), true)); // This functions assumes that the sparsity pattern sits on all // processors (completely). The parallel version uses an Epetra graph @@ -523,7 +523,7 @@ namespace TrilinosWrappers row_indices[col] = p->column(); } graph->Epetra_CrsGraph::InsertGlobalIndices (row, row_length, - &row_indices[0]); + row_indices.data()); } // Eventually, optimize the graph structure (sort indices, make memory @@ -613,7 +613,7 @@ namespace TrilinosWrappers Epetra_Map relevant_map (TrilinosWrappers::types::int_type(-1), TrilinosWrappers::types::int_type(relevant_rows.n_elements()), (indices.empty() ? nullptr : - reinterpret_cast(&indices[0])), + reinterpret_cast(indices.data())), 0, input_row_map.Comm()); if (relevant_map.SameAs(input_row_map)) have_ghost_rows = false; @@ -639,7 +639,7 @@ namespace TrilinosWrappers } Epetra_Map off_processor_map(-1, ghost_rows.size(), - (ghost_rows.size()>0)?(&ghost_rows[0]):nullptr, + (ghost_rows.size()>0)?(ghost_rows.data()):nullptr, 0, input_row_map.Comm()); std::shared_ptr graph; @@ -647,15 +647,15 @@ namespace TrilinosWrappers if (input_row_map.Comm().NumProc() > 1) { graph.reset (new Epetra_CrsGraph (Copy, input_row_map, - (n_entries_per_row.size()>0)?(&n_entries_per_row[0]):nullptr, + (n_entries_per_row.size()>0)?(n_entries_per_row.data()):nullptr, exchange_data ? false : true)); if (have_ghost_rows == true) nonlocal_graph.reset (new Epetra_CrsGraphMod (off_processor_map, - &n_entries_per_ghost_row[0])); + n_entries_per_ghost_row.data())); } else graph.reset (new Epetra_CrsGraph (Copy, input_row_map, input_col_map, - (n_entries_per_row.size()>0)?(&n_entries_per_row[0]):nullptr, + (n_entries_per_row.size()>0)?(n_entries_per_row.data()):nullptr, true)); // now insert the indices, select between the right matrix @@ -674,12 +674,12 @@ namespace TrilinosWrappers row_indices[col] = sparsity_pattern.column_number(global_row, col); if (input_row_map.MyGID(global_row)) - graph->InsertGlobalIndices (global_row, row_length, &row_indices[0]); + graph->InsertGlobalIndices (global_row, row_length, row_indices.data()); else { Assert(nonlocal_graph.get() != nullptr, ExcInternalError()); nonlocal_graph->InsertGlobalIndices (global_row, row_length, - &row_indices[0]); + row_indices.data()); } } @@ -937,8 +937,8 @@ namespace TrilinosWrappers ++select_index; ++it; } - set (row, col, reinterpret_cast(&row_indices[0]), - &values[0], false); + set (row, col, reinterpret_cast(row_indices.data()), + values.data(), false); } compress(VectorOperation::insert); } @@ -1015,7 +1015,7 @@ namespace TrilinosWrappers const TrilinosScalar *in_values = input_matrix[0]; TrilinosScalar *values = (*matrix)[0]; const size_type my_nonzeros = input_matrix.NumMyNonzeros(); - std::memcpy (&values[0], &in_values[0], + std::memcpy (values, in_values, my_nonzeros*sizeof (TrilinosScalar)); } @@ -1347,7 +1347,7 @@ namespace TrilinosWrappers ExcDimensionMismatch(col_indices.size(), values.n())); for (size_type i=0; iNumGlobalIndices(static_cast(row))); int n_indices = 0; graph->ExtractGlobalRowCopy(static_cast(row), - indices.size(), n_indices, &indices[0]); + indices.size(), n_indices, indices.data()); AssertDimension(static_cast(n_indices), indices.size()); for (TrilinosWrappers::types::int_type i=0; i 1) graph.reset(new Epetra_FECrsGraph(Copy, row_map, - &local_entries_per_row[0], + local_entries_per_row.data(), false // TODO: Check which new Trilinos // version supports this... Remember @@ -333,7 +333,7 @@ namespace TrilinosWrappers )); else graph.reset(new Epetra_FECrsGraph(Copy, row_map, col_map, - &local_entries_per_row[0], + local_entries_per_row.data(), false)); } @@ -373,11 +373,11 @@ namespace TrilinosWrappers if (row_map.Comm().NumProc() > 1) graph.reset(new Epetra_FECrsGraph(Copy, row_map, - &n_entries_per_row[0], + n_entries_per_row.data(), false)); else graph.reset (new Epetra_FECrsGraph(Copy, row_map, col_map, - &n_entries_per_row[0], + n_entries_per_row.data(), false)); AssertDimension (sp.n_rows(), @@ -407,7 +407,7 @@ namespace TrilinosWrappers } } graph->Epetra_CrsGraph::InsertGlobalIndices (row, row_length, - &row_indices[0]); + row_indices.data()); } else for (size_type row=0; rowInsertGlobalIndices (1, reinterpret_cast(&row), - row_length, &row_indices[0]); + row_length, row_indices.data()); } int ierr = diff --git a/source/lac/trilinos_vector.cc b/source/lac/trilinos_vector.cc index 5e1d7041fb..d566f9863c 100644 --- a/source/lac/trilinos_vector.cc +++ b/source/lac/trilinos_vector.cc @@ -298,7 +298,7 @@ namespace TrilinosWrappers } Assert (n_elements == added_elements, ExcInternalError()); - Epetra_Map new_map (v.size(), n_elements, &global_ids[0], 0, + Epetra_Map new_map (v.size(), n_elements, global_ids.data(), 0, v.block(0).vector_partitioner().Comm()); std::shared_ptr actual_vec; diff --git a/source/multigrid/mg_transfer_internal.cc b/source/multigrid/mg_transfer_internal.cc index 69b6c14204..b0ef61090d 100644 --- a/source/multigrid/mg_transfer_internal.cc +++ b/source/multigrid/mg_transfer_internal.cc @@ -200,7 +200,7 @@ namespace internal // just send an empty message. if (data.size()) { - const int ierr = MPI_Isend(&data[0], data.size()*sizeof(data[0]), + const int ierr = MPI_Isend(data.data(), data.size()*sizeof(data[0]), MPI_BYTE, dest, 71, tria->get_communicator(), &*requests.rbegin()); AssertThrowMPI(ierr); @@ -239,7 +239,7 @@ namespace internal Assert(static_cast(count * sizeof(DoFPair)) == len, ExcInternalError()); receive_buffer.resize(count); - void *ptr = &receive_buffer[0]; + void *ptr = receive_buffer.data(); ierr = MPI_Recv(ptr, len, MPI_BYTE, status.MPI_SOURCE, status.MPI_TAG, tria->get_communicator(), &status); AssertThrowMPI(ierr); @@ -256,7 +256,7 @@ namespace internal // * wait for all MPI_Isend to complete if (requests.size() > 0) { - const int ierr = MPI_Waitall(requests.size(), &requests[0], MPI_STATUSES_IGNORE); + const int ierr = MPI_Waitall(requests.size(), requests.data(), MPI_STATUSES_IGNORE); AssertThrowMPI(ierr); requests.clear(); } diff --git a/source/multigrid/mg_transfer_prebuilt.cc b/source/multigrid/mg_transfer_prebuilt.cc index e9b3e25b0a..1b71be7c91 100644 --- a/source/multigrid/mg_transfer_prebuilt.cc +++ b/source/multigrid/mg_transfer_prebuilt.cc @@ -280,7 +280,7 @@ void MGTransferPrebuilt::build_matrices for (unsigned int i=0; iset (dof_indices_child[i], dofs_per_cell, - &dof_indices_parent[0], + dof_indices_parent.data(), &prolongation(i,0), true); }