From 9dafdb468e8e157469a51470e172c19ea254dce5 Mon Sep 17 00:00:00 2001
From: Oliver Sander <sander@igpm.rwth-aachen.de>
Date: Thu, 11 Feb 2010 21:39:58 +0000
Subject: [PATCH] implement derivativeOfDistanceSquaredWRTSecondArgument()

[[Imported from SVN: r5547]]
---
 src/realtuple.hh | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/src/realtuple.hh b/src/realtuple.hh
index c16fe23a..d0a3b34e 100644
--- a/src/realtuple.hh
+++ b/src/realtuple.hh
@@ -48,6 +48,14 @@ public:
         return -gradient/distance(a,b);
     }
     
+    /** \brief Compute the gradient of the squared distance function keeping the first argument fixed
+
+    Unlike the distance itself the squared distance is differentiable at zero
+     */
+    static EmbeddedTangentVector derivativeOfDistanceSquaredWRTSecondArgument(const RealTuple& a, const RealTuple& b) {
+        return -2*(a.data_ - b.data_);
+    }
+    
     /** \brief Write LocalKey object to output stream */
     friend std::ostream& operator<< (std::ostream& s, const RealTuple& realTuple)
     {
-- 
GitLab