Skip to content

Commit

Permalink
Merge #3327
Browse files Browse the repository at this point in the history
3327: core: Fixed bitwise comparison of floating point numbers r=fweik a=fweik

Partial fix for #3315.


Co-authored-by: Florian Weik <fweik@icp.uni-stuttgart.de>
  • Loading branch information
bors[bot] and fweik authored Nov 20, 2019
2 parents f23a4d0 + c5e3795 commit c91ea5e
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
8 changes: 4 additions & 4 deletions src/core/unit_tests/MpiCallbacks_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,18 +38,18 @@ static bool called = false;
BOOST_AUTO_TEST_CASE(invoke_test) {
using Communication::detail::invoke;

auto f = [](int i, double d) { return i + d; };
auto f = [](int i, unsigned j) { return i + j; };

boost::mpi::communicator world;
boost::mpi::packed_oarchive::buffer_type buff;

auto const i = 123;
auto const d = 3.1415;
boost::mpi::packed_oarchive(world, buff) << i << d;
auto const j = 456u;
boost::mpi::packed_oarchive(world, buff) << i << j;

boost::mpi::packed_iarchive ia(world, buff);

BOOST_CHECK_EQUAL(f(i, d), (invoke<decltype(f), int, double>(f, ia)));
BOOST_CHECK_EQUAL(f(i, j), (invoke<decltype(f), int, unsigned>(f, ia)));
}

/*
Expand Down
5 changes: 4 additions & 1 deletion src/utils/tests/matrix_vector_product.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,16 @@

#include "utils/math/matrix_vector_product.hpp"

#include <limits>

extern constexpr std::array<std::array<int, 3>, 3> matrix{
{{{1, 2, 9}}, {{8, 41, 6}}, {{31, 15, 99}}}};

BOOST_AUTO_TEST_CASE(inner_product) {
const std::array<double, 3> vector{{0.5, 1.25, 3.1}};
auto const result = Utils::matrix_vector_product<double, 3, matrix>(vector);
for (int i = 0; i < 3; ++i) {
BOOST_CHECK(result[i] == boost::inner_product(matrix[i], vector, 0.0));
BOOST_CHECK_CLOSE(result[i], boost::inner_product(matrix[i], vector, 0.0),
std::numeric_limits<double>::epsilon());
}
}

0 comments on commit c91ea5e

Please sign in to comment.