diff --git a/src/algebra/TinyVector.hpp b/src/algebra/TinyVector.hpp index 6f09691d1f2cdfd5f8d46b64a46f28d24f5d5560..88f200720185fa6674f289356305428e6a123454 100644 --- a/src/algebra/TinyVector.hpp +++ b/src/algebra/TinyVector.hpp @@ -243,6 +243,7 @@ KOKKOS_INLINE_FUNCTION T l2Norm(const TinyVector<N,T>& x) { static_assert(std::is_arithmetic<T>(),"Cannot compute L2 norm for non-arithmetic types"); + static_assert(std::is_floating_point<T>::value, "L2 norm is defined for floating point types only"); return std::sqrt((x,x)); } diff --git a/tests/test_TinyVector.cpp b/tests/test_TinyVector.cpp index 3dd124cd3f95964893daf5621635e4503f0a0687..8f10f0127a2dc4f62cb3fada342fd1a9d3fa4d82 100644 --- a/tests/test_TinyVector.cpp +++ b/tests/test_TinyVector.cpp @@ -65,6 +65,8 @@ TEST_CASE("TinyVector", "[algebra]") { TinyVector<3,int> z1; z1 = zero; REQUIRE(((z1[0] == 0) and (z1[1] == 0) and (z1[2] == 0))); + REQUIRE(l2Norm(TinyVector<2,double>(3,4)) == Approx(5).epsilon(1E-14)); + #ifndef NDEBUG REQUIRE_THROWS_AS(x[4]=0, AssertError); const TinyVector<3,int>& const_x = x;