Skip to content
Snippets Groups Projects
Commit 0d2b8290 authored by Oliver Sander's avatar Oliver Sander Committed by sander@PCPOOL.MI.FU-BERLIN.DE
Browse files

rewrite the gradient assembler such as to demand the derivative of the...

rewrite the gradient assembler such as to demand the derivative of the _squared_ distance from the target space.  Unlike the distance itself, the squared distance is differentiable at zero

[[Imported from SVN: r5546]]
parent 59b577fd
No related branches found
No related tags found
No related merge requests found
...@@ -33,9 +33,16 @@ public: ...@@ -33,9 +33,16 @@ public:
typename TargetSpace::EmbeddedTangentVector& gradient) const typename TargetSpace::EmbeddedTangentVector& gradient) const
{ {
gradient = 0; gradient = 0;
#if 0 // This old code uses the derivative of dist(,), which is (frequently, at least)
// not differentiable at 0
for (size_t i=0; i<coefficients_.size(); i++) for (size_t i=0; i<coefficients_.size(); i++)
gradient.axpy(weights_[i]*TargetSpace::distance(coefficients_[i], x), gradient.axpy(weights_[i]*TargetSpace::distance(coefficients_[i], x),
TargetSpace::derivativeOfDistanceWRTSecondArgument(coefficients_[i], x)); TargetSpace::derivativeOfDistanceWRTSecondArgument(coefficients_[i], x));
#else
for (size_t i=0; i<coefficients_.size(); i++)
gradient.axpy(0.5*weights_[i],
TargetSpace::derivativeOfDistanceSquaredWRTSecondArgument(coefficients_[i], x));
#endif
} }
void assembleMatrix(const TargetSpace& x, void assembleMatrix(const TargetSpace& x,
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment