From 65032fa825c4c13c60bfc43f20d197febf0e0cbd Mon Sep 17 00:00:00 2001
From: Stephane Del Pino <stephane.delpino44@gmail.com>
Date: Thu, 21 Jun 2018 12:34:20 +0200
Subject: [PATCH] Added l2Norm function

---
 src/algebra/TinyVector.hpp | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/src/algebra/TinyVector.hpp b/src/algebra/TinyVector.hpp
index 34b73118b..6f09691d1 100644
--- a/src/algebra/TinyVector.hpp
+++ b/src/algebra/TinyVector.hpp
@@ -238,4 +238,12 @@ public:
   }
 };
 
+template <size_t N, typename T>
+KOKKOS_INLINE_FUNCTION
+T l2Norm(const TinyVector<N,T>& x)
+{
+  static_assert(std::is_arithmetic<T>(),"Cannot compute L2 norm for non-arithmetic types");
+  return std::sqrt((x,x));
+}
+
 #endif // TINYVECTOR_HPP
-- 
GitLab