8 Sep 2011 01:33
Yet another C++ wrapper for MPFR library
*** Please CC me, as I am not subscribed to the list! *** Dear MPFR developers and users, although there are already some C++ wrappers for the MPFR library, I decided to write another one. Its design is quite different from other wrappers: It consists of a template class with precision and rounding mode passed as template arguments. Hence, effectively a new type will be created for each precision and rounding that is used. All the operators available for fundamental floating point types as well as type conversions from and to other types, and the set of mathematical functions known from math.h/cmath are implemented. This should allow for an easy substitution of, e.g., a double with the wrapper class in most cases. Furthermore, the class allows to configure the conversions and support/handling for other types (such as fundamental types like "double"s or "int"s, character strings, or GMP types) with the help of type traits and some template metaprogramming. Last but not least, the compiler (= g++ with "-O2" in different test cases) seems to be able to optimize away the class overhead such that the generated code is effectively the same as it would be for direct use of the "low-level" MPFR functions. Some lines about the wrapper and, of course, the source code itself can be found here: http://chschneider.eu/programming/mpfr_real/ I am really interested in comments. The documentation will (hopefully)(Continue reading)
RSS Feed