Commit 559f4eff by Oliver Sander

### Implement a test for positive 1-homogeneity

```Functionals do not have to be positive 1-homogeneous, but some important ones are.
For those it is convenient to have a test.```
parent 8755dd4e
 ... ... @@ -52,6 +52,33 @@ void testConvexity(const Functional& functional, } } /** \brief Test whether a functional is positive 1-homogeneous * * Being positive 1-homogeneous is not a requirement for functionals to work * in a TNNMG algorithm. However, various important functionals are homogeneous * in this sense, therefore it is convenient to have a test for it. * * \tparam Functional Type of the functional to be tested * \param functional The functional to be tested * \param testDirections Test addGradient at these points */ template void testHomogeneity(const Functional& functional, const std::vector& testDirections) { for (auto&& testDirection : testDirections) { // Test convexity at a few selected points between the two test points for (double t : {0.0, 0.25, 0.5, 0.75, 1.0, 1.5, 2.0, 5.0}) { auto scaledDirection = testDirection; scaledDirection *= t; if (std::abs(functional(scaledDirection) - t*functional(testDirection)) > 1e-6) DUNE_THROW(MathError, "Functional is not positive 1-homogeneous!"); } } } /** \brief Test the addGradient method * ... ...
 ... ... @@ -35,6 +35,10 @@ int main(int argc, char** argv) try // Test whether the functional is convex testConvexity(functional, testPoints); // Test whether the functional positive 1-homogeneous // We abuse the test points as test directions. testHomogeneity(functional, testPoints); // Test the first derivative at the given test points testGradient(functional, testPoints); ... ...
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!