mpz_addmul_ui with ui = 1

Paul Zimmermann Paul.Zimmermann at loria.fr
Fri Jan 30 18:41:51 CET 2009


       Marc,

> (Not directly related)
> At some point I was wondering whether the special representation of 0 
> (size==0) should be extended to represent instead small numbers that can 
> fit in an integer at most as long as _mp_d. Hard to tell.

an alternate trick is to store in the mpz_t *pointer* a value of the form
p=2k+1, where k is a small integer. Since pointers are usually even, you
can easily distinguish between small integers and GMP integers,
and you obtain the value k = p >> 1. It is also more memory-efficient since
you don't allocate the mpz_t structure. A famous computer algebra system is
using that trick together with GMP.

It might make sense to have another layer on top of mpz with that trick.

Paul Zimmermann


More information about the gmp-discuss mailing list