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

Fix: No descent if the gradient is too small

At least for the tangential descent, a gradient of magnitude 1e-16
causes problems. Test included
parent 2203fc04
Branches
No related tags found
No related merge requests found
...@@ -104,7 +104,7 @@ void minimise(Functional const &J, typename Functional::SmallVector &x, ...@@ -104,7 +104,7 @@ void minimise(Functional const &J, typename Functional::SmallVector &x,
SmallVector descDir; SmallVector descDir;
bool const linesearchp = J.descentDirection(x, descDir); bool const linesearchp = J.descentDirection(x, descDir);
if (descDir == SmallVector(0.0)) if (descDir.two_norm() < 1e-14) // TODO: Make controllable
return; return;
if (linesearchp) { if (linesearchp) {
......
...@@ -20,7 +20,7 @@ int main() { ...@@ -20,7 +20,7 @@ int main() {
typedef Functional::SmallVector SmallVector; typedef Functional::SmallVector SmallVector;
SmallMatrix const A = { { 1, 0 }, { 0, 1 } }; SmallMatrix const A = { { 1, 0 }, { 0, 1 } };
SmallVector const b = { 1, 2 }; SmallVector const b = { 1, 2.5 };
auto const f = Dune::make_shared<Dune::SampleFunction<2> const>(); auto const f = Dune::make_shared<Dune::SampleFunction<2> const>();
auto const phi = Dune::make_shared<Functional::NonlinearityType const>(f); auto const phi = Dune::make_shared<Functional::NonlinearityType const>(f);
......
...@@ -29,7 +29,7 @@ int main() { ...@@ -29,7 +29,7 @@ int main() {
double ret1; double ret1;
{ {
SmallVector start = { 0, 1 }; SmallVector start = { 0, 1 };
ret1 = functionTester(J, start, 1); ret1 = functionTester(J, start, 2);
} }
double ret2; double ret2;
......
...@@ -29,7 +29,7 @@ int main() { ...@@ -29,7 +29,7 @@ int main() {
double ret1; double ret1;
{ {
SmallVector start = { 0, 1 }; SmallVector start = { 0, 1 };
ret1 = functionTester(J, start, 1); ret1 = functionTester(J, start, 2);
} }
double ret2; double ret2;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment