GMP¶
Usage
use GMP;
Support for GNU Multiple Precision Arithmetic
This module provides a low-level interface to a substantial fraction of the GMP library (the GNU Multiple Precision arithmetic library). This support includes the C types for GMP integers, floating point numbers, and random numbers, and nearly every operation on those types. These types and functions enable efficient multi-precision computation within a single locale. See the GMP homepage for more information on this library.
The module BigInteger
leverages this interface to define the
record bigint
. The methods on the record
bigint
are locale aware so that Chapel programs
can, for example, create a distributed array of GMP integers. That
record also provides operator overloads for the standard arithmetic
and assignment operators which tend to enable a more natural
expression of some algorithms. Please see the documentation in
BigInteger
for details.
Using the GMP Module¶
- Step 1:
Build Chapel with GMP
# To use the already-installed GMP export CHPL_GMP=system # To use the distributed GMP export CHPL_GMP=gmp # From $CHPL_HOME make clean; make
- Step 2:
Have your Chapel program
use
the standard GMP moduleuse GMP; // put this statement in your Chapel program
- Step 3:
- Start using the supported subset of GMP types and routines defined
in this module or the bigint record (see
BigInteger
).
Calling GMP functions directly¶
The low-level option for Chapel programs using multi-precision numbers is to the GMP functions directly. For a full reference to GMP capabilities, please refer to the GMP website and the GMP documentation.
At present, Chapel's GMP module supports the following GMP types:
And all mpz_t
GMP routines, as well as the following routines:
The BigInt class¶
This class is deprecated for release 1.14 (Fall 2016) and will not be
present in release 1.15 (Spring 2017). Please see the record
bigint
in the module BigInteger
for
the replacement for this class.
This module also provides a class BigInt
that wraps GMP
integers. Nearly every GMP function for the GMP type mpz_t
is
wrapped by a method with a similar name. These methods are locale
aware - so Chapel programs can, for example, create a distributed
array of GMP numbers. A method of a BigInt
object set the
receiver so that, for example, myBigInt.add(x,y) sets myBigInt to x
+ y
.
A code example:
use GMP;
// initialize a GMP value, set it to zero
var a = new BigInt();
a.fac_ui(100); // set a to 100!
writeln(a); // output 100!
delete a; // free memory used by the GMP value
// initialize from a decimal string
var b = new BigInt("48473822929893829847");
b.add_ui(b, 1); // add one to b
delete b; // free memory used by b
-
type
mp_bitcnt_t
= c_ulong¶ The GMP
mp_bitcnt_t
type
-
type
mp_size_t
= size_t¶ The GMP
mp_size_t
type
-
type
mp_limb_t
= uint(64)¶ The GMP
mp_limb_t
type.
-
const
mp_bits_per_limb
: c_int¶ The GMP mp_bits_per_limb` constant
-
type
mpz_t
= 1*__mpz_struct¶ The GMP
mpz_t
type
-
type
mpf_t
= 1*__mpf_struct¶ The GMP
mpf_t
type
-
type
gmp_randstate_t
= 1*__gmp_randstate_struct¶ The GMP
gmp_randstate_t
type
-
proc
mpz_init
(ref x: mpz_t)¶
-
proc
mpz_init2
(ref x: mpz_t, n: mp_bitcnt_t)¶
-
proc
mpz_clear
(ref x: mpz_t)¶
-
proc
mpz_realloc2
(ref x: mpz_t, n: mp_bitcnt_t)¶
-
proc
mpz_set
(ref rop: mpz_t, const ref op: mpz_t)¶
-
proc
mpz_set_ui
(ref rop: mpz_t, op: c_ulong)¶
-
proc
mpz_set_si
(ref rop: mpz_t, op: c_long)¶
-
proc
mpz_set_d
(ref rop: mpz_t, op: c_double)¶
-
proc
mpz_set_str
(ref rop: mpz_t, str: c_string, base: c_int)¶
-
proc
mpz_swap
(ref rop1: mpz_t, ref rop2: mpz_t)¶
-
proc
mpz_init_set
(ref rop: mpz_t, const ref op: mpz_t)¶
-
proc
mpz_init_set_ui
(ref rop: mpz_t, op: c_ulong)¶
-
proc
mpz_init_set_si
(ref rop: mpz_t, op: c_long)¶
-
proc
mpz_init_set_d
(ref rop: mpz_t, op: c_double)¶
-
proc
mpz_init_set_str
(ref rop: mpz_t, str: c_string, base: c_int): c_int¶
-
proc
mpz_get_ui
(const ref op: mpz_t): c_ulong¶
-
proc
mpz_get_si
(const ref op: mpz_t): c_long¶
-
proc
mpz_get_d
(const ref op: mpz_t): c_double¶
-
proc
mpz_get_d_2exp
(ref exp: c_long, const ref op: mpz_t): c_double¶
-
proc
mpz_get_str
(str: c_string, base: c_int, const ref op: mpz_t): c_string¶
-
proc
mpz_add
(ref rop: mpz_t, const ref op1: mpz_t, const ref op2: mpz_t)¶
-
proc
mpz_add_ui
(ref rop: mpz_t, const ref op1: mpz_t, op2: c_ulong)¶
-
proc
mpz_sub
(ref rop: mpz_t, const ref op1: mpz_t, const ref op2: mpz_t)¶
-
proc
mpz_sub_ui
(ref rop: mpz_t, const ref op1: mpz_t, op2: c_ulong)¶
-
proc
mpz_ui_sub
(ref rop: mpz_t, op1: c_ulong, const ref op2: mpz_t)¶
-
proc
mpz_mul
(ref rop: mpz_t, const ref op1: mpz_t, const ref op2: mpz_t)¶
-
proc
mpz_mul_si
(ref rop: mpz_t, const ref op1: mpz_t, op2: c_long)¶
-
proc
mpz_mul_ui
(ref rop: mpz_t, const ref op1: mpz_t, op2: c_ulong)¶
-
proc
mpz_addmul
(ref rop: mpz_t, const ref op1: mpz_t, const ref op2: mpz_t)¶
-
proc
mpz_addmul_ui
(ref rop: mpz_t, const ref op1: mpz_t, op2: c_ulong)¶
-
proc
mpz_submul
(ref rop: mpz_t, const ref op1: mpz_t, const ref op2: mpz_t)¶
-
proc
mpz_submul_ui
(ref rop: mpz_t, const ref op1: mpz_t, op2: c_ulong)¶
-
proc
mpz_mul_2exp
(ref rop: mpz_t, const ref op1: mpz_t, op2: mp_bitcnt_t)¶
-
proc
mpz_neg
(ref rop: mpz_t, const ref op: mpz_t)¶
-
proc
mpz_abs
(ref rop: mpz_t, const ref op: mpz_t)¶
-
proc
mpz_cdiv_q
(ref q: mpz_t, const ref n: mpz_t, const ref d: mpz_t)¶
-
proc
mpz_cdiv_r
(ref r: mpz_t, const ref n: mpz_t, const ref d: mpz_t)¶
-
proc
mpz_cdiv_qr
(ref q: mpz_t, ref r: mpz_t, const ref n: mpz_t, const ref d: mpz_t)¶
-
proc
mpz_cdiv_q_ui
(ref q: mpz_t, const ref n: mpz_t, d: c_ulong): c_ulong¶
-
proc
mpz_cdiv_r_ui
(ref r: mpz_t, const ref n: mpz_t, d: c_ulong): c_ulong¶
-
proc
mpz_cdiv_qr_ui
(ref q: mpz_t, ref r: mpz_t, const ref n: mpz_t, d: c_ulong): c_ulong¶
-
proc
mpz_cdiv_ui
(const ref n: mpz_t, d: c_ulong): c_ulong¶
-
proc
mpz_cdiv_q_2exp
(ref q: mpz_t, const ref n: mpz_t, b: mp_bitcnt_t)¶
-
proc
mpz_cdiv_r_2exp
(ref r: mpz_t, const ref n: mpz_t, b: mp_bitcnt_t)¶
-
proc
mpz_fdiv_q
(ref q: mpz_t, const ref n: mpz_t, const ref d: mpz_t)¶
-
proc
mpz_fdiv_r
(ref r: mpz_t, const ref n: mpz_t, const ref d: mpz_t)¶
-
proc
mpz_fdiv_qr
(ref q: mpz_t, ref r: mpz_t, const ref n: mpz_t, const ref d: mpz_t)¶
-
proc
mpz_fdiv_q_ui
(ref q: mpz_t, const ref n: mpz_t, d: c_ulong): c_ulong¶
-
proc
mpz_fdiv_r_ui
(ref r: mpz_t, const ref n: mpz_t, d: c_ulong): c_ulong¶
-
proc
mpz_fdiv_qr_ui
(ref q: mpz_t, ref r: mpz_t, const ref n: mpz_t, d: c_ulong): c_ulong¶
-
proc
mpz_fdiv_ui
(const ref n: mpz_t, d: c_ulong): c_ulong¶
-
proc
mpz_fdiv_q_2exp
(ref q: mpz_t, const ref n: mpz_t, b: mp_bitcnt_t)¶
-
proc
mpz_fdiv_r_2exp
(ref r: mpz_t, const ref n: mpz_t, b: mp_bitcnt_t)¶
-
proc
mpz_tdiv_q
(ref q: mpz_t, const ref n: mpz_t, const ref d: mpz_t)¶
-
proc
mpz_tdiv_r
(ref r: mpz_t, const ref n: mpz_t, const ref d: mpz_t)¶
-
proc
mpz_tdiv_qr
(ref q: mpz_t, ref r: mpz_t, const ref n: mpz_t, const ref d: mpz_t)¶
-
proc
mpz_tdiv_q_ui
(ref q: mpz_t, const ref n: mpz_t, d: c_ulong): c_ulong¶
-
proc
mpz_tdiv_r_ui
(ref r: mpz_t, const ref n: mpz_t, d: c_ulong): c_ulong¶
-
proc
mpz_tdiv_qr_ui
(ref q: mpz_t, ref r: mpz_t, const ref n: mpz_t, d: c_ulong): c_ulong¶
-
proc
mpz_tdiv_ui
(const ref n: mpz_t, d: c_ulong): c_ulong¶
-
proc
mpz_tdiv_q_2exp
(ref q: mpz_t, const ref n: mpz_t, b: mp_bitcnt_t)¶
-
proc
mpz_tdiv_r_2exp
(ref r: mpz_t, const ref n: mpz_t, b: mp_bitcnt_t)¶
-
proc
mpz_mod
(ref rop: mpz_t, const ref n: mpz_t, const ref d: mpz_t)¶
-
proc
mpz_mod_ui
(ref rop: mpz_t, const ref n: mpz_t, d: c_ulong): c_ulong¶
-
proc
mpz_divexact
(ref q: mpz_t, const ref n: mpz_t, const ref d: mpz_t)¶
-
proc
mpz_divexact_ui
(ref q: mpz_t, const ref n: mpz_t, d: c_ulong)¶
-
proc
mpz_divisible_p
(const ref n: mpz_t, const ref d: mpz_t): c_int¶
-
proc
mpz_divisible_ui_p
(const ref n: mpz_t, d: c_ulong): c_int¶
-
proc
mpz_divisible_2exp_p
(const ref n: mpz_t, b: mp_bitcnt_t): c_int¶
-
proc
mpz_congruent_p
(const ref n: mpz_t, const ref c: mpz_t, const ref d: mpz_t): c_int¶
-
proc
mpz_congruent_ui_p
(const ref n: mpz_t, c: c_ulong, d: c_ulong): c_int¶
-
proc
mpz_congruent_2exp_p
(const ref n: mpz_t, const ref c: mpz_t, b: mp_bitcnt_t): c_int¶
-
proc
mpz_powm
(ref rop: mpz_t, const ref base: mpz_t, const ref exp: mpz_t, const ref mod: mpz_t)¶
-
proc
mpz_powm_ui
(ref rop: mpz_t, const ref base: mpz_t, exp: c_ulong, const ref mod: mpz_t)¶
-
proc
mpz_powm_sec
(ref rop: mpz_t, const ref base: mpz_t, const ref exp: mpz_t, const ref mod: mpz_t)¶
-
proc
mpz_pow_ui
(ref rop: mpz_t, const ref base: mpz_t, exp: c_ulong)¶
-
proc
mpz_ui_pow_ui
(ref rop: mpz_t, base: c_ulong, exp: c_ulong)¶
-
proc
mpz_root
(ref rop: mpz_t, const ref op: mpz_t, n: c_ulong): c_int¶
-
proc
mpz_rootrem
(ref root: mpz_t, ref rem: mpz_t, const ref u: mpz_t, n: c_ulong)¶
-
proc
mpz_sqrt
(ref rop: mpz_t, const ref op: mpz_t)¶
-
proc
mpz_sqrtrem
(ref rop1: mpz_t, ref rop2: mpz_t, const ref op: mpz_t)¶
-
proc
mpz_perfect_power_p
(const ref op: mpz_t): c_int¶
-
proc
mpz_perfect_square_p
(const ref op: mpz_t): c_int¶
-
proc
mpz_probab_prime_p
(ref n: mpz_t, reps: c_int): c_int¶
-
proc
mpz_nextprime
(ref rop: mpz_t, const ref op: mpz_t)¶
-
proc
mpz_gcd
(ref rop: mpz_t, const ref op1: mpz_t, const ref op2: mpz_t)¶
-
proc
mpz_gcd_ui
(ref rop: mpz_t, const ref op1: mpz_t, op2: c_ulong)¶
-
proc
mpz_gcdext
(ref g: mpz_t, ref s: mpz_t, ref t: mpz_t, const ref a: mpz_t, const ref b: mpz_t)¶
-
proc
mpz_lcm
(ref rop: mpz_t, const ref op1: mpz_t, const ref op2: mpz_t)¶
-
proc
mpz_lcm_ui
(ref rop: mpz_t, const ref op1: mpz_t, op2: c_ulong)¶
-
proc
mpz_invert
(ref rop: mpz_t, const ref op1: mpz_t, const ref op2: mpz_t): c_int¶
-
proc
mpz_jacobi
(const ref a: mpz_t, const ref b: mpz_t): c_int¶
-
proc
mpz_legendre
(const ref a: mpz_t, const ref p: mpz_t): c_int¶
-
proc
mpz_kronecker
(const ref a: mpz_t, const ref b: mpz_t): c_int¶
-
proc
mpz_kronecker_si
(const ref a: mpz_t, b: c_long): c_int¶
-
proc
mpz_kronecker_ui
(const ref a: mpz_t, b: c_ulong): c_int¶
-
proc
mpz_si_kronecker
(a: c_long, const ref b: mpz_t): c_int¶
-
proc
mpz_ui_kronecker
(a: c_ulong, const ref b: mpz_t): c_int¶
-
proc
mpz_remove
(ref rop: mpz_t, const ref op: mpz_t, const ref f: mpz_t): c_ulong¶
-
proc
mpz_fac_ui
(ref rop: mpz_t, n: c_ulong)¶
-
proc
mpz_2fac_ui
(ref rop: mpz_t, n: c_ulong)¶
-
proc
mpz_mfac_uiui
(ref rop: mpz_t, n: c_ulong, m: c_ulong)¶
-
proc
mpz_primorial_ui
(ref rop: mpz_t, n: c_ulong)¶
-
proc
mpz_bin_ui
(ref rop: mpz_t, const ref n: mpz_t, k: c_ulong)¶
-
proc
mpz_bin_uiui
(ref rop: mpz_t, n: c_ulong, k: c_ulong)¶
-
proc
mpz_fib_ui
(ref fn: mpz_t, n: c_ulong)¶
-
proc
mpz_fib2_ui
(ref fn: mpz_t, ref fnsub1: mpz_t, n: c_ulong)¶
-
proc
mpz_lucnum_ui
(ref ln: mpz_t, n: c_ulong)¶
-
proc
mpz_lucnum2_ui
(ref ln: mpz_t, ref lnsub1: mpz_t, n: c_ulong)¶
-
proc
mpz_cmp
(const ref op1: mpz_t, const ref op2: mpz_t): c_int¶
-
proc
mpz_cmp_d
(const ref op1: mpz_t, op2: c_double): c_int¶
-
proc
mpz_cmp_si
(const ref op1: mpz_t, op2: c_long): c_int¶
-
proc
mpz_cmp_ui
(const ref op1: mpz_t, op2: c_ulong): c_int¶
-
proc
mpz_cmpabs
(const ref op1: mpz_t, const ref op2: mpz_t): c_int¶
-
proc
mpz_cmpabs_d
(const ref op1: mpz_t, op2: c_double): c_int¶
-
proc
mpz_cmpabs_ui
(const ref op1: mpz_t, op2: c_ulong): c_int¶
-
proc
mpz_sgn
(const ref op: mpz_t): c_int¶
-
proc
mpz_and
(ref rop: mpz_t, const ref op1: mpz_t, const ref op2: mpz_t)¶
-
proc
mpz_ior
(ref rop: mpz_t, const ref op1: mpz_t, const ref op2: mpz_t)¶
-
proc
mpz_xor
(ref rop: mpz_t, const ref op1: mpz_t, const ref op2: mpz_t)¶
-
proc
mpz_com
(ref rop: mpz_t, const ref op: mpz_t)¶
-
proc
mpz_popcount
(const ref op: mpz_t): c_ulong¶
-
proc
mpz_hamdist
(const ref op1: mpz_t, const ref op2: mpz_t): c_ulong¶
-
proc
mpz_scan0
(const ref op: mpz_t, starting_bit: mp_bitcnt_t): c_ulong¶
-
proc
mpz_scan1
(const ref op: mpz_t, starting_bit: mp_bitcnt_t): c_ulong¶
-
proc
mpz_setbit
(ref rop: mpz_t, bit_index: mp_bitcnt_t)¶
-
proc
mpz_clrbit
(ref rop: mpz_t, bit_index: mp_bitcnt_t)¶
-
proc
mpz_combit
(ref rop: mpz_t, bit_index: mp_bitcnt_t)¶
-
proc
mpz_tstbit
(const ref op: mpz_t, bit_index: mp_bitcnt_t): c_int¶
-
proc
mpz_urandomb
(ref rop: mpz_t, ref state: gmp_randstate_t, n: mp_bitcnt_t)¶
-
proc
mpz_urandomm
(ref rop: mpz_t, ref state: gmp_randstate_t, const ref n: mpz_t)¶
-
proc
mpz_rrandomb
(ref rop: mpz_t, ref state: gmp_randstate_t, n: mp_bitcnt_t)¶
-
proc
mpz_random
(ref rop: mpz_t, max_size: mp_size_t)¶
-
proc
mpz_random2
(ref rop: mpz_t, max_size: mp_size_t)¶
-
proc
mpz_fits_ulong_p
(const ref op: mpz_t): c_int¶
-
proc
mpz_fits_slong_p
(const ref op: mpz_t): c_int¶
-
proc
mpz_fits_uint_p
(const ref op: mpz_t): c_int¶
-
proc
mpz_fits_sint_p
(const ref op: mpz_t): c_int¶
-
proc
mpz_fits_ushort_p
(const ref op: mpz_t): c_int¶
-
proc
mpz_fits_sshort_p
(const ref op: mpz_t): c_int¶
-
proc
mpz_odd_p
(const ref op: mpz_t): c_int¶
-
proc
mpz_even_p
(const ref op: mpz_t): c_int¶
-
proc
mpz_sizeinbase
(const ref op: mpz_t, base: c_int): size_t¶
-
proc
mpz_getlimbn
(const ref op: mpz_t, n: mp_size_t): mp_limb_t¶
-
proc
mpz_size
(const ref x: mpz_t): size_t¶
-
proc
mpf_set_default_prec
(prec: mp_bitcnt_t)¶
-
proc
mpf_get_default_prec
(): mp_bitcnt_t¶
-
proc
mpf_init
(ref x: mpf_t)¶
-
proc
mpf_init2
(ref x: mpf_t, prec: mp_bitcnt_t)¶
-
proc
mpf_clear
(ref x: mpf_t)¶
-
proc
mpf_get_prec
(const ref op: mpf_t): mp_bitcnt_t¶
-
proc
mpf_set_prec
(ref rop: mpf_t, prec: mp_bitcnt_t)¶
-
proc
mpf_set_prec_raw
(ref rop: mpf_t, prec: mp_bitcnt_t)¶
-
proc
mpf_set
(ref rop: mpf_t, const ref op: mpz_t)¶
-
proc
mpf_set_ui
(ref rop: mpf_t, op: c_ulong)¶
-
proc
mpf_set_si
(ref rop: mpf_t, op: c_long)¶
-
proc
mpf_set_d
(ref rop: mpf_t, op: c_double)¶
-
proc
mpf_set_z
(ref rop: mpf_t, const ref op: mpz_t)¶
-
proc
mpf_set_q
(ref rop: mpf_t, const ref op: mpz_t)¶
-
proc
mpf_set_str
(ref rop: mpz_t, str: c_string, base: c_int)¶
-
proc
mpf_swap
(ref rop1: mpf_t, ref rop2: mpz_t)¶
-
proc
mpf_init_set
(ref rop: mpf_t, const ref op: mpz_t)¶
-
proc
mpf_init_set_ui
(ref rop: mpf_t, op: c_ulong)¶
-
proc
mpf_init_set_si
(ref rop: mpf_t, op: c_long)¶
-
proc
mpf_init_set_d
(ref rop: mpf_t, op: c_double)¶
-
proc
mpf_get_d
(const ref op: mpf_t): c_double¶
-
proc
mpf_get_d_2exp
(ref exp: c_long, const ref op: mpz_t): c_double¶
-
proc
mpf_get_si
(const ref op: mpf_t): c_long¶
-
proc
mpf_get_ui
(const ref op: mpf_t): c_ulong¶
-
proc
mpf_add
(ref rop: mpf_t, const ref op1: mpf_t, const ref op2: mpf_t)¶
-
proc
mpf_add_ui
(ref rop: mpf_t, const ref op1: mpf_t, op2: c_ulong)¶
-
proc
mpf_sub
(ref rop: mpf_t, const ref op1: mpf_t, const ref op2: mpf_t)¶
-
proc
mpf_ui_sub
(ref rop: mpf_t, op1: c_ulong, const ref op2: mpf_t)¶
-
proc
mpf_sub_ui
(ref rop: mpf_t, const ref op1: mpf_t, op2: c_ulong)¶
-
proc
mpf_mul
(ref rop: mpf_t, const ref op1: mpf_t, const ref op2: mpf_t)¶
-
proc
mpf_mul_ui
(ref rop: mpf_t, const ref op1: mpf_t, op2: c_ulong)¶
-
proc
mpf_div
(ref rop: mpf_t, const ref op1: mpf_t, const ref op2: mpf_t)¶
-
proc
mpf_ui_div
(ref rop: mpf_t, op1: c_ulong, const ref op2: mpf_t)¶
-
proc
mpf_div_ui
(ref rop: mpf_t, const ref op1: mpf_t, op2: c_ulong)¶
-
proc
mpf_sqrt
(ref rop: mpf_t, const ref op: mpf_t)¶
-
proc
mpf_sqrt_ui
(ref rop: mpf_t, op: c_ulong)¶
-
proc
mpf_pow_ui
(ref rop: mpf_t, const ref op1: mpf_t, op2: c_ulong)¶
-
proc
mpf_neg
(ref rop: mpf_t, const ref op: mpf_t)¶
-
proc
mpf_abs
(ref rop: mpf_t, const ref op: mpf_t)¶
-
proc
mpf_mul_2exp
(ref rop: mpf_t, const ref op1: mpf_t, op2: mp_bitcnt_t)¶
-
proc
mpf_div_2exp
(ref rop: mpf_t, const ref op1: mpf_t, op2: mp_bitcnt_t)¶
-
proc
mpf_cmp
(const ref op1: mpf_t, const ref op2: mpf_t): c_int¶
-
proc
mpf_cmp_z
(const ref op1: mpf_t, const ref op2: mpf_t): c_int¶
-
proc
mpf_cmp_d
(const ref op1: mpf_t, op2: c_double): c_int¶
-
proc
mpf_cmp_ui
(const ref op1: mpf_t, op2: c_ulong): c_int¶
-
proc
mpf_cmp_si
(const ref op1: mpf_t, op2: c_long): c_int¶
-
proc
mpf_eq
(const ref op1: mpf_t, const ref op2: mpf_t, op3: mp_bitcnt_t): c_int¶
-
proc
mpf_reldiff
(const ref rop: mpf_t, const ref op1: mpf_t, const ref op2: mpf_t)¶
-
proc
mpf_sgn
(const ref op: mpf_t)¶
-
proc
mpf_out_str
(stream: _file, base: c_int, n_digits: size_t, const ref op: mpf_t)¶
-
proc
mpf_inp_str
(ref rop: mpf_t, stream: _file, base: c_int)¶
-
proc
mpf_ceil
(ref rop: mpf_t, const ref op: mpf_t)¶
-
proc
mpf_floor
(ref rop: mpf_t, const ref op: mpf_t)¶
-
proc
mpf_trunc
(ref rop: mpf_t, const ref op: mpf_t)¶
-
proc
mpf_integer_p
(const ref op: mpf_t): c_int¶
-
proc
mpf_fits_ulong_p
(const ref op: mpf_t): c_int¶
-
proc
mpf_fits_slong_p
(const ref op: mpf_t): c_int¶
-
proc
mpf_fits_uint_p
(const ref op: mpf_t): c_int¶
-
proc
mpf_fits_sint_p
(const ref op: mpf_t): c_int¶
-
proc
mpf_fits_ushort_p
(const ref op: mpf_t): c_int¶
-
proc
mpf_fits_sshort_p
(const ref op: mpf_t): c_int¶
-
proc
mpf_urandomb
(ref rop: mpf_t, ref state: gmp_randstate_t, nbits: mp_bitcnt_t)¶
-
proc
gmp_randinit_default
(ref state: gmp_randstate_t)¶
-
proc
gmp_randinit_mt
(ref state: gmp_randstate_t)¶
-
proc
gmp_randinit_lc_2exp
(ref state: gmp_randstate_t, const ref a: mpz_t, c: c_ulong, m2exp: mp_bitcnt_t)¶
-
proc
gmp_randinit_lc_2exp_size
(ref state: gmp_randstate_t, size: mp_bitcnt_t)¶
-
proc
gmp_randinit_set
(ref rop: gmp_randstate_t, ref op: gmp_randstate_t)¶
-
proc
gmp_randclear
(ref state: gmp_randstate_t)¶
-
proc
gmp_randseed
(ref state: gmp_randstate_t, const ref seed: mpz_t)¶
-
proc
gmp_randseed_ui
(ref state: gmp_randstate_t, seed: c_ulong)¶
-
proc
gmp_urandomb_ui
(ref state: gmp_randstate_t, n: c_ulong): c_ulong¶
-
proc
gmp_urandomm_ui
(ref state: gmp_randstate_t, n: c_ulong): c_ulong¶
-
proc
gmp_printf
(fmt: c_string, arg ...)¶
-
proc
gmp_fprintf
(fp: _file, fmt: c_string, arg ...)¶
-
proc
gmp_fprintf
(fp: _file, fmt: c_string, arg ...)
-
proc
gmp_asprintf
(ref ret: c_string, fmt: c_string, arg ...)¶
-
proc
chpl_gmp_get_mpz
(ref ret: mpz_t, src_local: int, from: __mpz_struct)¶ Get an MPZ value stored on another locale
-
proc
chpl_gmp_mpz_print
(const ref x: mpz_t)¶ Print out an mpz_t (for debugging)
-
proc
chpl_gmp_mpz_get_str
(base: c_int, const ref x: mpz_t): c_string_copy¶ Get an mpz_t as a string
-
enum
Round
{ DOWN = -1, ZERO = 0, UP = 1 }¶
-
class
BigInt
¶ This class is deprecated for release 1.14 (Fall 2016) and will not be present in release 1.15 (Spring 2017). Please see the record
bigint
in the moduleBigInteger
for the replacement for this class.The BigInt class provides a more Chapel-friendly interface to the GMP integer functions. In particular, this class supports GMP integers that can be stored in distributed arrays.
All methods on BigInt work with Chapel types. Many of them use the gmp functions directly, which use C types. Runtime checks are used to ensure the Chapel types can safely be cast to the C types (e.g. when casting a Chapel uint it checks that it fits in the C ulong which could be a 32 bit type if running on linux32 platform).
The checks are controlled by the compiler options
--[no-]cast-checks
,--fast
, etc.-
var
mpz
: mpz_t¶
-
proc
BigInt
(init2: bool, nbits: uint)¶
-
proc
BigInt
(num: int)
-
proc
BigInt
(str: string, base: int = 0)
-
proc
BigInt
(str: string, base: int = 0, out error: syserr)
-
proc
BigInt
(num: BigInt)
-
proc
BigInt
()
-
proc BigInt.~BigInt()
-
proc
numLimbs
: uint(64)¶
-
proc
mpzStruct
(): __mpz_struct¶
-
proc
maybeCopy
(): (bool, BigInt)¶
-
proc
set
(a: BigInt)¶
-
proc
set_ui
(num: uint)¶
-
proc
set_si
(num: int)¶
-
proc
set
(num: int)
-
proc
set_d
(num: real)¶
-
proc
set_str
(str: string, base: int = 0)¶
-
proc
swap
(a: BigInt)¶
-
proc
get_ui
(): uint¶
-
proc
get_si
(): int¶
-
proc
get_d
(): real¶
-
proc
get_d_2exp
(): (int, real)¶
-
proc
get_str
(base: int = 10): string¶
-
proc
add
(a: BigInt, b: BigInt)¶
-
proc
add_ui
(a: BigInt, b: uint)¶
-
proc
sub
(a: BigInt, b: BigInt)¶
-
proc
sub_ui
(a: BigInt, b: uint)¶
-
proc
ui_sub
(a: uint, b: BigInt)¶
-
proc
mul
(a: BigInt, b: BigInt)¶
-
proc
mul_si
(a: BigInt, b: int)¶
-
proc
mul_ui
(a: BigInt, b: uint)¶
-
proc
addmul
(a: BigInt, b: BigInt)¶
-
proc
addmul_ui
(a: BigInt, b: uint)¶
-
proc
submul
(a: BigInt, b: BigInt)¶
-
proc
submul_ui
(a: BigInt, b: uint)¶
-
proc
mul_2exp
(a: BigInt, b: uint)¶
-
proc
neg
(a: BigInt)¶
-
proc
abs
(a: BigInt)¶
-
proc
div_q
(param rounding: Round, n: BigInt, d: BigInt)¶
-
proc
div_r
(param rounding: Round, n: BigInt, d: BigInt)¶
-
proc
div_qr
(param rounding: Round, r: BigInt, n: BigInt, d: BigInt)¶
-
proc
div_q_ui
(param rounding: Round, n: BigInt, d: uint): uint¶
-
proc
div_r_ui
(param rounding: Round, n: BigInt, d: uint): uint¶
-
proc
div_qr_ui
(param rounding: Round, r: BigInt, n: BigInt, d: uint): uint¶
-
proc
div_ui
(param rounding: Round, n: BigInt, d: uint): uint¶
-
proc
div_q_2exp
(param rounding: Round, n: BigInt, b: uint)¶
-
proc
div_r_2exp
(param rounding: Round, n: BigInt, b: uint)¶
-
proc
mod
(n: BigInt, d: BigInt)¶
-
proc
mod_ui
(n: BigInt, d: uint): uint¶
-
proc
divexact
(n: BigInt, d: BigInt)¶
-
proc
divexact_ui
(n: BigInt, d: uint)¶
-
proc
divisible_p
(d: BigInt): int¶
-
proc
divisible_ui_p
(d: uint): int¶
-
proc
divisible_2exp_p
(b: uint): int¶
-
proc
congruent_p
(c: BigInt, d: BigInt): int¶
-
proc
congruent_ui_p
(c: uint, d: uint): int¶
-
proc
congruent_2exp_p
(c: BigInt, b: uint): int¶
-
proc
powm
(base: BigInt, exp: BigInt, mod: BigInt)¶
-
proc
powm_ui
(base: BigInt, exp: uint, mod: BigInt)¶
-
proc
pow_ui
(base: BigInt, exp: uint)¶
-
proc
ui_pow_ui
(base: uint, exp: uint)¶
-
proc
root
(a: BigInt, n: uint): int¶
-
proc
mpz_rootrem
(rem: BigInt, u: BigInt, n: uint)¶
-
proc
sqrt
(a: BigInt)¶
-
proc
sqrtrem
(rem: BigInt, a: BigInt)¶
-
proc
perfect_power_p
(): int¶
-
proc
perfect_square
(): int¶
-
proc
probab_prime_p
(reps: int): int¶
-
proc
nextprime
(a: BigInt)¶
-
proc
gcd
(a: BigInt, b: BigInt)¶
-
proc
gcd_ui
(a: BigInt, b: uint)¶
-
proc
gcdext
(s: BigInt, t: BigInt, a: BigInt, b: BigInt)¶
-
proc
lcm
(a: BigInt, b: BigInt)¶
-
proc
lcm_ui
(a: BigInt, b: uint)¶
-
proc
invert
(a: BigInt, b: BigInt): int¶
-
proc
remove
(a: BigInt, f: BigInt): uint¶
-
proc
fac_ui
(a: uint)¶
-
proc
bin_ui
(n: BigInt, k: uint)¶
-
proc
bin_uiui
(n: uint, k: uint)¶
-
proc
fib_ui
(n: uint)¶
-
proc
fib2_ui
(fnsub1: BigInt, n: uint)¶
-
proc
lucnum_ui
(n: uint)¶
-
proc
lucnum2_ui
(lnsub1: BigInt, n: uint)¶
-
proc
cmp
(b: BigInt): int¶
-
proc
cmp_d
(b: real): int¶
-
proc
cmp_si
(b: int): int¶
-
proc
cmp_ui
(b: uint): int¶
-
proc
cmpabs
(b: BigInt): int¶
-
proc
cmpabs_d
(b: real): int¶
-
proc
cmp_abs_ui
(b: uint): int¶
-
proc
sgn
(): int¶
-
proc
and
(a: BigInt, b: BigInt)¶
-
proc
ior
(a: BigInt, b: BigInt)¶
-
proc
xor
(a: BigInt, b: BigInt)¶
-
proc
com
(a: BigInt)¶
-
proc
popcount
(): uint¶
-
proc
hamdist
(b: BigInt): uint¶
-
proc
scan0
(starting_bit: uint): uint¶
-
proc
scan1
(starting_bit: uint): uint¶
-
proc
setbit
(bit_index: uint)¶
-
proc
clrbit
(bit_index: uint)¶
-
proc
combit
(bit_index: uint)¶
-
proc
tstbit
(bit_index: uint): int¶
-
proc
fits_ulong_p
(): int¶
-
proc
fits_slong_p
(): int¶
-
proc
fits_uint_p
(): int¶
-
proc
fits_sint_p
(): int¶
-
proc
fits_ushort_p
(): int¶
-
proc
fits_sshort_p
(): int¶
-
proc
odd_p
(): int¶
-
proc
even_p
(): int¶
-
proc
sizeinbase
(base: int): uint¶
-
proc
realloc2
(nbits: uint)¶
-
proc
get_limbn
(n: uint): uint¶
-
proc
size
(): size_t¶
-
proc
debugprint
()¶
-
var
-
proc
BigInt.
writeThis
(writer)¶
-
proc
jacobi
(a: BigInt, b: BigInt): int¶
-
proc
legendre
(a: BigInt, p: BigInt): int¶
-
proc
kronecker
(a: BigInt, b: BigInt): int¶
-
proc
kronecker_si
(a: BigInt, b: int): int¶
-
proc
kronecker_ui
(a: BigInt, b: uint): int¶
-
proc
si_kronecker
(a: int, b: BigInt): int¶
-
proc
ui_kronecker
(a: uint, b: BigInt): int¶
-
class
GMPRandom
¶ -
var
state
: gmp_randstate_t¶
-
proc
GMPRandom
()¶
-
proc
GMPRandom
(twister: bool)
-
proc
GMPRandom
(a: bigint, c: uint, m2exp: uint)
-
proc
GMPRandom
(size: uint)
-
proc
GMPRandom
(a: GMPRandom)
-
proc GMPRandom.~GMPRandom()
-
proc
seed
(seed: bigint)¶
-
proc
seed
(seed: uint)
-
proc
urandomb
(nbits: uint): uint¶
-
proc
urandomm
(n: uint): uint¶
-
proc
urandomb_ui
(nbits: uint): uint¶
-
proc
urandomm_ui
(n: uint): uint¶
-
proc
urandomb
(ref r: bigint, nbits: uint)
-
proc
urandomm
(ref r: bigint, n: bigint)
-
proc
rrandomb
(ref r: bigint, nbits: uint)¶
-
var