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

Use axpy

parent c358a8e5
No related branches found
No related tags found
No related merge requests found
...@@ -53,24 +53,27 @@ class SampleFunctional : public SmallFunctional<dimension> { ...@@ -53,24 +53,27 @@ class SampleFunctional : public SmallFunctional<dimension> {
double l = 0; double l = 0;
double r = 1; double r = 1;
SmallVector tmp = descDir; SmallVector tmp;
tmp *= r; while (true) {
while (directionalDerivative(x + tmp, descDir) < 0) { tmp = x;
tmp.axpy(r, descDir);
if (directionalDerivative(tmp, descDir) >= 0)
break;
l = r; l = r;
r *= 2; r *= 2;
tmp *= 2;
Dune::dverb << "Widened interval!" << std::endl; Dune::dverb << "Widened interval!" << std::endl;
} }
Dune::dverb << "Interval now [" << l << "," << r << "]" << std::endl; Dune::dverb << "Interval now [" << l << "," << r << "]" << std::endl;
// Debugging // Debugging
{ {
SmallVector tmpl = tmp; SmallVector tmpl = x;
tmpl *= l; tmpl.axpy(l, descDir);
SmallVector tmpr = tmp; SmallVector tmpr = x;
tmpr *= r; tmpr.axpy(r, descDir);
assert(directionalDerivative(x + tmpl, descDir) < 0); assert(directionalDerivative(tmpl, descDir) < 0);
assert(directionalDerivative(x + tmpr, descDir) > 0); assert(directionalDerivative(tmpr, descDir) > 0);
} }
double m = l / 2 + r / 2; double m = l / 2 + r / 2;
......
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