version 1.1.1.1, 2000/01/10 15:35:21 |
version 1.1.1.2, 2000/09/09 14:12:18 |
|
|
This is Info file gmp.info, produced by Makeinfo-1.64 from the input |
This is gmp.info, produced by makeinfo version 4.0 from gmp.texi. |
file gmp.texi. |
|
|
|
|
INFO-DIR-SECTION GNU libraries |
START-INFO-DIR-ENTRY |
START-INFO-DIR-ENTRY |
* gmp: (gmp.info). GNU Multiple Precision Arithmetic Library. |
* gmp: (gmp). GNU Multiple Precision Arithmetic Library. |
END-INFO-DIR-ENTRY |
END-INFO-DIR-ENTRY |
|
|
This file documents GNU MP, a library for arbitrary-precision |
This file documents GNU MP, a library for arbitrary-precision |
arithmetic. |
arithmetic. |
|
|
Copyright (C) 1991, 1993, 1994, 1995, 1996 Free Software Foundation, |
Copyright (C) 1991, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000 |
Inc. |
Free Software Foundation, Inc. |
|
|
Permission is granted to make and distribute verbatim copies of this |
Permission is granted to make and distribute verbatim copies of this |
manual provided the copyright notice and this permission notice are |
manual provided the copyright notice and this permission notice are |
Line 26 versions, except that this permission notice may be st |
|
Line 26 versions, except that this permission notice may be st |
|
translation approved by the Foundation. |
translation approved by the Foundation. |
|
|
|
|
|
File: gmp.info, Node: Integer Exponentiation, Next: Integer Roots, Prev: Integer Division, Up: Integer Functions |
|
|
|
Exponentiation Functions |
|
======================== |
|
|
|
- Function: void mpz_powm (mpz_t ROP, mpz_t BASE, mpz_t EXP, mpz_t MOD) |
|
- Function: void mpz_powm_ui (mpz_t ROP, mpz_t BASE, unsigned long int |
|
EXP, mpz_t MOD) |
|
Set ROP to (BASE raised to EXP) `mod' MOD. If EXP is negative, |
|
the result is undefined. |
|
|
|
|
|
- Function: void mpz_pow_ui (mpz_t ROP, mpz_t BASE, unsigned long int |
|
EXP) |
|
- Function: void mpz_ui_pow_ui (mpz_t ROP, unsigned long int BASE, |
|
unsigned long int EXP) |
|
Set ROP to BASE raised to EXP. The case of 0^0 yields 1. |
|
|
|
|
|
File: gmp.info, Node: Integer Roots, Next: Number Theoretic Functions, Prev: Integer Exponentiation, Up: Integer Functions |
|
|
|
Root Extraction Functions |
|
========================= |
|
|
|
- Function: int mpz_root (mpz_t ROP, mpz_t OP, unsigned long int N) |
|
Set ROP to the truncated integer part of the Nth root of OP. |
|
Return non-zero if the computation was exact, i.e., if OP is ROP |
|
to the Nth power. |
|
|
|
- Function: void mpz_sqrt (mpz_t ROP, mpz_t OP) |
|
Set ROP to the truncated integer part of the square root of OP. |
|
|
|
- Function: void mpz_sqrtrem (mpz_t ROP1, mpz_t ROP2, mpz_t OP) |
|
Set ROP1 to the truncated integer part of the square root of OP, |
|
like `mpz_sqrt'. Set ROP2 to OP-ROP1*ROP1, (i.e., zero if OP is a |
|
perfect square). |
|
|
|
If ROP1 and ROP2 are the same variable, the results are undefined. |
|
|
|
- Function: int mpz_perfect_power_p (mpz_t OP) |
|
Return non-zero if OP is a perfect power, i.e., if there exist |
|
integers A and B, with B > 1, such that OP equals a raised to b. |
|
Return zero otherwise. |
|
|
|
- Function: int mpz_perfect_square_p (mpz_t OP) |
|
Return non-zero if OP is a perfect square, i.e., if the square |
|
root of OP is an integer. Return zero otherwise. |
|
|
|
|
|
File: gmp.info, Node: Number Theoretic Functions, Next: Integer Comparisons, Prev: Integer Roots, Up: Integer Functions |
|
|
|
Number Theoretic Functions |
|
========================== |
|
|
|
- Function: int mpz_probab_prime_p (mpz_t N, int REPS) |
|
If this function returns 0, N is definitely not prime. If it |
|
returns 1, then N is `probably' prime. If it returns 2, then N is |
|
surely prime. Reasonable values of reps vary from 5 to 10; a |
|
higher value lowers the probability for a non-prime to pass as a |
|
`probable' prime. |
|
|
|
The function uses Miller-Rabin's probabilistic test. |
|
|
|
- Function: int mpz_nextprime (mpz_t ROP, mpz_t OP) |
|
Set ROP to the next prime greater than OP. |
|
|
|
This function uses a probabilistic algorithm to identify primes, |
|
but for for practical purposes it's adequate, since the chance of |
|
a composite passing will be extremely small. |
|
|
|
- Function: void mpz_gcd (mpz_t ROP, mpz_t OP1, mpz_t OP2) |
|
Set ROP to the greatest common divisor of OP1 and OP2. The result |
|
is always positive even if either of or both input operands are |
|
negative. |
|
|
|
- Function: unsigned long int mpz_gcd_ui (mpz_t ROP, mpz_t OP1, |
|
unsigned long int OP2) |
|
Compute the greatest common divisor of OP1 and OP2. If ROP is not |
|
`NULL', store the result there. |
|
|
|
If the result is small enough to fit in an `unsigned long int', it |
|
is returned. If the result does not fit, 0 is returned, and the |
|
result is equal to the argument OP1. Note that the result will |
|
always fit if OP2 is non-zero. |
|
|
|
- Function: void mpz_gcdext (mpz_t G, mpz_t S, mpz_t T, mpz_t A, mpz_t |
|
B) |
|
Compute G, S, and T, such that AS + BT = G = `gcd'(A, B). If T is |
|
`NULL', that argument is not computed. |
|
|
|
- Function: void mpz_lcm (mpz_t ROP, mpz_t OP1, mpz_t OP2) |
|
Set ROP to the least common multiple of OP1 and OP2. |
|
|
|
- Function: int mpz_invert (mpz_t ROP, mpz_t OP1, mpz_t OP2) |
|
Compute the inverse of OP1 modulo OP2 and put the result in ROP. |
|
Return non-zero if an inverse exists, zero otherwise. When the |
|
function returns zero, ROP is undefined. |
|
|
|
- Function: int mpz_jacobi (mpz_t OP1, mpz_t OP2) |
|
- Function: int mpz_legendre (mpz_t OP1, mpz_t OP2) |
|
Compute the Jacobi and Legendre symbols, respectively. OP2 should |
|
be odd and must be positive. |
|
|
|
- Function: int mpz_si_kronecker (long A, mpz_t B); |
|
- Function: int mpz_ui_kronecker (unsigned long A, mpz_t B); |
|
- Function: int mpz_kronecker_si (mpz_t A, long B); |
|
- Function: int mpz_kronecker_ui (mpz_t A, unsigned long B); |
|
Calculate the value of the Kronecker/Jacobi symbol (A/B), with the |
|
Kronecker extension (a/2)=(2/a) when a odd, or (a/2)=0 when a even. |
|
All values of A and B give a well-defined result. See Henri |
|
Cohen, section 1.4.2, for more information (*note References::). |
|
See also the example program `demos/qcn.c' which uses |
|
`mpz_kronecker_ui'. |
|
|
|
- Function: unsigned long int mpz_remove (mpz_t ROP, mpz_t OP, mpz_t F) |
|
Remove all occurrences of the factor F from OP and store the |
|
result in ROP. Return the multiplicity of F in OP. |
|
|
|
- Function: void mpz_fac_ui (mpz_t ROP, unsigned long int OP) |
|
Set ROP to OP!, the factorial of OP. |
|
|
|
- Function: void mpz_bin_ui (mpz_t ROP, mpz_t N, unsigned long int K) |
|
- Function: void mpz_bin_uiui (mpz_t ROP, unsigned long int N, |
|
unsigned long int K) |
|
Compute the binomial coefficient N over K and store the result in |
|
ROP. Negative values of N are supported by `mpz_bin_ui', using |
|
the identity bin(-n,k) = (-1)^k * bin(n+k-1,k) (see Knuth volume 1 |
|
section 1.2.6 part G). |
|
|
|
- Function: void mpz_fib_ui (mpz_t ROP, unsigned long int N) |
|
Compute the Nth Fibonacci number and store the result in ROP. |
|
|
|
|
|
File: gmp.info, Node: Integer Comparisons, Next: Integer Logic and Bit Fiddling, Prev: Number Theoretic Functions, Up: Integer Functions |
|
|
|
Comparison Functions |
|
==================== |
|
|
|
- Function: int mpz_cmp (mpz_t OP1, mpz_t OP2) |
|
Compare OP1 and OP2. Return a positive value if OP1 > OP2, zero |
|
if OP1 = OP2, and a negative value if OP1 < OP2. |
|
|
|
- Macro: int mpz_cmp_ui (mpz_t OP1, unsigned long int OP2) |
|
- Macro: int mpz_cmp_si (mpz_t OP1, signed long int OP2) |
|
Compare OP1 and OP2. Return a positive value if OP1 > OP2, zero |
|
if OP1 = OP2, and a negative value if OP1 < OP2. |
|
|
|
These functions are actually implemented as macros. They evaluate |
|
their arguments multiple times. |
|
|
|
- Function: int mpz_cmpabs (mpz_t OP1, mpz_t OP2) |
|
- Function: int mpz_cmpabs_ui (mpz_t OP1, unsigned long int OP2) |
|
Compare the absolute values of OP1 and OP2. Return a positive |
|
value if OP1 > OP2, zero if OP1 = OP2, and a negative value if OP1 |
|
< OP2. |
|
|
|
- Macro: int mpz_sgn (mpz_t OP) |
|
Return +1 if OP > 0, 0 if OP = 0, and -1 if OP < 0. |
|
|
|
This function is actually implemented as a macro. It evaluates its |
|
arguments multiple times. |
|
|
|
|
|
File: gmp.info, Node: Integer Logic and Bit Fiddling, Next: I/O of Integers, Prev: Integer Comparisons, Up: Integer Functions |
|
|
|
Logical and Bit Manipulation Functions |
|
====================================== |
|
|
|
These functions behave as if two's complement arithmetic were used |
|
(although sign-magnitude is used by the actual implementation). |
|
|
|
- Function: void mpz_and (mpz_t ROP, mpz_t OP1, mpz_t OP2) |
|
Set ROP to OP1 logical-and OP2. |
|
|
|
- Function: void mpz_ior (mpz_t ROP, mpz_t OP1, mpz_t OP2) |
|
Set ROP to OP1 inclusive-or OP2. |
|
|
|
- Function: void mpz_xor (mpz_t ROP, mpz_t OP1, mpz_t OP2) |
|
Set ROP to OP1 exclusive-or OP2. |
|
|
|
- Function: void mpz_com (mpz_t ROP, mpz_t OP) |
|
Set ROP to the one's complement of OP. |
|
|
|
- Function: unsigned long int mpz_popcount (mpz_t OP) |
|
For non-negative numbers, return the population count of OP. For |
|
negative numbers, return the largest possible value (MAX_ULONG). |
|
|
|
- Function: unsigned long int mpz_hamdist (mpz_t OP1, mpz_t OP2) |
|
If OP1 and OP2 are both non-negative, return the hamming distance |
|
between the two operands. Otherwise, return the largest possible |
|
value (MAX_ULONG). |
|
|
|
It is possible to extend this function to return a useful value |
|
when the operands are both negative, but the current |
|
implementation returns MAX_ULONG in this case. *Do not depend on |
|
this behavior, since it will change in a future release.* |
|
|
|
- Function: unsigned long int mpz_scan0 (mpz_t OP, unsigned long int |
|
STARTING_BIT) |
|
Scan OP, starting with bit STARTING_BIT, towards more significant |
|
bits, until the first clear bit is found. Return the index of the |
|
found bit. |
|
|
|
- Function: unsigned long int mpz_scan1 (mpz_t OP, unsigned long int |
|
STARTING_BIT) |
|
Scan OP, starting with bit STARTING_BIT, towards more significant |
|
bits, until the first set bit is found. Return the index of the |
|
found bit. |
|
|
|
- Function: void mpz_setbit (mpz_t ROP, unsigned long int BIT_INDEX) |
|
Set bit BIT_INDEX in ROP. |
|
|
|
- Function: void mpz_clrbit (mpz_t ROP, unsigned long int BIT_INDEX) |
|
Clear bit BIT_INDEX in ROP. |
|
|
|
- Function: int mpz_tstbit (mpz_t OP, unsigned long int BIT_INDEX) |
|
Check bit BIT_INDEX in OP and return 0 or 1 accordingly. |
|
|
|
|
|
File: gmp.info, Node: I/O of Integers, Next: Integer Random Numbers, Prev: Integer Logic and Bit Fiddling, Up: Integer Functions |
|
|
|
Input and Output Functions |
|
========================== |
|
|
|
Functions that perform input from a stdio stream, and functions that |
|
output to a stdio stream. Passing a `NULL' pointer for a STREAM |
|
argument to any of these functions will make them read from `stdin' and |
|
write to `stdout', respectively. |
|
|
|
When using any of these functions, it is a good idea to include |
|
`stdio.h' before `gmp.h', since that will allow `gmp.h' to define |
|
prototypes for these functions. |
|
|
|
- Function: size_t mpz_out_str (FILE *STREAM, int BASE, mpz_t OP) |
|
Output OP on stdio stream STREAM, as a string of digits in base |
|
BASE. The base may vary from 2 to 36. |
|
|
|
Return the number of bytes written, or if an error occurred, |
|
return 0. |
|
|
|
- Function: size_t mpz_inp_str (mpz_t ROP, FILE *STREAM, int BASE) |
|
Input a possibly white-space preceded string in base BASE from |
|
stdio stream STREAM, and put the read integer in ROP. The base |
|
may vary from 2 to 36. If BASE is 0, the actual base is |
|
determined from the leading characters: if the first two |
|
characters are `0x' or `0X', hexadecimal is assumed, otherwise if |
|
the first character is `0', octal is assumed, otherwise decimal is |
|
assumed. |
|
|
|
Return the number of bytes read, or if an error occurred, return 0. |
|
|
|
- Function: size_t mpz_out_raw (FILE *STREAM, mpz_t OP) |
|
Output OP on stdio stream STREAM, in raw binary format. The |
|
integer is written in a portable format, with 4 bytes of size |
|
information, and that many bytes of limbs. Both the size and the |
|
limbs are written in decreasing significance order (i.e., in |
|
big-endian). |
|
|
|
The output can be read with `mpz_inp_raw'. |
|
|
|
Return the number of bytes written, or if an error occurred, |
|
return 0. |
|
|
|
The output of this can not be read by `mpz_inp_raw' from GMP 1, |
|
because of changes necessary for compatibility between 32-bit and |
|
64-bit machines. |
|
|
|
- Function: size_t mpz_inp_raw (mpz_t ROP, FILE *STREAM) |
|
Input from stdio stream STREAM in the format written by |
|
`mpz_out_raw', and put the result in ROP. Return the number of |
|
bytes read, or if an error occurred, return 0. |
|
|
|
This routine can read the output from `mpz_out_raw' also from GMP |
|
1, in spite of changes necessary for compatibility between 32-bit |
|
and 64-bit machines. |
|
|
|
|
|
File: gmp.info, Node: Integer Random Numbers, Next: Miscellaneous Integer Functions, Prev: I/O of Integers, Up: Integer Functions |
|
|
|
Random Number Functions |
|
======================= |
|
|
|
The random number functions of GMP come in two groups; older function |
|
that rely on a global state, and newer functions that accept a state |
|
parameter that is read and modified. Please see the *Note Random |
|
Number Functions:: for more information on how to use and not to use |
|
random number functions. |
|
|
|
- Function: void mpz_urandomb (mpz_t ROP, gmp_randstate_t STATE, |
|
unsigned long int N) Generate a uniformly distributed random |
|
integer in the range 0 to 2^N - 1, inclusive. |
|
|
|
The variable STATE must be initialized by calling one of the |
|
`gmp_randinit' functions (*Note Random State Initialization::) |
|
before invoking this function. |
|
|
|
- Function: void mpz_urandomm (mpz_t ROP, gmp_randstate_t STATE, |
|
mpz_t N) Generate a uniform random integer in the range 0 to N - |
|
1, inclusive. |
|
|
|
The variable STATE must be initialized by calling one of the |
|
`gmp_randinit' functions (*Note Random State Initialization::) |
|
before invoking this function. |
|
|
|
- Function: void mpz_rrandomb (mpz_t ROP, gmp_randstate_t STATE, |
|
unsigned long int N) |
|
Generate a random integer with long strings of zeros and ones in |
|
the binary representation. Useful for testing functions and |
|
algorithms, since this kind of random numbers have proven to be |
|
more likely to trigger corner-case bugs. The random number will |
|
be in the range 0 to 2^N - 1, inclusive. |
|
|
|
The variable STATE must be initialized by calling one of the |
|
`gmp_randinit' functions (*Note Random State Initialization::) |
|
before invoking this function. |
|
|
|
- Function: void mpz_random (mpz_t ROP, mp_size_t MAX_SIZE) |
|
Generate a random integer of at most MAX_SIZE limbs. The generated |
|
random number doesn't satisfy any particular requirements of |
|
randomness. Negative random numbers are generated when MAX_SIZE |
|
is negative. |
|
|
|
This function is obsolete. Use `mpz_urandomb' or `mpz_urandomm' |
|
instead. |
|
|
|
- Function: void mpz_random2 (mpz_t ROP, mp_size_t MAX_SIZE) |
|
Generate a random integer of at most MAX_SIZE limbs, with long |
|
strings of zeros and ones in the binary representation. Useful |
|
for testing functions and algorithms, since this kind of random |
|
numbers have proven to be more likely to trigger corner-case bugs. |
|
Negative random numbers are generated when MAX_SIZE is negative. |
|
|
|
This function is obsolete. Use `mpz_rrandomb' instead. |
|
|
|
|
|
File: gmp.info, Node: Miscellaneous Integer Functions, Prev: Integer Random Numbers, Up: Integer Functions |
|
|
|
Miscellaneous Functions |
|
======================= |
|
|
|
- Function: int mpz_fits_ulong_p (mpz_t OP) |
|
- Function: int mpz_fits_slong_p (mpz_t OP) |
|
- Function: int mpz_fits_uint_p (mpz_t OP) |
|
- Function: int mpz_fits_sint_p (mpz_t OP) |
|
- Function: int mpz_fits_ushort_p (mpz_t OP) |
|
- Function: int mpz_fits_sshort_p (mpz_t OP) |
|
Return non-zero iff the value of OP fits in an `unsigned long int', |
|
`signed long int', `unsigned int', `signed int', `unsigned short |
|
int', or `signed short int', respectively. Otherwise, return zero. |
|
|
|
- Macro: int mpz_odd_p (mpz_t OP) |
|
- Macro: int mpz_even_p (mpz_t OP) |
|
Determine whether OP is odd or even, respectively. Return |
|
non-zero if yes, zero if no. These macros evaluate their |
|
arguments more than once. |
|
|
|
- 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. |
|
|
|
- Function: size_t mpz_sizeinbase (mpz_t OP, int BASE) |
|
Return the size of OP measured in number of digits in base BASE. |
|
The base may vary from 2 to 36. The returned value will be exact |
|
or 1 too big. If BASE is a power of 2, the returned value will |
|
always be exact. |
|
|
|
This function is useful in order to allocate the right amount of |
|
space before converting OP to a string. The right amount of |
|
allocation is normally two more than the value returned by |
|
`mpz_sizeinbase' (one extra for a minus sign and one for the |
|
terminating '\0'). |
|
|
|
|
|
File: gmp.info, Node: Rational Number Functions, Next: Floating-point Functions, Prev: Integer Functions, Up: Top |
|
|
|
Rational Number Functions |
|
************************* |
|
|
|
This chapter describes the GMP functions for performing arithmetic |
|
on rational numbers. These functions start with the prefix `mpq_'. |
|
|
|
Rational numbers are stored in objects of type `mpq_t'. |
|
|
|
All rational arithmetic functions assume operands have a canonical |
|
form, and canonicalize their result. The canonical from means that the |
|
denominator and the numerator have no common factors, and that the |
|
denominator is positive. Zero has the unique representation 0/1. |
|
|
|
Pure assignment functions do not canonicalize the assigned variable. |
|
It is the responsibility of the user to canonicalize the assigned |
|
variable before any arithmetic operations are performed on that |
|
variable. *Note that this is an incompatible change from version 1 of |
|
the library.* |
|
|
|
- Function: void mpq_canonicalize (mpq_t OP) |
|
Remove any factors that are common to the numerator and |
|
denominator of OP, and make the denominator positive. |
|
|
|
* Menu: |
|
|
|
* Initializing Rationals:: |
|
* Rational Arithmetic:: |
|
* Comparing Rationals:: |
|
* Applying Integer Functions:: |
|
* I/O of Rationals:: |
|
* Miscellaneous Rational Functions:: |
|
|
|
|
|
File: gmp.info, Node: Initializing Rationals, Next: Rational Arithmetic, Prev: Rational Number Functions, Up: Rational Number Functions |
|
|
|
Initialization and Assignment Functions |
|
======================================= |
|
|
|
- Function: void mpq_init (mpq_t DEST_RATIONAL) |
|
Initialize DEST_RATIONAL and set it to 0/1. Each variable should |
|
normally only be initialized once, or at least cleared out (using |
|
the function `mpq_clear') between each initialization. |
|
|
|
- Function: void mpq_clear (mpq_t RATIONAL_NUMBER) |
|
Free the space occupied by RATIONAL_NUMBER. Make sure to call this |
|
function for all `mpq_t' variables when you are done with them. |
|
|
|
- Function: void mpq_set (mpq_t ROP, mpq_t OP) |
|
- Function: void mpq_set_z (mpq_t ROP, mpz_t OP) |
|
Assign ROP from OP. |
|
|
|
- Function: void mpq_set_ui (mpq_t ROP, unsigned long int OP1, |
|
unsigned long int OP2) |
|
- Function: void mpq_set_si (mpq_t ROP, signed long int OP1, unsigned |
|
long int OP2) |
|
Set the value of ROP to OP1/OP2. Note that if OP1 and OP2 have |
|
common factors, ROP has to be passed to `mpq_canonicalize' before |
|
any operations are performed on ROP. |
|
|
|
- Function: void mpq_swap (mpq_t ROP1, mpq_t ROP2) |
|
Swap the values ROP1 and ROP2 efficiently. |
|
|
|
|
|
File: gmp.info, Node: Rational Arithmetic, Next: Comparing Rationals, Prev: Initializing Rationals, Up: Rational Number Functions |
|
|
|
Arithmetic Functions |
|
==================== |
|
|
|
- Function: void mpq_add (mpq_t SUM, mpq_t ADDEND1, mpq_t ADDEND2) |
|
Set SUM to ADDEND1 + ADDEND2. |
|
|
|
- Function: void mpq_sub (mpq_t DIFFERENCE, mpq_t MINUEND, mpq_t |
|
SUBTRAHEND) |
|
Set DIFFERENCE to MINUEND - SUBTRAHEND. |
|
|
|
- Function: void mpq_mul (mpq_t PRODUCT, mpq_t MULTIPLIER, mpq_t |
|
MULTIPLICAND) |
|
Set PRODUCT to MULTIPLIER times MULTIPLICAND. |
|
|
|
- Function: void mpq_div (mpq_t QUOTIENT, mpq_t DIVIDEND, mpq_t |
|
DIVISOR) |
|
Set QUOTIENT to DIVIDEND/DIVISOR. |
|
|
|
- Function: void mpq_neg (mpq_t NEGATED_OPERAND, mpq_t OPERAND) |
|
Set NEGATED_OPERAND to -OPERAND. |
|
|
|
- Function: void mpq_inv (mpq_t INVERTED_NUMBER, mpq_t NUMBER) |
|
Set INVERTED_NUMBER to 1/NUMBER. If the new denominator is zero, |
|
this routine will divide by zero. |
|
|
|
|
|
File: gmp.info, Node: Comparing Rationals, Next: Applying Integer Functions, Prev: Rational Arithmetic, Up: Rational Number Functions |
|
|
|
Comparison Functions |
|
==================== |
|
|
|
- Function: int mpq_cmp (mpq_t OP1, mpq_t OP2) |
|
Compare OP1 and OP2. Return a positive value if OP1 > OP2, zero |
|
if OP1 = OP2, and a negative value if OP1 < OP2. |
|
|
|
To determine if two rationals are equal, `mpq_equal' is faster than |
|
`mpq_cmp'. |
|
|
|
- Macro: int mpq_cmp_ui (mpq_t OP1, unsigned long int NUM2, unsigned |
|
long int DEN2) |
|
Compare OP1 and NUM2/DEN2. Return a positive value if OP1 > |
|
NUM2/DEN2, zero if OP1 = NUM2/DEN2, and a negative value if OP1 < |
|
NUM2/DEN2. |
|
|
|
This routine allows that NUM2 and DEN2 have common factors. |
|
|
|
This function is actually implemented as a macro. It evaluates its |
|
arguments multiple times. |
|
|
|
- Macro: int mpq_sgn (mpq_t OP) |
|
Return +1 if OP > 0, 0 if OP = 0, and -1 if OP < 0. |
|
|
|
This function is actually implemented as a macro. It evaluates its |
|
arguments multiple times. |
|
|
|
- Function: int mpq_equal (mpq_t OP1, mpq_t OP2) |
|
Return non-zero if OP1 and OP2 are equal, zero if they are |
|
non-equal. Although `mpq_cmp' can be used for the same purpose, |
|
this function is much faster. |
|
|
|
|
|
File: gmp.info, Node: Applying Integer Functions, Next: I/O of Rationals, Prev: Comparing Rationals, Up: Rational Number Functions |
|
|
|
Applying Integer Functions to Rationals |
|
======================================= |
|
|
|
The set of `mpq' functions is quite small. In particular, there are |
|
few functions for either input or output. But there are two macros |
|
that allow us to apply any `mpz' function on the numerator or |
|
denominator of a rational number. If these macros are used to assign |
|
to the rational number, `mpq_canonicalize' normally need to be called |
|
afterwards. |
|
|
|
- Macro: mpz_t mpq_numref (mpq_t OP) |
|
- Macro: mpz_t mpq_denref (mpq_t OP) |
|
Return a reference to the numerator and denominator of OP, |
|
respectively. The `mpz' functions can be used on the result of |
|
these macros. |
|
|
|
|
|
File: gmp.info, Node: I/O of Rationals, Next: Miscellaneous Rational Functions, Prev: Applying Integer Functions, Up: Rational Number Functions |
|
|
|
Input and Output Functions |
|
========================== |
|
|
|
Functions that perform input from a stdio stream, and functions that |
|
output to a stdio stream. Passing a `NULL' pointer for a STREAM |
|
argument to any of these functions will make them read from `stdin' and |
|
write to `stdout', respectively. |
|
|
|
When using any of these functions, it is a good idea to include |
|
`stdio.h' before `gmp.h', since that will allow `gmp.h' to define |
|
prototypes for these functions. |
|
|
|
- Function: size_t mpq_out_str (FILE *STREAM, int BASE, mpq_t OP) |
|
Output OP on stdio stream STREAM, as a string of digits in base |
|
BASE. The base may vary from 2 to 36. Output is in the form |
|
`num/den' or if the denominator is 1 then just `num'. |
|
|
|
Return the number of bytes written, or if an error occurred, |
|
return 0. |
|
|
|
|
|
File: gmp.info, Node: Miscellaneous Rational Functions, Prev: I/O of Rationals, Up: Rational Number Functions |
|
|
|
Miscellaneous Functions |
|
======================= |
|
|
|
- Function: double mpq_get_d (mpq_t OP) |
|
Convert OP to a double. |
|
|
|
- Function: double mpq_set_d (mpq_t ROP, double D) |
|
Set ROP to the value of d, without rounding. |
|
|
|
These functions assign between either the numerator or denominator |
|
of a rational, and an integer. Instead of using these functions, it is |
|
preferable to use the more general mechanisms `mpq_numref' and |
|
`mpq_denref', together with `mpz_set'. |
|
|
|
- Function: void mpq_set_num (mpq_t RATIONAL, mpz_t NUMERATOR) |
|
Copy NUMERATOR to the numerator of RATIONAL. When this risks to |
|
make the numerator and denominator of RATIONAL have common |
|
factors, you have to pass RATIONAL to `mpq_canonicalize' before |
|
any operations are performed on RATIONAL. |
|
|
|
This function is equivalent to `mpz_set (mpq_numref (RATIONAL), |
|
NUMERATOR)'. |
|
|
|
- Function: void mpq_set_den (mpq_t RATIONAL, mpz_t DENOMINATOR) |
|
Copy DENOMINATOR to the denominator of RATIONAL. When this risks |
|
to make the numerator and denominator of RATIONAL have common |
|
factors, or if the denominator might be negative, you have to pass |
|
RATIONAL to `mpq_canonicalize' before any operations are performed |
|
on RATIONAL. |
|
|
|
*In version 1 of the library, negative denominators were handled by |
|
copying the sign to the numerator. That is no longer done.* |
|
|
|
This function is equivalent to `mpz_set (mpq_denref (RATIONAL), |
|
DENOMINATORS)'. |
|
|
|
- Function: void mpq_get_num (mpz_t NUMERATOR, mpq_t RATIONAL) |
|
Copy the numerator of RATIONAL to the integer NUMERATOR, to |
|
prepare for integer operations on the numerator. |
|
|
|
This function is equivalent to `mpz_set (NUMERATOR, mpq_numref |
|
(RATIONAL))'. |
|
|
|
- Function: void mpq_get_den (mpz_t DENOMINATOR, mpq_t RATIONAL) |
|
Copy the denominator of RATIONAL to the integer DENOMINATOR, to |
|
prepare for integer operations on the denominator. |
|
|
|
This function is equivalent to `mpz_set (DENOMINATOR, mpq_denref |
|
(RATIONAL))'. |
|
|
|
|
File: gmp.info, Node: Floating-point Functions, Next: Low-level Functions, Prev: Rational Number Functions, Up: Top |
File: gmp.info, Node: Floating-point Functions, Next: Low-level Functions, Prev: Rational Number Functions, Up: Top |
|
|
Floating-point Functions |
Floating-point Functions |
************************ |
************************ |
|
|
This is a description of the *preliminary* interface for |
This chapter describes the GMP functions for performing floating |
floating-point arithmetic in GNU MP 2. |
point arithmetic. These functions start with the prefix `mpf_'. |
|
|
The floating-point functions expect arguments of type `mpf_t'. |
GMP floating point numbers are stored in objects of type `mpf_t'. |
|
|
The MP floating-point functions have an interface that is similar to |
The GMP floating-point functions have an interface that is similar |
the MP integer functions. The function prefix for floating-point |
to the GMP integer functions. The function prefix for floating-point |
operations is `mpf_'. |
operations is `mpf_'. |
|
|
There is one significant characteristic of floating-point numbers |
There is one significant characteristic of floating-point numbers |
that has motivated a difference between this function class and other |
that has motivated a difference between this function class and other |
MP function classes: the inherent inexactness of floating point |
GMP function classes: the inherent inexactness of floating point |
arithmetic. The user has to specify the precision of each variable. A |
arithmetic. The user has to specify the precision of each variable. A |
computation that assigns a variable will take place with the precision |
computation that assigns a variable will take place with the precision |
of the assigned variable; the precision of variables used as input is |
of the assigned variable; the precision of variables used as input is |
|
|
The precision of a calculation is defined as follows: Compute the |
The precision of a calculation is defined as follows: Compute the |
requested operation exactly (with "infinite precision"), and truncate |
requested operation exactly (with "infinite precision"), and truncate |
the result to the destination variable precision. Even if the user has |
the result to the destination variable precision. Even if the user has |
asked for a very high precision, MP will not calculate with superfluous |
asked for a very high precision, GMP will not calculate with |
digits. For example, if two low-precision numbers of nearly equal |
superfluous digits. For example, if two low-precision numbers of |
magnitude are added, the precision of the result will be limited to |
nearly equal magnitude are added, the precision of the result will be |
what is required to represent the result accurately. |
limited to what is required to represent the result accurately. |
|
|
The MP floating-point functions are *not* intended as a smooth |
The GMP floating-point functions are _not_ intended as a smooth |
extension to the IEEE P754 arithmetic. Specifically, the results |
extension to the IEEE P754 arithmetic. Specifically, the results |
obtained on one computer often differs from the results obtained on a |
obtained on one computer often differs from the results obtained on a |
computer with a different word size. |
computer with a different word size. |
Line 73 computer with a different word size. |
|
Line 669 computer with a different word size. |
|
* Miscellaneous Float Functions:: |
* Miscellaneous Float Functions:: |
|
|
|
|
File: gmp.info, Node: Initializing Floats, Next: Assigning Floats, Up: Floating-point Functions |
File: gmp.info, Node: Initializing Floats, Next: Assigning Floats, Prev: Floating-point Functions, Up: Floating-point Functions |
|
|
Initialization and Assignment Functions |
Initialization Functions |
======================================= |
======================== |
|
|
- Function: void mpf_set_default_prec (unsigned long int PREC) |
- Function: void mpf_set_default_prec (unsigned long int PREC) |
Set the default precision to be *at least* PREC bits. All |
Set the default precision to be *at least* PREC bits. All |
|
|
{ |
{ |
mpf_t x, y; |
mpf_t x, y; |
mpf_init (x); /* use default precision */ |
mpf_init (x); /* use default precision */ |
mpf_init2 (y, 256); /* precision *at least* 256 bits */ |
mpf_init2 (y, 256); /* precision _at least_ 256 bits */ |
... |
... |
/* Unless the program is about to exit, do ... */ |
/* Unless the program is about to exit, do ... */ |
mpf_clear (x); |
mpf_clear (x); |
|
|
low-level function that does not change the allocation. The PREC |
low-level function that does not change the allocation. The PREC |
argument must not be larger that the precision previously returned |
argument must not be larger that the precision previously returned |
by `mpf_get_prec'. It is crucial that the precision of ROP is |
by `mpf_get_prec'. It is crucial that the precision of ROP is |
ultimately reset to exactly the value returned by `mpf_get_prec'. |
ultimately reset to exactly the value returned by `mpf_get_prec' |
|
before the first call to `mpf_set_prec_raw'. |
|
|
|
|
File: gmp.info, Node: Assigning Floats, Next: Simultaneous Float Init & Assign, Prev: Initializing Floats, Up: Floating-point Functions |
File: gmp.info, Node: Assigning Floats, Next: Simultaneous Float Init & Assign, Prev: Initializing Floats, Up: Floating-point Functions |
|
|
Assignment Functions |
Assignment Functions |
-------------------- |
==================== |
|
|
These functions assign new values to already initialized floats |
These functions assign new values to already initialized floats |
(*note Initializing Floats::.). |
(*note Initializing Floats::). |
|
|
- Function: void mpf_set (mpf_t ROP, mpf_t OP) |
- Function: void mpf_set (mpf_t ROP, mpf_t OP) |
- Function: void mpf_set_ui (mpf_t ROP, unsigned long int OP) |
- Function: void mpf_set_ui (mpf_t ROP, unsigned long int OP) |
Line 168 Assignment Functions |
|
Line 765 Assignment Functions |
|
This is so that numbers like `0.23' are not interpreted as octal. |
This is so that numbers like `0.23' are not interpreted as octal. |
|
|
White space is allowed in the string, and is simply ignored. |
White space is allowed in the string, and is simply ignored. |
|
[This is not really true; white-space is ignored in the beginning |
|
of the string and within the mantissa, but not in other places, |
|
such as after a minus sign or in the exponent. We are considering |
|
changing the definition of this function, making it fail when |
|
there is any white-space in the input, since that makes a lot of |
|
sense. Please tell us your opinion about this change. Do you |
|
really want it to accept "3 14" as meaning 314 as it does now?] |
|
|
This function returns 0 if the entire string up to the '\0' is a |
This function returns 0 if the entire string up to the '\0' is a |
valid number in base BASE. Otherwise it returns -1. |
valid number in base BASE. Otherwise it returns -1. |
|
|
|
- Function: void mpf_swap (mpf_t ROP1, mpf_t ROP2) |
|
Swap the values ROP1 and ROP2 efficiently. |
|
|
|
|
File: gmp.info, Node: Simultaneous Float Init & Assign, Next: Converting Floats, Prev: Assigning Floats, Up: Floating-point Functions |
File: gmp.info, Node: Simultaneous Float Init & Assign, Next: Converting Floats, Prev: Assigning Floats, Up: Floating-point Functions |
|
|
Combined Initialization and Assignment Functions |
Combined Initialization and Assignment Functions |
------------------------------------------------ |
================================================ |
|
|
For convenience, MP provides a parallel series of initialize-and-set |
For convenience, GMP provides a parallel series of |
functions which initialize the output and then store the value there. |
initialize-and-set functions which initialize the output and then store |
These functions' names have the form `mpf_init_set...' |
the value there. These functions' names have the form `mpf_init_set...' |
|
|
Once the float has been initialized by any of the `mpf_init_set...' |
Once the float has been initialized by any of the `mpf_init_set...' |
functions, it can be used as the source or destination operand for the |
functions, it can be used as the source or destination operand for the |
Line 222 Conversion Functions |
|
Line 829 Conversion Functions |
|
N_DIGITS is 0, the maximum number of digits accurately |
N_DIGITS is 0, the maximum number of digits accurately |
representable by OP. |
representable by OP. |
|
|
If STR is NULL, space for the mantissa is allocated using the |
If STR is `NULL', space for the mantissa is allocated using the |
default allocation function, and a pointer to the string is |
default allocation function. |
returned. |
|
|
|
If STR is not NULL, it should point to a block of storage enough |
If STR is not `NULL', it should point to a block of storage enough |
large for the mantissa, i.e., N_DIGITS + 2. The two extra bytes |
large for the mantissa, i.e., N_DIGITS + 2. The two extra bytes |
are for a possible minus sign, and for the terminating null |
are for a possible minus sign, and for the terminating null |
character. |
character. |
Line 236 Conversion Functions |
|
Line 842 Conversion Functions |
|
If N_DIGITS is 0, the maximum number of digits meaningfully |
If N_DIGITS is 0, the maximum number of digits meaningfully |
achievable from the precision of OP will be generated. Note that |
achievable from the precision of OP will be generated. Note that |
the space requirements for STR in this case will be impossible for |
the space requirements for STR in this case will be impossible for |
the user to predetermine. Therefore, you need to pass NULL for |
the user to predetermine. Therefore, you need to pass `NULL' for |
the string argument whenever N_DIGITS is 0. |
the string argument whenever N_DIGITS is 0. |
|
|
The generated string is a fraction, with an implicit radix point |
The generated string is a fraction, with an implicit radix point |
Line 244 Conversion Functions |
|
Line 850 Conversion Functions |
|
number 3.1416 would be returned as "31416" in the string and 1 |
number 3.1416 would be returned as "31416" in the string and 1 |
written at EXPPTR. |
written at EXPPTR. |
|
|
|
A pointer to the result string is returned. This pointer will |
|
will either equal STR, or if that is `NULL', will point to the |
|
allocated storage. |
|
|
|
|
File: gmp.info, Node: Float Arithmetic, Next: Float Comparison, Prev: Converting Floats, Up: Floating-point Functions |
File: gmp.info, Node: Float Arithmetic, Next: Float Comparison, Prev: Converting Floats, Up: Floating-point Functions |
|
|
Line 269 Arithmetic Functions |
|
Line 879 Arithmetic Functions |
|
|
|
Division is undefined if the divisor is zero, and passing a zero |
Division is undefined if the divisor is zero, and passing a zero |
divisor to the divide functions will make these functions intentionally |
divisor to the divide functions will make these functions intentionally |
divide by zero. This gives the user the possibility to handle |
divide by zero. This lets the user handle arithmetic exceptions in |
arithmetic exceptions in these functions in the same manner as other |
these functions in the same manner as other arithmetic exceptions. |
arithmetic exceptions. |
|
|
|
- Function: void mpf_div (mpf_t ROP, mpf_t OP1, mpf_t OP2) |
- Function: void mpf_div (mpf_t ROP, mpf_t OP1, mpf_t OP2) |
- Function: void mpf_ui_div (mpf_t ROP, unsigned long int OP1, mpf_t |
- Function: void mpf_ui_div (mpf_t ROP, unsigned long int OP1, mpf_t |
Line 284 arithmetic exceptions. |
|
Line 893 arithmetic exceptions. |
|
- Function: void mpf_sqrt_ui (mpf_t ROP, unsigned long int OP) |
- Function: void mpf_sqrt_ui (mpf_t ROP, unsigned long int OP) |
Set ROP to the square root of OP. |
Set ROP to the square root of OP. |
|
|
|
- Function: void mpf_pow_ui (mpf_t ROP, mpf_t OP1, unsigned long int |
|
OP2) |
|
Set ROP to OP1 raised to the power OP2. |
|
|
- Function: void mpf_neg (mpf_t ROP, mpf_t OP) |
- Function: void mpf_neg (mpf_t ROP, mpf_t OP) |
Set ROP to -OP. |
Set ROP to -OP. |
|
|
Line 331 Input and Output Functions |
|
Line 944 Input and Output Functions |
|
========================== |
========================== |
|
|
Functions that perform input from a stdio stream, and functions that |
Functions that perform input from a stdio stream, and functions that |
output to a stdio stream. Passing a NULL pointer for a STREAM argument |
output to a stdio stream. Passing a `NULL' pointer for a STREAM |
to any of these functions will make them read from `stdin' and write to |
argument to any of these functions will make them read from `stdin' and |
`stdout', respectively. |
write to `stdout', respectively. |
|
|
When using any of these functions, it is a good idea to include |
When using any of these functions, it is a good idea to include |
`stdio.h' before `gmp.h', since that will allow `gmp.h' to define |
`stdio.h' before `gmp.h', since that will allow `gmp.h' to define |
Line 378 File: gmp.info, Node: Miscellaneous Float Functions, |
|
Line 991 File: gmp.info, Node: Miscellaneous Float Functions, |
|
Miscellaneous Functions |
Miscellaneous Functions |
======================= |
======================= |
|
|
|
- Function: void mpf_ceil (mpf_t ROP, mpf_t OP) |
|
- Function: void mpf_floor (mpf_t ROP, mpf_t OP) |
|
- Function: void mpf_trunc (mpf_t ROP, mpf_t OP) |
|
Set ROP to OP rounded to an integer. `mpf_ceil' rounds to the |
|
next higher integer, `mpf_floor' to the next lower, and |
|
`mpf_trunc' to the integer towards zero. |
|
|
|
- Function: void mpf_urandomb (mpf_t ROP, gmp_randstate_t STATE, |
|
unsigned long int NBITS) |
|
Generate a uniformly distributed random float in ROP, such that 0 |
|
<= ROP < 1, with NBITS significant bits in the mantissa. |
|
|
|
The variable STATE must be initialized by calling one of the |
|
`gmp_randinit' functions (*Note Random State Initialization::) |
|
before invoking this function. |
|
|
- Function: void mpf_random2 (mpf_t ROP, mp_size_t MAX_SIZE, mp_exp_t |
- Function: void mpf_random2 (mpf_t ROP, mp_size_t MAX_SIZE, mp_exp_t |
MAX_EXP) |
MAX_EXP) |
Generate a random float of at most MAX_SIZE limbs, with long |
Generate a random float of at most MAX_SIZE limbs, with long |
Line 387 Miscellaneous Functions |
|
Line 1016 Miscellaneous Functions |
|
this kind of random numbers have proven to be more likely to |
this kind of random numbers have proven to be more likely to |
trigger corner-case bugs. Negative random numbers are generated |
trigger corner-case bugs. Negative random numbers are generated |
when MAX_SIZE is negative. |
when MAX_SIZE is negative. |
|
|
|
|
File: gmp.info, Node: Low-level Functions, Next: BSD Compatible Functions, Prev: Floating-point Functions, Up: Top |
|
|
|
Low-level Functions |
|
******************* |
|
|
|
This chapter describes low-level MP functions, used to implement the |
|
high-level MP functions, but also intended for time-critical user code. |
|
|
|
These functions start with the prefix `mpn_'. |
|
|
|
The `mpn' functions are designed to be as fast as possible, *not* to |
|
provide a coherent calling interface. The different functions have |
|
somewhat similar interfaces, but there are variations that make them |
|
hard to use. These functions do as little as possible apart from the |
|
real multiple precision computation, so that no time is spent on things |
|
that not all callers need. |
|
|
|
A source operand is specified by a pointer to the least significant |
|
limb and a limb count. A destination operand is specified by just a |
|
pointer. It is the responsibility of the caller to ensure that the |
|
destination has enough space for storing the result. |
|
|
|
With this way of specifying operands, it is possible to perform |
|
computations on subranges of an argument, and store the result into a |
|
subrange of a destination. |
|
|
|
A common requirement for all functions is that each source area |
|
needs at least one limb. No size argument may be zero. |
|
|
|
The `mpn' functions is the base for the implementation of the `mpz_', |
|
`mpf_', and `mpq_' functions. |
|
|
|
This example adds the number beginning at SRC1_PTR and the number |
|
beginning at SRC2_PTR and writes the sum at DEST_PTR. All areas have |
|
SIZE limbs. |
|
|
|
cy = mpn_add_n (dest_ptr, src1_ptr, src2_ptr, size) |
|
|
|
In the notation used here, a source operand is identified by the |
|
pointer to the least significant limb, and the limb count in braces. |
|
For example, {s1_ptr, s1_size}. |
|
|
|
- Function: mp_limb_t mpn_add_n (mp_limb_t * DEST_PTR, const mp_limb_t |
|
* SRC1_PTR, const mp_limb_t * SRC2_PTR, mp_size_t SIZE) |
|
Add {SRC1_PTR, SIZE} and {SRC2_PTR, SIZE}, and write the SIZE |
|
least significant limbs of the result to DEST_PTR. Return carry, |
|
either 0 or 1. |
|
|
|
This is the lowest-level function for addition. It is the |
|
preferred function for addition, since it is written in assembly |
|
for most targets. For addition of a variable to itself (i.e., |
|
SRC1_PTR equals SRC2_PTR, use `mpn_lshift' with a count of 1 for |
|
optimal speed. |
|
|
|
- Function: mp_limb_t mpn_add_1 (mp_limb_t * DEST_PTR, const mp_limb_t |
|
* SRC1_PTR, mp_size_t SIZE, mp_limb_t SRC2_LIMB) |
|
Add {SRC1_PTR, SIZE} and SRC2_LIMB, and write the SIZE least |
|
significant limbs of the result to DEST_PTR. Return carry, either |
|
0 or 1. |
|
|
|
- Function: mp_limb_t mpn_add (mp_limb_t * DEST_PTR, const mp_limb_t * |
|
SRC1_PTR, mp_size_t SRC1_SIZE, const mp_limb_t * SRC2_PTR, |
|
mp_size_t SRC2_SIZE) |
|
Add {SRC1_PTR, SRC1_SIZE} and {SRC2_PTR, SRC2_SIZE}, and write the |
|
SRC1_SIZE least significant limbs of the result to DEST_PTR. |
|
Return carry, either 0 or 1. |
|
|
|
This function requires that SRC1_SIZE is greater than or equal to |
|
SRC2_SIZE. |
|
|
|
- Function: mp_limb_t mpn_sub_n (mp_limb_t * DEST_PTR, const mp_limb_t |
|
* SRC1_PTR, const mp_limb_t * SRC2_PTR, mp_size_t SIZE) |
|
Subtract {SRC2_PTR, SRC2_SIZE} from {SRC1_PTR, SIZE}, and write |
|
the SIZE least significant limbs of the result to DEST_PTR. |
|
Return borrow, either 0 or 1. |
|
|
|
This is the lowest-level function for subtraction. It is the |
|
preferred function for subtraction, since it is written in |
|
assembly for most targets. |
|
|
|
- Function: mp_limb_t mpn_sub_1 (mp_limb_t * DEST_PTR, const mp_limb_t |
|
* SRC1_PTR, mp_size_t SIZE, mp_limb_t SRC2_LIMB) |
|
Subtract SRC2_LIMB from {SRC1_PTR, SIZE}, and write the SIZE least |
|
significant limbs of the result to DEST_PTR. Return borrow, |
|
either 0 or 1. |
|
|
|
- Function: mp_limb_t mpn_sub (mp_limb_t * DEST_PTR, const mp_limb_t * |
|
SRC1_PTR, mp_size_t SRC1_SIZE, const mp_limb_t * SRC2_PTR, |
|
mp_size_t SRC2_SIZE) |
|
Subtract {SRC2_PTR, SRC2_SIZE} from {SRC1_PTR, SRC1_SIZE}, and |
|
write the SRC1_SIZE least significant limbs of the result to |
|
DEST_PTR. Return borrow, either 0 or 1. |
|
|
|
This function requires that SRC1_SIZE is greater than or equal to |
|
SRC2_SIZE. |
|
|
|
- Function: void mpn_mul_n (mp_limb_t * DEST_PTR, const mp_limb_t * |
|
SRC1_PTR, const mp_limb_t * SRC2_PTR, mp_size_t SIZE) |
|
Multiply {SRC1_PTR, SIZE} and {SRC2_PTR, SIZE}, and write the |
|
*entire* result to DEST_PTR. |
|
|
|
The destination has to have space for 2SIZE limbs, even if the |
|
significant result might be one limb smaller. |
|
|
|
- Function: mp_limb_t mpn_mul_1 (mp_limb_t * DEST_PTR, const mp_limb_t |
|
* SRC1_PTR, mp_size_t SIZE, mp_limb_t SRC2_LIMB) |
|
Multiply {SRC1_PTR, SIZE} and SRC2_LIMB, and write the SIZE least |
|
significant limbs of the product to DEST_PTR. Return the most |
|
significant limb of the product. |
|
|
|
This is a low-level function that is a building block for general |
|
multiplication as well as other operations in MP. It is written |
|
in assembly for most targets. |
|
|
|
Don't call this function if SRC2_LIMB is a power of 2; use |
|
`mpn_lshift' with a count equal to the logarithm of SRC2_LIMB |
|
instead, for optimal speed. |
|
|
|
- Function: mp_limb_t mpn_addmul_1 (mp_limb_t * DEST_PTR, const |
|
mp_limb_t * SRC1_PTR, mp_size_t SIZE, mp_limb_t SRC2_LIMB) |
|
Multiply {SRC1_PTR, SIZE} and SRC2_LIMB, and add the SIZE least |
|
significant limbs of the product to {DEST_PTR, SIZE} and write the |
|
result to DEST_PTR DEST_PTR. Return the most significant limb of |
|
the product, plus carry-out from the addition. |
|
|
|
This is a low-level function that is a building block for general |
|
multiplication as well as other operations in MP. It is written |
|
in assembly for most targets. |
|
|
|
- Function: mp_limb_t mpn_submul_1 (mp_limb_t * DEST_PTR, const |
|
mp_limb_t * SRC1_PTR, mp_size_t SIZE, mp_limb_t SRC2_LIMB) |
|
Multiply {SRC1_PTR, SIZE} and SRC2_LIMB, and subtract the SIZE |
|
least significant limbs of the product from {DEST_PTR, SIZE} and |
|
write the result to DEST_PTR. Return the most significant limb of |
|
the product, minus borrow-out from the subtraction. |
|
|
|
This is a low-level function that is a building block for general |
|
multiplication and division as well as other operations in MP. It |
|
is written in assembly for most targets. |
|
|
|
- Function: mp_limb_t mpn_mul (mp_limb_t * DEST_PTR, const mp_limb_t * |
|
SRC1_PTR, mp_size_t SRC1_SIZE, const mp_limb_t * SRC2_PTR, |
|
mp_size_t SRC2_SIZE) |
|
Multiply {SRC1_PTR, SRC1_SIZE} and {SRC2_PTR, SRC2_SIZE}, and |
|
write the result to DEST_PTR. Return the most significant limb of |
|
the result. |
|
|
|
The destination has to have space for SRC1_SIZE + SRC1_SIZE limbs, |
|
even if the result might be one limb smaller. |
|
|
|
This function requires that SRC1_SIZE is greater than or equal to |
|
SRC2_SIZE. The destination must be distinct from either input |
|
operands. |
|
|
|
- Function: mp_size_t mpn_divrem (mp_limb_t * R1P, mp_size_t XSIZE, |
|
mp_limb_t * RS2P, mp_size_t RS2SIZE, const mp_limb_t * S3P, |
|
mp_size_t S3SIZE) |
|
Divide {RS2P, RS2SIZE} by {S3P, S3SIZE}, and write the quotient at |
|
R1P, with the exception of the most significant limb, which is |
|
returned. The remainder replaces the dividend at RS2P. |
|
|
|
In addition to an integer quotient, XSIZE fraction limbs are |
|
developed, and stored after the integral limbs. For most usages, |
|
XSIZE will be zero. |
|
|
|
It is required that RS2SIZE is greater than or equal to S3SIZE. |
|
It is required that the most significant bit of the divisor is set. |
|
|
|
If the quotient is not needed, pass RS2P + S3SIZE as R1P. Aside |
|
from that special case, no overlap between arguments is permitted. |
|
|
|
Return the most significant limb of the quotient, either 0 or 1. |
|
|
|
The area at R1P needs to be RS2SIZE - S3SIZE + XSIZE limbs large. |
|
|
|
- Function: mp_limb_t mpn_divrem_1 (mp_limb_t * R1P, mp_size_t XSIZE, |
|
mp_limb_t * S2P, mp_size_t S2SIZE, mp_limb_t S3LIMB) |
|
Divide {S2P, S2SIZE} by S3LIMB, and write the quotient at R1P. |
|
Return the remainder. |
|
|
|
In addition to an integer quotient, XSIZE fraction limbs are |
|
developed, and stored after the integral limbs. For most usages, |
|
XSIZE will be zero. |
|
|
|
The areas at R1P and S2P have to be identical or completely |
|
separate, not partially overlapping. |
|
|
|
- Function: mp_size_t mpn_divmod (mp_limb_t * R1P, mp_limb_t * RS2P, |
|
mp_size_t RS2SIZE, const mp_limb_t * S3P, mp_size_t S3SIZE) |
|
*This interface is obsolete. It will disappear from future |
|
releases. Use `mpn_divrem' in its stead.* |
|
|
|
- Function: mp_limb_t mpn_divmod_1 (mp_limb_t * R1P, mp_limb_t * S2P, |
|
mp_size_t S2SIZE, mp_limb_t S3LIMB) |
|
*This interface is obsolete. It will disappear from future |
|
releases. Use `mpn_divrem_1' in its stead.* |
|
|
|
- Function: mp_limb_t mpn_mod_1 (mp_limb_t * S1P, mp_size_t S1SIZE, |
|
mp_limb_t S2LIMB) |
|
Divide {S1P, S1SIZE} by S2LIMB, and return the remainder. |
|
|
|
- Function: mp_limb_t mpn_preinv_mod_1 (mp_limb_t * S1P, mp_size_t |
|
S1SIZE, mp_limb_t S2LIMB, mp_limb_t S3LIMB) |
|
*This interface is obsolete. It will disappear from future |
|
releases. Use `mpn_mod_1' in its stead.* |
|
|
|
- Function: mp_limb_t mpn_bdivmod (mp_limb_t * DEST_PTR, mp_limb_t * |
|
S1P, mp_size_t S1SIZE, const mp_limb_t * S2P, mp_size_t |
|
S2SIZE, unsigned long int D) |
|
The function puts the low [D/BITS_PER_MP_LIMB] limbs of Q = {S1P, |
|
S1SIZE}/{S2P, S2SIZE} mod 2^D at DEST_PTR, and returns the high D |
|
mod BITS_PER_MP_LIMB bits of Q. |
|
|
|
{S1P, S1SIZE} - Q * {S2P, S2SIZE} mod 2^(S1SIZE*BITS_PER_MP_LIMB) |
|
is placed at S1P. Since the low [D/BITS_PER_MP_LIMB] limbs of |
|
this difference are zero, it is possible to overwrite the low |
|
limbs at S1P with this difference, provided DEST_PTR <= S1P. |
|
|
|
This function requires that S1SIZE * BITS_PER_MP_LIMB >= D, and |
|
that {S2P, S2SIZE} is odd. |
|
|
|
*This interface is preliminary. It might change incompatibly in |
|
future revisions.* |
|
|
|
- Function: mp_limb_t mpn_lshift (mp_limb_t * DEST_PTR, const |
|
mp_limb_t * SRC_PTR, mp_size_t SRC_SIZE, unsigned long int |
|
COUNT) |
|
Shift {SRC_PTR, SRC_SIZE} COUNT bits to the left, and write the |
|
SRC_SIZE least significant limbs of the result to DEST_PTR. COUNT |
|
might be in the range 1 to n - 1, on an n-bit machine. The bits |
|
shifted out to the left are returned. |
|
|
|
Overlapping of the destination space and the source space is |
|
allowed in this function, provided DEST_PTR >= SRC_PTR. |
|
|
|
This function is written in assembly for most targets. |
|
|
|
- Function: mp_limp_t mpn_rshift (mp_limb_t * DEST_PTR, const |
|
mp_limb_t * SRC_PTR, mp_size_t SRC_SIZE, unsigned long int |
|
COUNT) |
|
Shift {SRC_PTR, SRC_SIZE} COUNT bits to the right, and write the |
|
SRC_SIZE most significant limbs of the result to DEST_PTR. COUNT |
|
might be in the range 1 to n - 1, on an n-bit machine. The bits |
|
shifted out to the right are returned. |
|
|
|
Overlapping of the destination space and the source space is |
|
allowed in this function, provided DEST_PTR <= SRC_PTR. |
|
|
|
This function is written in assembly for most targets. |
|
|
|
- Function: int mpn_cmp (const mp_limb_t * SRC1_PTR, const mp_limb_t * |
|
SRC2_PTR, mp_size_t SIZE) |
|
Compare {SRC1_PTR, SIZE} and {SRC2_PTR, SIZE} and return a |
|
positive value if src1 > src2, 0 of they are equal, and a negative |
|
value if src1 < src2. |
|
|
|
- Function: mp_size_t mpn_gcd (mp_limb_t * DEST_PTR, mp_limb_t * |
|
SRC1_PTR, mp_size_t SRC1_SIZE, mp_limb_t * SRC2_PTR, |
|
mp_size_t SRC2_SIZE) |
|
Puts at DEST_PTR the greatest common divisor of {SRC1_PTR, |
|
SRC1_SIZE} and {SRC2_PTR, SRC2_SIZE}; both source operands are |
|
destroyed by the operation. The size in limbs of the greatest |
|
common divisor is returned. |
|
|
|
{SRC1_PTR, SRC1_SIZE} must be odd, and {SRC2_PTR, SRC2_SIZE} must |
|
have at least as many bits as {SRC1_PTR, SRC1_SIZE}. |
|
|
|
*This interface is preliminary. It might change incompatibly in |
|
future revisions.* |
|
|
|
- Function: mp_limb_t mpn_gcd_1 (const mp_limb_t * SRC1_PTR, mp_size_t |
|
SRC1_SIZE, mp_limb_t SRC2_LIMB) |
|
Return the greatest common divisor of {SRC1_PTR, SRC1_SIZE} and |
|
SRC2_LIMB, where SRC2_LIMB (as well as SRC1_SIZE) must be |
|
different from 0. |
|
|
|
- Function: mp_size_t mpn_gcdext (mp_limb_t * R1P, mp_limb_t * R2P, |
|
mp_limb_t * S1P, mp_size_t S1SIZE, mp_limb_t * S2P, mp_size_t |
|
S2SIZE) |
|
Puts at R1P the greatest common divisor of {S1P, S1SIZE} and {S2P, |
|
S2SIZE}. The first cofactor is written at R2P. Both source |
|
operands are destroyed by the operation. The size in limbs of the |
|
greatest common divisor is returned. |
|
|
|
*This interface is preliminary. It might change incompatibly in |
|
future revisions.* |
|
|
|
- Function: mp_size_t mpn_sqrtrem (mp_limb_t * R1P, mp_limb_t * R2P, |
|
const mp_limb_t * SP, mp_size_t SIZE) |
|
Compute the square root of {SP, SIZE} and put the result at R1P. |
|
Write the remainder at R2P, unless R2P is NULL. |
|
|
|
Return the size of the remainder, whether R2P was NULL or non-NULL. |
|
Iff the operand was a perfect square, the return value will be 0. |
|
|
|
The areas at R1P and SP have to be distinct. The areas at R2P and |
|
SP have to be identical or completely separate, not partially |
|
overlapping. |
|
|
|
The area at R1P needs to have space for ceil(SIZE/2) limbs. The |
|
area at R2P needs to be SIZE limbs large. |
|
|
|
*This interface is preliminary. It might change incompatibly in |
|
future revisions.* |
|
|
|
- Function: mp_size_t mpn_get_str (unsigned char *STR, int BASE, |
|
mp_limb_t * S1P, mp_size_t S1SIZE) |
|
Convert {S1P, S1SIZE} to a raw unsigned char array in base BASE. |
|
The string is not in ASCII; to convert it to printable format, add |
|
the ASCII codes for `0' or `A', depending on the base and range. |
|
There may be leading zeros in the string. |
|
|
|
The area at S1P is clobbered. |
|
|
|
Return the number of characters in STR. |
|
|
|
The area at STR has to have space for the largest possible number |
|
represented by a S1SIZE long limb array, plus one extra character. |
|
|
|
- Function: mp_size_t mpn_set_str (mp_limb_t * R1P, const char *STR, |
|
size_t strsize, int BASE) |
|
Convert the raw unsigned char array at STR of length STRSIZE to a |
|
limb array {S1P, S1SIZE}. The base of STR is BASE. |
|
|
|
Return the number of limbs stored in R1P. |
|
|
|
- Function: unsigned long int mpn_scan0 (const mp_limb_t * S1P, |
|
unsigned long int BIT) |
|
Scan S1P from bit position BIT for the next clear bit. |
|
|
|
It is required that there be a clear bit within the area at S1P at |
|
or beyond bit position BIT, so that the function has something to |
|
return. |
|
|
|
*This interface is preliminary. It might change incompatibly in |
|
future revisions.* |
|
|
|
- Function: unsigned long int mpn_scan1 (const mp_limb_t * S1P, |
|
unsigned long int BIT) |
|
Scan S1P from bit position BIT for the next set bit. |
|
|
|
It is required that there be a set bit within the area at S1P at or |
|
beyond bit position BIT, so that the function has something to |
|
return. |
|
|
|
*This interface is preliminary. It might change incompatibly in |
|
future revisions.* |
|
|
|
- Function: void mpn_random2 (mp_limb_t * R1P, mp_size_t R1SIZE) |
|
Generate a random number of length R1SIZE with long strings of |
|
zeros and ones in the binary representation, and store it at R1P. |
|
|
|
The generated random numbers are intended for testing the |
|
correctness of the implementation of the `mpn' routines. |
|
|
|
- Function: unsigned long int mpn_popcount (const mp_limb_t * S1P, |
|
unsigned long int SIZE) |
|
Count the number of set bits in {S1P, SIZE}. |
|
|
|
- Function: unsigned long int mpn_hamdist (const mp_limb_t * S1P, |
|
const mp_limb_t * S2P, unsigned long int SIZE) |
|
Compute the hamming distance between {S1P, SIZE} and {S2P, SIZE}. |
|
|
|
- Function: int mpn_perfect_square_p (const mp_limb_t * S1P, mp_size_t |
|
SIZE) |
|
Return non-zero iff {S1P, SIZE} is a perfect square. |
|
|
|
|
|
File: gmp.info, Node: BSD Compatible Functions, Next: Custom Allocation, Prev: Low-level Functions, Up: Top |
|
|
|
Berkeley MP Compatible Functions |
|
******************************** |
|
|
|
These functions are intended to be fully compatible with the |
|
Berkeley MP library which is available on many BSD derived U*ix systems. |
|
|
|
The original Berkeley MP library has a usage restriction: you cannot |
|
use the same variable as both source and destination in a single |
|
function call. The compatible functions in GNU MP do not share this |
|
restriction--inputs and outputs may overlap. |
|
|
|
It is not recommended that new programs are written using these |
|
functions. Apart from the incomplete set of functions, the interface |
|
for initializing `MINT' objects is more error prone, and the `pow' |
|
function collides with `pow' in `libm.a'. |
|
|
|
Include the header `mp.h' to get the definition of the necessary |
|
types and functions. If you are on a BSD derived system, make sure to |
|
include GNU `mp.h' if you are going to link the GNU `libmp.a' to you |
|
program. This means that you probably need to give the -I<dir> option |
|
to the compiler, where <dir> is the directory where you have GNU `mp.h'. |
|
|
|
- Function: MINT * itom (signed short int INITIAL_VALUE) |
|
Allocate an integer consisting of a `MINT' object and dynamic limb |
|
space. Initialize the integer to INITIAL_VALUE. Return a pointer |
|
to the `MINT' object. |
|
|
|
- Function: MINT * xtom (char *INITIAL_VALUE) |
|
Allocate an integer consisting of a `MINT' object and dynamic limb |
|
space. Initialize the integer from INITIAL_VALUE, a hexadecimal, |
|
'\0'-terminate C string. Return a pointer to the `MINT' object. |
|
|
|
- Function: void move (MINT *SRC, MINT *DEST) |
|
Set DEST to SRC by copying. Both variables must be previously |
|
initialized. |
|
|
|
- Function: void madd (MINT *SRC_1, MINT *SRC_2, MINT *DESTINATION) |
|
Add SRC_1 and SRC_2 and put the sum in DESTINATION. |
|
|
|
- Function: void msub (MINT *SRC_1, MINT *SRC_2, MINT *DESTINATION) |
|
Subtract SRC_2 from SRC_1 and put the difference in DESTINATION. |
|
|
|
- Function: void mult (MINT *SRC_1, MINT *SRC_2, MINT *DESTINATION) |
|
Multiply SRC_1 and SRC_2 and put the product in DESTINATION. |
|
|
|
- Function: void mdiv (MINT *DIVIDEND, MINT *DIVISOR, MINT *QUOTIENT, |
|
MINT *REMAINDER) |
|
- Function: void sdiv (MINT *DIVIDEND, signed short int DIVISOR, MINT |
|
*QUOTIENT, signed short int *REMAINDER) |
|
Set QUOTIENT to DIVIDEND/DIVISOR, and REMAINDER to DIVIDEND mod |
|
DIVISOR. The quotient is rounded towards zero; the remainder has |
|
the same sign as the dividend unless it is zero. |
|
|
|
Some implementations of these functions work differently--or not |
|
at all--for negative arguments. |
|
|
|
- Function: void msqrt (MINT *OPERAND, MINT *ROOT, MINT *REMAINDER) |
|
Set ROOT to the truncated integer part of the square root of |
|
OPERAND. Set REMAINDER to OPERAND-ROOT*ROOT, (i.e., zero if |
|
OPERAND is a perfect square). |
|
|
|
If ROOT and REMAINDER are the same variable, the results are |
|
undefined. |
|
|
|
- Function: void pow (MINT *BASE, MINT *EXP, MINT *MOD, MINT *DEST) |
|
Set DEST to (BASE raised to EXP) modulo MOD. |
|
|
|
- Function: void rpow (MINT *BASE, signed short int EXP, MINT *DEST) |
|
Set DEST to BASE raised to EXP. |
|
|
|
- Function: void gcd (MINT *OPERAND1, MINT *OPERAND2, MINT *RES) |
|
Set RES to the greatest common divisor of OPERAND1 and OPERAND2. |
|
|
|
- Function: int mcmp (MINT *OPERAND1, MINT *OPERAND2) |
|
Compare OPERAND1 and OPERAND2. Return a positive value if |
|
OPERAND1 > OPERAND2, zero if OPERAND1 = OPERAND2, and a negative |
|
value if OPERAND1 < OPERAND2. |
|
|
|
- Function: void min (MINT *DEST) |
|
Input a decimal string from `stdin', and put the read integer in |
|
DEST. SPC and TAB are allowed in the number string, and are |
|
ignored. |
|
|
|
- Function: void mout (MINT *SRC) |
|
Output SRC to `stdout', as a decimal string. Also output a |
|
newline. |
|
|
|
- Function: char * mtox (MINT *OPERAND) |
|
Convert OPERAND to a hexadecimal string, and return a pointer to |
|
the string. The returned string is allocated using the default |
|
memory allocation function, `malloc' by default. |
|
|
|
- Function: void mfree (MINT *OPERAND) |
|
De-allocate, the space used by OPERAND. *This function should |
|
only be passed a value returned by `itom' or `xtom'.* |
|
|
|
|
|
File: gmp.info, Node: Custom Allocation, Next: Contributors, Prev: BSD Compatible Functions, Up: Top |
|
|
|
Custom Allocation |
|
***************** |
|
|
|
By default, the MP functions use `malloc', `realloc', and `free' for |
|
memory allocation. If `malloc' or `realloc' fails, the MP library |
|
terminates execution after printing a fatal error message to standard |
|
error. |
|
|
|
For some applications, you may wish to allocate memory in other |
|
ways, or you may not want to have a fatal error when there is no more |
|
memory available. To accomplish this, you can specify alternative |
|
memory allocation functions. |
|
|
|
- Function: void mp_set_memory_functions ( |
|
void *(*ALLOC_FUNC_PTR) (size_t), |
|
void *(*REALLOC_FUNC_PTR) (void *, size_t, size_t), |
|
void (*FREE_FUNC_PTR) (void *, size_t)) |
|
Replace the current allocation functions from the arguments. If |
|
an argument is NULL, the corresponding default function is |
|
retained. |
|
|
|
*Make sure to call this function in such a way that there are no |
|
active MP objects that were allocated using the previously active |
|
allocation function! Usually, that means that you have to call |
|
this function before any other MP function.* |
|
|
|
The functions you supply should fit the following declarations: |
|
|
|
- Function: void * allocate_function (size_t ALLOC_SIZE) |
|
This function should return a pointer to newly allocated space |
|
with at least ALLOC_SIZE storage units. |
|
|
|
- Function: void * reallocate_function (void *PTR, size_t OLD_SIZE, |
|
size_t NEW_SIZE) |
|
This function should return a pointer to newly allocated space of |
|
at least NEW_SIZE storage units, after copying at least the first |
|
OLD_SIZE storage units from PTR. It should also de-allocate the |
|
space at PTR. |
|
|
|
You can assume that the space at PTR was formerly returned from |
|
`allocate_function' or `reallocate_function', for a request for |
|
OLD_SIZE storage units. |
|
|
|
- Function: void deallocate_function (void *PTR, size_t SIZE) |
|
De-allocate the space pointed to by PTR. |
|
|
|
You can assume that the space at PTR was formerly returned from |
|
`allocate_function' or `reallocate_function', for a request for |
|
SIZE storage units. |
|
|
|
(A "storage unit" is the unit in which the `sizeof' operator returns |
|
the size of an object, normally an 8 bit byte.) |
|
|
|
|
|
File: gmp.info, Node: Contributors, Next: References, Prev: Custom Allocation, Up: Top |
|
|
|
Contributors |
|
************ |
|
|
|
I would like to thank Gunnar Sjoedin and Hans Riesel for their help |
|
with mathematical problems, Richard Stallman for his help with design |
|
issues and for revising the first version of this manual, Brian Beuning |
|
and Doug Lea for their testing of early versions of the library. |
|
|
|
John Amanatides of York University in Canada contributed the function |
|
`mpz_probab_prime_p'. |
|
|
|
Paul Zimmermann of Inria sparked the development of GMP 2, with his |
|
comparisons between bignum packages. |
|
|
|
Ken Weber (Kent State University, Universidade Federal do Rio Grande |
|
do Sul) contributed `mpz_gcd', `mpz_divexact', `mpn_gcd', and |
|
`mpn_bdivmod', partially supported by CNPq (Brazil) grant 301314194-2. |
|
|
|
Per Bothner of Cygnus Support helped to set up MP to use Cygnus' |
|
configure. He has also made valuable suggestions and tested numerous |
|
intermediary releases. |
|
|
|
Joachim Hollman was involved in the design of the `mpf' interface, |
|
and in the `mpz' design revisions for version 2. |
|
|
|
Bennet Yee contributed the functions `mpz_jacobi' and `mpz_legendre'. |
|
|
|
Andreas Schwab contributed the files `mpn/m68k/lshift.S' and |
|
`mpn/m68k/rshift.S'. |
|
|
|
The development of floating point functions of GNU MP 2, were |
|
supported in part by the ESPRIT-BRA (Basic Research Activities) 6846 |
|
project POSSO (POlynomial System SOlving). |
|
|
|
GNU MP 2 was finished and released by TMG Datakonsult, |
|
Sodermannagatan 5, 116 23 STOCKHOLM, SWEDEN, in cooperation with the |
|
IDA Center for Computing Sciences, USA. |
|
|
|
|
|
File: gmp.info, Node: References, Prev: Contributors, Up: Top |
|
|
|
References |
|
********** |
|
|
|
* Donald E. Knuth, "The Art of Computer Programming", vol 2, |
|
"Seminumerical Algorithms", 2nd edition, Addison-Wesley, 1981. |
|
|
|
* John D. Lipson, "Elements of Algebra and Algebraic Computing", The |
|
Benjamin Cummings Publishing Company Inc, 1981. |
|
|
|
* Richard M. Stallman, "Using and Porting GCC", Free Software |
|
Foundation, 1995. |
|
|
|
* Peter L. Montgomery, "Modular Multiplication Without Trial |
|
Division", in Mathematics of Computation, volume 44, number 170, |
|
April 1985. |
|
|
|
* Torbjorn Granlund and Peter L. Montgomery, "Division by Invariant |
|
Integers using Multiplication", in Proceedings of the SIGPLAN |
|
PLDI'94 Conference, June 1994. |
|
|
|
* Tudor Jebelean, "An algorithm for exact division", Journal of |
|
Symbolic Computation, v. 15, 1993, pp. 169-180. |
|
|
|
* Kenneth Weber, "The accelerated integer GCD algorithm", ACM |
|
Transactions on Mathematical Software, v. 21 (March), 1995, pp. |
|
111-122. |
|
|
|
|
|
File: gmp.info, Node: Concept Index, Up: Top |
|
|
|
Concept Index |
|
************* |
|
|
|
* Menu: |
|
|
|
* gmp.h: MP Basics. |
|
* mp.h: BSD Compatible Functions. |
|
* Arithmetic functions <1>: Float Arithmetic. |
|
* Arithmetic functions: Integer Arithmetic. |
|
* Bit manipulation functions: Integer Logic and Bit Fiddling. |
|
* BSD MP compatible functions: BSD Compatible Functions. |
|
* Comparison functions: Float Comparison. |
|
* Conditions for copying GNU MP: Copying. |
|
* Conversion functions <1>: Converting Integers. |
|
* Conversion functions: Converting Floats. |
|
* Copying conditions: Copying. |
|
* Float arithmetic functions: Float Arithmetic. |
|
* Float assignment functions: Assigning Floats. |
|
* Float comparisons functions: Float Comparison. |
|
* Float functions: Floating-point Functions. |
|
* Float input and output functions: I/O of Floats. |
|
* Floating-point functions: Floating-point Functions. |
|
* Floating-point number: MP Basics. |
|
* I/O functions <1>: I/O of Floats. |
|
* I/O functions: I/O of Integers. |
|
* Initialization and assignment functions <1>: Simultaneous Float Init & Assign. |
|
* Initialization and assignment functions: Simultaneous Integer Init & Assign. |
|
* Input functions <1>: I/O of Integers. |
|
* Input functions: I/O of Floats. |
|
* Installation: Installing MP. |
|
* Integer: MP Basics. |
|
* Integer arithmetic functions: Integer Arithmetic. |
|
* Integer assignment functions: Assigning Integers. |
|
* Integer conversion functions: Converting Integers. |
|
* Integer functions: Integer Functions. |
|
* Integer input and output functions: I/O of Integers. |
|
* Limb: MP Basics. |
|
* Logical functions: Integer Logic and Bit Fiddling. |
|
* Low-level functions: Low-level Functions. |
|
* Miscellaneous float functions: Miscellaneous Float Functions. |
|
* Miscellaneous integer functions: Miscellaneous Integer Functions. |
|
* Output functions <1>: I/O of Floats. |
|
* Output functions: I/O of Integers. |
|
* Rational number: MP Basics. |
|
* Rational number functions: Rational Number Functions. |
|
* Reporting bugs: Reporting Bugs. |
|
* User-defined precision: Floating-point Functions. |
|
|
|