Skip to content

Commit

Permalink
Bring MPI test in line with serial
Browse files Browse the repository at this point in the history
  • Loading branch information
Michael McLeod committed Oct 18, 2024
1 parent e1190b1 commit ebbfcce
Showing 1 changed file with 8 additions and 12 deletions.
20 changes: 8 additions & 12 deletions cpp/tests/mpi_algo_factory.cc
Original file line number Diff line number Diff line change
Expand Up @@ -358,16 +358,12 @@ TEST_CASE("Serial vs. Serial with MPI Forward Backward") {
const auto solution = pfitsio::read2d(expected_solution_path);
const auto residual = pfitsio::read2d(expected_residual_path);

const Image<t_complex> image = Image<t_complex>::Map(diagnostic.x.data(), imsizey, imsizex);
CAPTURE(Vector<t_complex>::Map(solution.data(), solution.size()).real().head(10));
CAPTURE(Vector<t_complex>::Map(image.data(), image.size()).real().head(10));
CAPTURE(Vector<t_complex>::Map((image / solution).eval().data(), image.size()).real().head(10));
CHECK(image.isApprox(solution, 1e-4));

const Vector<t_complex> residuals = measurements_transform->adjoint() *
(uv_data.vis - ((*measurements_transform) * diagnostic.x));
const Image<t_complex> residual_image = Image<t_complex>::Map(residuals.data(), imsizey, imsizex);
CAPTURE(Vector<t_complex>::Map(residual.data(), residual.size()).real().head(10));
CAPTURE(Vector<t_complex>::Map(residuals.data(), residuals.size()).real().head(10));
CHECK(residual_image.real().isApprox(residual.real(), 1e-4));
double average_intensity = diagnostic.x.real().sum() / diagnostic.x.size();
SOPT_HIGH_LOG("Average intensity = {}", average_intensity);
double mse = (Vector<t_complex>::Map(solution.data(), solution.size()) - diagnostic.x)
.real()
.squaredNorm() /
solution.size();
SOPT_HIGH_LOG("MSE = {}", mse);
CHECK(mse <= average_intensity * 1e-3);
}

0 comments on commit ebbfcce

Please sign in to comment.