Node:Initializing Integers, Next:Assigning Integers, Previous:Integer Functions, Up:Integer Functions
The functions for integer arithmetic assume that all integer objects are
initialized. You do that by calling the function mpz_init
. For
example,
{ mpz_t integ; mpz_init (integ); ... mpz_add (integ, ...); ... mpz_sub (integ, ...); /* Unless the program is about to exit, do ... */ mpz_clear (integ); }
As you can see, you can store new values any number of times, once an object is initialized.
void mpz_init (mpz_t integer) | Function |
Initialize integer, and set its value to 0. |
void mpz_init2 (mpz_t integer, unsigned long n) | Function |
Initialize integer, with space for n bits, and set its value to 0.
n is only the initial space, integer will grow automatically in
the normal way, if necessary, for subsequent values stored. |
void mpz_clear (mpz_t integer) | Function |
Free the space occupied by integer. Call this function for all
mpz_t variables when you are done with them.
|
void mpz_realloc2 (mpz_t integer, unsigned long n) | Function |
Change the space allocated for integer to n bits. The value in
integer is preserved if it fits, or is set to 0 if not.
This function can be used to increase the space for a variable in order to avoid repeated automatic reallocations, or to decrease it to give memory back to the heap. |
void mpz_array_init (mpz_t integer_array[], size_t array_size, mp_size_t fixed_num_bits) | Function |
This is a special type of initialization. Fixed space of
fixed_num_bits bits is allocated to each of the array_size
integers in integer_array.
The space will not be automatically increased, unlike the normal
For other functions, or if in doubt, the suggestion is to calculate in a
regular
|
void * _mpz_realloc (mpz_t integer, mp_size_t new_alloc) | Function |
Change the space for integer to new_alloc limbs. The value in
integer is preserved if it fits, or is set to 0 if not. The return
value is not useful to applications and should be ignored.
|