Skip to content

Commit

Permalink
Change deduction guide for Vector
Browse files Browse the repository at this point in the history
  • Loading branch information
aprokop committed May 2, 2024
1 parent ed0119c commit 09b1977
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
7 changes: 2 additions & 5 deletions src/details/ArborX_DetailsVector.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -70,11 +70,8 @@ struct Vector
}
};

template <typename... T>
Vector(T...) -> Vector<
sizeof...(T),
std::conditional_t<(... || std::is_same_v<std::decay_t<T>, double>), double,
float>>;
template <typename T, typename... U>
Vector(T, U...) -> Vector<1 + sizeof...(U), T>;

} // namespace ArborX::Details

Expand Down
9 changes: 6 additions & 3 deletions test/tstDetailsVector.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,17 +12,17 @@

#include <boost/test/unit_test.hpp>

using ArborX::Details::Vector;
using ArborX::ExperimentalHyperGeometry::Point;

BOOST_AUTO_TEST_CASE(make_euclidean_vector)
{
using Point = ArborX::ExperimentalHyperGeometry::Point<3, float>;
using Vector = ArborX::Details::Vector<3, float>;
static_assert(Point{1, 2, 3} - Point{0, 0, 0} == Vector{1, 2, 3});
static_assert(Point{4, 5, 6} - Point{1, 2, 3} == Vector{3, 3, 3});
}

BOOST_AUTO_TEST_CASE(vector_dot_product)
{
using Vector = ArborX::Details::Vector<3, float>;
static_assert(Vector{1, 0, 0}.dot(Vector{1, 0, 0}) == 1);
static_assert(Vector{1, 0, 0}.dot(Vector{0, 1, 0}) == 0);
static_assert(Vector{1, 0, 0}.dot(Vector{0, 0, 1}) == 0);
Expand All @@ -31,12 +31,15 @@ BOOST_AUTO_TEST_CASE(vector_dot_product)

BOOST_AUTO_TEST_CASE(vector_norm)
{
using Vector = ArborX::Details::Vector<3, float>;
BOOST_TEST((Vector{3, 4}.norm()) == 5);
BOOST_TEST((Vector{6, 13, 18}.norm()) == 23);
}

BOOST_AUTO_TEST_CASE(vector_cross_product)
{
using Vector = ArborX::Details::Vector<3, float>;

// clang-format off
static_assert(Vector{1, 0, 0}.cross(Vector{1, 0, 0}) == Vector{0, 0, 0});
static_assert(Vector{1, 0, 0}.cross(Vector{0, 1, 0}) == Vector{0, 0, 1});
Expand Down

0 comments on commit 09b1977

Please sign in to comment.