Skip to content

Add GNU quad-precision arithmetic type

Summary

Add support for __float128 floating point type to dune. Since the gnu quad-precision library provides only a C interface and only very limited support in C++ standard library, some cmath and type_traits utilities are added to allow for a usage of quad precision types in FieldVector and FieldMatrix. The additional headers are quadmath.hh for input/output and type_traits, e.g is_floating_point_type and numeric_limits. And std/cmath.hh where some standard cmath functions are imported into the namespace Dune::Std and extended by some functions for __float128 type as well as std::complex<__float128>.

Motivation

High precision calculations can be done using multi-precision types, like GMP and if the long double precision is not enough quad precision might be sufficient already. The GNU multiprecision library adds this feature and is supported in GCC and clang >= 3.9

Discussion

The introduction of cmath function in the namespace Dune::Std might be debatable, but maybe it is also interesting for SIMD types. The reason is,, that __float128 is not a user-defined type and is thus cmath function are not found by ADL automatically. Since libstdc++ dies not procide overload for this type it is difficult to make them visibly in Dune functions. This design decision was: If you want to have cmath functions work on quad precision and other types as well, add using Dune::Std::foo before calling foo. So far only a few functions are added to make all tests in dune-common happy. But this can be extended when needed.

Merge request reports