Commit 2241fdf4 authored by Lasse Hinrichsen's avatar Lasse Hinrichsen
Browse files

Add some domain and subDifferential methods.

These do not neccessarily need to stay in. A user could also just
implement these themselves, but for now, let's have these here.
parent 3805f46f
Pipeline #34611 passed with stage
in 8 minutes and 21 seconds
......@@ -12,6 +12,7 @@
#include <dune/matrix-vector/algorithm.hh>
#include <dune/solvers/common/interval.hh>
#include <dune/solvers/common/resize.hh>
#include <dune/solvers/common/copyorreference.hh>
......@@ -181,7 +182,22 @@ protected:
Vector linearPart_;
};
template<class M, class V, class R>
auto
domain(const QuadraticDirectionalRestriction<M, V, R>&)
{
return Dune::Solvers::Interval<double>(
{ std::numeric_limits<double>::lowest(),
std::numeric_limits<double>::max() });
}
template<class M, class V, class R>
auto
subDifferential(const QuadraticDirectionalRestriction<M, V, R>& f, double x)
{
return Dune::Solvers::Interval<double>(x * f.quadraticPart() -
f.linearPart());
}
/** \brief A quadratic functional
*
......@@ -253,6 +269,21 @@ protected:
};
template<class M, class V, class R>
auto
domain(const QuadraticFunctional<M, V, R>&)
{
return Dune::Solvers::Interval<double>({std::numeric_limits<double>::lowest(),
std::numeric_limits<double>::max()});
}
template<class M, class V, class R>
auto
subDifferential(const QuadraticFunctional<M, V, R>& f, double x)
{
return Dune::Solvers::Interval<double>(x * f.quadraticPart() -
f.linearPart());
}
} // end namespace TNNMG
......
......@@ -5,6 +5,7 @@
#include <dune/common/shared_ptr.hh>
#include "dune/tnnmg/functionals/nonsmoothconvexfunctional.hh"
#include <dune/tnnmg/localsolvers/functionproperties.hh>
#include <dune/common/hybridutilities.hh>
#include <dune/common/std/apply.hh>
......@@ -70,7 +71,25 @@ auto directionalRestriction(const SumFunctional<F...>& f, const Vector& origin,
}, f.functions());
}
/** \brief Returns the domain by computing the intersection of the individual
* domains of the SumFunctional's functions.
*/
template<class... F>
auto
domain(const SumFunctional<F...>& f)
{
return TNNMG::domain(f.functions());
}
/** \brief Returns the subdifferential by computing the sum of the individual
* subdifferentials of the SumFunctional's functions.
*/
template<class... F>
auto
subDifferential(const SumFunctional<F...>& f, double x)
{
return TNNMG::subDifferential(f.functions(), x);
}
/** \brief Sum of several functionals
*
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment