[ANN] gmpxx_mkII.h: Yet another GMP C++ Wrapper for High-Precision Calculations
Hans Åberg
haberg_1 at icloud.com
Fri Oct 11 10:19:04 CEST 2024
> On 11 Oct 2024, at 06:50, maho nakata <nakatamaho at outlook.com> wrote:
>
> Dear Hans Åberg
> I don't use templates extensively, and I implemented mpf_class as a typical class.
> For performance comparison, please have a look,
> https://github.com/nakatamaho/gmpxx_mkII?tab=readme-ov-file#performance-improvements-and-benchmarks
My C++ wrapper is on:
https://git.savannah.gnu.org/cgit/metalogic-inference.git/tree/src/gmp.hh
It might be possible to make some adaptations to GMP to facilitate the C++ implementation:
One difference is that for the move operators, I use the functions mpz_move and mpq_move. Whereas std::swap is legal, an analysis showed it is actually slower, in addition to the destruction order getting out of sync, so is better avoided.
The functions mpz_move and mpq_move strictly depend on the GMP implementation, below the its interface.
When I did a more extensive C++ wrapper, the only part I put in a source file was a hack of the GMP stream functions for the adaptation to C++ streams, as C streams cannot be directly converted to C++. I do not need std::istream in the current interface, as I use a parser that produces strings. But otherwise, GMP might add something here.
I think that the mpf type may be essentially deprecated in favour of the MPFR package, having a more extensive multiprecision floating point implementation, and in GMP only uses mpz and mpq.
More information about the gmp-discuss
mailing list