Skip to content
Snippets Groups Projects
Commit 73c75344 authored by Stéphane Del Pino's avatar Stéphane Del Pino
Browse files

Added cross product for TinyVector<3,T>

- just remind that cross product is only defined for dimension 3 vectors
parent bf8059e7
No related branches found
No related tags found
No related merge requests found
......@@ -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
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment