Click or drag to resize
gmp_lib Class
Represents all of the functions of the GNU MP library.
Inheritance Hierarchy
SystemObject
  Math.Gmp.Nativegmp_lib

Namespace:  Math.Gmp.Native
Assembly:  Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
public static class gmp_lib

The gmp_lib type exposes the following members.

Properties
  NameDescription
Public propertyStatic membergmp_errno
Gets or sets the global GMP error number.
Top
Methods
  NameDescription
Public methodStatic memberCode example_mpz_realloc
Change the space for integer to new_alloc limbs.
Public methodStatic memberallocate
Return a pointer to newly allocated space with at least alloc_size bytes.
Public methodStatic memberfree(IntPtr)
Free the unmanaged memory at ptr.
Public methodStatic memberfree(char_ptr)
De-allocate the space pointed to by ptr.
Public methodStatic memberfree(gmp_randstate_t)
De-allocate the space pointed to by ptr.
Public methodStatic memberfree(mp_ptr)
De-allocate the space pointed to by ptrs.
Public methodStatic memberfree(void_ptr)
De-allocate the space pointed to by ptr.
Public methodStatic memberfree(void_ptr, size_t)
De-allocate the space pointed to by ptr.
Public methodStatic memberCode examplegmp_asprintf
Form a null-terminated string in a block of memory obtained from the current memory allocation function.
Public methodStatic memberCode examplegmp_fprintf
Print to the stream fp.
Public methodStatic memberCode examplegmp_fscanf
Read from the stream fp.
Public methodStatic memberCode examplegmp_printf
Print to the standard output stdout.
Public methodStatic membergmp_randclear
Free all memory occupied by state.
Public methodStatic memberCode examplegmp_randinit_default
Initialize state with a default algorithm.
Public methodStatic memberCode examplegmp_randinit_lc_2exp
Initialize state with a linear congruential algorithm X = (aX + c) mod 2^m2exp.
Public methodStatic memberCode examplegmp_randinit_lc_2exp_size
Initialize state for a linear congruential algorithm as per gmp_randinit_lc_2exp.
Public methodStatic memberCode examplegmp_randinit_mt
Initialize state for a Mersenne Twister algorithm.
Public methodStatic memberCode examplegmp_randinit_set
Initialize rop with a copy of the algorithm and state from op.
Public methodStatic memberCode examplegmp_randseed
Set an initial seed value into state.
Public methodStatic memberCode examplegmp_randseed_ui
Set an initial seed value into state.
Public methodStatic memberCode examplegmp_scanf
Read from the standard input stdin.
Public methodStatic memberCode examplegmp_snprintf
Form a null-terminated string in buf.
Public methodStatic memberCode examplegmp_sprintf
Form a null-terminated string in buf.
Public methodStatic memberCode examplegmp_sscanf
Read from a null-terminated string s.
Public methodStatic memberCode examplegmp_urandomb_ui
Generate a uniformly distributed random number of n bits, i.e. in the range 0 to 2^n - 1 inclusive.
Public methodStatic memberCode examplegmp_urandomm_ui
Generate a uniformly distributed random number in the range 0 to n - 1, inclusive.
Public methodStatic memberCode examplegmp_vasprintf
Form a null-terminated string in a block of memory obtained from the current memory allocation function.
Public methodStatic memberCode examplegmp_vfprintf
Print to the stream fp.
Public methodStatic memberCode examplegmp_vfscanf
Read from the stream fp.
Public methodStatic memberCode examplegmp_vprintf
Print to the standard output stdout.
Public methodStatic memberCode examplegmp_vscanf
Read from the standard input stdin.
Public methodStatic memberCode examplegmp_vsnprintf
Form a null-terminated string in buf.
Public methodStatic memberCode examplegmp_vsprintf
Form a null-terminated string in buf.
Public methodStatic memberCode examplegmp_vsscanf
Read from a null-terminated string s.
Public methodStatic memberCode examplemp_get_memory_functions
Get the current allocation functions, storing function pointers to the locations given by the arguments.
Public methodStatic memberCode examplemp_set_memory_functions
Replace the current allocation functions from the arguments.
Public methodStatic memberCode examplempf_abs
Set rop to | op |.
Public methodStatic memberCode examplempf_add
Set rop to op1 + op2.
Public methodStatic memberCode examplempf_add_ui
Set rop to op1 + op2.
Public methodStatic memberCode examplempf_ceil
Set rop to op rounded to the next higher integer.
Public methodStatic memberCode examplempf_clear
Free the space occupied by x.
Public methodStatic memberCode examplempf_clears
Free the space occupied by a NULL-terminated list of mpf_t variables.
Public methodStatic memberCode examplempf_cmp
Compare op1 and op2.
Public methodStatic memberCode examplempf_cmp_d
Compare op1 and op2.
Public methodStatic memberCode examplempf_cmp_si
Compare op1 and op2.
Public methodStatic memberCode examplempf_cmp_ui
Compare op1 and op2.
Public methodStatic memberCode examplempf_cmp_z
Compare op1 and op2.
Public methodStatic memberCode examplempf_div
Set rop to op1 / op2.
Public methodStatic memberCode examplempf_div_2exp
Set rop to op1 / 2^op2.
Public methodStatic memberCode examplempf_div_ui
Set rop to op1 / op2.
Public methodStatic memberCode examplempf_fits_sint_p
Return non-zero if op fits in a 32-bit integer, when truncated to an integer.
Public methodStatic memberCode examplempf_fits_slong_p
Return non-zero if op fits in a 32-bit integer, when truncated to an integer.
Public methodStatic memberCode examplempf_fits_sshort_p
Return non-zero if op fits in a 16-bit integer, when truncated to an integer.
Public methodStatic memberCode examplempf_fits_uint_p
Return non-zero if op fits in an unsigned 32-bit integer, when truncated to an integer.
Public methodStatic memberCode examplempf_fits_ulong_p
Return non-zero if op fits in an unsigned 32-bit integer, when truncated to an integer.
Public methodStatic memberCode examplempf_fits_ushort_p
Return non-zero if op fits in an unsigned 16-bit integer, when truncated to an integer.
Public methodStatic memberCode examplempf_floor
Set rop to op rounded to the next lower integer.
Public methodStatic memberCode examplempf_get_d
Convert op to a double, truncating if necessary (i.e. rounding towards zero).
Public methodStatic memberCode examplempf_get_d_2exp
Convert op to a double, truncating if necessary (i.e. rounding towards zero), and with an exponent returned separately.
Public methodStatic memberCode examplempf_get_default_prec
Return the default precision actually used.
Public methodStatic memberCode examplempf_get_prec
Return the current precision of op, in bits.
Public methodStatic memberCode examplempf_get_si
Convert op to a 32-bit integer, truncating any fraction part.
Public methodStatic memberCode examplempf_get_str(char_ptr, mp_exp_t, Int32, size_t, mpf_t)
Convert op to a string of digits in base base.
Public methodStatic memberCode examplempf_get_str(char_ptr, ptrmp_exp_t, Int32, size_t, mpf_t)
Convert op to a string of digits in base base.
Public methodStatic memberCode examplempf_get_ui
Convert op to an unsigned 32-bit integer, truncating any fraction part.
Public methodStatic memberCode examplempf_init
Initialize x to 0.
Public methodStatic memberCode examplempf_init_set
Initialize rop and set its value from op.
Public methodStatic memberCode examplempf_init_set_d
Initialize rop and set its value from op.
Public methodStatic memberCode examplempf_init_set_si
Initialize rop and set its value from op.
Public methodStatic memberCode examplempf_init_set_str
Initialize rop and set its value from the string in str.
Public methodStatic memberCode examplempf_init_set_ui
Initialize rop and set its value from op.
Public methodStatic memberCode examplempf_init2
Initialize x to 0 and set its precision to be at least prec bits.
Public methodStatic memberCode examplempf_inits
Initialize a NULL-terminated list of mpf_t variables, and set their values to 0.
Public methodStatic memberCode examplempf_inp_str
Read a string in base base from stream, and put the read float in rop.
Public methodStatic memberCode examplempf_integer_p
Return non-zero if op is an integer.
Public methodStatic memberCode examplempf_mul
Set rop to op1 * op2.
Public methodStatic memberCode examplempf_mul_2exp
Set rop to op1 * 2^op2.
Public methodStatic memberCode examplempf_mul_ui
Set rop to op1 * op2.
Public methodStatic memberCode examplempf_neg
Set rop to -op.
Public methodStatic memberCode examplempf_out_str
Print op to stream, as a string of digits.
Public methodStatic memberCode examplempf_pow_ui
Set rop to op1^op2.
Public methodStatic memberCode examplempf_random2
Generate a random float of at most max_size limbs, with long strings of zeros and ones in the binary representation.
Public methodStatic memberCode examplempf_reldiff
Compute the relative difference between op1 and op2 and store the result in rop. This is | op1 - op2 | / op1.
Public methodStatic memberCode examplempf_set
Set the value of rop from op.
Public methodStatic memberCode examplempf_set_d
Set the value of rop from op.
Public methodStatic memberCode examplempf_set_default_prec
Set the default precision to be at least prec bits.
Public methodStatic memberCode examplempf_set_prec
Set the precision of rop to be at least prec bits.
Public methodStatic memberCode examplempf_set_prec_raw
Set the precision of rop to be at least prec bits, without changing the memory allocated.
Public methodStatic memberCode examplempf_set_q
Set the value of rop from op.
Public methodStatic memberCode examplempf_set_si
Set the value of rop from op.
Public methodStatic memberCode examplempf_set_str
Set the value of rop from the string in str.
Public methodStatic memberCode examplempf_set_ui
Set the value of rop from op.
Public methodStatic memberCode examplempf_set_z
Set the value of rop from op.
Public methodStatic memberCode examplempf_sgn
Return +1 if op > 0, 0 if op = 0, and -1 if op < 0.
Public methodStatic memberCode examplempf_size
Return the number of limbs currently in use.
Public methodStatic memberCode examplempf_sqrt
Set rop to the square root of op.
Public methodStatic memberCode examplempf_sqrt_ui
Set rop to the square root of op.
Public methodStatic memberCode examplempf_sub
Set rop to op1 - op2.
Public methodStatic memberCode examplempf_sub_ui
Set rop to op1 - op2.
Public methodStatic memberCode examplempf_swap
Swap rop1 and rop2 efficiently.
Public methodStatic memberCode examplempf_trunc
Set rop to op rounded to the integer towards zero.
Public methodStatic memberCode examplempf_ui_div
Set rop to op1 / op2.
Public methodStatic memberCode examplempf_ui_sub
Set rop to op1 - op2.
Public methodStatic memberCode examplempf_urandomb
Generate a uniformly distributed random float in rop, such that 0 ≤ rop < 1, with nbits significant bits in the mantissa or less if the precision of rop is smaller.
Public methodStatic memberCode examplempn_add
Add {s1p, s1n} and {s2p, s2n}, and write the s1n least significant limbs of the result to rp.
Public methodStatic memberCode examplempn_add_1
Add {s1p, n} and s2limb, and write the n least significant limbs of the result to rp.
Public methodStatic memberCode examplempn_add_n
Add {s1p, n} and {s2p, n}, and write the n least significant limbs of the result to rp.
Public methodStatic memberCode examplempn_addmul_1
Multiply {s1p, n} and s2limb, and add the n least significant limbs of the product to {rp, n} and write the result to rp.
Public methodStatic memberCode examplempn_and_n
Perform the bitwise logical and of {s1p, n} and {s2p, n}, and write the result to {rp, n}.
Public methodStatic memberCode examplempn_andn_n
Perform the bitwise logical and of {s1p, n} and the bitwise complement of {s2p, n}, and write the result to {rp, n}.
Public methodStatic memberCode examplempn_cmp
Compare {s1p, n} and {s2p, n}.
Public methodStatic memberCode examplempn_cnd_add_n
If cnd is non-zero, it produces the same result as a regular mpn_add_n, and if cnd is zero, it copies {s1p, n} to the result area and returns zero.
Public methodStatic memberCode examplempn_cnd_sub_n
If cnd is non-zero, it produces the same result as a regular mpn_sub_n, and if cnd is zero, it copies {s1p, n} to the result area and returns zero.
Public methodStatic memberCode examplempn_cnd_swap
If cnd is non-zero, swaps the contents of the areas {ap, n} and {bp, n}. Otherwise, the areas are left unmodified.
Public methodStatic memberCode examplempn_com
Perform the bitwise complement of {sp, n}, and write the result to {rp, n}.
Public methodStatic memberCode examplempn_copyd
Copy from {s1p, n} to {rp, n}, decreasingly.
Public methodStatic memberCode examplempn_copyi
Copy from {s1p, n} to {rp, n}, increasingly.
Public methodStatic memberCode examplempn_divexact_1
Divide {sp, n} by d, expecting it to divide exactly, and writing the result to {rrp, n}.
Public methodStatic memberCode examplempn_divexact_by3
Divide {sp, n} by 3, expecting it to divide exactly, and writing the result to {rp, n}.
Public methodStatic memberCode examplempn_divexact_by3c
Divide {sp, n} by 3, expecting it to divide exactly, and writing the result to {rp, n}.
Public methodStatic memberCode examplempn_divmod_1
Divide {s2p, s2n} by s3limb, and write the quotient at r1p.
Public methodStatic memberCode examplempn_divrem_1
Divide {s2p, s2n} by s3limb, and write the quotient at r1p.
Public methodStatic memberCode examplempn_gcd
Set {rp, retval} to the greatest common divisor of {xp, xn} and {yp, yn}.
Public methodStatic memberCode examplempn_gcd_1
Return the greatest common divisor of {xp, xn} and ylimb.
Public methodStatic memberCode examplempn_gcdext(mp_ptr, mp_ptr, mp_size_t, mp_ptr, mp_size_t, mp_ptr, mp_size_t)
Compute the greatest common divisor G of U and V. Compute a cofactor S such that G = US + VT.
Public methodStatic memberCode examplempn_gcdext(mp_ptr, mp_ptr, ptrmp_size_t, mp_ptr, mp_size_t, mp_ptr, mp_size_t)
Compute the greatest common divisor G of U and V. Compute a cofactor S such that G = US + VT.
Public methodStatic memberCode examplempn_get_str
Convert {s1p, s1n} to a raw unsigned char array at str in base base, and return the number of characters produced.
Public methodStatic memberCode examplempn_hamdist
Compute the hamming distance between {s1p, n} and {s2p, n}, which is the number of bit positions where the two operands have different bit values.
Public methodStatic memberCode examplempn_ior_n
Perform the bitwise logical inclusive or of {s1p, n} and {s2p, n}, and write the result to {rp, n}.
Public methodStatic memberCode examplempn_iorn_n
Perform the bitwise logical inclusive or of {s1p, n} and the bitwise complement of {s2p, n}, and write the result to {rp, n}.
Public methodStatic memberCode examplempn_lshift
Shift {sp, n} left by count bits, and write the result to {rp, n}.
Public methodStatic memberCode examplempn_mod_1
Divide {s1p, s1n} by s2limb, and return the remainder.
Public methodStatic memberCode examplempn_mul
Multiply {s1p, s1n} and {s2p, s2n}, and write the (s1n + s2n)-limb result to rp.
Public methodStatic memberCode examplempn_mul_1
Multiply {s1p, n} by s2limb, and write the n least significant limbs of the product to rp.
Public methodStatic memberCode examplempn_mul_n
Multiply {s1p, n} and {s2p, n}, and write the (2 * n)-limb result to rp.
Public methodStatic memberCode examplempn_nand_n
Perform the bitwise logical and of {s1p, n} and {s2p, n}, and write the bitwise complement of the result to {rp, n}.
Public methodStatic memberCode examplempn_neg
Perform the negation of {sp, n}, and write the result to {rp, n}.
Public methodStatic memberCode examplempn_nior_n
Perform the bitwise logical inclusive or of {s1p, n} and {s2p, n}, and write the bitwise complement of the result to {rp, n}.
Public methodStatic memberCode examplempn_perfect_power_p
Return non-zero iff {sp, n} is a perfect power.
Public methodStatic memberCode examplempn_perfect_square_p
Return non-zero iff {s1p, n} is a perfect square.
Public methodStatic memberCode examplempn_popcount
Count the number of set bits in {s1p, n}.
Public methodStatic memberCode examplempn_random
Generate a random number of length r1n and store it at r1p.
Public methodStatic memberCode examplempn_random2
Generate a random number of length r1n and store it at r1p.
Public methodStatic memberCode examplempn_rshift
Shift {sp, n} right by count bits, and write the result to {rp, n}.
Public methodStatic memberCode examplempn_scan0
Scan s1p from bit position bit for the next clear bit.
Public methodStatic memberCode examplempn_scan1
Scan s1p from bit position bit for the next set bit.
Public methodStatic memberCode examplempn_sec_add_1
Set R to A + b, where R = {rp, n}, A = {ap, n}, and b is a single limb.
Public methodStatic membermpn_sec_add_1_itch
Return the scratch space in number of limbs required by the function mpn_sec_add_1.
Public methodStatic memberCode examplempn_sec_div_qr
Set Q to the truncated quotient N / D and R to N modulo D, where N = {np, nn}, D = {dp, dn}, Q’s most significant limb is the function return value and the remaining limbs are {qp, nn - dn}, and R = {np, dn}.
Public methodStatic membermpn_sec_div_qr_itch
Return the scratch space in number of limbs required by the function mpn_sec_div_qr.
Public methodStatic memberCode examplempn_sec_div_r
Set R to N modulo D, where N = {np, nn}, D = {dp, dn}, and R = {np, dn}.
Public methodStatic membermpn_sec_div_r_itch
Return the scratch space in number of limbs required by the function mpn_sec_div_r.
Public methodStatic memberCode examplempn_sec_invert
Set R to the inverse of A modulo M, where R = {rp, n}, A = {ap, n}, and M = {mp, n}. This function’s interface is preliminary.
Public methodStatic membermpn_sec_invert_itch
Return the scratch space in number of limbs required by the function mpn_sec_invert.
Public methodStatic memberCode examplempn_sec_mul
Set R to A * B, where A = {ap, an}, B = {bp, bn}, and R = {rp, an + bn}.
Public methodStatic membermpn_sec_mul_itch
Return the scratch space in number of limbs required by the function mpn_sec_mul.
Public methodStatic memberCode examplempn_sec_powm
Set R to (B^E) modulo M, where R = {rp, n}, M = {mp, n}, and E = {ep, ceil(enb / mp_bits_per_limb)}.
Public methodStatic membermpn_sec_powm_itch
Return the scratch space in number of limbs required by the function mpn_sec_powm.
Public methodStatic memberCode examplempn_sec_sqr
Set R to A^2, where A = {ap, an}, and R = {rp, 2 * an}.
Public methodStatic membermpn_sec_sqr_itch
Return the scratch space in number of limbs required by the function mpn_sec_sqr.
Public methodStatic memberCode examplempn_sec_sub_1
Set R to A - b, where R = {rp, n}, A = {ap, n}, and b is a single limb.
Public methodStatic membermpn_sec_sub_1_itch
Return the scratch space in number of limbs required by the function mpn_sec_sub_1.
Public methodStatic memberCode examplempn_sec_tabselect
Select entry which from table tab, which has nents entries, each n limbs. Store the selected entry at rp.
Public methodStatic memberCode examplempn_set_str
Convert bytes {str, strsize} in the given base to limbs at rp.
Public methodStatic memberCode examplempn_sizeinbase
Return the size of {xp, n} measured in number of digits in the given base.
Public methodStatic memberCode examplempn_sqr
Compute the square of {s1p, n} and write the (2 * n)-limb result to rp.
Public methodStatic memberCode examplempn_sqrtrem
Compute the square root of {sp, n} and put the result at {r1p, ceil(n / 2)} and the remainder at {r2p, retval}.
Public methodStatic memberCode examplempn_sub
Subtract {s2p, s2n} from {s1p, s1n}, and write the s1n least significant limbs of the result to rp.
Public methodStatic memberCode examplempn_sub_1
Subtract s2limb from {s1p, n}, and write the n least significant limbs of the result to rp.
Public methodStatic memberCode examplempn_sub_n
Subtract {s2p, n} from {s1p, n}, and write the n least significant limbs of the result to rp.
Public methodStatic memberCode examplempn_submul_1
Multiply {s1p, n} and s2limb, and subtract the n least significant limbs of the product from {rp, n} and write the result to rp.
Public methodStatic memberCode examplempn_tdiv_qr
Divide {np, nn} by {dp, dn} and put the quotient at {qp, nn - dn + 1} and the remainder at {rp, dn}.
Public methodStatic memberCode examplempn_xnor_n
Perform the bitwise logical exclusive or of {s1p, n} and {s2p, n}, and write the bitwise complement of the result to {rp, n}.
Public methodStatic memberCode examplempn_xor_n
Perform the bitwise logical exclusive or of {s1p, n} and {s2p, n}, and write the result to {rp, n}.
Public methodStatic memberCode examplempn_zero
Zero {rp, n}.
Public methodStatic memberCode examplempn_zero_p
Test {sp, n} and return 1 if the operand is zero, 0 otherwise.
Public methodStatic memberCode examplempq_abs
Set rop to the absolute value of op.
Public methodStatic memberCode examplempq_add
Set sum to addend1 + addend2.
Public methodStatic memberCode examplempq_canonicalize
Remove any factors that are common to the numerator and denominator of op, and make the denominator positive.
Public methodStatic memberCode examplempq_clear
Free the space occupied by x.
Public methodStatic memberCode examplempq_clears
Free the space occupied by a NULL-terminated list of mpq_t variables.
Public methodStatic memberCode examplempq_cmp
Compare op1 and op2.
Public methodStatic memberCode examplempq_cmp_si
Compare op1 and num2 / den2.
Public methodStatic memberCode examplempq_cmp_ui
Compare op1 and num2 / den2.
Public methodStatic memberCode examplempq_cmp_z
Compare op1 and op2.
Public methodStatic memberCode examplempq_denref
Return a reference to the denominator op.
Public methodStatic memberCode examplempq_div
Set quotient to dividend / divisor.
Public methodStatic memberCode examplempq_div_2exp
Set rop to op1 / 2^op2.
Public methodStatic memberCode examplempq_equal
Return non-zero if op1 and op2 are equal, zero if they are non-equal.
Public methodStatic memberCode examplempq_get_d
Convert op to a double, truncating if necessary (i.e. rounding towards zero).
Public methodStatic memberCode examplempq_get_den
Set denominator to the denominator of rational.
Public methodStatic memberCode examplempq_get_num
Set numerator to the numerator of rational.
Public methodStatic memberCode examplempq_get_str
Convert op to a string of digits in base base.
Public methodStatic memberCode examplempq_init
Initialize x and set it to 0/1.
Public methodStatic memberCode examplempq_inits
Initialize a NULL-terminated list of mpq_t variables, and set their values to 0/1.
Public methodStatic memberCode examplempq_inp_str
Read a string of digits from stream and convert them to a rational in rop.
Public methodStatic memberCode examplempq_inv
Set inverted_number to 1 / number.
Public methodStatic memberCode examplempq_mul
Set product to multiplier * multiplicand.
Public methodStatic memberCode examplempq_mul_2exp
Set rop to op1 * 2*op2.
Public methodStatic memberCode examplempq_neg
Set negated_operand to -operand.
Public methodStatic memberCode examplempq_numref
Return a reference to the numerator op.
Public methodStatic memberCode examplempq_out_str
Output op on stdio stream stream, as a string of digits in base base.
Public methodStatic memberCode examplempq_set
Assign rop from op.
Public methodStatic memberCode examplempq_set_d
Set rop to the value of op. There is no rounding, this conversion is exact.
Public methodStatic memberCode examplempq_set_den
Set the denominator of rational to denominator.
Public methodStatic memberCode examplempq_set_f
Set rop to the value of op. There is no rounding, this conversion is exact.
Public methodStatic memberCode examplempq_set_num
Set the numerator of rational to numerator.
Public methodStatic memberCode examplempq_set_si
Set the value of rop to op1 / op2.
Public methodStatic memberCode examplempq_set_str
Set rop from a null-terminated string str in the given base.
Public methodStatic memberCode examplempq_set_ui
Set the value of rop to op1 / op2.
Public methodStatic memberCode examplempq_set_z
Assign rop from op.
Public methodStatic memberCode examplempq_sgn
Return +1 if op > 0, 0 if op = 0, and -1 if op < 0.
Public methodStatic memberCode examplempq_sub
Set difference to minuend - subtrahend.
Public methodStatic memberCode examplempq_swap
Swap the values rop1 and rop2 efficiently.
Public methodStatic memberCode examplempz_2fac_ui
Set rop to the double-factorial n!!.
Public methodStatic memberCode examplempz_abs
Set rop to the absolute value of op.
Public methodStatic memberCode examplempz_add
Set rop to op1 + op2.
Public methodStatic memberCode examplempz_add_ui
Set rop to op1 + op2.
Public methodStatic memberCode examplempz_addmul
Set rop to rop + op1 * op2.
Public methodStatic memberCode examplempz_addmul_ui
Set rop to rop + op1 * op2.
Public methodStatic memberCode examplempz_and
Set rop to op1 bitwise-and op2.
Public methodStatic memberCode examplempz_bin_ui
Compute the binomial coefficient n over k and store the result in rop.
Public methodStatic memberCode examplempz_bin_uiui
Compute the binomial coefficient n over k and store the result in rop.
Public methodStatic memberCode examplempz_cdiv_q
Set the quotient q to ceiling(n / d).
Public methodStatic memberCode examplempz_cdiv_q_2exp
Set the quotient q to ceiling(n / 2^b).
Public methodStatic memberCode examplempz_cdiv_q_ui
Set the quotient q to ceiling(n / d), and return the remainder r = | n - q * d |.
Public methodStatic memberCode examplempz_cdiv_qr
Set the quotient q to ceiling(n / d), and set the remainder r to n - q * d.
Public methodStatic memberCode examplempz_cdiv_qr_ui
Set quotient q to ceiling(n / d), set the remainder r to n - q * d, and return | r |.
Public methodStatic memberCode examplempz_cdiv_r
Set the remainder r to n - q * d where q = ceiling(n / d).
Public methodStatic memberCode examplempz_cdiv_r_2exp
Set the remainder r to n - q * 2^b where q = ceiling(n / 2^b).
Public methodStatic memberCode examplempz_cdiv_r_ui
Set the remainder r to n - q * d where q = ceiling(n / d), and return | r |.
Public methodStatic memberCode examplempz_cdiv_ui
Return the remainder | r | where r = n - q * d, and where q = ceiling(n / d).
Public methodStatic memberCode examplempz_clear
Free the space occupied by x.
Public methodStatic memberCode examplempz_clears
Free the space occupied by a NULL-terminated list of mpz_t variables.
Public methodStatic memberCode examplempz_clrbit
Clear bit bit_index in rop.
Public methodStatic memberCode examplempz_cmp
Compare op1 and op2.
Public methodStatic memberCode examplempz_cmp_d
Compare op1 and op2.
Public methodStatic memberCode examplempz_cmp_si
Compare op1 and op2.
Public methodStatic memberCode examplempz_cmp_ui
Compare op1 and op2.
Public methodStatic memberCode examplempz_cmpabs
Compare the absolute values of op1 and op2.
Public methodStatic memberCode examplempz_cmpabs_d
Compare the absolute values of op1 and op2.
Public methodStatic memberCode examplempz_cmpabs_ui
Compare the absolute values of op1 and op2.
Public methodStatic memberCode examplempz_com
Set rop to the one’s complement of op.
Public methodStatic memberCode examplempz_combit
Complement bit bit_index in rop.
Public methodStatic memberCode examplempz_congruent_2exp_p
Return non-zero if n is congruent to c modulo 2^b.
Public methodStatic memberCode examplempz_congruent_p
Return non-zero if n is congruent to c modulo d.
Public methodStatic memberCode examplempz_congruent_ui_p
Return non-zero if n is congruent to c modulo d.
Public methodStatic memberCode examplempz_divexact
Set q to n / d when it is known in advance that d divides n.
Public methodStatic memberCode examplempz_divexact_ui
Set q to n / d when it is known in advance that d divides n.
Public methodStatic memberCode examplempz_divisible_2exp_p
Return non-zero if n is exactly divisible by 2^b.
Public methodStatic memberCode examplempz_divisible_p
Return non-zero if n is exactly divisible by d.
Public methodStatic memberCode examplempz_divisible_ui_p
Return non-zero if n is exactly divisible by d.
Public methodStatic memberCode examplempz_even_p
Determine whether op is even.
Public methodStatic memberCode examplempz_export(void_ptr, ptrsize_t, Int32, size_t, Int32, size_t, mpz_t)
Fill rop with word data from op.
Public methodStatic memberCode examplempz_export(void_ptr, size_t, Int32, size_t, Int32, size_t, mpz_t)
Fill rop with word data from op.
Public methodStatic memberCode examplempz_fac_ui
Set rop to the factorial n!.
Public methodStatic memberCode examplempz_fdiv_q
Set the quotient q to floor(n / d).
Public methodStatic memberCode examplempz_fdiv_q_2exp
Set the quotient q to floor(n / 2^b).
Public methodStatic memberCode examplempz_fdiv_q_ui
Set the quotient q to floor(n / d), and return the remainder r = | n - q * d |.
Public methodStatic memberCode examplempz_fdiv_qr
Set the quotient q to floor(n / d), and set the remainder r to n - q * d.
Public methodStatic memberCode examplempz_fdiv_qr_ui
Set quotient q to floor(n / d), set the remainder r to n - q * d, and return | r |.
Public methodStatic memberCode examplempz_fdiv_r
Set the remainder r to n - q * d where q = floor(n / d).
Public methodStatic memberCode examplempz_fdiv_r_2exp
Set the remainder r to n - q * 2^b where q = floor(n / 2^b).
Public methodStatic memberCode examplempz_fdiv_r_ui
Set the remainder r to n - q * d where q = floor(n / d), and return | r |.
Public methodStatic memberCode examplempz_fdiv_ui
Return the remainder | r | where r = n - q * d, and where q = floor(n / d).
Public methodStatic memberCode examplempz_fib_ui
Sets fn to to F[n], the n’th Fibonacci number.
Public methodStatic memberCode examplempz_fib2_ui
Sets fn to F[n], and fnsub1 to F[n - 1].
Public methodStatic memberCode examplempz_fits_sint_p
Return non-zero iff the value of op fits in a signed 32-bit integer. Otherwise, return zero.
Public methodStatic memberCode examplempz_fits_slong_p
Return non-zero iff the value of op fits in a signed 32-bit integer. Otherwise, return zero.
Public methodStatic memberCode examplempz_fits_sshort_p
Return non-zero iff the value of op fits in a signed 16-bit integer. Otherwise, return zero.
Public methodStatic memberCode examplempz_fits_uint_p
Return non-zero iff the value of op fits in an unsigned 32-bit integer. Otherwise, return zero.
Public methodStatic memberCode examplempz_fits_ulong_p
Return non-zero iff the value of op fits in an unsigned 32-bit integer. Otherwise, return zero.
Public methodStatic memberCode examplempz_fits_ushort_p
Return non-zero iff the value of op fits in an unsigned 16-bit integer. Otherwise, return zero.
Public methodStatic memberCode examplempz_gcd
Set rop to the greatest common divisor of op1 and op2.
Public methodStatic memberCode examplempz_gcd_ui
Compute the greatest common divisor of op1 and op2. If rop is not null, store the result there.
Public methodStatic memberCode examplempz_gcdext
Set g to the greatest common divisor of a and b, and in addition set s and t to coefficients satisfying a * s + b * t = g.
Public methodStatic memberCode examplempz_get_d
Convert op to a double, truncating if necessary (i.e. rounding towards zero).
Public methodStatic memberCode examplempz_get_d_2exp
Convert op to a double, truncating if necessary (i.e. rounding towards zero), and returning the exponent separately.
Public methodStatic memberCode examplempz_get_si
Return the value of op as an signed long.
Public methodStatic memberCode examplempz_get_str
Convert op to a string of digits in base base.
Public methodStatic memberCode examplempz_get_ui
Return the value of op as an unsigned long.
Public methodStatic memberCode examplempz_getlimbn
Return limb number n from op.
Public methodStatic memberCode examplempz_hamdist
Return the hamming distance between the two operands.
Public methodStatic memberCode examplempz_import
Set rop from an array of word data at op.
Public methodStatic memberCode examplempz_init
Initialize x, and set its value to 0.
Public methodStatic memberCode examplempz_init_set
Initialize rop with limb space and set the initial numeric value from op.
Public methodStatic memberCode examplempz_init_set_d
Initialize rop with limb space and set the initial numeric value from op.
Public methodStatic memberCode examplempz_init_set_si
Initialize rop with limb space and set the initial numeric value from op.
Public methodStatic memberCode examplempz_init_set_str
Initialize rop and set its value like mpz_set_str.
Public methodStatic memberCode examplempz_init_set_ui
Initialize rop with limb space and set the initial numeric value from op.
Public methodStatic memberCode examplempz_init2
Initialize x, with space for n-bit numbers, and set its value to 0.
Public methodStatic memberCode examplempz_inits
Initialize a NULL-terminated list of mpz_t variables, and set their values to 0.
Public methodStatic memberCode examplempz_inp_raw
Input from stdio stream stream in the format written by mpz_out_raw, and put the result in rop.
Public methodStatic memberCode examplempz_inp_str
Input a possibly white-space preceded string in base base from stdio stream stream, and put the read integer in rop.
Public methodStatic memberCode examplempz_invert
Compute the inverse of op1 modulo op2 and put the result in rop.
Public methodStatic memberCode examplempz_ior
Set rop to op1 bitwise inclusive-or op2.
Public methodStatic memberCode examplempz_jacobi
Calculate the Jacobi symbol (a/b).
Public methodStatic memberCode examplempz_kronecker
Calculate the Jacobi symbol (a/b) with the Kronecker extension (a/2) = (2/a) when a odd, or (a/2) = 0 when a even.
Public methodStatic memberCode examplempz_kronecker_si
Calculate the Jacobi symbol (a/b) with the Kronecker extension (a/2) = (2/a) when a odd, or (a/2) = 0 when a even.
Public methodStatic memberCode examplempz_kronecker_ui
Calculate the Jacobi symbol (a/b) with the Kronecker extension (a/2) = (2/a) when a odd, or (a/2) = 0 when a even.
Public methodStatic memberCode examplempz_lcm
Set rop to the least common multiple of op1 and op2.
Public methodStatic memberCode examplempz_lcm_ui
Set rop to the least common multiple of op1 and op2.
Public methodStatic memberCode examplempz_legendre
Calculate the Legendre symbol (a/p).
Public methodStatic membermpz_limbs_finish
Updates the internal size field of x.
Public methodStatic memberCode examplempz_limbs_modify
Return a pointer to the limb array of x, intended for write access.
Public methodStatic memberCode examplempz_limbs_read
Return a pointer to the limb array representing the absolute value of x.
Public methodStatic memberCode examplempz_limbs_write
Return a pointer to the limb array of x, intended for write access.
Public methodStatic memberCode examplempz_lucnum_ui
Sets ln to to L[n], the n’th Lucas number.
Public methodStatic memberCode examplempz_lucnum2_ui
Sets ln to L[n], and lnsub1 to L[n - 1].
Public methodStatic memberCode examplempz_mfac_uiui
Set rop to the m-multi-factorial n!^(m)n.
Public methodStatic memberCode examplempz_millerrabin
An implementation of the probabilistic primality test found in Knuth's Seminumerical Algorithms book.
Public methodStatic memberCode examplempz_mod
Set r to n mod d.
Public methodStatic memberCode examplempz_mod_ui
Set r to n mod d.
Public methodStatic memberCode examplempz_mul
Set rop to op1 * op2.
Public methodStatic memberCode examplempz_mul_2exp
Set rop to op1 * 2^op2.
Public methodStatic memberCode examplempz_mul_si
Set rop to op1 * op2.
Public methodStatic memberCode examplempz_mul_ui
Set rop to op1 * op2.
Public methodStatic memberCode examplempz_neg
Set rop to -op.
Public methodStatic memberCode examplempz_nextprime
Set rop to the next prime greater than op.
Public methodStatic memberCode examplempz_odd_p
Determine whether op is odd.
Public methodStatic memberCode examplempz_out_raw
Output op on stdio stream stream, in raw binary format.
Public methodStatic memberCode examplempz_out_str
Output op on stdio stream stream, as a string of digits in base base.
Public methodStatic memberCode examplempz_perfect_power_p
Return non-zero if op is a perfect power, i.e., if there exist integers a and b, with b > 1, such that op = a^b.
Public methodStatic memberCode examplempz_perfect_square_p
Return non-zero if op is a perfect square, i.e., if the square root of op is an integer.
Public methodStatic memberCode examplempz_popcount
Return the population count of op.
Public methodStatic memberCode examplempz_pow_ui
Set rop to base^exp. The case 0^0 yields 1.
Public methodStatic memberCode examplempz_powm
Set rop to (base^exp) modulo mod.
Public methodStatic memberCode examplempz_powm_sec
Set rop to (base^exp) modulo mod.
Public methodStatic memberCode examplempz_powm_ui
Set rop to (base^exp) modulo mod.
Public methodStatic memberCode examplempz_primorial_ui
Set rop to the primorial of n, i.e. the product of all positive prime numbers ≤ n.
Public methodStatic memberCode examplempz_probab_prime_p
Determine whether n is prime.
Public methodStatic memberCode examplempz_random
Generate a random integer of at most max_size limbs.
Public methodStatic memberCode examplempz_random2
Generate a random integer of at most max_size limbs, with long strings of zeros and ones in the binary representation.
Public methodStatic memberCode examplempz_realloc2
Change the space allocated for x to n bits.
Public methodStatic memberCode examplempz_remove
Remove all occurrences of the factor f from op and store the result in rop.
Public methodStatic memberCode examplempz_roinit_n
Special initialization of x, using the given limb array and size.
Public methodStatic memberCode examplempz_root
Set rop to the truncated integer part of the nth root of op.
Public methodStatic memberCode examplempz_rootrem
Set root to the truncated integer part of the nth root of u. Set rem to the remainder, u - root^n.
Public methodStatic memberCode examplempz_rrandomb
Generate a random integer with long strings of zeros and ones in the binary representation.
Public methodStatic memberCode examplempz_scan0
Scan op for 0 bit.
Public methodStatic memberCode examplempz_scan1
Scan op for 1 bit.
Public methodStatic memberCode examplempz_set
Set the value of rop from op.
Public methodStatic memberCode examplempz_set_d
Set the value of rop from op.
Public methodStatic memberCode examplempz_set_f
Set the value of rop from op.
Public methodStatic memberCode examplempz_set_q
Set the value of rop from op.
Public methodStatic memberCode examplempz_set_si
Set the value of rop from op.
Public methodStatic memberCode examplempz_set_str
Set the value of rop from str, a null-terminated C string in base base.
Public methodStatic memberCode examplempz_set_ui
Set the value of rop from op.
Public methodStatic memberCode examplempz_setbit
Set bit bit_index in rop.
Public methodStatic memberCode examplempz_sgn
Return +1 if op > 0, 0 if op = 0, and -1 if op < 0.
Public methodStatic memberCode examplempz_si_kronecker
Calculate the Jacobi symbol (a/b) with the Kronecker extension (a/2) = (2/a) when a odd, or (a/2) = 0 when a even.
Public methodStatic memberCode examplempz_size
Return the size of op measured in number of limbs.
Public methodStatic memberCode examplempz_sizeinbase
Return the size of op measured in number of digits in the given base.
Public methodStatic memberCode examplempz_sqrt
Set rop to the truncated integer part of the square root of op.
Public methodStatic memberCode examplempz_sqrtrem
Set rop1 to the truncated integer part of the square root of op, like mpz_sqrt. Set rop2 to the remainder op - rop1 * rop1, which will be zero if op is a perfect square.
Public methodStatic memberCode examplempz_sub
Set rop to op1 - op2.
Public methodStatic memberCode examplempz_sub_ui
Set rop to op1 - op2.
Public methodStatic memberCode examplempz_submul
Set rop to rop - op1 * op2.
Public methodStatic memberCode examplempz_submul_ui
Set rop to rop - op1 * op2.
Public methodStatic memberCode examplempz_swap
Swap the values rop1 and rop2 efficiently.
Public methodStatic memberCode examplempz_tdiv_q
Set the quotient q to trunc(n / d).
Public methodStatic memberCode examplempz_tdiv_q_2exp
Set the quotient q to trunc(n / 2^b).
Public methodStatic memberCode examplempz_tdiv_q_ui
Set the quotient q to trunc(n / d), and return the remainder r = | n - q * d |.
Public methodStatic memberCode examplempz_tdiv_qr
Set the quotient q to trunc(n / d), and set the remainder r to n - q * d.
Public methodStatic memberCode examplempz_tdiv_qr_ui
Set quotient q to trunc(n / d), set the remainder r to n - q * d, and return | r |.
Public methodStatic memberCode examplempz_tdiv_r
Set the remainder r to n - q * d where q = trunc(n / d).
Public methodStatic memberCode examplempz_tdiv_r_2exp
Set the remainder r to n - q * 2^b where q = trunc(n / 2^b).
Public methodStatic memberCode examplempz_tdiv_r_ui
Set the remainder r to n - q * d where q = trunc(n / d), and return | r |.
Public methodStatic memberCode examplempz_tdiv_ui
Return the remainder | r | where r = n - q * d, and where q = trunc(n / d).
Public methodStatic memberCode examplempz_tstbit
Test bit bit_index in op and return 0 or 1 accordingly.
Public methodStatic memberCode examplempz_ui_kronecker
Calculate the Jacobi symbol (a/b) with the Kronecker extension (a/2) = (2/a) when a odd, or (a/2) = 0 when a even.
Public methodStatic memberCode examplempz_ui_pow_ui
Set rop to base^exp. The case 0^0 yields 1.
Public methodStatic memberCode examplempz_ui_sub
Set rop to op1 - op2.
Public methodStatic memberCode examplempz_urandomb
Generate a uniformly distributed random integer in the range 0 to 2^n - 1, inclusive.
Public methodStatic memberCode examplempz_urandomm
Generate a uniform random integer in the range 0 to n - 1, inclusive.
Public methodStatic memberCode examplempz_xor
Set rop to op1 bitwise exclusive-or op2.
Public methodStatic memberreallocate
Resize a previously allocated block ptr of old_size bytes to be new_size bytes.
Public methodStatic memberZeroMemory
The ZeroMemory routine fills a block of memory with zeros, given a pointer to the block and the length, in bytes, to be filled.
Top
Fields
  NameDescription
Public fieldStatic memberCode examplegmp_version
The GMP version number in the form “i.j.k”. This release is "6.1.2".
Public fieldStatic memberCode examplemp_bits_per_limb
The number of bits per limb.
Public fieldStatic memberCode examplemp_bytes_per_limb
The number of bytes per limb.
Public fieldStatic memberCode examplemp_uint_per_limb
The number of 32-bit, unsigned integers per limb.
Top
Remarks

Functions Categories

Global Variable and Constants:

Integer Functions:

Initializing Integers:

  • mpz_init - Initialize x, and set its value to 0.
  • mpz_inits - Initialize a NULL-terminated list of mpz_t variables, and set their values to 0.
  • mpz_init2 - Initialize x, with space for n-bit numbers, and set its value to 0.
  • mpz_clear - Free the space occupied by x.
  • mpz_clears - Free the space occupied by a NULL-terminated list of mpz_t variables.
  • mpz_realloc2 - Change the space allocated for x to n bits.

Assigning Integers:

  • mpz_set - Set the value of rop from op.
  • mpz_set_ui - Set the value of rop from op.
  • mpz_set_si - Set the value of rop from op.
  • mpz_set_d - Set the value of rop from op.
  • mpz_set_q - Set the value of rop from op.
  • mpz_set_f - Set the value of rop from op.
  • mpz_set_str - Set the value of rop from str, a null-terminated C string in base base.
  • mpz_swap - Swap the values rop1 and rop2 efficiently.

Simultaneous Integer Init & Assign:

  • mpz_init_set - Initialize rop with limb space and set the initial numeric value from op.
  • mpz_init_set_ui - Initialize rop with limb space and set the initial numeric value from op.
  • mpz_init_set_si - Initialize rop with limb space and set the initial numeric value from op.
  • mpz_init_set_d - Initialize rop with limb space and set the initial numeric value from op.
  • mpz_set_str - Set the value of rop from str, a null-terminated C string in base base.

Converting Integers:

  • mpz_get_ui - Return the value of op as an unsigned long.
  • mpz_get_si - Return the value of op as an signed long.
  • mpz_get_d - Convert op to a double, truncating if necessary (i.e. rounding towards zero).
  • mpz_get_d_2exp - Convert op to a double, truncating if necessary (i.e. rounding towards zero), and returning the exponent separately.
  • mpz_get_str - Convert op to a string of digits in base base.

Integer Arithmetic:

Integer Division:

  • mpz_cdiv_q - Set the quotient q to ceiling(n / d).
  • mpz_cdiv_r - Set the remainder r to n - q * d where q = ceiling(n / d).
  • mpz_cdiv_qr - Set the quotient q to ceiling(n / d), and set the remainder r to n - q * d.
  • mpz_cdiv_q_ui - Set the quotient q to ceiling(n / d), and return the remainder r = | n - q * d |.
  • mpz_cdiv_r_ui - Set the remainder r to n - q * d where q = ceiling(n / d), and return | r |.
  • mpz_cdiv_qr_ui - Set quotient q to ceiling(n / d), set the remainder r to n - q * d, and return | r |.
  • mpz_cdiv_ui - Return the remainder | r | where r = n - q * d, and where q = ceiling(n / d).
  • mpz_cdiv_q_2exp - Set the quotient q to ceiling(n / 2^b).
  • mpz_cdiv_r_2exp - Set the remainder r to n - q * 2^b where q = ceiling(n / 2^b).
  • mpz_fdiv_q - Set the quotient q to floor(n / d).
  • mpz_fdiv_r - Set the remainder r to n - q * d where q = floor(n / d).
  • mpz_fdiv_qr - Set the quotient q to floor(n / d), and set the remainder r to n - q * d.
  • mpz_fdiv_q_ui - Set the quotient q to floor(n / d), and return the remainder r = | n - q * d |.
  • mpz_fdiv_r_ui - Set the remainder r to n - q * d where q = floor(n / d), and return | r |.
  • mpz_fdiv_qr_ui - Set quotient q to floor(n / d), set the remainder r to n - q * d, and return | r |.
  • mpz_fdiv_ui - Return the remainder | r | where r = n - q * d, and where q = floor(n / d).
  • mpz_fdiv_q_2exp - Set the quotient q to floor(n / 2^b).
  • mpz_fdiv_r_2exp - Set the remainder r to n - q * 2^b where q = floor(n / 2^b).
  • mpz_tdiv_q - Set the quotient q to trunc(n / d).
  • mpz_tdiv_r - Set the remainder r to n - q * d where q = trunc(n / d).
  • mpz_tdiv_qr - Set the quotient q to trunc(n / d), and set the remainder r to n - q * d.
  • mpz_tdiv_q_ui - Set the quotient q to trunc(n / d), and return the remainder r = | n - q * d |.
  • mpz_tdiv_r_ui - Set the remainder r to n - q * d where q = trunc(n / d), and return | r |.
  • mpz_tdiv_qr_ui - Set quotient q to trunc(n / d), set the remainder r to n - q * d, and return | r |.
  • mpz_tdiv_ui - Return the remainder | r | where r = n - q * d, and where q = trunc(n / d).
  • mpz_tdiv_q_2exp - Set the quotient q to trunc(n / 2^b).
  • mpz_tdiv_r_2exp - Set the remainder r to n - q * 2^b where q = trunc(n / 2^b).
  • mpz_mod - Set r to n mod d.
  • mpz_mod_ui - Set r to n mod d.
  • mpz_divexact - Set q to n / d when it is known in advance that d divides n.
  • mpz_divexact_ui - Set q to n / d when it is known in advance that d divides n.
  • mpz_divisible_p - Return non-zero if n is exactly divisible by d.
  • mpz_divisible_ui_p - Return non-zero if n is exactly divisible by d.
  • mpz_divisible_2exp_p - Return non-zero if n is exactly divisible by 2^b.
  • mpz_congruent_p - Return non-zero if n is congruent to c modulo d.
  • mpz_congruent_ui_p - Return non-zero if n is congruent to c modulo d.
  • mpz_congruent_2exp_p - Return non-zero if n is congruent to c modulo 2^b.

Integer Exponentiation:

Integer Roots:

  • mpz_root - Set rop to the truncated integer part of the nth root of op.
  • mpz_rootrem - Set root to the truncated integer part of the nth root of u. Set rem to the remainder, u - root^n.
  • mpz_sqrt - Set rop to the truncated integer part of the square root of op.
  • mpz_sqrtrem - Set rop1 to the truncated integer part of the square root of op, like mpz_sqrt. Set rop2 to the remainder op - rop1 * rop1, which will be zero if op is a perfect square.
  • mpz_perfect_power_p - Return non-zero if op is a perfect power, i.e., if there exist integers a and b, with b > 1, such that op = a^b.
  • mpz_perfect_square_p - Return non-zero if op is a perfect square, i.e., if the square root of op is an integer.

Number Theoretic Functions:

  • mpz_probab_prime_p - Determine whether n is prime.
  • mpz_nextprime - Set rop to the next prime greater than op.
  • mpz_gcd - Set rop to the greatest common divisor of op1 and op2.
  • mpz_gcd_ui - Compute the greatest common divisor of op1 and op2. If rop is not null, store the result there.
  • mpz_gcdext - Set g to the greatest common divisor of a and b, and in addition set s and t to coefficients satisfying a * s + b * t = g.
  • mpz_lcm - Set rop to the least common multiple of op1 and op2.
  • mpz_lcm_ui - Set rop to the least common multiple of op1 and op2.
  • mpz_invert - Compute the inverse of op1 modulo op2 and put the result in rop.
  • mpz_jacobi - Calculate the Jacobi symbol (a/b).
  • mpz_legendre - Calculate the Legendre symbol (a/p).
  • mpz_kronecker - Calculate the Jacobi symbol (a/b) with the Kronecker extension (a/2) = (2/a) when a odd, or (a/2) = 0 when a even.
  • mpz_kronecker_si - Calculate the Jacobi symbol (a/b) with the Kronecker extension (a/2) = (2/a) when a odd, or (a/2) = 0 when a even.
  • mpz_kronecker_ui - Calculate the Jacobi symbol (a/b) with the Kronecker extension (a/2) = (2/a) when a odd, or (a/2) = 0 when a even.
  • mpz_si_kronecker - Calculate the Jacobi symbol (a/b) with the Kronecker extension (a/2) = (2/a) when a odd, or (a/2) = 0 when a even.
  • mpz_ui_kronecker - Calculate the Jacobi symbol (a/b) with the Kronecker extension (a/2) = (2/a) when a odd, or (a/2) = 0 when a even.
  • mpz_remove - Remove all occurrences of the factor f from op and store the result in rop.
  • mpz_fac_ui - Set rop to the factorial n!.
  • mpz_2fac_ui - Set rop to the double-factorial n!!.
  • mpz_mfac_uiui - Set rop to the m-multi-factorial n!^(m)n.
  • mpz_primorial_ui - Set rop to the primorial of n, i.e. the product of all positive prime numbers ≤ n.
  • mpz_bin_ui - Compute the binomial coefficient n over k and store the result in rop.
  • mpz_bin_uiui - Compute the binomial coefficient n over k and store the result in rop.
  • mpz_fib_ui - Sets fn to to F[n], the n’th Fibonacci number.
  • mpz_fib2_ui - Sets fn to F[n], and fnsub1 to F[n - 1].
  • mpz_lucnum_ui - Sets ln to to L[n], the n’th Lucas number.
  • mpz_lucnum2_ui - Sets ln to L[n], and lnsub1 to L[n - 1].
  • mpz_millerrabin - An implementation of the probabilistic primality test found in Knuth's Seminumerical Algorithms book.

Integer Comparisons:

Integer Logic and Bit Fiddling:

  • mpz_and - Set rop to op1 bitwise-and op2.
  • mpz_ior - Set rop to op1 bitwise inclusive-or op2.
  • mpz_xor - Set rop to op1 bitwise exclusive-or op2.
  • mpz_com - Set rop to the one’s complement of op.
  • mpz_popcount - Return the population count of op.
  • mpz_hamdist - Return the hamming distance between the two operands.
  • mpz_scan0 - Scan op for 0 bit.
  • mpz_scan1 - Scan op for 1 bit.
  • mpz_setbit - Set bit bit_index in rop.
  • mpz_clrbit - Clear bit bit_index in rop.
  • mpz_combit - Complement bit bit_index in rop.
  • mpz_tstbit - Test bit bit_index in op and return 0 or 1 accordingly.

I/O of Integers:

  • mpz_out_str - Output op on stdio stream stream, as a string of digits in base base.
  • mpz_inp_str - Input a possibly white-space preceded string in base base from stdio stream stream, and put the read integer in rop.
  • mpz_out_raw - Output op on stdio stream stream, in raw binary format.
  • mpz_out_raw, and put the result in rop.

Integer Random Numbers:

  • mpz_urandomb - Generate a uniformly distributed random integer in the range 0 to 2^n - 1, inclusive.
  • mpz_urandomm - Generate a uniform random integer in the range 0 to n - 1, inclusive.
  • mpz_rrandomb - Generate a random integer with long strings of zeros and ones in the binary representation.
  • mpz_random - Generate a random integer of at most max_size limbs.
  • mpz_random2 - Generate a random integer of at most max_size limbs, with long strings of zeros and ones in the binary representation.

Integer Import and Export:

Miscellaneous Integer Functions:

  • mpz_fits_sint_p - Return non-zero iff the value of op fits in a signed 32-bit integer. Otherwise, return zero.
  • mpz_fits_slong_p - Return non-zero iff the value of op fits in a signed 32-bit integer. Otherwise, return zero.
  • mpz_fits_sshort_p - Return non-zero iff the value of op fits in a signed 16-bit integer. Otherwise, return zero.
  • mpz_fits_uint_p - Return non-zero iff the value of op fits in an unsigned 32-bit integer. Otherwise, return zero.
  • mpz_fits_ulong_p - Return non-zero iff the value of op fits in an unsigned 32-bit integer. Otherwise, return zero.
  • mpz_fits_ushort_p - Return non-zero iff the value of op fits in an unsigned 16-bit integer. Otherwise, return zero.
  • mpz_sizeinbase - Return the size of op measured in number of digits in the given base.
  • mpz_even_p - Determine whether op is even.
  • mpz_odd_p - Determine whether op is odd.

Integer Special Functions:

  • _mpz_realloc - Change the space for integer to new_alloc limbs.
  • mpz_getlimbn - Return limb number n from op.
  • mpz_size - Return the size of op measured in number of limbs.
  • mpz_limbs_read - Return a pointer to the limb array representing the absolute value of x.
  • mpz_limbs_write - Return a pointer to the limb array of x, intended for write access.
  • mpz_limbs_modify - Return a pointer to the limb array of x, intended for write access.
  • mpz_limbs_finish - Updates the internal size field of x.
  • mpz_roinit_n - Special initialization of x, using the given limb array and size.

Rational Number Functions:

Initializing Rationals:

  • mpq_canonicalize - Remove any factors that are common to the numerator and denominator of op, and make the denominator positive.
  • mpq_init - Initialize x and set it to 0/1.
  • mpq_inits - Initialize a NULL-terminated list of mpq_t variables, and set their values to 0/1.
  • mpq_clear - Free the space occupied by x.
  • mpq_clears - Free the space occupied by a NULL-terminated list of mpq_t variables.
  • mpq_set - Assign rop from op.
  • mpq_set_z - Assign rop from op.
  • mpq_set_ui - Set the value of rop to op1 / op2.
  • mpq_set_si - Set the value of rop to op1 / op2.
  • mpq_set_str - Set rop from a null-terminated string str in the given base.
  • mpq_swap - Swap the values rop1 and rop2 efficiently.

Rational Conversions:

  • mpq_get_d - Convert op to a System.Double, truncating if necessary (i.e. rounding towards zero).
  • mpq_set_d - Set rop to the value of op. There is no rounding, this conversion is exact.
  • mpq_set_f - Set rop to the value of op. There is no rounding, this conversion is exact.
  • mpq_get_str - Convert op to a string of digits in base base.

Rational Arithmetic:

  • mpq_add - Set sum to addend1 + addend2.
  • mpq_sub - Set difference to minuend - subtrahend.
  • mpq_mul - Set product to multiplier * multiplicand.
  • mpq_mul_2exp - Set rop to op1 * 2^op2.
  • mpq_div - Set quotient to dividend / divisor.
  • mpq_div_2exp - Set rop to op1 / 2^op2.
  • mpq_neg - Set negated_operand to -operand.
  • mpq_abs - Set rop to the absolute value of op.
  • mpq_inv - Set inverted_number to 1 / number.

Comparing Rationals:

  • mpq_cmp - Compare op1 and op2.
  • mpq_cmp_z - Compare op1 and op2.
  • mpq_cmp_ui - Compare op1 and num2 / den2.
  • mpq_cmp_si - Compare op1 and num2 / den2.
  • mpq_sgn - Return +1 if op > 0, 0 if op = 0, and -1 if op < 0.
  • mpq_equal - Return non-zero if op1 and op2 are equal, zero if they are non-equal.

Applying Integer Functions:

  • mpq_numref - Return a reference to the numerator op.
  • mpq_denref - Return a reference to the denominator op.
  • mpq_get_num - Set numerator to the numerator of rational.
  • mpq_get_den - Set denominator to the denominator of rational.
  • mpq_set_num - Set the numerator of rational to numerator.
  • mpq_set_den - Set the denominator of rational to denominator.

I/O of Rationals:

  • mpq_out_str - Output op on stdio stream stream, as a string of digits in base base.
  • mpq_inp_str - Read a string of digits from stream and convert them to a rational in rop.

Floating-point Functions:

Initializing Floats:

  • mpf_set_default_prec - Set the default precision to be at least prec bits.
  • mpf_get_default_prec - Return the default precision actually used.
  • mpf_init - Initialize x to 0.
  • mpf_init2 - Initialize x to 0 and set its precision to be at least prec bits.
  • mpf_inits - Initialize a NULL-terminated list of mpf_t variables, and set their values to 0.
  • mpf_clear - Free the space occupied by x.
  • mpf_clears - Free the space occupied by a NULL-terminated list of mpf_t variables.
  • mpf_get_prec - Return the current precision of op, in bits.
  • mpf_set_prec - Set the precision of rop to be at least prec bits.
  • mpf_set_prec_raw - Set the precision of rop to be at least prec bits, without changing the memory allocated.
  • mpf_size - Return the number of limbs currently in use.

Assigning Floats:

Simultaneous Float Init & Assign:

Converting Floats:

  • mpf_get_d - Convert op to a System.Double, truncating if necessary (i.e. rounding towards zero).
  • mpf_get_d_2exp - Convert op to a double, truncating if necessary (i.e. rounding towards zero), and with an exponent returned separately.
  • mpf_get_si - Convert op to a 32-bit integer, truncating any fraction part.
  • mpf_get_ui - Convert op to an unsigned 32-bit integer, truncating any fraction part.
  • mpf_get_str - Convert op to a string of digits in base base.

Float Arithmetic:

Float Comparison:

  • mpf_cmp - Compare op1 and op2.
  • mpf_cmp_z - Compare op1 and op2.
  • mpf_cmp_d - Compare op1 and op2.
  • mpf_cmp_ui - Compare op1 and op2.
  • mpf_cmp_si - Compare op1 and op2.
  • mpf_reldiff - Compute the relative difference between op1 and op2 and store the result in rop. This is | op1 - op2 | / op1.
  • mpf_sgn - Return +1 if op > 0, 0 if op = 0, and -1 if op < 0.

I/O of Floats:

  • mpf_out_str - Print op to stream, as a string of digits.
  • mpf_inp_str - Read a string in base base from stream, and put the read float in rop.

Miscellaneous Float Functions:

  • mpf_ceil - Set rop to op rounded to the next higher integer.
  • mpf_floor - Set rop to op rounded to the next lower integer.
  • mpf_trunc - Set rop to op rounded to the integer towards zero.
  • mpf_integer_p - Return non-zero if op is an integer.
  • mpf_fits_ulong_p - Return non-zero if op fits in an unsigned 32-bit integer, when truncated to an integer.
  • mpf_fits_slong_p - Return non-zero if op fits in a 32-bit integer, when truncated to an integer.
  • mpf_fits_uint_p - Return non-zero if op fits in an unsigned 32-bit integer, when truncated to an integer.
  • mpf_fits_sint_p - Return non-zero if op fits in a 32-bit integer, when truncated to an integer.
  • mpf_fits_sshort_p - Return non-zero if op fits in a 16-bit integer, when truncated to an integer.
  • mpf_fits_ushort_p - Return non-zero if op fits in an unsigned 16-bit integer, when truncated to an integer.
  • mpf_urandomb - Generate a uniformly distributed random float in rop, such that 0 ≤ rop < 1, with nbits significant bits in the mantissa or less if the precision of rop is smaller.
  • mpf_random2 - Generate a random float of at most max_size limbs, with long strings of zeros and ones in the binary representation.

