.. default-domain:: chpl .. module:: GMP :synopsis: Support for GNU Multiple Precision Arithmetic GMP === **Usage** .. code-block:: chapel 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 :mod:`BigInteger` leverages this interface to define the record :record:`~BigInteger.bigint`. The methods on the record :record:`~BigInteger.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 :mod:`BigInteger` for details. Using the GMP Module -------------------- Step 1: Build Chapel with GMP .. code-block:: sh # 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 module .. code-block:: chapel use 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 :mod:`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: * :type:`mp_bitcnt_t` * :type:`mpf_t` * :type:`mpz_t` And all :type:`mpz_t` GMP routines, as well as the following routines: * :proc:`gmp_fprintf()` * :proc:`gmp_printf()` * :proc:`mpf_add()` * :proc:`mpf_clear()` * :proc:`mpf_div_2exp()` * :proc:`mpf_get_d()` * :proc:`mpf_get_prec()` * :proc:`mpf_init()` * :proc:`mpf_mul()` * :proc:`mpf_mul_ui()` * :proc:`mpf_out_str()` * :proc:`mpf_set_d()` * :proc:`mpf_set_default_prec()` * :proc:`mpf_set_prec_raw()` * :proc:`mpf_set_z()` * :proc:`mpf_sub()` * :proc:`mpf_ui_div()` * :proc:`mpf_ui_sub()` 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 :record:`~BigInteger.bigint` in the module :mod:`BigInteger` for the replacement for this class. This module also provides a class :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 :class:`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:: type mp_bitcnt_t = c_ulong The GMP ``mp_bitcnt_t`` type .. type:: type mp_size_t = size_t The GMP ``mp_size_t`` type .. type:: type mp_limb_t = uint(64) The GMP ``mp_limb_t`` type. .. data:: const mp_bits_per_limb: c_int The GMP `mp_bits_per_limb`` constant .. type:: type mpz_t = 1*__mpz_struct The GMP ``mpz_t`` type .. type:: type mpf_t = 1*__mpf_struct The GMP ``mpf_t`` type .. type:: type gmp_randstate_t = 1*__gmp_randstate_struct The GMP ``gmp_randstate_t`` type .. function:: proc mpz_init(ref x: mpz_t) .. function:: proc mpz_init2(ref x: mpz_t, n: mp_bitcnt_t) .. function:: proc mpz_clear(ref x: mpz_t) .. function:: proc mpz_realloc2(ref x: mpz_t, n: mp_bitcnt_t) .. function:: proc mpz_set(ref rop: mpz_t, const ref op: mpz_t) .. function:: proc mpz_set_ui(ref rop: mpz_t, op: c_ulong) .. function:: proc mpz_set_si(ref rop: mpz_t, op: c_long) .. function:: proc mpz_set_d(ref rop: mpz_t, op: c_double) .. function:: proc mpz_set_str(ref rop: mpz_t, str: c_string, base: c_int) .. function:: proc mpz_swap(ref rop1: mpz_t, ref rop2: mpz_t) .. function:: proc mpz_init_set(ref rop: mpz_t, const ref op: mpz_t) .. function:: proc mpz_init_set_ui(ref rop: mpz_t, op: c_ulong) .. function:: proc mpz_init_set_si(ref rop: mpz_t, op: c_long) .. function:: proc mpz_init_set_d(ref rop: mpz_t, op: c_double) .. function:: proc mpz_init_set_str(ref rop: mpz_t, str: c_string, base: c_int): c_int .. function:: proc mpz_get_ui(const ref op: mpz_t): c_ulong .. function:: proc mpz_get_si(const ref op: mpz_t): c_long .. function:: proc mpz_get_d(const ref op: mpz_t): c_double .. function:: proc mpz_get_d_2exp(ref exp: c_long, const ref op: mpz_t): c_double .. function:: proc mpz_get_str(str: c_string, base: c_int, const ref op: mpz_t): c_string .. function:: proc mpz_add(ref rop: mpz_t, const ref op1: mpz_t, const ref op2: mpz_t) .. function:: proc mpz_add_ui(ref rop: mpz_t, const ref op1: mpz_t, op2: c_ulong) .. function:: proc mpz_sub(ref rop: mpz_t, const ref op1: mpz_t, const ref op2: mpz_t) .. function:: proc mpz_sub_ui(ref rop: mpz_t, const ref op1: mpz_t, op2: c_ulong) .. function:: proc mpz_ui_sub(ref rop: mpz_t, op1: c_ulong, const ref op2: mpz_t) .. function:: proc mpz_mul(ref rop: mpz_t, const ref op1: mpz_t, const ref op2: mpz_t) .. function:: proc mpz_mul_si(ref rop: mpz_t, const ref op1: mpz_t, op2: c_long) .. function:: proc mpz_mul_ui(ref rop: mpz_t, const ref op1: mpz_t, op2: c_ulong) .. function:: proc mpz_addmul(ref rop: mpz_t, const ref op1: mpz_t, const ref op2: mpz_t) .. function:: proc mpz_addmul_ui(ref rop: mpz_t, const ref op1: mpz_t, op2: c_ulong) .. function:: proc mpz_submul(ref rop: mpz_t, const ref op1: mpz_t, const ref op2: mpz_t) .. function:: proc mpz_submul_ui(ref rop: mpz_t, const ref op1: mpz_t, op2: c_ulong) .. function:: proc mpz_mul_2exp(ref rop: mpz_t, const ref op1: mpz_t, op2: mp_bitcnt_t) .. function:: proc mpz_neg(ref rop: mpz_t, const ref op: mpz_t) .. function:: proc mpz_abs(ref rop: mpz_t, const ref op: mpz_t) .. function:: proc mpz_cdiv_q(ref q: mpz_t, const ref n: mpz_t, const ref d: mpz_t) .. function:: proc mpz_cdiv_r(ref r: mpz_t, const ref n: mpz_t, const ref d: mpz_t) .. function:: proc mpz_cdiv_qr(ref q: mpz_t, ref r: mpz_t, const ref n: mpz_t, const ref d: mpz_t) .. function:: proc mpz_cdiv_q_ui(ref q: mpz_t, const ref n: mpz_t, d: c_ulong): c_ulong .. function:: proc mpz_cdiv_r_ui(ref r: mpz_t, const ref n: mpz_t, d: c_ulong): c_ulong .. function:: proc mpz_cdiv_qr_ui(ref q: mpz_t, ref r: mpz_t, const ref n: mpz_t, d: c_ulong): c_ulong .. function:: proc mpz_cdiv_ui(const ref n: mpz_t, d: c_ulong): c_ulong .. function:: proc mpz_cdiv_q_2exp(ref q: mpz_t, const ref n: mpz_t, b: mp_bitcnt_t) .. function:: proc mpz_cdiv_r_2exp(ref r: mpz_t, const ref n: mpz_t, b: mp_bitcnt_t) .. function:: proc mpz_fdiv_q(ref q: mpz_t, const ref n: mpz_t, const ref d: mpz_t) .. function:: proc mpz_fdiv_r(ref r: mpz_t, const ref n: mpz_t, const ref d: mpz_t) .. function:: proc mpz_fdiv_qr(ref q: mpz_t, ref r: mpz_t, const ref n: mpz_t, const ref d: mpz_t) .. function:: proc mpz_fdiv_q_ui(ref q: mpz_t, const ref n: mpz_t, d: c_ulong): c_ulong .. function:: proc mpz_fdiv_r_ui(ref r: mpz_t, const ref n: mpz_t, d: c_ulong): c_ulong .. function:: proc mpz_fdiv_qr_ui(ref q: mpz_t, ref r: mpz_t, const ref n: mpz_t, d: c_ulong): c_ulong .. function:: proc mpz_fdiv_ui(const ref n: mpz_t, d: c_ulong): c_ulong .. function:: proc mpz_fdiv_q_2exp(ref q: mpz_t, const ref n: mpz_t, b: mp_bitcnt_t) .. function:: proc mpz_fdiv_r_2exp(ref r: mpz_t, const ref n: mpz_t, b: mp_bitcnt_t) .. function:: proc mpz_tdiv_q(ref q: mpz_t, const ref n: mpz_t, const ref d: mpz_t) .. function:: proc mpz_tdiv_r(ref r: mpz_t, const ref n: mpz_t, const ref d: mpz_t) .. function:: proc mpz_tdiv_qr(ref q: mpz_t, ref r: mpz_t, const ref n: mpz_t, const ref d: mpz_t) .. function:: proc mpz_tdiv_q_ui(ref q: mpz_t, const ref n: mpz_t, d: c_ulong): c_ulong .. function:: proc mpz_tdiv_r_ui(ref r: mpz_t, const ref n: mpz_t, d: c_ulong): c_ulong .. function:: proc mpz_tdiv_qr_ui(ref q: mpz_t, ref r: mpz_t, const ref n: mpz_t, d: c_ulong): c_ulong .. function:: proc mpz_tdiv_ui(const ref n: mpz_t, d: c_ulong): c_ulong .. function:: proc mpz_tdiv_q_2exp(ref q: mpz_t, const ref n: mpz_t, b: mp_bitcnt_t) .. function:: proc mpz_tdiv_r_2exp(ref r: mpz_t, const ref n: mpz_t, b: mp_bitcnt_t) .. function:: proc mpz_mod(ref rop: mpz_t, const ref n: mpz_t, const ref d: mpz_t) .. function:: proc mpz_mod_ui(ref rop: mpz_t, const ref n: mpz_t, d: c_ulong): c_ulong .. function:: proc mpz_divexact(ref q: mpz_t, const ref n: mpz_t, const ref d: mpz_t) .. function:: proc mpz_divexact_ui(ref q: mpz_t, const ref n: mpz_t, d: c_ulong) .. function:: proc mpz_divisible_p(const ref n: mpz_t, const ref d: mpz_t): c_int .. function:: proc mpz_divisible_ui_p(const ref n: mpz_t, d: c_ulong): c_int .. function:: proc mpz_divisible_2exp_p(const ref n: mpz_t, b: mp_bitcnt_t): c_int .. function:: proc mpz_congruent_p(const ref n: mpz_t, const ref c: mpz_t, const ref d: mpz_t): c_int .. function:: proc mpz_congruent_ui_p(const ref n: mpz_t, c: c_ulong, d: c_ulong): c_int .. function:: proc mpz_congruent_2exp_p(const ref n: mpz_t, const ref c: mpz_t, b: mp_bitcnt_t): c_int .. function:: proc mpz_powm(ref rop: mpz_t, const ref base: mpz_t, const ref exp: mpz_t, const ref mod: mpz_t) .. function:: proc mpz_powm_ui(ref rop: mpz_t, const ref base: mpz_t, exp: c_ulong, const ref mod: mpz_t) .. function:: proc mpz_powm_sec(ref rop: mpz_t, const ref base: mpz_t, const ref exp: mpz_t, const ref mod: mpz_t) .. function:: proc mpz_pow_ui(ref rop: mpz_t, const ref base: mpz_t, exp: c_ulong) .. function:: proc mpz_ui_pow_ui(ref rop: mpz_t, base: c_ulong, exp: c_ulong) .. function:: proc mpz_root(ref rop: mpz_t, const ref op: mpz_t, n: c_ulong): c_int .. function:: proc mpz_rootrem(ref root: mpz_t, ref rem: mpz_t, const ref u: mpz_t, n: c_ulong) .. function:: proc mpz_sqrt(ref rop: mpz_t, const ref op: mpz_t) .. function:: proc mpz_sqrtrem(ref rop1: mpz_t, ref rop2: mpz_t, const ref op: mpz_t) .. function:: proc mpz_perfect_power_p(const ref op: mpz_t): c_int .. function:: proc mpz_perfect_square_p(const ref op: mpz_t): c_int .. function:: proc mpz_probab_prime_p(ref n: mpz_t, reps: c_int): c_int .. function:: proc mpz_nextprime(ref rop: mpz_t, const ref op: mpz_t) .. function:: proc mpz_gcd(ref rop: mpz_t, const ref op1: mpz_t, const ref op2: mpz_t) .. function:: proc mpz_gcd_ui(ref rop: mpz_t, const ref op1: mpz_t, op2: c_ulong) .. function:: 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) .. function:: proc mpz_lcm(ref rop: mpz_t, const ref op1: mpz_t, const ref op2: mpz_t) .. function:: proc mpz_lcm_ui(ref rop: mpz_t, const ref op1: mpz_t, op2: c_ulong) .. function:: proc mpz_invert(ref rop: mpz_t, const ref op1: mpz_t, const ref op2: mpz_t): c_int .. function:: proc mpz_jacobi(const ref a: mpz_t, const ref b: mpz_t): c_int .. function:: proc mpz_legendre(const ref a: mpz_t, const ref p: mpz_t): c_int .. function:: proc mpz_kronecker(const ref a: mpz_t, const ref b: mpz_t): c_int .. function:: proc mpz_kronecker_si(const ref a: mpz_t, b: c_long): c_int .. function:: proc mpz_kronecker_ui(const ref a: mpz_t, b: c_ulong): c_int .. function:: proc mpz_si_kronecker(a: c_long, const ref b: mpz_t): c_int .. function:: proc mpz_ui_kronecker(a: c_ulong, const ref b: mpz_t): c_int .. function:: proc mpz_remove(ref rop: mpz_t, const ref op: mpz_t, const ref f: mpz_t): c_ulong .. function:: proc mpz_fac_ui(ref rop: mpz_t, n: c_ulong) .. function:: proc mpz_2fac_ui(ref rop: mpz_t, n: c_ulong) .. function:: proc mpz_mfac_uiui(ref rop: mpz_t, n: c_ulong, m: c_ulong) .. function:: proc mpz_primorial_ui(ref rop: mpz_t, n: c_ulong) .. function:: proc mpz_bin_ui(ref rop: mpz_t, const ref n: mpz_t, k: c_ulong) .. function:: proc mpz_bin_uiui(ref rop: mpz_t, n: c_ulong, k: c_ulong) .. function:: proc mpz_fib_ui(ref fn: mpz_t, n: c_ulong) .. function:: proc mpz_fib2_ui(ref fn: mpz_t, ref fnsub1: mpz_t, n: c_ulong) .. function:: proc mpz_lucnum_ui(ref ln: mpz_t, n: c_ulong) .. function:: proc mpz_lucnum2_ui(ref ln: mpz_t, ref lnsub1: mpz_t, n: c_ulong) .. function:: proc mpz_cmp(const ref op1: mpz_t, const ref op2: mpz_t): c_int .. function:: proc mpz_cmp_d(const ref op1: mpz_t, op2: c_double): c_int .. function:: proc mpz_cmp_si(const ref op1: mpz_t, op2: c_long): c_int .. function:: proc mpz_cmp_ui(const ref op1: mpz_t, op2: c_ulong): c_int .. function:: proc mpz_cmpabs(const ref op1: mpz_t, const ref op2: mpz_t): c_int .. function:: proc mpz_cmpabs_d(const ref op1: mpz_t, op2: c_double): c_int .. function:: proc mpz_cmpabs_ui(const ref op1: mpz_t, op2: c_ulong): c_int .. function:: proc mpz_sgn(const ref op: mpz_t): c_int .. function:: proc mpz_and(ref rop: mpz_t, const ref op1: mpz_t, const ref op2: mpz_t) .. function:: proc mpz_ior(ref rop: mpz_t, const ref op1: mpz_t, const ref op2: mpz_t) .. function:: proc mpz_xor(ref rop: mpz_t, const ref op1: mpz_t, const ref op2: mpz_t) .. function:: proc mpz_com(ref rop: mpz_t, const ref op: mpz_t) .. function:: proc mpz_popcount(const ref op: mpz_t): c_ulong .. function:: proc mpz_hamdist(const ref op1: mpz_t, const ref op2: mpz_t): c_ulong .. function:: proc mpz_scan0(const ref op: mpz_t, starting_bit: mp_bitcnt_t): c_ulong .. function:: proc mpz_scan1(const ref op: mpz_t, starting_bit: mp_bitcnt_t): c_ulong .. function:: proc mpz_setbit(ref rop: mpz_t, bit_index: mp_bitcnt_t) .. function:: proc mpz_clrbit(ref rop: mpz_t, bit_index: mp_bitcnt_t) .. function:: proc mpz_combit(ref rop: mpz_t, bit_index: mp_bitcnt_t) .. function:: proc mpz_tstbit(const ref op: mpz_t, bit_index: mp_bitcnt_t): c_int .. function:: proc mpz_urandomb(ref rop: mpz_t, ref state: gmp_randstate_t, n: mp_bitcnt_t) .. function:: proc mpz_urandomm(ref rop: mpz_t, ref state: gmp_randstate_t, const ref n: mpz_t) .. function:: proc mpz_rrandomb(ref rop: mpz_t, ref state: gmp_randstate_t, n: mp_bitcnt_t) .. function:: proc mpz_random(ref rop: mpz_t, max_size: mp_size_t) .. function:: proc mpz_random2(ref rop: mpz_t, max_size: mp_size_t) .. function:: proc mpz_fits_ulong_p(const ref op: mpz_t): c_int .. function:: proc mpz_fits_slong_p(const ref op: mpz_t): c_int .. function:: proc mpz_fits_uint_p(const ref op: mpz_t): c_int .. function:: proc mpz_fits_sint_p(const ref op: mpz_t): c_int .. function:: proc mpz_fits_ushort_p(const ref op: mpz_t): c_int .. function:: proc mpz_fits_sshort_p(const ref op: mpz_t): c_int .. function:: proc mpz_odd_p(const ref op: mpz_t): c_int .. function:: proc mpz_even_p(const ref op: mpz_t): c_int .. function:: proc mpz_sizeinbase(const ref op: mpz_t, base: c_int): size_t .. function:: proc mpz_getlimbn(const ref op: mpz_t, n: mp_size_t): mp_limb_t .. function:: proc mpz_size(const ref x: mpz_t): size_t .. function:: proc mpf_set_default_prec(prec: mp_bitcnt_t) .. function:: proc mpf_get_default_prec(): mp_bitcnt_t .. function:: proc mpf_init(ref x: mpf_t) .. function:: proc mpf_init2(ref x: mpf_t, prec: mp_bitcnt_t) .. function:: proc mpf_clear(ref x: mpf_t) .. function:: proc mpf_get_prec(const ref op: mpf_t): mp_bitcnt_t .. function:: proc mpf_set_prec(ref rop: mpf_t, prec: mp_bitcnt_t) .. function:: proc mpf_set_prec_raw(ref rop: mpf_t, prec: mp_bitcnt_t) .. function:: proc mpf_set(ref rop: mpf_t, const ref op: mpz_t) .. function:: proc mpf_set_ui(ref rop: mpf_t, op: c_ulong) .. function:: proc mpf_set_si(ref rop: mpf_t, op: c_long) .. function:: proc mpf_set_d(ref rop: mpf_t, op: c_double) .. function:: proc mpf_set_z(ref rop: mpf_t, const ref op: mpz_t) .. function:: proc mpf_set_q(ref rop: mpf_t, const ref op: mpz_t) .. function:: proc mpf_set_str(ref rop: mpz_t, str: c_string, base: c_int) .. function:: proc mpf_swap(ref rop1: mpf_t, ref rop2: mpz_t) .. function:: proc mpf_init_set(ref rop: mpf_t, const ref op: mpz_t) .. function:: proc mpf_init_set_ui(ref rop: mpf_t, op: c_ulong) .. function:: proc mpf_init_set_si(ref rop: mpf_t, op: c_long) .. function:: proc mpf_init_set_d(ref rop: mpf_t, op: c_double) .. function:: proc mpf_get_d(const ref op: mpf_t): c_double .. function:: proc mpf_get_d_2exp(ref exp: c_long, const ref op: mpz_t): c_double .. function:: proc mpf_get_si(const ref op: mpf_t): c_long .. function:: proc mpf_get_ui(const ref op: mpf_t): c_ulong .. function:: proc mpf_add(ref rop: mpf_t, const ref op1: mpf_t, const ref op2: mpf_t) .. function:: proc mpf_add_ui(ref rop: mpf_t, const ref op1: mpf_t, op2: c_ulong) .. function:: proc mpf_sub(ref rop: mpf_t, const ref op1: mpf_t, const ref op2: mpf_t) .. function:: proc mpf_ui_sub(ref rop: mpf_t, op1: c_ulong, const ref op2: mpf_t) .. function:: proc mpf_sub_ui(ref rop: mpf_t, const ref op1: mpf_t, op2: c_ulong) .. function:: proc mpf_mul(ref rop: mpf_t, const ref op1: mpf_t, const ref op2: mpf_t) .. function:: proc mpf_mul_ui(ref rop: mpf_t, const ref op1: mpf_t, op2: c_ulong) .. function:: proc mpf_div(ref rop: mpf_t, const ref op1: mpf_t, const ref op2: mpf_t) .. function:: proc mpf_ui_div(ref rop: mpf_t, op1: c_ulong, const ref op2: mpf_t) .. function:: proc mpf_div_ui(ref rop: mpf_t, const ref op1: mpf_t, op2: c_ulong) .. function:: proc mpf_sqrt(ref rop: mpf_t, const ref op: mpf_t) .. function:: proc mpf_sqrt_ui(ref rop: mpf_t, op: c_ulong) .. function:: proc mpf_pow_ui(ref rop: mpf_t, const ref op1: mpf_t, op2: c_ulong) .. function:: proc mpf_neg(ref rop: mpf_t, const ref op: mpf_t) .. function:: proc mpf_abs(ref rop: mpf_t, const ref op: mpf_t) .. function:: proc mpf_mul_2exp(ref rop: mpf_t, const ref op1: mpf_t, op2: mp_bitcnt_t) .. function:: proc mpf_div_2exp(ref rop: mpf_t, const ref op1: mpf_t, op2: mp_bitcnt_t) .. function:: proc mpf_cmp(const ref op1: mpf_t, const ref op2: mpf_t): c_int .. function:: proc mpf_cmp_z(const ref op1: mpf_t, const ref op2: mpf_t): c_int .. function:: proc mpf_cmp_d(const ref op1: mpf_t, op2: c_double): c_int .. function:: proc mpf_cmp_ui(const ref op1: mpf_t, op2: c_ulong): c_int .. function:: proc mpf_cmp_si(const ref op1: mpf_t, op2: c_long): c_int .. function:: proc mpf_eq(const ref op1: mpf_t, const ref op2: mpf_t, op3: mp_bitcnt_t): c_int .. function:: proc mpf_reldiff(const ref rop: mpf_t, const ref op1: mpf_t, const ref op2: mpf_t) .. function:: proc mpf_sgn(const ref op: mpf_t) .. function:: proc mpf_out_str(stream: _file, base: c_int, n_digits: size_t, const ref op: mpf_t) .. function:: proc mpf_inp_str(ref rop: mpf_t, stream: _file, base: c_int) .. function:: proc mpf_ceil(ref rop: mpf_t, const ref op: mpf_t) .. function:: proc mpf_floor(ref rop: mpf_t, const ref op: mpf_t) .. function:: proc mpf_trunc(ref rop: mpf_t, const ref op: mpf_t) .. function:: proc mpf_integer_p(const ref op: mpf_t): c_int .. function:: proc mpf_fits_ulong_p(const ref op: mpf_t): c_int .. function:: proc mpf_fits_slong_p(const ref op: mpf_t): c_int .. function:: proc mpf_fits_uint_p(const ref op: mpf_t): c_int .. function:: proc mpf_fits_sint_p(const ref op: mpf_t): c_int .. function:: proc mpf_fits_ushort_p(const ref op: mpf_t): c_int .. function:: proc mpf_fits_sshort_p(const ref op: mpf_t): c_int .. function:: proc mpf_urandomb(ref rop: mpf_t, ref state: gmp_randstate_t, nbits: mp_bitcnt_t) .. function:: proc gmp_randinit_default(ref state: gmp_randstate_t) .. function:: proc gmp_randinit_mt(ref state: gmp_randstate_t) .. function:: proc gmp_randinit_lc_2exp(ref state: gmp_randstate_t, const ref a: mpz_t, c: c_ulong, m2exp: mp_bitcnt_t) .. function:: proc gmp_randinit_lc_2exp_size(ref state: gmp_randstate_t, size: mp_bitcnt_t) .. function:: proc gmp_randinit_set(ref rop: gmp_randstate_t, ref op: gmp_randstate_t) .. function:: proc gmp_randclear(ref state: gmp_randstate_t) .. function:: proc gmp_randseed(ref state: gmp_randstate_t, const ref seed: mpz_t) .. function:: proc gmp_randseed_ui(ref state: gmp_randstate_t, seed: c_ulong) .. function:: proc gmp_urandomb_ui(ref state: gmp_randstate_t, n: c_ulong): c_ulong .. function:: proc gmp_urandomm_ui(ref state: gmp_randstate_t, n: c_ulong): c_ulong .. function:: proc gmp_printf(fmt: c_string, arg ...) .. function:: proc gmp_fprintf(fp: _file, fmt: c_string, arg ...) .. function:: proc gmp_fprintf(fp: _file, fmt: c_string, arg ...) .. function:: proc gmp_asprintf(ref ret: c_string, fmt: c_string, arg ...) .. function:: proc chpl_gmp_get_mpz(ref ret: mpz_t, src_local: int, from: __mpz_struct) Get an MPZ value stored on another locale .. function:: proc chpl_gmp_mpz_print(const ref x: mpz_t) Print out an mpz_t (for debugging) .. function:: 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:: 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 :record:`~BigInteger.bigint` in the module :mod:`BigInteger` 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. .. attribute:: var mpz: mpz_t .. method:: proc BigInt(init2: bool, nbits: uint) .. method:: proc BigInt(num: int) .. method:: proc BigInt(str: string, base: int = 0) .. method:: proc BigInt(str: string, base: int = 0, out error: syserr) .. method:: proc BigInt(num: BigInt) .. method:: proc BigInt() .. method:: proc BigInt.~BigInt() .. method:: proc numLimbs: uint(64) .. method:: proc mpzStruct(): __mpz_struct .. method:: proc maybeCopy(): (bool, BigInt) .. method:: proc set(a: BigInt) .. method:: proc set_ui(num: uint) .. method:: proc set_si(num: int) .. method:: proc set(num: int) .. method:: proc set_d(num: real) .. method:: proc set_str(str: string, base: int = 0) .. method:: proc swap(a: BigInt) .. method:: proc get_ui(): uint .. method:: proc get_si(): int .. method:: proc get_d(): real .. method:: proc get_d_2exp(): (int, real) .. method:: proc get_str(base: int = 10): string .. method:: proc add(a: BigInt, b: BigInt) .. method:: proc add_ui(a: BigInt, b: uint) .. method:: proc sub(a: BigInt, b: BigInt) .. method:: proc sub_ui(a: BigInt, b: uint) .. method:: proc ui_sub(a: uint, b: BigInt) .. method:: proc mul(a: BigInt, b: BigInt) .. method:: proc mul_si(a: BigInt, b: int) .. method:: proc mul_ui(a: BigInt, b: uint) .. method:: proc addmul(a: BigInt, b: BigInt) .. method:: proc addmul_ui(a: BigInt, b: uint) .. method:: proc submul(a: BigInt, b: BigInt) .. method:: proc submul_ui(a: BigInt, b: uint) .. method:: proc mul_2exp(a: BigInt, b: uint) .. method:: proc neg(a: BigInt) .. method:: proc abs(a: BigInt) .. method:: proc div_q(param rounding: Round, n: BigInt, d: BigInt) .. method:: proc div_r(param rounding: Round, n: BigInt, d: BigInt) .. method:: proc div_qr(param rounding: Round, r: BigInt, n: BigInt, d: BigInt) .. method:: proc div_q_ui(param rounding: Round, n: BigInt, d: uint): uint .. method:: proc div_r_ui(param rounding: Round, n: BigInt, d: uint): uint .. method:: proc div_qr_ui(param rounding: Round, r: BigInt, n: BigInt, d: uint): uint .. method:: proc div_ui(param rounding: Round, n: BigInt, d: uint): uint .. method:: proc div_q_2exp(param rounding: Round, n: BigInt, b: uint) .. method:: proc div_r_2exp(param rounding: Round, n: BigInt, b: uint) .. method:: proc mod(n: BigInt, d: BigInt) .. method:: proc mod_ui(n: BigInt, d: uint): uint .. method:: proc divexact(n: BigInt, d: BigInt) .. method:: proc divexact_ui(n: BigInt, d: uint) .. method:: proc divisible_p(d: BigInt): int .. method:: proc divisible_ui_p(d: uint): int .. method:: proc divisible_2exp_p(b: uint): int .. method:: proc congruent_p(c: BigInt, d: BigInt): int .. method:: proc congruent_ui_p(c: uint, d: uint): int .. method:: proc congruent_2exp_p(c: BigInt, b: uint): int .. method:: proc powm(base: BigInt, exp: BigInt, mod: BigInt) .. method:: proc powm_ui(base: BigInt, exp: uint, mod: BigInt) .. method:: proc pow_ui(base: BigInt, exp: uint) .. method:: proc ui_pow_ui(base: uint, exp: uint) .. method:: proc root(a: BigInt, n: uint): int .. method:: proc mpz_rootrem(rem: BigInt, u: BigInt, n: uint) .. method:: proc sqrt(a: BigInt) .. method:: proc sqrtrem(rem: BigInt, a: BigInt) .. method:: proc perfect_power_p(): int .. method:: proc perfect_square(): int .. method:: proc probab_prime_p(reps: int): int .. method:: proc nextprime(a: BigInt) .. method:: proc gcd(a: BigInt, b: BigInt) .. method:: proc gcd_ui(a: BigInt, b: uint) .. method:: proc gcdext(s: BigInt, t: BigInt, a: BigInt, b: BigInt) .. method:: proc lcm(a: BigInt, b: BigInt) .. method:: proc lcm_ui(a: BigInt, b: uint) .. method:: proc invert(a: BigInt, b: BigInt): int .. method:: proc remove(a: BigInt, f: BigInt): uint .. method:: proc fac_ui(a: uint) .. method:: proc bin_ui(n: BigInt, k: uint) .. method:: proc bin_uiui(n: uint, k: uint) .. method:: proc fib_ui(n: uint) .. method:: proc fib2_ui(fnsub1: BigInt, n: uint) .. method:: proc lucnum_ui(n: uint) .. method:: proc lucnum2_ui(lnsub1: BigInt, n: uint) .. method:: proc cmp(b: BigInt): int .. method:: proc cmp_d(b: real): int .. method:: proc cmp_si(b: int): int .. method:: proc cmp_ui(b: uint): int .. method:: proc cmpabs(b: BigInt): int .. method:: proc cmpabs_d(b: real): int .. method:: proc cmp_abs_ui(b: uint): int .. method:: proc sgn(): int .. method:: proc and(a: BigInt, b: BigInt) .. method:: proc ior(a: BigInt, b: BigInt) .. method:: proc xor(a: BigInt, b: BigInt) .. method:: proc com(a: BigInt) .. method:: proc popcount(): uint .. method:: proc hamdist(b: BigInt): uint .. method:: proc scan0(starting_bit: uint): uint .. method:: proc scan1(starting_bit: uint): uint .. method:: proc setbit(bit_index: uint) .. method:: proc clrbit(bit_index: uint) .. method:: proc combit(bit_index: uint) .. method:: proc tstbit(bit_index: uint): int .. method:: proc fits_ulong_p(): int .. method:: proc fits_slong_p(): int .. method:: proc fits_uint_p(): int .. method:: proc fits_sint_p(): int .. method:: proc fits_ushort_p(): int .. method:: proc fits_sshort_p(): int .. method:: proc odd_p(): int .. method:: proc even_p(): int .. method:: proc sizeinbase(base: int): uint .. method:: proc realloc2(nbits: uint) .. method:: proc get_limbn(n: uint): uint .. method:: proc size(): size_t .. method:: proc debugprint() .. method:: proc BigInt.writeThis(writer) .. function:: proc jacobi(a: BigInt, b: BigInt): int .. function:: proc legendre(a: BigInt, p: BigInt): int .. function:: proc kronecker(a: BigInt, b: BigInt): int .. function:: proc kronecker_si(a: BigInt, b: int): int .. function:: proc kronecker_ui(a: BigInt, b: uint): int .. function:: proc si_kronecker(a: int, b: BigInt): int .. function:: proc ui_kronecker(a: uint, b: BigInt): int .. class:: GMPRandom .. attribute:: var state: gmp_randstate_t .. method:: proc GMPRandom() .. method:: proc GMPRandom(twister: bool) .. method:: proc GMPRandom(a: bigint, c: uint, m2exp: uint) .. method:: proc GMPRandom(size: uint) .. method:: proc GMPRandom(a: GMPRandom) .. method:: proc GMPRandom.~GMPRandom() .. method:: proc seed(seed: bigint) .. method:: proc seed(seed: uint) .. method:: proc urandomb(nbits: uint): uint .. method:: proc urandomm(n: uint): uint .. method:: proc urandomb_ui(nbits: uint): uint .. method:: proc urandomm_ui(n: uint): uint .. method:: proc urandomb(ref r: bigint, nbits: uint) .. method:: proc urandomm(ref r: bigint, n: bigint) .. method:: proc rrandomb(ref r: bigint, nbits: uint)