Comparing boost::multiprecision cpp_int and mpz_int

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Comparing boost::multiprecision cpp_int and mpz_int

Boost - Users mailing list
cpp_int is more convenient but mpz_int is faster especially for long numbers? What say benchmarks? For mpz_int I must install GMP on Linux or build MPIR on WIndows (build lib_mpir_core2) ?
I want make sample benchmark test but I can't convert cpp_it to mpz_int nor iport bits, whereas for cpp_int I can import_bits(x, xBytes.begin(), xBytes.end()) where vector<uint8_t> xBytes;
Question: is possible import byte array to mpz_int?

_______________________________________________
Boost-users mailing list
[hidden email]
https://lists.boost.org/mailman/listinfo.cgi/boost-users
Reply | Threaded
Open this post in threaded view
|

Re: Comparing boost::multiprecision cpp_int and mpz_int

Boost - Users mailing list

On 05/11/2019 07:47, Andy via Boost-users wrote:
> cpp_int is more convenient but mpz_int is faster especially for long
> numbers?

Probably quite a slower for small numbers, and a lot faster for large ones.

> What say benchmarks?

Out of date, but these may give some clue:
https://www.boost.org/doc/libs/1_71_0/libs/multiprecision/doc/html/boost_multiprecision/perf/int_real_world.html

> For mpz_int I must install GMP on Linux or build MPIR on WIndows
> (build lib_mpir_core2) ?
Yes.
> I want make sample benchmark test but I can't convert cpp_it to
> mpz_int nor iport bits, whereas for cpp_int I can import_bits(x,
> xBytes.begin(), xBytes.end()) where vector<uint8_t> xBytes;
> Question: is possible import byte array to mpz_int?

No, but the 2 types are explicitly convertible to each other, ie this works:

    cpp_int i(2);
    mpz_int j(i);
    i = cpp_int(j);

John.


--
This email has been checked for viruses by Avast antivirus software.
https://www.avast.com/antivirus

_______________________________________________
Boost-users mailing list
[hidden email]
https://lists.boost.org/mailman/listinfo.cgi/boost-users