diff --git a/src/algebra/TinyVector.hpp b/src/algebra/TinyVector.hpp index 88f200720185fa6674f289356305428e6a123454..35cdb5d35f219979a406d3de0fe49e73924af7d8 100644 --- a/src/algebra/TinyVector.hpp +++ b/src/algebra/TinyVector.hpp @@ -10,7 +10,7 @@ template <size_t N, typename T=double> class TinyVector { -private: + private: T m_values[N]; static_assert((N>0),"TinyVector size must be strictly positive"); @@ -26,7 +26,7 @@ private: this->_unpackVariadicInput(args...); } -public: + public: KOKKOS_INLINE_FUNCTION TinyVector operator-() const { @@ -247,4 +247,15 @@ T l2Norm(const TinyVector<N,T>& x) return std::sqrt((x,x)); } +// Cross product is only defined for K^3 vectors +template <typename T> +KOKKOS_INLINE_FUNCTION +TinyVector<3,T> crossProduct(const TinyVector<3,T>& u, const TinyVector<3,T>& v) +{ + TinyVector<3,T> cross_product(u[1]*v[2]-u[2]*v[1], + u[2]*v[0]-u[0]*v[2], + u[0]*v[1]-u[1]*v[0]); + return std::move(cross_product); +} + #endif // TINYVECTOR_HPP