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
Branches
No related tags found
No related merge requests found
......@@ -53,24 +53,27 @@ class SampleFunctional : public SmallFunctional<dimension> {
double l = 0;
double r = 1;
SmallVector tmp = descDir;
tmp *= r;
while (directionalDerivative(x + tmp, descDir) < 0) {
SmallVector tmp;
while (true) {
tmp = x;
tmp.axpy(r, descDir);
if (directionalDerivative(tmp, descDir) >= 0)
break;
l = r;
r *= 2;
tmp *= 2;
Dune::dverb << "Widened interval!" << std::endl;
}
Dune::dverb << "Interval now [" << l << "," << r << "]" << std::endl;
// Debugging
{
SmallVector tmpl = tmp;
tmpl *= l;
SmallVector tmpr = tmp;
tmpr *= r;
assert(directionalDerivative(x + tmpl, descDir) < 0);
assert(directionalDerivative(x + tmpr, descDir) > 0);
SmallVector tmpl = x;
tmpl.axpy(l, descDir);
SmallVector tmpr = x;
tmpr.axpy(r, descDir);
assert(directionalDerivative(tmpl, descDir) < 0);
assert(directionalDerivative(tmpr, descDir) > 0);
}
double m = l / 2 + r / 2;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment