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

Use the pseudo directional derivative

In most cases (x != 0) this is a lot faster than normalising the direction and computing the actual directional derivative
parent ae7a3bb2
No related branches found
No related tags found
No related merge requests found
......@@ -63,7 +63,7 @@ class SampleFunctional {
while (true) {
tmp = x;
tmp.axpy(r, descDir);
if (directionalDerivative(tmp, descDir) >= 0)
if (pseudoDirectionalDerivative(tmp, descDir) >= 0)
break;
l = r;
......@@ -91,12 +91,13 @@ class SampleFunctional {
middle = descDir;
middle *= m;
double derivative = directionalDerivative(x + middle, descDir);
double pseudoDerivative =
pseudoDirectionalDerivative(x + middle, descDir);
if (derivative < 0) {
if (pseudoDerivative < 0) {
l = m;
m = (m + r) / 2;
} else if (derivative > 0) {
} else if (pseudoDerivative > 0) {
r = m;
m = (l + m) / 2;
} else
......@@ -131,7 +132,9 @@ class SampleFunctional {
return y;
}
// |dir|-times the directional derivative wrt dir/|dir|.
// |dir|-times the directional derivative wrt dir/|dir|. If only
// the sign of the directionalDerivative matters, this saves the
// cost of normalising.
double pseudoDirectionalDerivative(const SmallVector x,
const SmallVector dir) const {
if (x == SmallVector(0.0))
......
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