diff --git a/dune/solvers/common/arithmetic.hh b/dune/solvers/common/arithmetic.hh index fee061f63ff6176d43ac45e587e94d2aee15a09f..b1d682be9c7314a3a3809c1f51d0e226670734fb 100644 --- a/dune/solvers/common/arithmetic.hh +++ b/dune/solvers/common/arithmetic.hh @@ -14,6 +14,7 @@ #include <dune/istl/scaledidmatrix.hh> #include <dune/matrix-vector/axpy.hh> +#include <dune/matrix-vector/crossproduct.hh> #include <dune/matrix-vector/transpose.hh> #include <dune/solvers/common/resize.hh> @@ -145,32 +146,6 @@ namespace Arithmetic template <bool Condition, typename Type=void> using enable_if_t = typename std::enable_if<Condition, Type>::type; - //! Helper class for computing the cross product - template <class T, int n> - struct CrossProductHelper - { - static Dune::FieldVector<T,n> crossProduct(const Dune::FieldVector<T,n>& a, const Dune::FieldVector<T,n>& b) - { - DUNE_UNUSED_PARAMETER(a); - DUNE_UNUSED_PARAMETER(b); - DUNE_THROW(Dune::Exception, "You can only call crossProduct with dim==3"); - } - }; - - //! Specialisation for n=3 - template <class T> - struct CrossProductHelper<T,3> - { - static Dune::FieldVector<T,3> crossProduct(const Dune::FieldVector<T,3>& a, const Dune::FieldVector<T,3>& b) - { - Dune::FieldVector<T,3> r; - r[0] = a[1]*b[2] - a[2]*b[1]; - r[1] = a[2]*b[0] - a[0]*b[2]; - r[2] = a[0]*b[1] - a[1]*b[0]; - return r; - } - }; - template <class MatrixType> using Transposed = typename Dune::MatrixVector::Transposed<MatrixType>; @@ -212,7 +187,7 @@ namespace Arithmetic template<class T, int n> Dune::FieldVector<T,n> crossProduct(const Dune::FieldVector<T,n>& a, const Dune::FieldVector<T,n>& b) { - return CrossProductHelper<T,n>::crossProduct(a,b); + return Dune::MatrixVector::crossProduct(a,b); } //! Compute the transposed of a matrix