Low-level Functions:

  • mpn_add_n - Add {s1p, n} and {s2p, n}, and write the n least significant limbs of the result to rp.
  • mpn_add_1 - Add {s1p, n} and s2limb, and write the n least significant limbs of the result to rp.
  • mpn_add - Add {s1p, s1n} and {s2p, s2n}, and write the s1n least significant limbs of the result to rp.
  • mpn_sub_n - Subtract {s2p, n} from {s1p, n}, and write the n least significant limbs of the result to rp.
  • mpn_sub_1 - Subtract s2limb from {s1p, n}, and write the n least significant limbs of the result to rp.
  • mpn_sub - Subtract {s2p, s2n} from {s1p, s1n}, and write the s1n least significant limbs of the result to rp.
  • mpn_neg - Perform the negation of {sp, n}, and write the result to {rp, n}.
  • mpn_mul_n - Multiply {s1p, n} and {s2p, n}, and write the (2 * n)-limb result to rp.
  • mpn_mul - Multiply {s1p, s1n} and {s2p, s2n}, and write the (s1n + s2n)-limb result to rp.
  • mpn_sqr - Compute the square of {s1p, n} and write the (2 * n)-limb result to rp.
  • mpn_mul_1 - Multiply {s1p, n} by s2limb, and write the n least significant limbs of the product to rp.
  • mpn_addmul_1 - Multiply {s1p, n} and s2limb, and add the n least significant limbs of the product to {rp, n} and write the result to rp.
  • mpn_submul_1 - Multiply {s1p, n} and s2limb, and subtract the n least significant limbs of the product from {rp, n} and write the result to rp.
  • mpn_tdiv_qr - Divide {np, nn} by {dp, dn} and put the quotient at {qp, nn - dn + 1} and the remainder at {rp, dn}.
  • mpn_divrem_1 - Divide {s2p, s2n} by s3limb, and write the quotient at r1p.
  • mpn_divmod_1 - Divide {s2p, s2n} by s3limb, and write the quotient at r1p.
  • mpn_divexact_1 - Divide {sp, n} by d, expecting it to divide exactly, and writing the result to {rrp, n}.
  • mpn_divexact_by3 - Divide {sp, n} by 3, expecting it to divide exactly, and writing the result to {rp, n}.
  • mpn_divexact_by3c - Divide {sp, n} by 3, expecting it to divide exactly, and writing the result to {rp, n}.
  • mpn_mod_1 - Divide {s1p, s1n} by s2limb, and return the remainder.
  • mpn_lshift - Shift {sp, n} left by count bits, and write the result to {rp, n}.
  • mpn_rshift - Shift {sp, n} right by count bits, and write the result to {rp, n}.
  • mpn_cmp - Compare {s1p, n} and {s2p, n}.
  • mpn_zero_p - Test {sp, n} and return 1 if the operand is zero, 0 otherwise.
  • mpn_gcd - Set {rp, retval} to the greatest common divisor of {xp, xn} and {yp, yn}.
  • mpn_gcd_1 - Return the greatest common divisor of {xp, xn} and ylimb.
  • mpn_gcdext - Compute the greatest common divisor G of U and V. Compute a cofactor S such that G = US + VT.
  • mpn_sqrtrem - Compute the square root of {sp, n} and put the result at {r1p, ceil(n / 2)} and the remainder at {r2p, retval}.
  • mpn_sizeinbase - Return the size of {xp, n} measured in number of digits in the given base.
  • mpn_get_str - Convert {s1p, s1n} to a raw unsigned char array at str in base base, and return the number of characters produced.
  • mpn_set_str - Convert bytes {str, strsize} in the given base to limbs at rp.
  • mpn_scan0 - Scan s1p from bit position bit for the next clear bit.
  • mpn_scan1 - Scan s1p from bit position bit for the next set bit.
  • mpn_random - Generate a random number of length r1n and store it at r1p.
  • mpn_random2 - Generate a random number of length r1n and store it at r1p.
  • mpn_popcount - Count the number of set bits in {s1p, n}.
  • mpn_hamdist - Compute the hamming distance between {s1p, n} and {s2p, n}, which is the number of bit positions where the two operands have different bit values.
  • mpn_perfect_square_p - Return non-zero iff {s1p, n} is a perfect square.
  • mpn_perfect_power_p - Return non-zero iff {sp, n} is a perfect power.
  • mpn_and_n - Perform the bitwise logical and of {s1p, n} and {s2p, n}, and write the result to {rp, n}.
  • mpn_ior_n - Perform the bitwise logical inclusive or of {s1p, n} and {s2p, n}, and write the result to {rp, n}.
  • mpn_xor_n - Perform the bitwise logical exclusive or of {s1p, n} and {s2p, n}, and write the result to {rp, n}.
  • mpn_andn_n - Perform the bitwise logical and of {s1p, n} and the bitwise complement of {s2p, n}, and write the result to {rp, n}.
  • mpn_iorn_n - Perform the bitwise logical inclusive or of {s1p, n} and the bitwise complement of {s2p, n}, and write the result to {rp, n}.
  • mpn_nand_n - Perform the bitwise logical and of {s1p, n} and {s2p, n}, and write the bitwise complement of the result to {rp, n}.
  • mpn_nior_n - Perform the bitwise logical inclusive or of {s1p, n} and {s2p, n}, and write the bitwise complement of the result to {rp, n}.
  • mpn_xnor_n - Perform the bitwise logical exclusive or of {s1p, n} and {s2p, n}, and write the bitwise complement of the result to {rp, n}.
  • mpn_com - Perform the bitwise complement of {sp, n}, and write the result to {rp, n}.
  • mpn_copyi - Copy from {s1p, n} to {rp, n}, increasingly.
  • mpn_copyd - Copy from {s1p, n} to {rp, n}, decreasingly.
  • mpn_zero - Zero {rp, n}.

Low-level functions for cryptography:

  • mpn_cnd_add_n - If cnd is non-zero, it produces the same result as a regular mpn_add_n, and if cnd is zero, it copies {s1p, n} to the result area and returns zero.
  • mpn_cnd_sub_n - If cnd is non-zero, it produces the same result as a regular mpn_sub_n, and if cnd is zero, it copies {s1p, n} to the result area and returns zero.
  • mpn_sec_add_1 - Set R to A + b, where R = {rp, n}, A = {ap, n}, and b is a single limb.
  • mpn_sec_add_1_itch - Return the scratch space in number of limbs required by the function mpn_sec_add_1.
  • mpn_sec_sub_1 - Set R to A - b, where R = {rp, n}, A = {ap, n}, and b is a single limb.
  • mpn_sec_sub_1_itch - Return the scratch space in number of limbs required by the function mpn_sec_sub_1.
  • mpn_cnd_swap - If cnd is non-zero, swaps the contents of the areas {ap, n} and {bp, n}. Otherwise, the areas are left unmodified.
  • mpn_sec_mul - Set R to A * B, where A = {ap, an}, B = {bp, bn}, and R = {rp, an + bn}.
  • mpn_sec_mul_itch - Return the scratch space in number of limbs required by the function mpn_sec_mul.
  • mpn_sec_sqr - Set R to A^2, where A = {ap, an}, and R = {rp, 2 * an}.
  • mpn_sec_sqr_itch - Return the scratch space in number of limbs required by the function mpn_sec_sqr.
  • mpn_sec_powm - Set R to (B^E) modulo M, where R = {rp, n}, M = {mp, n}, and E = {ep, ceil(enb / mp_bits_per_limb)}.
  • mpn_sec_powm_itch - Return the scratch space in number of limbs required by the function mpn_sec_powm.
  • mpn_sec_tabselect - Select entry which from table tab, which has nents entries, each n limbs. Store the selected entry at rp.
  • mpn_sec_div_qr - Set Q to the truncated quotient N / D and R to N modulo D, where N = {np, nn}, D = {dp, dn}, Q’s most significant limb is the function return value and the remaining limbs are {qp, nn - dn}, and R = {np, dn}.
  • mpn_sec_div_qr_itch - Return the scratch space in number of limbs required by the function mpn_sec_div_qr.
  • mpn_sec_div_r - Set R to N modulo D, where N = {np, nn}, D = {dp, dn}, and R = {np, dn}.
  • mpn_sec_div_r_itch - Return the scratch space in number of limbs required by the function mpn_sec_div_r.
  • mpn_sec_invert - Set R to the inverse of A modulo M, where R = {rp, n}, A = {ap, n}, and M = {mp, n}. This function’s interface is preliminary.
  • mpn_sec_invert_itch - Return the scratch space in number of limbs required by the function mpn_sec_invert.

Random Number Functions:

Random State Initialization:

Random State Seeding:

Random State Miscellaneous:

  • gmp_urandomb_ui - Generate a uniformly distributed random number of n bits, i.e. in the range 0 to 2^n - 1 inclusive.
  • gmp_urandomm_ui - Generate a uniformly distributed random number in the range 0 to n - 1, inclusive.

Formatted Output:

Formatted Output Functions:

  • gmp_printf - Print to the standard output stdout.
  • gmp_vprintf - Print to the standard output stdout.
  • gmp_fprintf - Print to the stream fp.
  • gmp_vfprintf - Print to the stream fp.
  • gmp_sprintf - Form a null-terminated string in buf.
  • gmp_vsprintf - Form a null-terminated string in buf.
  • gmp_snprintf - Form a null-terminated string in buf.
  • gmp_vsnprintf - Form a null-terminated string in buf.
  • gmp_asprintf - Form a null-terminated string in a block of memory obtained from the current memory allocation function.
  • gmp_vasprintf - Form a null-terminated string in a block of memory obtained from the current memory allocation function.

Formatted Input:

Formatted Input Functions:

Custom Allocation:

  • mp_set_memory_functions - Replace the current allocation functions from the arguments.
  • mp_get_memory_functions - Get the current allocation functions, storing function pointers to the locations given by the arguments.
  • allocate - Return a pointer to newly allocated space with at least alloc_size bytes.
  • reallocate - Resize a previously allocated block ptr of old_size bytes to be new_size bytes.
  • free - De-allocate the space pointed to by ptrs.
  • ZeroMemory - The ZeroMemory routine fills a block of memory with zeros, given a pointer to the block and the length, in bytes, to be filled.
See Also