Skip to content
Snippets Groups Projects
Commit 6fc30684 authored by René Fritze's avatar René Fritze
Browse files

[common/float_cmp] changes complex comparison mode to element-wise

refs #59 and also tests float_cmp for actual floats
parent 79bd4ed7
No related branches found
No related tags found
No related merge requests found
......@@ -115,10 +115,8 @@ typename std::enable_if<std::is_arithmetic<T>::value, bool>::type cmp_gt(const T
template <class T>
bool cmp_gt(const std::complex<T>& xx, const std::complex<T>& yy)
{
T x = std::abs(xx);
T y = std::abs(yy);
static_assert(std::is_arithmetic<T>::value, "");
return std::greater<double>()(x, y);
using namespace std;
return cmp_gt({real(xx), real(yy)}, {imag(xx), imag(yy)});
}
template <class XType, class YType>
......@@ -147,7 +145,8 @@ typename std::enable_if<std::is_arithmetic<T>::value, bool>::type cmp_lt(const T
template <class T>
bool cmp_lt(const std::complex<T>& xx, const std::complex<T>& yy)
{
return std::less<T>()(std::abs(xx), std::abs(yy));
using namespace std;
return cmp_lt({real(xx), real(yy)}, {imag(xx), imag(yy)});
}
template <class XType, class YType>
......
......@@ -436,7 +436,7 @@ struct FloatCmpVector : public FloatCmpBase
}; // struct FloatCmpVector
typedef testing::Types<double, std::complex<double>
typedef testing::Types<double, std::complex<double>, float,
// , long double // <- this requires a patch in dune/common/float_cmp.cc
// (bc. of std::max and 1e-6)
> ScalarTypes;
......
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