From ae7a3bb2c4ac6f38765b4bb9009ea2d39a2c1538 Mon Sep 17 00:00:00 2001 From: Elias Pipping <elias.pipping@fu-berlin.de> Date: Wed, 7 Sep 2011 16:14:28 +0200 Subject: [PATCH] Make pseudoDirectionalDerivative private --- src/bisection-example-flexible.cc | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/src/bisection-example-flexible.cc b/src/bisection-example-flexible.cc index 61398aee..a3d06cdf 100644 --- a/src/bisection-example-flexible.cc +++ b/src/bisection-example-flexible.cc @@ -34,18 +34,6 @@ class SampleFunctional { return y * v + func_(v.two_norm()); // <1/2 Av - b,v> + H(|v|) } - // |dir|-times the directional derivative wrt dir/|dir|. - double pseudoDirectionalDerivative(const SmallVector x, - const SmallVector dir) const { - if (x == SmallVector(0.0)) - return func_.rightDifferential(0) * dir.two_norm(); - - if (x * dir > 0) - return PlusGrad(x) * dir; - else - return MinusGrad(x) * dir; - } - double directionalDerivative(const SmallVector x, const SmallVector dir) const { double norm = dir.two_norm(); @@ -143,6 +131,18 @@ class SampleFunctional { return y; } + // |dir|-times the directional derivative wrt dir/|dir|. + double pseudoDirectionalDerivative(const SmallVector x, + const SmallVector dir) const { + if (x == SmallVector(0.0)) + return func_.rightDifferential(0) * dir.two_norm(); + + if (x * dir > 0) + return PlusGrad(x) * dir; + else + return MinusGrad(x) * dir; + } + SmallVector ModifiedGradient(const SmallVector x) const { if (x == SmallVector(0.0)) { SmallVector d = SmoothGrad(x); @@ -197,7 +197,7 @@ void testSampleFunction() { SampleFunctional J(A, b); std::cout << J.directionalDerivative(b, b) << std::endl; - assert(J.pseudoDirectionalDerivative(b, b) == 10 + 2 * sqrt(5)); + assert(J.directionalDerivative(b, b) == 2 * sqrt(5) + 2); SampleFunctional::SmallVector start = b; start *= 17; @@ -223,7 +223,7 @@ void testTrivialFunction() { SampleFunctional J(A, b); std::cout << J.directionalDerivative(b, b) << std::endl; - assert(J.pseudoDirectionalDerivative(b, b) == 10); + assert(J.directionalDerivative(b, b) == 2 * sqrt(5)); SampleFunctional::SmallVector start = b; start *= 17; -- GitLab