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

Tests based on manual computations

parent c195a0da
Branches
No related tags found
No related merge requests found
......@@ -8,6 +8,8 @@
#include "samplefunctional.hh"
#include <cassert>
template <int dim, class Function>
void functionTester(
Dune::SampleFunctional<dim, Function> J,
......@@ -42,6 +44,19 @@ void testSampleFunction() {
SampleFunctional::SmallVector start = b;
start *= 17;
/*
j(x)
= Ax - b + 2/|x| x
= 17*(6, 9.5) - (1, 2) + 2/sqrt(5) (1, 2)
= (102 - 1 + 2/sqrt(5), 161.5 - 2 + 4/sqrt(5))
*/
SampleFunctional::SmallVector error;
error[0] = -(102 - 1 + 2 / sqrt(5));
error[1] = -(161.5 - 2 + 4 / sqrt(5));
SampleFunctional::SmallVector returned = J.descentDirection(start);
error -= returned;
assert(error.two_norm() < 1e-10); // FIXME: 1e-10 sounds reasonable. Is it?
functionTester(J, start, 6);
}
......@@ -63,6 +78,19 @@ void testTrivialFunction() {
SampleFunctional::SmallVector start = b;
start *= 17;
/*
j(x)
= Ax - b
= 17*(6, 9.5) - (1, 2)
= (102 - 1, 161.5 - 2)
*/
SampleFunctional::SmallVector error;
error[0] = -101;
error[1] = -159.5;
SampleFunctional::SmallVector returned = J.descentDirection(start);
error -= returned;
assert(error.two_norm() < 1e-10); // FIXME: 1e-10 sounds reasonable. Is it?
functionTester(J, start, 5);
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment