From 9486d9e45ca8e997460f8d9b6f76c85c0ed8ab74 Mon Sep 17 00:00:00 2001 From: Krishnakumar Gopalakrishnan Date: Fri, 23 Jun 2023 13:24:13 +0100 Subject: [PATCH] chore: replace postfix increment and decrement operators with their prefix equivalents --- cpp/examples/forward_backward/inpainting.cc | 2 +- .../forward_backward/inpainting_credible_interval.cc | 2 +- cpp/examples/forward_backward/inpainting_joint_map.cc | 2 +- cpp/examples/forward_backward/l2_inpainting.cc | 2 +- cpp/examples/primal_dual/inpainting.cc | 2 +- cpp/examples/primal_dual/tv_inpainting.cc | 2 +- cpp/examples/proximal_admm/inpainting.cc | 2 +- cpp/examples/proximal_admm/reweighted.cc | 2 +- cpp/examples/sdmm/inpainting.cc | 2 +- cpp/examples/sdmm/reweighted.cc | 2 +- cpp/sopt/chained_operators.h | 6 +++--- cpp/sopt/cppflow_utils.cc | 2 +- cpp/sopt/credible_region.h | 4 ++-- cpp/sopt/gradient_operator.h | 8 ++++---- cpp/sopt/imaging_primal_dual.h | 2 +- cpp/sopt/joint_map.h | 2 +- cpp/sopt/l2_primal_dual.h | 2 +- cpp/sopt/mpi/communicator.h | 4 ++-- cpp/sopt/proximal.h | 4 ++-- cpp/sopt/sdmm.h | 2 +- cpp/sopt/tf_g_proximal.h | 2 +- cpp/sopt/tv_primal_dual.h | 2 +- cpp/sopt/wavelets/innards.impl.h | 2 +- cpp/tests/communicator.cc | 4 ++-- cpp/tests/credible_region.cc | 2 +- cpp/tests/gradient_operator.cc | 4 ++-- cpp/tests/inpainting.cc | 2 +- cpp/tests/serial_vs_parallel_padmm.cc | 2 +- cpp/tests/tf_inpainting.cc | 2 +- cpp/tests/wavelets.cc | 2 +- cpp/tools_for_tests/inpainting.h | 2 +- 31 files changed, 41 insertions(+), 41 deletions(-) diff --git a/cpp/examples/forward_backward/inpainting.cc b/cpp/examples/forward_backward/inpainting.cc index f00a6845d..bc9c34921 100644 --- a/cpp/examples/forward_backward/inpainting.cc +++ b/cpp/examples/forward_backward/inpainting.cc @@ -80,7 +80,7 @@ int main(int argc, char const **argv) { SOPT_HIGH_LOG("Create dirty vector"); std::normal_distribution<> gaussian_dist(0, sigma); Vector y(y0.size()); - for (sopt::t_int i = 0; i < y0.size(); i++) y(i) = y0(i) + gaussian_dist(mersenne); + for (sopt::t_int i = 0; i < y0.size(); ++i) y(i) = y0(i) + gaussian_dist(mersenne); // Write dirty imagte to file if (output != "none") { Vector const dirty = sampling.adjoint() * y; diff --git a/cpp/examples/forward_backward/inpainting_credible_interval.cc b/cpp/examples/forward_backward/inpainting_credible_interval.cc index 636db0cf5..8082f9013 100644 --- a/cpp/examples/forward_backward/inpainting_credible_interval.cc +++ b/cpp/examples/forward_backward/inpainting_credible_interval.cc @@ -82,7 +82,7 @@ int main(int argc, char const **argv) { SOPT_HIGH_LOG("Create dirty vector"); std::normal_distribution<> gaussian_dist(0, sigma); Vector y(y0.size()); - for (sopt::t_int i = 0; i < y0.size(); i++) y(i) = y0(i) + gaussian_dist(mersenne); + for (sopt::t_int i = 0; i < y0.size(); ++i) y(i) = y0(i) + gaussian_dist(mersenne); // Write dirty imagte to file if (output != "none") { Vector const dirty = sampling.adjoint() * y; diff --git a/cpp/examples/forward_backward/inpainting_joint_map.cc b/cpp/examples/forward_backward/inpainting_joint_map.cc index 6d57ab9c1..440a8fff4 100644 --- a/cpp/examples/forward_backward/inpainting_joint_map.cc +++ b/cpp/examples/forward_backward/inpainting_joint_map.cc @@ -81,7 +81,7 @@ int main(int argc, char const **argv) { SOPT_HIGH_LOG("Create dirty vector"); std::normal_distribution<> gaussian_dist(0, sigma); Vector y(y0.size()); - for (sopt::t_int i = 0; i < y0.size(); i++) y(i) = y0(i) + gaussian_dist(mersenne); + for (sopt::t_int i = 0; i < y0.size(); ++i) y(i) = y0(i) + gaussian_dist(mersenne); // Write dirty imagte to file if (output != "none") { Vector const dirty = sampling.adjoint() * y; diff --git a/cpp/examples/forward_backward/l2_inpainting.cc b/cpp/examples/forward_backward/l2_inpainting.cc index 0a330706d..3a044c673 100644 --- a/cpp/examples/forward_backward/l2_inpainting.cc +++ b/cpp/examples/forward_backward/l2_inpainting.cc @@ -78,7 +78,7 @@ int main(int argc, char const **argv) { SOPT_HIGH_LOG("Create dirty vector"); std::normal_distribution<> gaussian_dist(0, sigma); Vector y(y0.size()); - for (sopt::t_int i = 0; i < y0.size(); i++) y(i) = y0(i) + gaussian_dist(mersenne); + for (sopt::t_int i = 0; i < y0.size(); ++i) y(i) = y0(i) + gaussian_dist(mersenne); // Write dirty imagte to file if (output != "none") { Vector const dirty = sampling.adjoint() * y; diff --git a/cpp/examples/primal_dual/inpainting.cc b/cpp/examples/primal_dual/inpainting.cc index deba7205c..b73e283cb 100644 --- a/cpp/examples/primal_dual/inpainting.cc +++ b/cpp/examples/primal_dual/inpainting.cc @@ -89,7 +89,7 @@ int main(int argc, char const **argv) { SOPT_HIGH_LOG("Create dirty vector"); std::normal_distribution<> gaussian_dist(0, sigma); Vector y(y0.size()); - for (sopt::t_int i = 0; i < y0.size(); i++) y(i) = y0(i) + gaussian_dist(mersenne); + for (sopt::t_int i = 0; i < y0.size(); ++i) y(i) = y0(i) + gaussian_dist(mersenne); // Write dirty image to file if (output != "none") { Vector const dirty = sampling.adjoint() * y; diff --git a/cpp/examples/primal_dual/tv_inpainting.cc b/cpp/examples/primal_dual/tv_inpainting.cc index 8d1326a52..92a3702b7 100644 --- a/cpp/examples/primal_dual/tv_inpainting.cc +++ b/cpp/examples/primal_dual/tv_inpainting.cc @@ -82,7 +82,7 @@ int main(int argc, char const **argv) { SOPT_HIGH_LOG("Create dirty vector"); std::normal_distribution<> gaussian_dist(0, sigma); Vector y(y0.size()); - for (sopt::t_int i = 0; i < y0.size(); i++) y(i) = y0(i) + gaussian_dist(mersenne); + for (sopt::t_int i = 0; i < y0.size(); ++i) y(i) = y0(i) + gaussian_dist(mersenne); // Write dirty image to file if (output != "none") { Vector const dirty = sampling.adjoint() * y; diff --git a/cpp/examples/proximal_admm/inpainting.cc b/cpp/examples/proximal_admm/inpainting.cc index 3e9715750..99d62b236 100644 --- a/cpp/examples/proximal_admm/inpainting.cc +++ b/cpp/examples/proximal_admm/inpainting.cc @@ -75,7 +75,7 @@ int main(int argc, char const **argv) { SOPT_HIGH_LOG("Create dirty vector"); std::normal_distribution<> gaussian_dist(0, sigma); Vector y(y0.size()); - for (sopt::t_int i = 0; i < y0.size(); i++) y(i) = y0(i) + gaussian_dist(mersenne); + for (sopt::t_int i = 0; i < y0.size(); ++i) y(i) = y0(i) + gaussian_dist(mersenne); // Write dirty imagte to file if (output != "none") { Vector const dirty = sampling.adjoint() * y; diff --git a/cpp/examples/proximal_admm/reweighted.cc b/cpp/examples/proximal_admm/reweighted.cc index 1d9279bf3..2047ca8e3 100644 --- a/cpp/examples/proximal_admm/reweighted.cc +++ b/cpp/examples/proximal_admm/reweighted.cc @@ -79,7 +79,7 @@ int main(int argc, char const **argv) { SOPT_MEDIUM_LOG("Create dirty vector"); std::normal_distribution<> gaussian_dist(0, sigma); Vector y(y0.size()); - for (sopt::t_int i = 0; i < y0.size(); i++) y(i) = y0(i) + gaussian_dist(mersenne); + for (sopt::t_int i = 0; i < y0.size(); ++i) y(i) = y0(i) + gaussian_dist(mersenne); // Write dirty imagte to file if (output != "none") { Vector const dirty = sampling.adjoint() * y; diff --git a/cpp/examples/sdmm/inpainting.cc b/cpp/examples/sdmm/inpainting.cc index a1849d0b5..205e953ef 100644 --- a/cpp/examples/sdmm/inpainting.cc +++ b/cpp/examples/sdmm/inpainting.cc @@ -74,7 +74,7 @@ int main(int argc, char const **argv) { SOPT_HIGH_LOG("Create dirty vector"); std::normal_distribution<> gaussian_dist(0, sigma); Vector y(y0.size()); - for (sopt::t_int i = 0; i < y0.size(); i++) y(i) = y0(i) + gaussian_dist(mersenne); + for (sopt::t_int i = 0; i < y0.size(); ++i) y(i) = y0(i) + gaussian_dist(mersenne); // Write dirty imagte to file if (output != "none") { Vector const dirty = sampling.adjoint() * y; diff --git a/cpp/examples/sdmm/reweighted.cc b/cpp/examples/sdmm/reweighted.cc index 7860dc333..010522f6b 100644 --- a/cpp/examples/sdmm/reweighted.cc +++ b/cpp/examples/sdmm/reweighted.cc @@ -78,7 +78,7 @@ int main(int argc, char const **argv) { SOPT_HIGH_LOG("Create dirty vector"); std::normal_distribution<> gaussian_dist(0, sigma); Vector y(y0.size()); - for (sopt::t_int i = 0; i < y0.size(); i++) y(i) = y0(i) + gaussian_dist(mersenne); + for (sopt::t_int i = 0; i < y0.size(); ++i) y(i) = y0(i) + gaussian_dist(mersenne); // Write dirty imagte to file if (output != "none") { Vector const dirty = sampling.adjoint() * y; diff --git a/cpp/sopt/chained_operators.h b/cpp/sopt/chained_operators.h index 3c4694ffd..479f07e6a 100644 --- a/cpp/sopt/chained_operators.h +++ b/cpp/sopt/chained_operators.h @@ -23,12 +23,12 @@ OperatorFunction chained_operators(OperatorFunction const &arg0, T const (*first)(output, input); else { (*first)(*buffer, input); - first++; + ++first; (*first)(output, *buffer); } - for (++first; first != last; first++) { + for (++first; first != last; ++first) { (*first)(*buffer, output); - first++; + ++first; (*first)(output, *buffer); } }; diff --git a/cpp/sopt/cppflow_utils.cc b/cpp/sopt/cppflow_utils.cc index 90c8dd10f..723de7db6 100644 --- a/cpp/sopt/cppflow_utils.cc +++ b/cpp/sopt/cppflow_utils.cc @@ -70,7 +70,7 @@ namespace cppflowutils { cppflow::tensor convert_image_to_tensor(sopt::Vector> const &image, int image_rows, int image_cols) { std::vector input_values(image_rows); - for(int i = 0; i < image_rows; i++) + for(int i = 0; i < image_rows; ++i) { if(std::abs(image(i).real()) > cppflowutils::imaginary_threshold) { diff --git a/cpp/sopt/credible_region.h b/cpp/sopt/credible_region.h index 292271ac5..cdb990b56 100644 --- a/cpp/sopt/credible_region.h +++ b/cpp/sopt/credible_region.h @@ -145,8 +145,8 @@ credible_interval_grid(const Eigen::MatrixBase &solution, const t_uint &rows, Image credible_grid_upper_bound = Image::Zero(grid_rows, grid_cols); Image credible_grid_mean = Image::Zero(grid_rows, grid_cols); SOPT_LOW_LOG("Starting calculation of credible interval: {} x {} grid.", grid_rows, grid_cols); - for (t_uint i = 0; i < grid_rows; i++) { - for (t_uint j = 0; j < grid_cols; j++) { + for (t_uint i = 0; i < grid_rows; ++i) { + for (t_uint j = 0; j < grid_cols; ++j) { const t_uint start_row = i * drow; const t_uint start_col = j * dcol; if (static_cast(rows - start_row - drow) < 0) diff --git a/cpp/sopt/gradient_operator.h b/cpp/sopt/gradient_operator.h index 906aea5dc..d9c9984ab 100644 --- a/cpp/sopt/gradient_operator.h +++ b/cpp/sopt/gradient_operator.h @@ -28,9 +28,9 @@ template Vector diff2d(const Vector &x, const t_int rows, const t_int cols) { Matrix output = Matrix::Zero(rows, 2 * cols); const Matrix &input_image = Matrix::Map(x.data(), rows, cols); - for (Eigen::Index i(0); i < rows; i++) + for (Eigen::Index i(0); i < rows; ++i) output.block(0, 0, rows, cols).row(i) = diff(input_image.row(i)); - for (Eigen::Index i(0); i < cols; i++) + for (Eigen::Index i(0); i < cols; ++i) output.block(0, cols, rows, cols).col(i) = diff(input_image.col(i)); return Vector::Map(output.data(), output.size()); } @@ -39,9 +39,9 @@ template Vector diff2d_adjoint(const Vector &x, const t_int rows, const t_int cols) { const Matrix &input_image = Matrix::Map(x.data(), rows, 2 * cols); Matrix output = Matrix::Zero(rows, cols); - for (Eigen::Index i(0); i < rows; i++) + for (Eigen::Index i(0); i < rows; ++i) output.row(i) += diff_adjoint(input_image.block(0, 0, rows, cols).row(i)); - for (Eigen::Index i(0); i < cols; i++) + for (Eigen::Index i(0); i < cols; ++i) output.col(i) += diff_adjoint(input_image.block(0, cols, rows, cols).col(i)); return Vector::Map(output.data(), output.size()); } diff --git a/cpp/sopt/imaging_primal_dual.h b/cpp/sopt/imaging_primal_dual.h index 1274fce7b..9850452b3 100644 --- a/cpp/sopt/imaging_primal_dual.h +++ b/cpp/sopt/imaging_primal_dual.h @@ -318,7 +318,7 @@ typename ImagingPrimalDual::Diagnostic ImagingPrimalDual::operat auto const g_proximal = [this](t_Vector &out, Real gamma, t_Vector const &x) { this->l2ball_proximal()(out, gamma, x); // applying preconditioning - for (t_int i = 0; i < this->precondition_iters(); i++) + for (t_int i = 0; i < this->precondition_iters(); ++i) this->l2ball_proximal()( out, gamma, out - this->precondition_stepsize() * diff --git a/cpp/sopt/joint_map.h b/cpp/sopt/joint_map.h index fa3e69f90..7801d29b2 100644 --- a/cpp/sopt/joint_map.h +++ b/cpp/sopt/joint_map.h @@ -104,7 +104,7 @@ class JointMAP { typedef typename ALGORITHM::DiagnosticAndResult ResultType; ResultType result = (*(this->algo_ptr_))(std::forward(args)...); t_real gamma = 0; - niters++; + ++niters; t_uint algo_iters(result.niters); for (; (not converged) && (niters < itermax()); ++niters) { SOPT_LOW_LOG(" - [JMAP] Iteration {}/{}", niters, itermax()); diff --git a/cpp/sopt/l2_primal_dual.h b/cpp/sopt/l2_primal_dual.h index b1c478427..ea9058baf 100644 --- a/cpp/sopt/l2_primal_dual.h +++ b/cpp/sopt/l2_primal_dual.h @@ -317,7 +317,7 @@ typename ImagingPrimalDual::Diagnostic ImagingPrimalDual::operat auto const g_proximal = [this](t_Vector &out, Real gamma, t_Vector const &x) { this->l2ball_proximal()(out, gamma, x); // applying preconditioning - for (t_int i = 0; i < this->precondition_iters(); i++) + for (t_int i = 0; i < this->precondition_iters(); ++i) this->l2ball_proximal()( out, gamma, out - this->precondition_stepsize() * diff --git a/cpp/sopt/mpi/communicator.h b/cpp/sopt/mpi/communicator.h index 2441f4669..05902b511 100644 --- a/cpp/sopt/mpi/communicator.h +++ b/cpp/sopt/mpi/communicator.h @@ -334,7 +334,7 @@ Communicator::all_to_allv(const std::vector &vec, std::vector const &s return vec; } std::vector rec_sizes(send_sizes.size(), 0); - for (t_int i = 0; i < size(); i++) { + for (t_int i = 0; i < size(); ++i) { if (i == rank()) rec_sizes = gather(send_sizes[i], i); else @@ -383,7 +383,7 @@ typename std::enable_if::value, Vector>::type Communica return vec; } std::vector rec_sizes(send_sizes.size(), 0); - for (t_int i = 0; i < size(); i++) { + for (t_int i = 0; i < size(); ++i) { if (i == rank()) rec_sizes = gather(send_sizes[i], i); else diff --git a/cpp/sopt/proximal.h b/cpp/sopt/proximal.h index d94f358bb..88b37ea79 100644 --- a/cpp/sopt/proximal.h +++ b/cpp/sopt/proximal.h @@ -101,7 +101,7 @@ void tv_norm(Eigen::DenseBase &out, typename real_type: typename T1::PlainObject const &u = x.segment(0, size); typename T1::PlainObject const &v = x.segment(size, size); out = T0::Zero(size * 2); - for (typename Eigen::Index i(0); i < size; i++) { + for (typename Eigen::Index i(0); i < size; ++i) { const t_real norm = std::sqrt(std::abs(u(i) * u(i) + v(i) * v(i))); if (norm > gamma) { out(i) = (1 - gamma / norm) * u(i); @@ -119,7 +119,7 @@ void tv_norm(Eigen::DenseBase &out, Eigen::DenseBase const &gamma, typename T1::PlainObject const &u = x.segment(0, size); typename T1::PlainObject const &v = x.segment(size, size); out = T0::Zero(size * 2); - for (typename Eigen::Index i(0); i < size; i++) { + for (typename Eigen::Index i(0); i < size; ++i) { const t_real norm = std::sqrt(std::abs(u(i) * u(i) + v(i) * v(i))); if (norm > gamma(i)) { out(i) = (1 - gamma(i) / norm) * u(i); diff --git a/cpp/sopt/sdmm.h b/cpp/sopt/sdmm.h index 7d7453bea..610967558 100644 --- a/cpp/sopt/sdmm.h +++ b/cpp/sopt/sdmm.h @@ -275,7 +275,7 @@ void SDMM::update_directions(t_Vectors &y, t_Vectors &z, t_Vector const template void SDMM::initialization(t_Vectors &y, t_Vectors &z, t_Vector const &x) const { SOPT_TRACE("Initializing SDMM"); - for (t_uint i(0); i < transforms().size(); i++) { + for (t_uint i(0); i < transforms().size(); ++i) { y[i] = transforms(i) * x; z[i].resize(y[i].size()); z[i].fill(0); diff --git a/cpp/sopt/tf_g_proximal.h b/cpp/sopt/tf_g_proximal.h index 4be635e22..adae38353 100644 --- a/cpp/sopt/tf_g_proximal.h +++ b/cpp/sopt/tf_g_proximal.h @@ -106,7 +106,7 @@ class TFGProximal : public GProximal { // https://stackoverflow.com/questions/3786360/confusing-template-error auto output_vector = model_output[0].template get_data(); - for(int i = 0; i < image_size; i++) { + for(int i = 0; i < image_size; ++i) { image_out[i] = static_cast(output_vector[i]); } } diff --git a/cpp/sopt/tv_primal_dual.h b/cpp/sopt/tv_primal_dual.h index 0ee1149c0..7392152b2 100644 --- a/cpp/sopt/tv_primal_dual.h +++ b/cpp/sopt/tv_primal_dual.h @@ -316,7 +316,7 @@ typename TVPrimalDual::Diagnostic TVPrimalDual::operator()( auto const g_proximal = [this](t_Vector &out, Real gamma, t_Vector const &x) { this->l2ball_proximal()(out, gamma, x); // applying preconditioning - for (t_int i = 0; i < this->precondition_iters(); i++) + for (t_int i = 0; i < this->precondition_iters(); ++i) this->l2ball_proximal()( out, gamma, out - this->precondition_stepsize() * diff --git a/cpp/sopt/wavelets/innards.impl.h b/cpp/sopt/wavelets/innards.impl.h index 5135225d0..4588ac8c0 100644 --- a/cpp/sopt/wavelets/innards.impl.h +++ b/cpp/sopt/wavelets/innards.impl.h @@ -128,7 +128,7 @@ void up_convolve_sum(Eigen::ArrayBase &result, Eigen::ArrayBase const &c #ifdef SOPT_OPENMP #pragma omp parallel for #endif - for (typename T0::Index i = 0; i < result.size() / 2; i++) { + for (typename T0::Index i = 0; i < result.size() / 2; ++i) { result(2 * i + index_place_even) = periodic_scalar_product(coeffs.head(Nlow), low_even, i + even_offset) + periodic_scalar_product(coeffs.tail(Nhigh), high_even, i + even_offset); diff --git a/cpp/tests/communicator.cc b/cpp/tests/communicator.cc index 6908204f9..dc2cff44c 100644 --- a/cpp/tests/communicator.cc +++ b/cpp/tests/communicator.cc @@ -60,7 +60,7 @@ TEST_CASE("Creates an mpi communicator") { auto const result = world.scatter_one(scattered); REQUIRE(result == world.rank() + 2); auto const gathered = world.gather(result); - for (decltype(gathered)::size_type i = 0; i < gathered.size(); i++) + for (decltype(gathered)::size_type i = 0; i < gathered.size(); ++i) CHECK(gathered[i] == scattered[i]); } else { auto const result = world.scatter_one(); @@ -160,7 +160,7 @@ TEST_CASE("Creates an mpi communicator") { Vector::Constant(std::accumulate(sizes.begin(), sizes.end(), 0), world.rank()); const Vector output = world.all_to_allv(sendee, sizes); t_int sum = 0; - for (t_int i = 0; i < world.size() - 1; i++) { + for (t_int i = 0; i < world.size() - 1; ++i) { const Vector expected = Vector::Constant(i + 1, i + 1); CAPTURE(sum); CAPTURE(i); diff --git a/cpp/tests/credible_region.cc b/cpp/tests/credible_region.cc index bc99cf3f6..de02d86b2 100644 --- a/cpp/tests/credible_region.cc +++ b/cpp/tests/credible_region.cc @@ -19,7 +19,7 @@ TEST_CASE("calculating gamma") { }; const t_Vector x = t_Vector::Random(N); CHECK(0 == energy_function(x)); - for (t_uint i = 1; i < 10; i++) { + for (t_uint i = 1; i < 10; ++i) { const t_real alpha = 0.9 + i * 0.01; const t_real gamma = credible_region::compute_energy_upper_bound(alpha, x, energy_function); CHECK(gamma == Approx(N * (std::sqrt(16 * std::log(3 / (1 - alpha)) / N) + 1))); diff --git a/cpp/tests/gradient_operator.cc b/cpp/tests/gradient_operator.cc index c3eee11bf..7b4f4d85a 100644 --- a/cpp/tests/gradient_operator.cc +++ b/cpp/tests/gradient_operator.cc @@ -26,7 +26,7 @@ TEST_CASE("Gradient Operator") { Image const image = sopt::notinstalled::read_standard_tiff("cameraman256"); auto const psi = sopt::gradient_operator::gradient_operator(image.rows(), image.cols()); Matrix input = Matrix::Ones(image.rows(), image.cols()); - for (Eigen::Index i(0); i < image.rows(); i++) input.row(i) *= static_cast(i); + for (Eigen::Index i(0); i < image.rows(); ++i) input.row(i) *= static_cast(i); Vector output = psi.adjoint() * Vector::Map(input.data(), input.size()); CAPTURE(output.segment(0, 5)); CAPTURE(output.segment(image.size(), 5)); @@ -35,7 +35,7 @@ TEST_CASE("Gradient Operator") { CHECK(output.segment(input.size(), input.size() - 1) .isApprox(Vector::Constant(0.5, input.size() - 1))); input = Matrix::Ones(image.rows(), image.cols()); - for (Eigen::Index i(0); i < image.cols(); i++) input.col(i) *= static_cast(i); + for (Eigen::Index i(0); i < image.cols(); ++i) input.col(i) *= static_cast(i); output = psi.adjoint() * Vector::Map(input.data(), input.size()); CAPTURE(output.segment(0, 5)); CAPTURE(output.segment(image.size(), 5)); diff --git a/cpp/tests/inpainting.cc b/cpp/tests/inpainting.cc index 1f674a0d3..6bebcf49b 100644 --- a/cpp/tests/inpainting.cc +++ b/cpp/tests/inpainting.cc @@ -50,7 +50,7 @@ TEST_CASE("Inpainting"){ std::normal_distribution<> gaussian_dist(0, sigma); Vector y(y0.size()); - for (sopt::t_int i = 0; i < y0.size(); i++) y(i) = y0(i) + gaussian_dist(*mersenne); + for (sopt::t_int i = 0; i < y0.size(); ++i) y(i) = y0(i) + gaussian_dist(*mersenne); sopt::t_real const gamma = 18; sopt::t_real const beta = sigma * sigma * 0.5; diff --git a/cpp/tests/serial_vs_parallel_padmm.cc b/cpp/tests/serial_vs_parallel_padmm.cc index 31cd71c2f..9fee10a52 100644 --- a/cpp/tests/serial_vs_parallel_padmm.cc +++ b/cpp/tests/serial_vs_parallel_padmm.cc @@ -69,7 +69,7 @@ TEST_CASE("Parallel vs serial inpainting") { std::normal_distribution<> gaussian_dist(0, sigma); Vector y = world.is_root() ? y0 : world.broadcast(); if (world.is_root()) { - for (sopt::t_int i = 0; i < y0.size(); i++) y(i) += gaussian_dist(*mersenne); + for (sopt::t_int i = 0; i < y0.size(); ++i) y(i) += gaussian_dist(*mersenne); world.broadcast(y); } if (split_comm.size() > 1) { diff --git a/cpp/tests/tf_inpainting.cc b/cpp/tests/tf_inpainting.cc index 4e762282c..50a0d245f 100644 --- a/cpp/tests/tf_inpainting.cc +++ b/cpp/tests/tf_inpainting.cc @@ -46,7 +46,7 @@ TEST_CASE("Inpainting"){ std::normal_distribution<> gaussian_dist(0, sigma); Vector y(y0.size()); - for (sopt::t_int i = 0; i < y0.size(); i++) y(i) = y0(i) + gaussian_dist(*mersenne); + for (sopt::t_int i = 0; i < y0.size(); ++i) y(i) = y0(i) + gaussian_dist(*mersenne); sopt::t_real const gamma = 18; sopt::t_real const beta = sigma * sigma * 0.5; diff --git a/cpp/tests/wavelets.cc b/cpp/tests/wavelets.cc index 84af0d031..e0344a0ca 100644 --- a/cpp/tests/wavelets.cc +++ b/cpp/tests/wavelets.cc @@ -60,7 +60,7 @@ void check_round_trip(Eigen::ArrayBase const &input_, sopt::t_uint db, } TEST_CASE("wavelet data") { - for (sopt::t_int num = 1; num < 100; num++) { + for (sopt::t_int num = 1; num < 100; ++num) { if (num < 39) REQUIRE(sopt::wavelets::daubechies_data(num).coefficients.size() == 2 * num); else diff --git a/cpp/tools_for_tests/inpainting.h b/cpp/tools_for_tests/inpainting.h index 37114b386..7f29b408e 100644 --- a/cpp/tools_for_tests/inpainting.h +++ b/cpp/tools_for_tests/inpainting.h @@ -29,7 +29,7 @@ Vector dirty(sopt::LinearTransform> const &sampling, sopt::Image auto const y0 = target(sampling, image); std::normal_distribution<> gaussian_dist(0, sigma(sampling, image)); Vector y(y0.size()); - for (t_int i = 0; i < y0.size(); i++) y(i) = y0(i) + gaussian_dist(mersenne); + for (t_int i = 0; i < y0.size(); ++i) y(i) = y0(i) + gaussian_dist(mersenne); return y; }