1
1
/* mini-gmp, a minimalistic implementation of a GNU GMP subset.
3
Copyright 2011, 2012, 2013 Free Software Foundation, Inc.
3
Copyright 2011-2014 Free Software Foundation, Inc.
5
5
This file is part of the GNU MP Library.
7
7
The GNU MP Library is free software; you can redistribute it and/or modify
8
it under the terms of the GNU Lesser General Public License as published by
9
the Free Software Foundation; either version 3 of the License, or (at your
10
option) any later version.
8
it under the terms of either:
10
* the GNU Lesser General Public License as published by the Free
11
Software Foundation; either version 3 of the License, or (at your
12
option) any later version.
16
* the GNU General Public License as published by the Free Software
17
Foundation; either version 2 of the License, or (at your option) any
20
or both in parallel, as here.
12
22
The GNU MP Library is distributed in the hope that it will be useful, but
13
23
WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
14
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
15
License for more details.
24
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
17
You should have received a copy of the GNU Lesser General Public License
18
along with the GNU MP Library. If not, see http://www.gnu.org/licenses/. */
27
You should have received copies of the GNU General Public License and the
28
GNU Lesser General Public License along with the GNU MP Library. If not,
29
see https://www.gnu.org/licenses/. */
20
31
/* About mini-gmp: This is a minimal implementation of a subset of the
21
32
GMP interface. It is intended for inclusion into applications which
64
75
typedef __mpz_struct *mpz_ptr;
65
76
typedef const __mpz_struct *mpz_srcptr;
78
extern const int mp_bits_per_limb;
67
80
void mpn_copyi (mp_ptr, mp_srcptr, mp_size_t);
68
81
void mpn_copyd (mp_ptr, mp_srcptr, mp_size_t);
82
void mpn_zero (mp_ptr, mp_size_t);
70
84
int mpn_cmp (mp_srcptr, mp_srcptr, mp_size_t);
84
98
mp_limb_t mpn_mul (mp_ptr, mp_srcptr, mp_size_t, mp_srcptr, mp_size_t);
85
99
void mpn_mul_n (mp_ptr, mp_srcptr, mp_srcptr, mp_size_t);
86
100
void mpn_sqr (mp_ptr, mp_srcptr, mp_size_t);
101
int mpn_perfect_square_p (mp_srcptr, mp_size_t);
102
mp_size_t mpn_sqrtrem (mp_ptr, mp_ptr, mp_srcptr, mp_size_t);
88
104
mp_limb_t mpn_lshift (mp_ptr, mp_srcptr, mp_size_t, unsigned int);
89
105
mp_limb_t mpn_rshift (mp_ptr, mp_srcptr, mp_size_t, unsigned int);
107
mp_bitcnt_t mpn_scan0 (mp_srcptr, mp_bitcnt_t);
108
mp_bitcnt_t mpn_scan1 (mp_srcptr, mp_bitcnt_t);
110
mp_bitcnt_t mpn_popcount (mp_srcptr, mp_size_t);
91
112
mp_limb_t mpn_invert_3by2 (mp_limb_t, mp_limb_t);
92
113
#define mpn_invert_limb(x) mpn_invert_3by2 ((x), 0)
124
145
void mpz_mul_ui (mpz_t, const mpz_t, unsigned long int);
125
146
void mpz_mul (mpz_t, const mpz_t, const mpz_t);
126
147
void mpz_mul_2exp (mpz_t, const mpz_t, mp_bitcnt_t);
148
void mpz_addmul_ui (mpz_t, const mpz_t, unsigned long int);
149
void mpz_addmul (mpz_t, const mpz_t, const mpz_t);
150
void mpz_submul_ui (mpz_t, const mpz_t, unsigned long int);
151
void mpz_submul (mpz_t, const mpz_t, const mpz_t);
128
153
void mpz_cdiv_qr (mpz_t, mpz_t, const mpz_t, const mpz_t);
129
154
void mpz_fdiv_qr (mpz_t, mpz_t, const mpz_t, const mpz_t);
147
172
void mpz_divexact (mpz_t, const mpz_t, const mpz_t);
149
174
int mpz_divisible_p (const mpz_t, const mpz_t);
175
int mpz_congruent_p (const mpz_t, const mpz_t, const mpz_t);
151
177
unsigned long mpz_cdiv_qr_ui (mpz_t, mpz_t, const mpz_t, unsigned long);
152
178
unsigned long mpz_fdiv_qr_ui (mpz_t, mpz_t, const mpz_t, unsigned long);
177
203
void mpz_sqrtrem (mpz_t, mpz_t, const mpz_t);
178
204
void mpz_sqrt (mpz_t, const mpz_t);
205
int mpz_perfect_square_p (const mpz_t);
180
207
void mpz_pow_ui (mpz_t, const mpz_t, unsigned long);
181
208
void mpz_ui_pow_ui (mpz_t, unsigned long, unsigned long);
188
215
void mpz_fac_ui (mpz_t, unsigned long);
189
216
void mpz_bin_uiui (mpz_t, unsigned long, unsigned long);
218
int mpz_probab_prime_p (const mpz_t, int);
191
220
int mpz_tstbit (const mpz_t, mp_bitcnt_t);
192
221
void mpz_setbit (mpz_t, mp_bitcnt_t);
193
222
void mpz_clrbit (mpz_t, mp_bitcnt_t);
211
240
size_t mpz_size (const mpz_t);
212
241
mp_limb_t mpz_getlimbn (const mpz_t, mp_size_t);
243
void mpz_realloc2 (mpz_t, mp_bitcnt_t);
244
mp_srcptr mpz_limbs_read (mpz_srcptr);
245
mp_ptr mpz_limbs_modify (mpz_t, mp_size_t);
246
mp_ptr mpz_limbs_write (mpz_t, mp_size_t);
247
void mpz_limbs_finish (mpz_t, mp_size_t);
248
mpz_srcptr mpz_roinit_n (mpz_t, mp_srcptr, mp_size_t);
250
#define MPZ_ROINIT_N(xp, xs) {{0, (xs),(xp) }}
214
252
void mpz_set_si (mpz_t, signed long int);
215
253
void mpz_set_ui (mpz_t, unsigned long int);
216
254
void mpz_set (mpz_t, const mpz_t);