DOC HOME SITE MAP MAN PAGES GNU INFO SEARCH PRINT BOOK
 

(gmp.info.gz) Integer Special Functions

Info Catalog (gmp.info.gz) Miscellaneous Integer Functions (gmp.info.gz) Integer Functions
 
 Special Functions
 =================
 
 The functions in this section are for various special purposes.  Most
 applications will not need them.
 
  - Function: void mpz_array_init (mpz_t INTEGER_ARRAY, size_t
           ARRAY_SIZE, mp_size_t FIXED_NUM_BITS)
      This is a special type of initialization.  *Fixed* space of
      FIXED_NUM_BITS is allocated to each of the ARRAY_SIZE integers in
      INTEGER_ARRAY.  There is no way to free the storage allocated by
      this function.  Don't call `mpz_clear'!
 
      The INTEGER_ARRAY parameter is the first `mpz_t' in the array.  For
      example,
 
           mpz_t  arr[20000];
           mpz_array_init (arr[0], 20000, 512);
 
      This function is only intended for programs that create a large
      number of integers and need to reduce memory usage by avoiding the
      overheads of allocating and reallocating lots of small blocks.  In
      normal programs this function is not recommended.
 
      The space allocated to each integer by this function will not be
      automatically increased, unlike the normal `mpz_init', so an
      application must ensure it is sufficient for any value stored.
      The following space requirements apply to various routines,
 
         * `mpz_abs', `mpz_neg', `mpz_set', `mpz_set_si' and
           `mpz_set_ui' need room for the value they store.
 
         * `mpz_add', `mpz_add_ui', `mpz_sub' and `mpz_sub_ui' need room
           for the larger of the two operands, plus an extra
           `mp_bits_per_limb'.
 
         * `mpz_mul', `mpz_mul_ui' and `mpz_mul_ui' need room for the sum
           of the number of bits in their operands, but each rounded up
           to a multiple of `mp_bits_per_limb'.
 
         * `mpz_swap' can be used between two array variables, but not
           between an array and a normal variable.
 
      For other functions, or if in doubt, the suggestion is to
      calculate in a regular `mpz_init' variable and copy the result to
      an array variable with `mpz_set'.
 
  - Function: void * _mpz_realloc (mpz_t INTEGER, mp_size_t NEW_ALLOC)
      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.
 
      `mpz_realloc2' is the preferred way to accomplish allocation
      changes like this.  `mpz_realloc2' and `_mpz_realloc' are the same
      except that `_mpz_realloc' takes its size in limbs.
 
  - Function: mp_limb_t mpz_getlimbn (mpz_t OP, mp_size_t N)
      Return limb number N from OP.  The sign of OP is ignored, just the
      absolute value is used.  The least significant limb is number 0.
 
      `mpz_size' can be used to find how many limbs make up OP.
      `mpz_getlimbn' returns zero if N is outside the range 0 to
      `mpz_size(OP)-1'.
 
  - Function: size_t mpz_size (mpz_t OP)
      Return the size of OP measured in number of limbs.  If OP is zero,
      the returned value will be zero.
 
Info Catalog (gmp.info.gz) Miscellaneous Integer Functions (gmp.info.gz) Integer Functions
automatically generated byinfo2html