From 04fe01c51ec6ed60478ec3d7927c271b0f2651ec Mon Sep 17 00:00:00 2001 From: Oliver Sander <sander@igpm.rwth-aachen.de> Date: Sun, 7 Mar 2010 09:28:06 +0000 Subject: [PATCH] add method secondDerivativeOfDistanceSquaredWRTSecondArgument [[Imported from SVN: r5668]] --- src/realtuple.hh | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/realtuple.hh b/src/realtuple.hh index d0a3b34e..b326cb98 100644 --- a/src/realtuple.hh +++ b/src/realtuple.hh @@ -55,6 +55,20 @@ public: static EmbeddedTangentVector derivativeOfDistanceSquaredWRTSecondArgument(const RealTuple& a, const RealTuple& b) { return -2*(a.data_ - b.data_); } + + /** \brief Compute the Hessian of the squared distance function keeping the first argument fixed + + Unlike the distance itself the squared distance is differentiable at zero + */ + static Dune::FieldMatrix<double,N,N> secondDerivativeOfDistanceSquaredWRTSecondArgument(const RealTuple& a, const RealTuple& b) { + + Dune::FieldMatrix<double,N,N> result; + for (int i=0; i<N; i++) + for (int j=0; j<N; j++) + result[i][j] = (i==j); + + return result; + } /** \brief Write LocalKey object to output stream */ friend std::ostream& operator<< (std::ostream& s, const RealTuple& realTuple) -- GitLab