diff --git a/dune/gfe/unitvector.hh b/dune/gfe/unitvector.hh index a1145af47f0c2f1990cd7031e6bbaedeeb8ac1cc..734188488d5accf9b290a535ec518148507d1350 100644 --- a/dune/gfe/unitvector.hh +++ b/dune/gfe/unitvector.hh @@ -413,10 +413,13 @@ public: static DerivativeOfProjection derivativeOfProjection(const Dune::FieldVector<T,N>& p) { + auto normSquared = p.two_norm2(); + auto norm = std::sqrt(normSquared); + Dune::FieldMatrix<T,N,N> result; for (int i=0; i<N; i++) for (int j=0; j<N; j++) - result[i][j] = ( (i==j) - p[i]*p[j] / p.two_norm2() ) / p.two_norm(); + result[i][j] = ( (i==j) - p[i]*p[j] / normSquared ) / norm; return result; }