Re: Seeking Endorsement: Boost.int128

Matt Borland via Boost <[email protected]>
Newsgroups gmane.comp.lib.boost.devel
Message-ID <QMp_dbVc5ExI3IA-mqrARtekSOvHGBX_cjAjWeZGs47X5NnjHLM6fWa9DuoW5PLy3aYcQfK5CKWDE0uZEbAlbQYwQJx3Qhf_OCKnqUbcxHE=@mattborland.com>
> What is needed to use GMP mpz_powm() modular exponention on int128?
> Conversion to Boost.Multiprecision gmp_int, or directly to GMP?
> 

> Would adding mpz_powm() like function to new library make sense?
> If such int128 powm would be faster than GMP mpz_powm I would say yes.
> 


To convert to mpz_t you could do something like:

boost::int128::uint128_t val;
mpz_t z;
mpz_init(z);
uint64_t words[2] = { val.high, val.low };
mpz_import(z, 2, 1, sizeof(uint64_t), 0, 0, words);

I don't have any special bindings for easy conversions to multiprecision types.

Without measuring I will assume that a special case of a two word modular exponentiation in the library would be a good bit faster. I already have a way for 128 by 128 mul to result in a 256-bit array in the library (I use this for mul in decimal128_t). Same for the 256-bit by 128-bit reduction. I believe that GMP's small value optimization is 128-bits, so they would need to make at least one heap allocation for this operation.

I can look into this in the next few days for you.

Matt

_______________________________________________
Boost mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://lists.boost.org/mailman3/lists/boost.lists.boost.org/
Archived at: https://lists.boost.org/archives/list/[email protected]/message/G43KWSQKKHBMQXRMHBFDHKH27BIBFJPN/
publickey - [email protected] - 0xC1382EAD.asc (application/pgp-keys, 653 B)
-----BEGIN PGP PUBLIC KEY BLOCK-----

xjMEX2wgdBYJKwYBBAHaRw8BAQdAUHOh0KpbZCszhdvKztWj4C6FR1ozMBQE
waBi3m2PJHLNK21hdHRAbWF0dGJvcmxhbmQuY29tIDxtYXR0QG1hdHRib3Js
YW5kLmNvbT7CjwQQFgoAIAUCX2wgdAYLCQcIAwIEFQgKAgQWAgEAAhkBAhsD
Ah4BACEJEFmBWlVCFaWlFiEEwTgurTcoHwbdSbIsWYFaVUIVpaVWuwEA77rm
OA4TB6Xxe6q8gI42bEICMhMyZKSMcakz39/djYkBAMJOG+IGQC/d0n3dsl10
Kg/oxX88kFO1oPKn4/XW+ToBzjgEX2wgdBIKKwYBBAGXVQEFAQEHQOsmo6wR
UuXRAvFIiqmQkzYrPyvKYKna2z4ZtmnTQMkMAwEIB8J4BBgWCAAJBQJfbCB0
AhsMACEJEFmBWlVCFaWlFiEEwTgurTcoHwbdSbIsWYFaVUIVpaWUJwEA5G0c
ZRnG5WGNErI+y90iQrTv02i4Ivhv7twoFcLD/zwA/jKypw+vehE99mEj1/uI
EkoDFlNzQZqNldbjRcPyI5UH
=462S
-----END PGP PUBLIC KEY BLOCK-----
signature.asc (application/pgp-signature, 343 B)
-----BEGIN PGP SIGNATURE-----
Version: ProtonMail

wrsEARYKAG0FgmnxRQMJEFmBWlVCFaWlRRQAAAAAABwAIHNhbHRAbm90YXRp
b25zLm9wZW5wZ3Bqcy5vcmdvLKkPObnPmweQeHds9u9/sJQCPT1RkJTvGyVV
xztx5hYhBME4Lq03KB8G3UmyLFmBWlVCFaWlAAAepwD9HqWEDIQ9WQYFWrEJ
u1n02YVMB5j0egGQKL1nW3Yq0JAA/27Pod/234xhQs2pqQZpADeOwUpgK/y+
giv3fRPmEQYH
=0NlM
-----END PGP SIGNATURE-----
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.