Commit 48060caf authored by oliver.sander_at_tu-dresden.de's avatar oliver.sander_at_tu-dresden.de
Browse files

Port bcqfconstrainedlinearization.hh to 'if constexpr'

parent d13a9cbb
Pipeline #28816 failed with stage
in 2 minutes and 47 seconds
......@@ -30,28 +30,34 @@ class BoxConstrainedQuadraticFunctionalConstrainedLinearization
static void determineTruncation(const NV& x, const NV& lower, const NV& upper, NBV&& truncationFlags, const T& truncationTolerance)
{
namespace H = Dune::Hybrid;
H::ifElse(IsNumber<NV>(), [&](auto id){
if ((id(x) <= id(lower)+truncationTolerance) || (id(x) >= id(upper) - truncationTolerance))
id(truncationFlags) = true;
}, [&](auto id){
H::forEach(H::integralRange(H::size(id(x))), [&](auto&& i) {
if constexpr (IsNumber<NV>())
{
if ((x <= lower+truncationTolerance) || (x >= upper - truncationTolerance))
truncationFlags = true;
}
else
{
H::forEach(H::integralRange(H::size(x)), [&](auto&& i) {
This::determineTruncation(x[i], lower[i], upper[i], truncationFlags[i], truncationTolerance);
});
});
}
}
template<class NV, class NBV>
static void truncateVector(NV& x, const NBV& truncationFlags)
{
namespace H = Dune::Hybrid;
H::ifElse(IsNumber<NV>(), [&](auto id){
if (id(truncationFlags))
id(x) = 0;
}, [&](auto id){
H::forEach(H::integralRange(H::size(id(x))), [&](auto&& i) {
if constexpr (IsNumber<NV>())
{
if (truncationFlags)
x = 0;
}
else
{
H::forEach(H::integralRange(H::size(x)), [&](auto&& i) {
This::truncateVector(x[i], truncationFlags[i]);
});
});
}
}
template<class NM, class RBV, class CBV>
......@@ -59,17 +65,20 @@ class BoxConstrainedQuadraticFunctionalConstrainedLinearization
{
namespace H = Dune::Hybrid;
using namespace Dune::MatrixVector;
H::ifElse(IsNumber<NM>(), [&](auto id){
if(id(rowTruncationFlags) or id(colTruncationFlags))
if constexpr (IsNumber<NM>())
{
if (rowTruncationFlags or colTruncationFlags)
A = 0;
}, [&](auto id){
H::forEach(H::integralRange(H::size(id(rowTruncationFlags))), [&](auto&& i) {
}
else
{
H::forEach(H::integralRange(H::size(rowTruncationFlags)), [&](auto&& i) {
auto&& Ai = A[i];
sparseRangeFor(Ai, [&](auto&& Aij, auto&& j) {
This::truncateMatrix(Aij, rowTruncationFlags[i], colTruncationFlags[j]);
});
});
});
}
}
public:
......
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