Skip to content
Snippets Groups Projects
Commit ae7a3bb2 authored by Elias Pipping's avatar Elias Pipping Committed by Elias Pipping
Browse files

Make pseudoDirectionalDerivative private

parent c70ebe65
No related branches found
No related tags found
No related merge requests found
......@@ -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;
......
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