Skip to content
Snippets Groups Projects
Commit f9c9e264 authored by Sander, Oliver's avatar Sander, Oliver
Browse files

Move norm computation out of a loop

parent 7584df4c
No related branches found
No related tags found
No related merge requests found
...@@ -413,10 +413,13 @@ public: ...@@ -413,10 +413,13 @@ public:
static DerivativeOfProjection derivativeOfProjection(const Dune::FieldVector<T,N>& p) 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; Dune::FieldMatrix<T,N,N> result;
for (int i=0; i<N; i++) for (int i=0; i<N; i++)
for (int j=0; j<N; j++) 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; return result;
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment