Skip to content
Snippets Groups Projects
Commit 32c9360e authored by René Fritze's avatar René Fritze Committed by René Fritze
Browse files

[functions.inverse] simplify helper

parent 7982f374
No related branches found
No related tags found
1 merge request!31Sfinae and stuff
......@@ -40,34 +40,18 @@ public:
using DomainType = Dune::FieldVector<double, d>;
using RangeReturnType = typename RangeTypeSelector<R, r, rC>::return_type;
template <size_t r_ = r, size_t rC_ = rC, bool anything = true>
struct dim_switch
{
static const constexpr bool available = false;
};
public:
static const constexpr bool available = (FunctionType::rC == FunctionType::r);
template <bool anything>
struct dim_switch<1, 1, anything>
static RangeReturnType compute(const FunctionType& func, const DomainType& xx, const XT::Common::Parameter& param)
{
static const constexpr bool available = true;
static RangeReturnType compute(const FunctionType& func, const DomainType& xx, const XT::Common::Parameter& param)
{
if constexpr (FunctionType::rC == 1 && FunctionType::r == 1) {
auto value_to_invert = func.evaluate(xx, param);
DUNE_THROW_IF(XT::Common::FloatCmp::eq(value_to_invert, 0.),
Exceptions::wrong_input_given,
"Scalar function value was not invertible!\n\nvalue_to_invert = " << value_to_invert);
return 1. / value_to_invert;
}
};
template <size_t r_, bool anything>
struct dim_switch<r_, r_, anything>
{
static const constexpr bool available = true;
static RangeReturnType compute(const FunctionType& func, const DomainType& xx, const XT::Common::Parameter& param)
{
} else if constexpr (available) {
auto matrix_to_invert = func.evaluate(xx, param);
RangeReturnType inverse_matrix;
try {
......@@ -78,15 +62,9 @@ public:
<< matrix_to_invert << "\n\nThis was the original error: " << ee.what());
}
return inverse_matrix;
} else {
static_assert(false, "compute not available");
}
};
public:
static const constexpr bool available = dim_switch<>::available;
static RangeReturnType compute(const FunctionType& func, const DomainType& xx, const XT::Common::Parameter& param)
{
return dim_switch<>::compute(func, xx, param);
}
}; // class InverseFunctionHelper
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment