From 3f033a907205b52cfe4a45a9eff3ab756500e124 Mon Sep 17 00:00:00 2001 From: Oliver Sander <sander@igpm.rwth-aachen.de> Date: Fri, 1 Apr 2011 12:51:56 +0000 Subject: [PATCH] some cleanup of secondDerivativeOfDistanceSquaredWRTSecondArgument [[Imported from SVN: r7050]] --- dune/gfe/unitvector.hh | 22 ++++++++-------------- 1 file changed, 8 insertions(+), 14 deletions(-) diff --git a/dune/gfe/unitvector.hh b/dune/gfe/unitvector.hh index e180b4b1..ca57b78b 100644 --- a/dune/gfe/unitvector.hh +++ b/dune/gfe/unitvector.hh @@ -160,22 +160,16 @@ public: */ static Dune::FieldMatrix<double,N,N> secondDerivativeOfDistanceSquaredWRTSecondArgument(const UnitVector& p, const UnitVector& q) { - Dune::FieldMatrix<double,N,N> result; - double sp = p.data_ * q.data_; - - // Compute vector A (see notes) - Dune::FieldMatrix<double,1,N> row; - row[0] = q.projectOntoTangentSpace(p.globalCoordinates()); - row *= secondDerivativeOfArcCosSquared(sp); - - Dune::FieldMatrix<double,N,1> column; - for (int i=0; i<N; i++) - column[i] = p.globalCoordinates()[i] - q.globalCoordinates()[i]*sp; + + Dune::FieldVector<double,N> pProjected = q.projectOntoTangentSpace(p.globalCoordinates()); Dune::FieldMatrix<double,N,N> A; - // A = row * column - Dune::FMatrixHelp::multMatrix(column,row,A); + for (int i=0; i<N; i++) + for (int j=0; j<N; j++) + A[i][j] = pProjected[i]*pProjected[j]; + + A *= secondDerivativeOfArcCosSquared(sp); // Compute matrix B (see notes) Dune::FieldMatrix<double,N,N> B; @@ -184,7 +178,7 @@ public: B[i][j] = (i==j)*sp + p.data_[i]*q.data_[j]; // Bring it all together - result = A; + Dune::FieldMatrix<double,N,N> result = A; result.axpy(-1*derivativeOfArcCosSquared(sp), B); for (int i=0; i<N; i++) -- GitLab