Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions cmake/Modules/FindQuadMath.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -84,9 +84,19 @@ if(QuadMath_FOUND AND NOT TARGET QuadMath::QuadMath)
__float128 b=10;
__float128 c=std::atan(b);
}" QuadMath_HAS_MATH_OPS)
check_cxx_source_compiles("
#include <cmath>
int main()
{
__float128 b=10;
__float128 c=std::abs(b);
}" QuadMath_HAS_MATH_ABS)
cmake_pop_check_state() # Reset CMAKE_REQUIRED_XXX variables
if(QuadMath_HAS_MATH_OPS)
target_compile_definitions(QuadMath::QuadMath INTERFACE QUADMATH_HAS_MATH_OPERATORS=1)
endif()
if(QuadMath_HAS_MATH_ABS)
target_compile_definitions(QuadMath::QuadMath INTERFACE QUADMATH_HAS_MATH_ABS=1)
endif()
cmake_pop_check_state() # Reset CMAKE_REQUIRED_XXX variables
endif()
8 changes: 5 additions & 3 deletions opm/material/common/quad.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -267,6 +267,11 @@ inline typename std::istream& operator>>(std::istream& is, quad& val)
}
#endif

#if !QUADMATH_HAS_MATH_ABS
inline quad abs(quad val)
{ return (val < 0) ? -val : val; }
#endif

#if !QUADMATH_HAS_MATH_OPERATORS
inline quad real(quad val)
{ return val; }
Expand All @@ -280,9 +285,6 @@ inline quad imag(quad)
inline quad imag(const std::complex<quad>& val)
{ return val.imag(); }

inline quad abs(quad val)
{ return (val < 0) ? -val : val; }

inline quad floor(quad val)
{ return floorq(val); }

Expand Down