Annotation of OpenXM_contrib/gmp/gmp.h, Revision 1.1.1.3
1.1 maekawa 1: /* gmp.h -- Definitions for GNU multiple precision functions.
2:
1.1.1.2 maekawa 3: Copyright (C) 1991, 1993, 1994, 1995, 1996, 1997, 1999, 2000 Free Software
4: Foundation, Inc.
1.1 maekawa 5:
6: This file is part of the GNU MP Library.
7:
8: The GNU MP Library is free software; you can redistribute it and/or modify
1.1.1.2 maekawa 9: it under the terms of the GNU Lesser General Public License as published by
10: the Free Software Foundation; either version 2.1 of the License, or (at your
1.1 maekawa 11: option) any later version.
12:
13: The GNU MP Library is distributed in the hope that it will be useful, but
14: WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
1.1.1.2 maekawa 15: or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
1.1 maekawa 16: License for more details.
17:
1.1.1.2 maekawa 18: You should have received a copy of the GNU Lesser General Public License
1.1 maekawa 19: along with the GNU MP Library; see the file COPYING.LIB. If not, write to
20: the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
21: MA 02111-1307, USA. */
22:
23: #ifndef __GMP_H__
24:
1.1.1.2 maekawa 25: #ifndef __GNU_MP__ /* to allow inclusion of both gmp.h and mp.h */
1.1 maekawa 26: #define __GNU_MP__ 2
27: #define __need_size_t
28: #include <stddef.h>
29: #undef __need_size_t
30:
1.1.1.2 maekawa 31: #if defined (__mips) && defined (_ABIN32)
32: /* Force the use of 64-bit limbs for all 64-bit MIPS CPUs if ABI permits. */
33: #define _LONG_LONG_LIMB
34: #endif
35:
36: #if (__STDC__-0) || defined (__cplusplus)
1.1 maekawa 37: #define __gmp_const const
1.1.1.2 maekawa 38: #define __gmp_signed signed
1.1 maekawa 39: #else
40: #define __gmp_const
1.1.1.2 maekawa 41: #define __gmp_signed
1.1 maekawa 42: #endif
43:
44: #if defined (__GNUC__)
45: #define __gmp_inline __inline__
46: #else
47: #define __gmp_inline
48: #endif
49:
50: #ifndef _EXTERN_INLINE
51: #ifdef __GNUC__
52: #define _EXTERN_INLINE extern __inline__
53: #else
54: #define _EXTERN_INLINE static
55: #endif
56: #endif
57:
58: #ifdef _SHORT_LIMB
59: typedef unsigned int mp_limb_t;
60: typedef int mp_limb_signed_t;
61: #else
62: #ifdef _LONG_LONG_LIMB
63: typedef unsigned long long int mp_limb_t;
64: typedef long long int mp_limb_signed_t;
65: #else
66: typedef unsigned long int mp_limb_t;
67: typedef long int mp_limb_signed_t;
68: #endif
69: #endif
70:
71: typedef mp_limb_t * mp_ptr;
72: typedef __gmp_const mp_limb_t * mp_srcptr;
1.1.1.2 maekawa 73: #if defined (_CRAY) && ! defined (_CRAYMPP)
74: /* plain `int' is much faster (48 bits) */
75: typedef int mp_size_t;
76: typedef int mp_exp_t;
77: #else
1.1 maekawa 78: typedef long int mp_size_t;
79: typedef long int mp_exp_t;
1.1.1.2 maekawa 80: #endif
1.1 maekawa 81:
82: typedef struct
83: {
84: int _mp_alloc; /* Number of *limbs* allocated and pointed
1.1.1.2 maekawa 85: to by the _mp_d field. */
86: int _mp_size; /* abs(_mp_size) is the number of limbs the
87: last field points to. If _mp_size is
88: negative this is a negative number. */
1.1 maekawa 89: mp_limb_t *_mp_d; /* Pointer to the limbs. */
90: } __mpz_struct;
91: #endif /* __GNU_MP__ */
92:
93: typedef __mpz_struct MP_INT;
94: typedef __mpz_struct mpz_t[1];
95:
96: typedef struct
97: {
98: __mpz_struct _mp_num;
99: __mpz_struct _mp_den;
100: } __mpq_struct;
101:
102: typedef __mpq_struct MP_RAT;
103: typedef __mpq_struct mpq_t[1];
104:
105: typedef struct
106: {
107: int _mp_prec; /* Max precision, in number of `mp_limb_t's.
108: Set by mpf_init and modified by
1.1.1.2 maekawa 109: mpf_set_prec. The area pointed to by the
110: _mp_d field contains `prec' + 1 limbs. */
111: int _mp_size; /* abs(_mp_size) is the number of limbs the
112: last field points to. If _mp_size is
113: negative this is a negative number. */
1.1 maekawa 114: mp_exp_t _mp_exp; /* Exponent, in the base of `mp_limb_t'. */
115: mp_limb_t *_mp_d; /* Pointer to the limbs. */
116: } __mpf_struct;
117:
118: /* typedef __mpf_struct MP_FLOAT; */
119: typedef __mpf_struct mpf_t[1];
120:
1.1.1.2 maekawa 121: /* Available random number generation algorithms. */
122: typedef enum
123: {
124: GMP_RAND_ALG_DEFAULT = 0,
125: GMP_RAND_ALG_LC = GMP_RAND_ALG_DEFAULT /* Linear congruential. */
126: } gmp_randalg_t;
127:
128: /* Linear congruential data struct. */
129: typedef struct {
130: mpz_t a; /* Multiplier. */
131: unsigned long int c; /* Adder. */
132: mpz_t m; /* Modulus (valid only if m2exp == 0). */
133: unsigned long int m2exp; /* If != 0, modulus is 2 ^ m2exp. */
134: } __gmp_randata_lc;
135:
136: /* Random state struct. */
137: typedef struct
138: {
139: mpz_t seed; /* Current seed. */
140: gmp_randalg_t alg; /* Algorithm used. */
141: union { /* Algorithm specific data. */
142: __gmp_randata_lc *lc; /* Linear congruential. */
143: } algdata;
144: } __gmp_randstate_struct;
145: typedef __gmp_randstate_struct gmp_randstate_t[1];
146:
1.1 maekawa 147: /* Types for function declarations in gmp files. */
148: /* ??? Should not pollute user name space with these ??? */
149: typedef __gmp_const __mpz_struct *mpz_srcptr;
150: typedef __mpz_struct *mpz_ptr;
151: typedef __gmp_const __mpf_struct *mpf_srcptr;
152: typedef __mpf_struct *mpf_ptr;
153: typedef __gmp_const __mpq_struct *mpq_srcptr;
154: typedef __mpq_struct *mpq_ptr;
155:
156: #ifndef _PROTO
1.1.1.2 maekawa 157: #if (__STDC__-0) || defined (__cplusplus)
1.1 maekawa 158: #define _PROTO(x) x
159: #else
160: #define _PROTO(x) ()
161: #endif
162: #endif
163:
164: #ifndef __MPN
1.1.1.2 maekawa 165: /* Really use `defined (__STDC__)' here; we want it to be true for Sun C */
1.1 maekawa 166: #if defined (__STDC__) || defined (__cplusplus)
1.1.1.2 maekawa 167: #define __MPN(x) __gmpn_##x
1.1 maekawa 168: #else
1.1.1.2 maekawa 169: #define __MPN(x) __gmpn_/**/x
1.1 maekawa 170: #endif
171: #endif
172:
173: #if defined (FILE) || defined (H_STDIO) || defined (_H_STDIO) \
174: || defined (_STDIO_H) || defined (_STDIO_H_) || defined (__STDIO_H__) \
1.1.1.2 maekawa 175: || defined (_STDIO_INCLUDED) || defined (__dj_include_stdio_h_)
1.1 maekawa 176: #define _GMP_H_HAVE_FILE 1
177: #endif
178:
1.1.1.2 maekawa 179: #if defined (__cplusplus)
180: extern "C" {
181: #endif
182:
183: #define mp_set_memory_functions __gmp_set_memory_functions
1.1 maekawa 184: void mp_set_memory_functions _PROTO ((void *(*) (size_t),
185: void *(*) (void *, size_t, size_t),
186: void (*) (void *, size_t)));
1.1.1.2 maekawa 187:
188: #define mp_bits_per_limb __gmp_bits_per_limb
1.1 maekawa 189: extern __gmp_const int mp_bits_per_limb;
190:
1.1.1.2 maekawa 191: #if defined (__cplusplus)
192: }
193: #endif
194:
195:
196: /**************** Random number routines. ****************/
197:
198: #define _gmp_rand __gmp_rand
199: #define gmp_randinit __gmp_randinit
200: #define gmp_randinit_lc __gmp_randinit_lc
201: #define gmp_randinit_lc_2exp __gmp_randinit_lc_2exp
202: #define gmp_randseed __gmp_randseed
203: #define gmp_randseed_ui __gmp_randseed_ui
204: #define gmp_randclear __gmp_randclear
205:
206: #if defined (__cplusplus)
207: extern "C" {
208: #endif
209:
210: void _gmp_rand _PROTO ((mp_ptr, gmp_randstate_t, unsigned long int));
211: void gmp_randinit _PROTO ((gmp_randstate_t, gmp_randalg_t, ...));
212: void gmp_randinit_lc _PROTO ((gmp_randstate_t, mpz_t, unsigned long int,
213: mpz_t));
214: void gmp_randinit_lc_2exp _PROTO ((gmp_randstate_t, mpz_t, unsigned long int,
215: unsigned long int));
216: void gmp_randseed _PROTO ((gmp_randstate_t, mpz_t));
217: void gmp_randseed_ui _PROTO ((gmp_randstate_t, unsigned long int));
218: void gmp_randclear _PROTO ((gmp_randstate_t));
219:
220: #if defined (__cplusplus)
221: }
222: #endif
223:
1.1 maekawa 224: /**************** Integer (i.e. Z) routines. ****************/
225:
1.1.1.2 maekawa 226: #define _mpz_realloc __gmpz_realloc
227: #define mpz_realloc __gmpz_realloc
228: #define mpz_abs __gmpz_abs
229: #define mpz_add __gmpz_add
230: #define mpz_add_ui __gmpz_add_ui
231: #define mpz_addmul_ui __gmpz_addmul_ui
232: #define mpz_and __gmpz_and
233: #define mpz_array_init __gmpz_array_init
234: #define mpz_bin_ui __gmpz_bin_ui
235: #define mpz_bin_uiui __gmpz_bin_uiui
236: #define mpz_cdiv_q __gmpz_cdiv_q
237: #define mpz_cdiv_q_ui __gmpz_cdiv_q_ui
238: #define mpz_cdiv_qr __gmpz_cdiv_qr
239: #define mpz_cdiv_qr_ui __gmpz_cdiv_qr_ui
240: #define mpz_cdiv_r __gmpz_cdiv_r
241: #define mpz_cdiv_r_ui __gmpz_cdiv_r_ui
242: #define mpz_cdiv_ui __gmpz_cdiv_ui
243: #define mpz_clear __gmpz_clear
244: #define mpz_clrbit __gmpz_clrbit
245: #define mpz_cmp __gmpz_cmp
246: #define _mpz_cmp_si __gmpz_cmp_si
247: #define _mpz_cmp_ui __gmpz_cmp_ui
248: #define mpz_cmpabs __gmpz_cmpabs
249: #define mpz_cmpabs_ui __gmpz_cmpabs_ui
250: #define mpz_com __gmpz_com
251: #define mpz_divexact __gmpz_divexact
252: #define mpz_dump __gmpz_dump
253: #define mpz_fac_ui __gmpz_fac_ui
254: #define mpz_fdiv_q __gmpz_fdiv_q
255: #define mpz_fdiv_q_2exp __gmpz_fdiv_q_2exp
256: #define mpz_fdiv_q_ui __gmpz_fdiv_q_ui
257: #define mpz_fdiv_qr __gmpz_fdiv_qr
258: #define mpz_fdiv_qr_ui __gmpz_fdiv_qr_ui
259: #define mpz_fdiv_r __gmpz_fdiv_r
260: #define mpz_fdiv_r_2exp __gmpz_fdiv_r_2exp
261: #define mpz_fdiv_r_ui __gmpz_fdiv_r_ui
262: #define mpz_fdiv_ui __gmpz_fdiv_ui
263: #define mpz_fib_ui __gmpz_fib_ui
264: #define mpz_fits_sint_p __gmpz_fits_sint_p
265: #define mpz_fits_slong_p __gmpz_fits_slong_p
266: #define mpz_fits_sshort_p __gmpz_fits_sshort_p
267: #define mpz_fits_uint_p __gmpz_fits_uint_p
268: #define mpz_fits_ulong_p __gmpz_fits_ulong_p
269: #define mpz_fits_ushort_p __gmpz_fits_ushort_p
270: #define mpz_gcd __gmpz_gcd
271: #define mpz_gcd_ui __gmpz_gcd_ui
272: #define mpz_gcdext __gmpz_gcdext
273: #define mpz_get_d __gmpz_get_d
274: #define mpz_get_si __gmpz_get_si
275: #define mpz_get_str __gmpz_get_str
276: #define mpz_get_ui __gmpz_get_ui
277: #define mpz_getlimbn __gmpz_getlimbn
278: #define mpz_hamdist __gmpz_hamdist
279: #define mpz_init __gmpz_init
280: #define mpz_inp_binary __gmpz_inp_binary
281: #define mpz_inp_raw __gmpz_inp_raw
282: #define mpz_inp_str __gmpz_inp_str
283: #define mpz_init_set __gmpz_init_set
284: #define mpz_init_set_d __gmpz_init_set_d
285: #define mpz_init_set_si __gmpz_init_set_si
286: #define mpz_init_set_str __gmpz_init_set_str
287: #define mpz_init_set_ui __gmpz_init_set_ui
288: #define mpz_invert __gmpz_invert
289: #define mpz_ior __gmpz_ior
290: #define mpz_jacobi __gmpz_jacobi
291: #define mpz_lcm __gmpz_lcm
292: #define mpz_legendre __gmpz_legendre
293: #define mpz_mod __gmpz_mod
294: #define mpz_mul __gmpz_mul
295: #define mpz_mul_2exp __gmpz_mul_2exp
296: #define mpz_neg __gmpz_neg
297: #define mpz_nextprime __gmpz_nextprime
298: #define mpz_out_binary __gmpz_out_binary
299: #define mpz_out_raw __gmpz_out_raw
300: #define mpz_out_str __gmpz_out_str
301: #define mpz_perfect_power_p __gmpz_perfect_power_p
302: #define mpz_perfect_square_p __gmpz_perfect_square_p
303: #define mpz_popcount __gmpz_popcount
304: #define mpz_pow_ui __gmpz_pow_ui
305: #define mpz_powm __gmpz_powm
306: #define mpz_powm_ui __gmpz_powm_ui
307: #define mpz_probab_prime_p __gmpz_probab_prime_p
308: #define mpz_random __gmpz_random
309: #define mpz_random2 __gmpz_random2
310: #define mpz_remove __gmpz_remove
311: #define mpz_root __gmpz_root
312: #define mpz_rrandomb __gmpz_rrandomb
313: #define mpz_scan0 __gmpz_scan0
314: #define mpz_scan1 __gmpz_scan1
315: #define mpz_set __gmpz_set
316: #define mpz_set_d __gmpz_set_d
317: #define mpz_set_f __gmpz_set_f
318: #define mpz_set_q __gmpz_set_q
319: #define mpz_set_si __gmpz_set_si
320: #define mpz_set_str __gmpz_set_str
321: #define mpz_set_ui __gmpz_set_ui
322: #define mpz_setbit __gmpz_setbit
323: #define mpz_size __gmpz_size
324: #define mpz_sizeinbase __gmpz_sizeinbase
325: #define mpz_sqrt __gmpz_sqrt
326: #define mpz_sqrtrem __gmpz_sqrtrem
327: #define mpz_sub __gmpz_sub
328: #define mpz_sub_ui __gmpz_sub_ui
329: #define mpz_swap __gmpz_swap
330: #define mpz_tdiv_ui __gmpz_tdiv_ui
331: #define mpz_tdiv_q __gmpz_tdiv_q
332: #define mpz_tdiv_q_2exp __gmpz_tdiv_q_2exp
333: #define mpz_tdiv_q_ui __gmpz_tdiv_q_ui
334: #define mpz_tdiv_qr __gmpz_tdiv_qr
335: #define mpz_tdiv_qr_ui __gmpz_tdiv_qr_ui
336: #define mpz_tdiv_r __gmpz_tdiv_r
337: #define mpz_tdiv_r_2exp __gmpz_tdiv_r_2exp
338: #define mpz_tdiv_r_ui __gmpz_tdiv_r_ui
339: #define mpz_tstbit __gmpz_tstbit
340: #define mpz_ui_pow_ui __gmpz_ui_pow_ui
341: #define mpz_urandomb __gmpz_urandomb
342: #define mpz_urandomm __gmpz_urandomm
343: #define mpz_xor __gmpz_xor
344: #define mpz_eor __gmpz_xor
345:
1.1 maekawa 346: #if defined (__cplusplus)
347: extern "C" {
348: #endif
349: void *_mpz_realloc _PROTO ((mpz_ptr, mp_size_t));
350:
351: void mpz_abs _PROTO ((mpz_ptr, mpz_srcptr));
352: void mpz_add _PROTO ((mpz_ptr, mpz_srcptr, mpz_srcptr));
353: void mpz_add_ui _PROTO ((mpz_ptr, mpz_srcptr, unsigned long int));
1.1.1.2 maekawa 354: void mpz_addmul_ui _PROTO ((mpz_ptr, mpz_srcptr, unsigned long int));
1.1 maekawa 355: void mpz_and _PROTO ((mpz_ptr, mpz_srcptr, mpz_srcptr));
356: void mpz_array_init _PROTO ((mpz_ptr, mp_size_t, mp_size_t));
1.1.1.2 maekawa 357: void mpz_bin_ui _PROTO ((mpz_ptr, mpz_srcptr, unsigned long int));
358: void mpz_bin_uiui _PROTO ((mpz_ptr, unsigned long int, unsigned long int));
1.1 maekawa 359: void mpz_cdiv_q _PROTO ((mpz_ptr, mpz_srcptr, mpz_srcptr));
360: unsigned long int mpz_cdiv_q_ui _PROTO ((mpz_ptr, mpz_srcptr, unsigned long int));
361: void mpz_cdiv_qr _PROTO ((mpz_ptr, mpz_ptr, mpz_srcptr, mpz_srcptr));
362: unsigned long int mpz_cdiv_qr_ui _PROTO ((mpz_ptr, mpz_ptr, mpz_srcptr, unsigned long int));
363: void mpz_cdiv_r _PROTO ((mpz_ptr, mpz_srcptr, mpz_srcptr));
364: unsigned long int mpz_cdiv_r_ui _PROTO ((mpz_ptr, mpz_srcptr, unsigned long int));
365: unsigned long int mpz_cdiv_ui _PROTO ((mpz_srcptr, unsigned long int));
366: void mpz_clear _PROTO ((mpz_ptr));
367: void mpz_clrbit _PROTO ((mpz_ptr, unsigned long int));
368: int mpz_cmp _PROTO ((mpz_srcptr, mpz_srcptr));
1.1.1.2 maekawa 369: int _mpz_cmp_si _PROTO ((mpz_srcptr, signed long int));
370: int _mpz_cmp_ui _PROTO ((mpz_srcptr, unsigned long int));
371: int mpz_cmpabs _PROTO ((mpz_srcptr, mpz_srcptr));
372: int mpz_cmpabs_ui _PROTO ((mpz_srcptr, unsigned long int));
1.1 maekawa 373: void mpz_com _PROTO ((mpz_ptr, mpz_srcptr));
374: void mpz_divexact _PROTO ((mpz_ptr, mpz_srcptr, mpz_srcptr));
1.1.1.2 maekawa 375: void mpz_dump _PROTO ((mpz_srcptr));
1.1 maekawa 376: void mpz_fac_ui _PROTO ((mpz_ptr, unsigned long int));
377: void mpz_fdiv_q _PROTO ((mpz_ptr, mpz_srcptr, mpz_srcptr));
378: void mpz_fdiv_q_2exp _PROTO ((mpz_ptr, mpz_srcptr, unsigned long int));
379: unsigned long int mpz_fdiv_q_ui _PROTO ((mpz_ptr, mpz_srcptr, unsigned long int));
380: void mpz_fdiv_qr _PROTO ((mpz_ptr, mpz_ptr, mpz_srcptr, mpz_srcptr));
381: unsigned long int mpz_fdiv_qr_ui _PROTO ((mpz_ptr, mpz_ptr, mpz_srcptr, unsigned long int));
382: void mpz_fdiv_r _PROTO ((mpz_ptr, mpz_srcptr, mpz_srcptr));
383: void mpz_fdiv_r_2exp _PROTO ((mpz_ptr, mpz_srcptr, unsigned long int));
384: unsigned long int mpz_fdiv_r_ui _PROTO ((mpz_ptr, mpz_srcptr, unsigned long int));
385: unsigned long int mpz_fdiv_ui _PROTO ((mpz_srcptr, unsigned long int));
1.1.1.2 maekawa 386: void mpz_fib_ui _PROTO ((mpz_ptr, unsigned long int));
387: int mpz_fits_sint_p _PROTO ((mpz_srcptr));
388: int mpz_fits_slong_p _PROTO ((mpz_srcptr));
389: int mpz_fits_sshort_p _PROTO ((mpz_srcptr));
390: int mpz_fits_uint_p _PROTO ((mpz_srcptr));
391: int mpz_fits_ulong_p _PROTO ((mpz_srcptr));
392: int mpz_fits_ushort_p _PROTO ((mpz_srcptr));
1.1 maekawa 393: void mpz_gcd _PROTO ((mpz_ptr, mpz_srcptr, mpz_srcptr));
394: unsigned long int mpz_gcd_ui _PROTO ((mpz_ptr, mpz_srcptr, unsigned long int));
395: void mpz_gcdext _PROTO ((mpz_ptr, mpz_ptr, mpz_ptr, mpz_srcptr, mpz_srcptr));
396: double mpz_get_d _PROTO ((mpz_srcptr));
397: /* signed */ long int mpz_get_si _PROTO ((mpz_srcptr));
398: char *mpz_get_str _PROTO ((char *, int, mpz_srcptr));
399: unsigned long int mpz_get_ui _PROTO ((mpz_srcptr));
400: mp_limb_t mpz_getlimbn _PROTO ((mpz_srcptr, mp_size_t));
401: unsigned long int mpz_hamdist _PROTO ((mpz_srcptr, mpz_srcptr));
402: void mpz_init _PROTO ((mpz_ptr));
403: #ifdef _GMP_H_HAVE_FILE
404: size_t mpz_inp_binary _PROTO ((mpz_ptr, FILE *));
405: size_t mpz_inp_raw _PROTO ((mpz_ptr, FILE *));
406: size_t mpz_inp_str _PROTO ((mpz_ptr, FILE *, int));
407: #endif
408: void mpz_init_set _PROTO ((mpz_ptr, mpz_srcptr));
409: void mpz_init_set_d _PROTO ((mpz_ptr, double));
410: void mpz_init_set_si _PROTO ((mpz_ptr, signed long int));
1.1.1.2 maekawa 411: int mpz_init_set_str _PROTO ((mpz_ptr, __gmp_const char *, int));
1.1 maekawa 412: void mpz_init_set_ui _PROTO ((mpz_ptr, unsigned long int));
413: int mpz_invert _PROTO ((mpz_ptr, mpz_srcptr, mpz_srcptr));
414: void mpz_ior _PROTO ((mpz_ptr, mpz_srcptr, mpz_srcptr));
415: int mpz_jacobi _PROTO ((mpz_srcptr, mpz_srcptr));
1.1.1.2 maekawa 416:
417: #define mpz_kronecker_si __gmpz_kronecker_si
418: int mpz_kronecker_si _PROTO ((mpz_srcptr, long));
419:
420: #define mpz_kronecker_ui __gmpz_kronecker_ui
421: int mpz_kronecker_ui _PROTO ((mpz_srcptr, unsigned long));
422:
423: #define mpz_si_kronecker __gmpz_si_kronecker
424: int mpz_si_kronecker _PROTO ((long, mpz_srcptr));
425:
426: #define mpz_ui_kronecker __gmpz_ui_kronecker
427: int mpz_ui_kronecker _PROTO ((unsigned long, mpz_srcptr));
428:
429: void mpz_lcm _PROTO ((mpz_ptr, mpz_srcptr, mpz_srcptr));
1.1 maekawa 430: int mpz_legendre _PROTO ((mpz_srcptr, mpz_srcptr));
431: void mpz_mod _PROTO ((mpz_ptr, mpz_srcptr, mpz_srcptr));
432: void mpz_mul _PROTO ((mpz_ptr, mpz_srcptr, mpz_srcptr));
433: void mpz_mul_2exp _PROTO ((mpz_ptr, mpz_srcptr, unsigned long int));
1.1.1.2 maekawa 434:
435: #define mpz_mul_si __gmpz_mul_si
436: void mpz_mul_si _PROTO ((mpz_ptr, mpz_srcptr, long int));
437:
438: #define mpz_mul_ui __gmpz_mul_ui
1.1 maekawa 439: void mpz_mul_ui _PROTO ((mpz_ptr, mpz_srcptr, unsigned long int));
1.1.1.2 maekawa 440:
1.1 maekawa 441: void mpz_neg _PROTO ((mpz_ptr, mpz_srcptr));
1.1.1.2 maekawa 442: void mpz_nextprime _PROTO ((mpz_ptr, mpz_srcptr));
1.1 maekawa 443: #ifdef _GMP_H_HAVE_FILE
444: size_t mpz_out_binary _PROTO ((FILE *, mpz_srcptr));
445: size_t mpz_out_raw _PROTO ((FILE *, mpz_srcptr));
446: size_t mpz_out_str _PROTO ((FILE *, int, mpz_srcptr));
447: #endif
1.1.1.2 maekawa 448: int mpz_perfect_power_p _PROTO ((mpz_srcptr));
1.1 maekawa 449: int mpz_perfect_square_p _PROTO ((mpz_srcptr));
450: unsigned long int mpz_popcount _PROTO ((mpz_srcptr));
451: void mpz_pow_ui _PROTO ((mpz_ptr, mpz_srcptr, unsigned long int));
452: void mpz_powm _PROTO ((mpz_ptr, mpz_srcptr, mpz_srcptr, mpz_srcptr));
453: void mpz_powm_ui _PROTO ((mpz_ptr, mpz_srcptr, unsigned long int, mpz_srcptr));
454: int mpz_probab_prime_p _PROTO ((mpz_srcptr, int));
455: void mpz_random _PROTO ((mpz_ptr, mp_size_t));
456: void mpz_random2 _PROTO ((mpz_ptr, mp_size_t));
1.1.1.2 maekawa 457: unsigned long int mpz_remove _PROTO ((mpz_ptr, mpz_srcptr, mpz_srcptr));
458: int mpz_root _PROTO ((mpz_ptr, mpz_srcptr, unsigned long int));
459: void mpz_rrandomb _PROTO ((mpz_ptr, gmp_randstate_t, unsigned long int));
1.1 maekawa 460: unsigned long int mpz_scan0 _PROTO ((mpz_srcptr, unsigned long int));
461: unsigned long int mpz_scan1 _PROTO ((mpz_srcptr, unsigned long int));
462: void mpz_set _PROTO ((mpz_ptr, mpz_srcptr));
463: void mpz_set_d _PROTO ((mpz_ptr, double));
464: void mpz_set_f _PROTO ((mpz_ptr, mpf_srcptr));
465: void mpz_set_q _PROTO ((mpz_ptr, mpq_srcptr));
466: void mpz_set_si _PROTO ((mpz_ptr, signed long int));
1.1.1.2 maekawa 467: int mpz_set_str _PROTO ((mpz_ptr, __gmp_const char *, int));
1.1 maekawa 468: void mpz_set_ui _PROTO ((mpz_ptr, unsigned long int));
469: void mpz_setbit _PROTO ((mpz_ptr, unsigned long int));
470: size_t mpz_size _PROTO ((mpz_srcptr));
471: size_t mpz_sizeinbase _PROTO ((mpz_srcptr, int));
472: void mpz_sqrt _PROTO ((mpz_ptr, mpz_srcptr));
473: void mpz_sqrtrem _PROTO ((mpz_ptr, mpz_ptr, mpz_srcptr));
474: void mpz_sub _PROTO ((mpz_ptr, mpz_srcptr, mpz_srcptr));
475: void mpz_sub_ui _PROTO ((mpz_ptr, mpz_srcptr, unsigned long int));
1.1.1.2 maekawa 476: void mpz_swap _PROTO ((mpz_ptr, mpz_ptr));
1.1 maekawa 477: void mpz_tdiv_q _PROTO ((mpz_ptr, mpz_srcptr, mpz_srcptr));
478: void mpz_tdiv_q_2exp _PROTO ((mpz_ptr, mpz_srcptr, unsigned long int));
1.1.1.2 maekawa 479: unsigned long int mpz_tdiv_ui _PROTO ((mpz_srcptr, unsigned long int));
480: unsigned long int mpz_tdiv_q_ui _PROTO ((mpz_ptr, mpz_srcptr, unsigned long int));
1.1 maekawa 481: void mpz_tdiv_qr _PROTO ((mpz_ptr, mpz_ptr, mpz_srcptr, mpz_srcptr));
1.1.1.2 maekawa 482: unsigned long int mpz_tdiv_qr_ui _PROTO ((mpz_ptr, mpz_ptr, mpz_srcptr, unsigned long int));
1.1 maekawa 483: void mpz_tdiv_r _PROTO ((mpz_ptr, mpz_srcptr, mpz_srcptr));
484: void mpz_tdiv_r_2exp _PROTO ((mpz_ptr, mpz_srcptr, unsigned long int));
1.1.1.2 maekawa 485: unsigned long int mpz_tdiv_r_ui _PROTO ((mpz_ptr, mpz_srcptr, unsigned long int));
486: int mpz_tstbit _PROTO ((mpz_srcptr, unsigned long int));
1.1 maekawa 487: void mpz_ui_pow_ui _PROTO ((mpz_ptr, unsigned long int, unsigned long int));
1.1.1.2 maekawa 488: void mpz_urandomb _PROTO ((mpz_t, gmp_randstate_t, unsigned long int));
489: void mpz_urandomm _PROTO ((mpz_t, gmp_randstate_t, mpz_t));
490: void mpz_xor _PROTO ((mpz_ptr, mpz_srcptr, mpz_srcptr));
491: #if defined (__cplusplus)
492: }
493: #endif
1.1 maekawa 494:
495: /**************** Rational (i.e. Q) routines. ****************/
496:
1.1.1.2 maekawa 497: #define mpq_init __gmpq_init
498: #define mpq_clear __gmpq_clear
499: #define mpq_set __gmpq_set
500: #define mpq_set_ui __gmpq_set_ui
501: #define mpq_set_si __gmpq_set_si
502: #define mpq_set_z __gmpq_set_z
503: #define mpq_add __gmpq_add
504: #define mpq_sub __gmpq_sub
505: #define mpq_mul __gmpq_mul
506: #define mpq_div __gmpq_div
507: #define mpq_neg __gmpq_neg
508: #define mpq_cmp __gmpq_cmp
509: #define _mpq_cmp_ui __gmpq_cmp_ui
510: #define mpq_equal __gmpq_equal
511: #define mpq_inv __gmpq_inv
512: #define mpq_set_num __gmpq_set_num
513: #define mpq_set_den __gmpq_set_den
514: #define mpq_get_num __gmpq_get_num
515: #define mpq_get_den __gmpq_get_den
516: #define mpq_get_d __gmpq_get_d
517: #define mpq_set_d __gmpq_set_d
518: #define mpq_canonicalize __gmpq_canonicalize
519:
520: #if defined (__cplusplus)
521: extern "C" {
522: #endif
1.1 maekawa 523: void mpq_init _PROTO ((mpq_ptr));
524: void mpq_clear _PROTO ((mpq_ptr));
525: void mpq_set _PROTO ((mpq_ptr, mpq_srcptr));
526: void mpq_set_ui _PROTO ((mpq_ptr, unsigned long int, unsigned long int));
527: void mpq_set_si _PROTO ((mpq_ptr, signed long int, unsigned long int));
528: void mpq_set_z _PROTO ((mpq_ptr, mpz_srcptr));
529: void mpq_add _PROTO ((mpq_ptr, mpq_srcptr, mpq_srcptr));
530: void mpq_sub _PROTO ((mpq_ptr, mpq_srcptr, mpq_srcptr));
531: void mpq_mul _PROTO ((mpq_ptr, mpq_srcptr, mpq_srcptr));
532: void mpq_div _PROTO ((mpq_ptr, mpq_srcptr, mpq_srcptr));
533: void mpq_neg _PROTO ((mpq_ptr, mpq_srcptr));
534: int mpq_cmp _PROTO ((mpq_srcptr, mpq_srcptr));
1.1.1.2 maekawa 535: int _mpq_cmp_ui _PROTO ((mpq_srcptr, unsigned long int, unsigned long int));
1.1 maekawa 536: int mpq_equal _PROTO ((mpq_srcptr, mpq_srcptr));
537: void mpq_inv _PROTO ((mpq_ptr, mpq_srcptr));
538: void mpq_set_num _PROTO ((mpq_ptr, mpz_srcptr));
539: void mpq_set_den _PROTO ((mpq_ptr, mpz_srcptr));
540: void mpq_get_num _PROTO ((mpz_ptr, mpq_srcptr));
541: void mpq_get_den _PROTO ((mpz_ptr, mpq_srcptr));
542: double mpq_get_d _PROTO ((mpq_srcptr));
1.1.1.2 maekawa 543: void mpq_set_d _PROTO ((mpq_ptr, double));
1.1 maekawa 544: void mpq_canonicalize _PROTO ((mpq_ptr));
545:
1.1.1.2 maekawa 546: #define mpq_swap __gmpq_swap
547: void mpq_swap _PROTO ((mpq_ptr, mpq_ptr));
548:
549: #ifdef _GMP_H_HAVE_FILE
550: #define mpq_out_str __gmpq_out_str
551: size_t mpq_out_str _PROTO ((FILE *, int, mpq_srcptr));
552: #endif
553:
554: #if defined (__cplusplus)
555: }
556: #endif
557:
1.1 maekawa 558: /**************** Float (i.e. F) routines. ****************/
559:
1.1.1.2 maekawa 560: #define mpf_abs __gmpf_abs
561: #define mpf_add __gmpf_add
562: #define mpf_add_ui __gmpf_add_ui
563: #define mpf_ceil __gmpf_ceil
564: #define mpf_clear __gmpf_clear
565: #define mpf_cmp __gmpf_cmp
566: #define mpf_cmp_si __gmpf_cmp_si
567: #define mpf_cmp_ui __gmpf_cmp_ui
568: #define mpf_div __gmpf_div
569: #define mpf_div_2exp __gmpf_div_2exp
570: #define mpf_div_ui __gmpf_div_ui
571: #define mpf_dump __gmpf_dump
572: #define mpf_floor __gmpf_floor
573: #define mpf_eq __gmpf_eq
574: #define mpf_get_d __gmpf_get_d
575: #define mpf_get_prec __gmpf_get_prec
576: #define mpf_get_str __gmpf_get_str
577: #define mpf_init __gmpf_init
578: #define mpf_init2 __gmpf_init2
579: #define mpf_inp_str __gmpf_inp_str
580: #define mpf_init_set __gmpf_init_set
581: #define mpf_init_set_d __gmpf_init_set_d
582: #define mpf_init_set_si __gmpf_init_set_si
583: #define mpf_init_set_str __gmpf_init_set_str
584: #define mpf_init_set_ui __gmpf_init_set_ui
585: #define mpf_mul __gmpf_mul
586: #define mpf_mul_2exp __gmpf_mul_2exp
587: #define mpf_mul_ui __gmpf_mul_ui
588: #define mpf_neg __gmpf_neg
589: #define mpf_out_str __gmpf_out_str
590: #define mpf_pow_ui __gmpf_pow_ui
591: #define mpf_random2 __gmpf_random2
592: #define mpf_reldiff __gmpf_reldiff
593: #define mpf_set __gmpf_set
594: #define mpf_set_d __gmpf_set_d
595: #define mpf_set_default_prec __gmpf_set_default_prec
596: #define mpf_set_prec __gmpf_set_prec
597: #define mpf_set_prec_raw __gmpf_set_prec_raw
598: #define mpf_set_q __gmpf_set_q
599: #define mpf_set_si __gmpf_set_si
600: #define mpf_set_str __gmpf_set_str
601: #define mpf_set_ui __gmpf_set_ui
602: #define mpf_set_z __gmpf_set_z
603: #define mpf_size __gmpf_size
604: #define mpf_sqrt __gmpf_sqrt
605: #define mpf_sqrt_ui __gmpf_sqrt_ui
606: #define mpf_sub __gmpf_sub
607: #define mpf_sub_ui __gmpf_sub_ui
608: #define mpf_trunc __gmpf_trunc
609: #define mpf_ui_div __gmpf_ui_div
610: #define mpf_ui_sub __gmpf_ui_sub
611: #define mpf_urandomb __gmpf_urandomb
612:
613: #if defined (__cplusplus)
614: extern "C" {
615: #endif
1.1 maekawa 616: void mpf_abs _PROTO ((mpf_ptr, mpf_srcptr));
617: void mpf_add _PROTO ((mpf_ptr, mpf_srcptr, mpf_srcptr));
618: void mpf_add_ui _PROTO ((mpf_ptr, mpf_srcptr, unsigned long int));
1.1.1.2 maekawa 619: void mpf_ceil _PROTO ((mpf_ptr, mpf_srcptr));
1.1 maekawa 620: void mpf_clear _PROTO ((mpf_ptr));
621: int mpf_cmp _PROTO ((mpf_srcptr, mpf_srcptr));
622: int mpf_cmp_si _PROTO ((mpf_srcptr, signed long int));
623: int mpf_cmp_ui _PROTO ((mpf_srcptr, unsigned long int));
624: void mpf_div _PROTO ((mpf_ptr, mpf_srcptr, mpf_srcptr));
625: void mpf_div_2exp _PROTO ((mpf_ptr, mpf_srcptr, unsigned long int));
626: void mpf_div_ui _PROTO ((mpf_ptr, mpf_srcptr, unsigned long int));
627: void mpf_dump _PROTO ((mpf_srcptr));
628: int mpf_eq _PROTO ((mpf_srcptr, mpf_srcptr, unsigned long int));
1.1.1.2 maekawa 629: void mpf_floor _PROTO ((mpf_ptr, mpf_srcptr));
1.1 maekawa 630: double mpf_get_d _PROTO ((mpf_srcptr));
631: unsigned long int mpf_get_prec _PROTO ((mpf_srcptr));
632: char *mpf_get_str _PROTO ((char *, mp_exp_t *, int, size_t, mpf_srcptr));
633: void mpf_init _PROTO ((mpf_ptr));
634: void mpf_init2 _PROTO ((mpf_ptr, unsigned long int));
635: #ifdef _GMP_H_HAVE_FILE
636: size_t mpf_inp_str _PROTO ((mpf_ptr, FILE *, int));
637: #endif
638: void mpf_init_set _PROTO ((mpf_ptr, mpf_srcptr));
639: void mpf_init_set_d _PROTO ((mpf_ptr, double));
640: void mpf_init_set_si _PROTO ((mpf_ptr, signed long int));
1.1.1.2 maekawa 641: int mpf_init_set_str _PROTO ((mpf_ptr, __gmp_const char *, int));
1.1 maekawa 642: void mpf_init_set_ui _PROTO ((mpf_ptr, unsigned long int));
643: void mpf_mul _PROTO ((mpf_ptr, mpf_srcptr, mpf_srcptr));
644: void mpf_mul_2exp _PROTO ((mpf_ptr, mpf_srcptr, unsigned long int));
645: void mpf_mul_ui _PROTO ((mpf_ptr, mpf_srcptr, unsigned long int));
646: void mpf_neg _PROTO ((mpf_ptr, mpf_srcptr));
647: #ifdef _GMP_H_HAVE_FILE
648: size_t mpf_out_str _PROTO ((FILE *, int, size_t, mpf_srcptr));
649: #endif
1.1.1.2 maekawa 650: void mpf_pow_ui _PROTO ((mpf_ptr, mpf_srcptr, unsigned long int));
1.1 maekawa 651: void mpf_random2 _PROTO ((mpf_ptr, mp_size_t, mp_exp_t));
652: void mpf_reldiff _PROTO ((mpf_ptr, mpf_srcptr, mpf_srcptr));
653: void mpf_set _PROTO ((mpf_ptr, mpf_srcptr));
654: void mpf_set_d _PROTO ((mpf_ptr, double));
655: void mpf_set_default_prec _PROTO ((unsigned long int));
656: void mpf_set_prec _PROTO ((mpf_ptr, unsigned long int));
657: void mpf_set_prec_raw _PROTO ((mpf_ptr, unsigned long int));
658: void mpf_set_q _PROTO ((mpf_ptr, mpq_srcptr));
659: void mpf_set_si _PROTO ((mpf_ptr, signed long int));
1.1.1.2 maekawa 660: int mpf_set_str _PROTO ((mpf_ptr, __gmp_const char *, int));
1.1 maekawa 661: void mpf_set_ui _PROTO ((mpf_ptr, unsigned long int));
662: void mpf_set_z _PROTO ((mpf_ptr, mpz_srcptr));
663: size_t mpf_size _PROTO ((mpf_srcptr));
664: void mpf_sqrt _PROTO ((mpf_ptr, mpf_srcptr));
665: void mpf_sqrt_ui _PROTO ((mpf_ptr, unsigned long int));
666: void mpf_sub _PROTO ((mpf_ptr, mpf_srcptr, mpf_srcptr));
667: void mpf_sub_ui _PROTO ((mpf_ptr, mpf_srcptr, unsigned long int));
1.1.1.2 maekawa 668: void mpf_trunc _PROTO ((mpf_ptr, mpf_srcptr));
1.1 maekawa 669: void mpf_ui_div _PROTO ((mpf_ptr, unsigned long int, mpf_srcptr));
670: void mpf_ui_sub _PROTO ((mpf_ptr, unsigned long int, mpf_srcptr));
1.1.1.2 maekawa 671: void mpf_urandomb _PROTO ((mpf_t, gmp_randstate_t, unsigned long int));
672:
673: #define mpf_swap __gmpf_swap
674: void mpf_swap _PROTO ((mpf_ptr, mpf_ptr));
675:
1.1 maekawa 676: #if defined (__cplusplus)
677: }
678: #endif
679: /************ Low level positive-integer (i.e. N) routines. ************/
680:
1.1.1.2 maekawa 681: /* This is ugly, but we need to make user calls reach the prefixed function. */
1.1 maekawa 682: #define mpn_add __MPN(add)
683: #define mpn_add_1 __MPN(add_1)
684: #define mpn_add_n __MPN(add_n)
1.1.1.2 maekawa 685: #define mpn_add_nc __MPN(add_nc)
1.1 maekawa 686: #define mpn_addmul_1 __MPN(addmul_1)
1.1.1.2 maekawa 687: #define mpn_addsub_n __MPN(addsub_n)
688: #define mpn_addsub_nc __MPN(addsub_nc)
689: /* #define mpn_and_n __MPN(and_n) */
690: /* #define mpn_andn_n __MPN(andn_n) */
1.1 maekawa 691: #define mpn_bdivmod __MPN(bdivmod)
692: #define mpn_cmp __MPN(cmp)
1.1.1.2 maekawa 693: /* #define mpn_com_n __MPN(com_n) */
694: #define mpn_copyd __MPN(copyd)
695: #define mpn_copyi __MPN(copyi)
1.1 maekawa 696: #define mpn_divrem __MPN(divrem)
697: #define mpn_divrem_1 __MPN(divrem_1)
1.1.1.2 maekawa 698: #define mpn_divrem_2 __MPN(divrem_2)
1.1 maekawa 699: #define mpn_dump __MPN(dump)
700: #define mpn_gcd __MPN(gcd)
701: #define mpn_gcd_1 __MPN(gcd_1)
702: #define mpn_gcdext __MPN(gcdext)
703: #define mpn_get_str __MPN(get_str)
704: #define mpn_hamdist __MPN(hamdist)
1.1.1.2 maekawa 705: #define mpn_invert_limb __MPN(invert_limb)
706: /* #define mpn_ior_n __MPN(ior_n) */
707: /* #define mpn_iorn_n __MPN(iorn_n) */
708: /* #define mpn_kara_mul_n __MPN(kara_mul_n) internal */
709: /* #define mpn_kara_sqr_n __MPN(kara_sqr_n) internal */
1.1 maekawa 710: #define mpn_lshift __MPN(lshift)
1.1.1.2 maekawa 711: #define mpn_lshiftc __MPN(lshiftc)
1.1 maekawa 712: #define mpn_mod_1 __MPN(mod_1)
713: #define mpn_mul __MPN(mul)
714: #define mpn_mul_1 __MPN(mul_1)
1.1.1.2 maekawa 715: #define mpn_mul_basecase __MPN(mul_basecase)
1.1 maekawa 716: #define mpn_mul_n __MPN(mul_n)
717: #define mpn_perfect_square_p __MPN(perfect_square_p)
718: #define mpn_popcount __MPN(popcount)
719: #define mpn_preinv_mod_1 __MPN(preinv_mod_1)
1.1.1.2 maekawa 720: /* #define mpn_nand_n __MPN(nand_n) */
721: /* #define mpn_nior_n __MPN(nior_n) */
722: #define mpn_random __MPN(random)
1.1 maekawa 723: #define mpn_random2 __MPN(random2)
724: #define mpn_rshift __MPN(rshift)
1.1.1.2 maekawa 725: #define mpn_rshiftc __MPN(rshiftc)
1.1 maekawa 726: #define mpn_scan0 __MPN(scan0)
727: #define mpn_scan1 __MPN(scan1)
728: #define mpn_set_str __MPN(set_str)
1.1.1.2 maekawa 729: #define mpn_sqr_basecase __MPN(sqr_basecase)
730: #define mpn_sqr_n __MPN(sqr_n)
1.1 maekawa 731: #define mpn_sqrtrem __MPN(sqrtrem)
732: #define mpn_sub __MPN(sub)
733: #define mpn_sub_1 __MPN(sub_1)
734: #define mpn_sub_n __MPN(sub_n)
1.1.1.2 maekawa 735: #define mpn_sub_nc __MPN(sub_nc)
1.1 maekawa 736: #define mpn_submul_1 __MPN(submul_1)
1.1.1.2 maekawa 737: /* #define mpn_toom3_mul_n __MPN(toom3_mul_n) internal */
738: /* #define mpn_toom3_sqr_n __MPN(toom3_sqr_n) internal */
739: /* #define mpn_xnor_n __MPN(xnor_n) */
740: /* #define mpn_xor_n __MPN(xor_n) */
1.1 maekawa 741:
742: #if defined (__cplusplus)
743: extern "C" {
744: #endif
745: mp_limb_t mpn_add _PROTO ((mp_ptr, mp_srcptr, mp_size_t, mp_srcptr,mp_size_t));
746: mp_limb_t mpn_add_1 _PROTO ((mp_ptr, mp_srcptr, mp_size_t, mp_limb_t));
747: mp_limb_t mpn_add_n _PROTO ((mp_ptr, mp_srcptr, mp_srcptr, mp_size_t));
1.1.1.2 maekawa 748: mp_limb_t mpn_add_nc _PROTO ((mp_ptr, mp_srcptr, mp_srcptr, mp_size_t, mp_limb_t));
749:
1.1 maekawa 750: mp_limb_t mpn_addmul_1 _PROTO ((mp_ptr, mp_srcptr, mp_size_t, mp_limb_t));
1.1.1.2 maekawa 751:
752: #define mpn_addmul_1c __MPN(addmul_1c)
753: mp_limb_t mpn_addmul_1c _PROTO ((mp_ptr, mp_srcptr, mp_size_t, mp_limb_t, mp_limb_t));
754:
755: mp_limb_t mpn_addsub_n _PROTO ((mp_ptr, mp_ptr, mp_srcptr, mp_srcptr, mp_size_t));
1.1 maekawa 756: mp_limb_t mpn_bdivmod _PROTO ((mp_ptr, mp_ptr, mp_size_t, mp_srcptr, mp_size_t, unsigned long int));
757: int mpn_cmp _PROTO ((mp_srcptr, mp_srcptr, mp_size_t));
1.1.1.2 maekawa 758:
759: #define mpn_divexact_by3(dst, src, size) mpn_divexact_by3c (dst, src, size, 0)
760:
761: #define mpn_divexact_by3c __MPN(divexact_by3c)
762: mp_limb_t mpn_divexact_by3c _PROTO ((mp_ptr dst, mp_srcptr src,
763: mp_size_t size, mp_limb_t carry));
764:
765: #define mpn_divmod_1(qp,np,nsize,dlimb) mpn_divrem_1 (qp,0,np,nsize,dlimb)
766:
767: mp_limb_t mpn_divrem _PROTO((mp_ptr, mp_size_t, mp_ptr, mp_size_t, mp_srcptr, mp_size_t));
768:
1.1 maekawa 769: mp_limb_t mpn_divrem_1 _PROTO ((mp_ptr, mp_size_t, mp_srcptr, mp_size_t, mp_limb_t));
1.1.1.2 maekawa 770:
771: #define mpn_divrem_1c __MPN(divrem_1c)
772: mp_limb_t mpn_divrem_1c _PROTO ((mp_ptr, mp_size_t, mp_srcptr, mp_size_t,
773: mp_limb_t, mp_limb_t));
774:
775: mp_limb_t mpn_divrem_2 _PROTO ((mp_ptr, mp_size_t, mp_ptr, mp_size_t, mp_srcptr));
1.1 maekawa 776: void mpn_dump _PROTO ((mp_srcptr, mp_size_t));
777: mp_size_t mpn_gcd _PROTO ((mp_ptr, mp_ptr, mp_size_t, mp_ptr, mp_size_t));
778: mp_limb_t mpn_gcd_1 _PROTO ((mp_srcptr, mp_size_t, mp_limb_t));
1.1.1.2 maekawa 779: mp_size_t mpn_gcdext _PROTO ((mp_ptr, mp_ptr, mp_size_t *, mp_ptr, mp_size_t, mp_ptr, mp_size_t));
1.1 maekawa 780: size_t mpn_get_str _PROTO ((unsigned char *, int, mp_ptr, mp_size_t));
781: unsigned long int mpn_hamdist _PROTO ((mp_srcptr, mp_srcptr, mp_size_t));
1.1.1.2 maekawa 782:
783: #define mpn_jacobi_base __MPN(jacobi_base)
784: int mpn_jacobi_base _PROTO ((mp_limb_t a, mp_limb_t b, int result_bit1));
785:
1.1 maekawa 786: mp_limb_t mpn_lshift _PROTO ((mp_ptr, mp_srcptr, mp_size_t, unsigned int));
787: mp_limb_t mpn_mod_1 _PROTO ((mp_srcptr, mp_size_t, mp_limb_t));
1.1.1.2 maekawa 788:
789: #define mpn_mod_1c __MPN(mod_1c)
790: mp_limb_t mpn_mod_1c _PROTO ((mp_srcptr, mp_size_t, mp_limb_t, mp_limb_t));
791:
792: #define mpn_mod_1_rshift __MPN(mod_1_rshift)
793: mp_limb_t mpn_mod_1_rshift _PROTO ((mp_srcptr, mp_size_t, unsigned,mp_limb_t));
794:
1.1 maekawa 795: mp_limb_t mpn_mul _PROTO ((mp_ptr, mp_srcptr, mp_size_t, mp_srcptr, mp_size_t));
796: mp_limb_t mpn_mul_1 _PROTO ((mp_ptr, mp_srcptr, mp_size_t, mp_limb_t));
1.1.1.2 maekawa 797:
798: #define mpn_mul_1c __MPN(mul_1c)
799: mp_limb_t mpn_mul_1c _PROTO ((mp_ptr, mp_srcptr, mp_size_t, mp_limb_t, mp_limb_t));
800:
801: void mpn_mul_basecase _PROTO ((mp_ptr, mp_srcptr, mp_size_t, mp_srcptr, mp_size_t));
1.1 maekawa 802: void mpn_mul_n _PROTO ((mp_ptr, mp_srcptr, mp_srcptr, mp_size_t));
803: int mpn_perfect_square_p _PROTO ((mp_srcptr, mp_size_t));
804: unsigned long int mpn_popcount _PROTO ((mp_srcptr, mp_size_t));
805: mp_limb_t mpn_preinv_mod_1 _PROTO ((mp_srcptr, mp_size_t, mp_limb_t, mp_limb_t));
1.1.1.2 maekawa 806: void mpn_random _PROTO ((mp_ptr, mp_size_t));
1.1 maekawa 807: void mpn_random2 _PROTO ((mp_ptr, mp_size_t));
808: mp_limb_t mpn_rshift _PROTO ((mp_ptr, mp_srcptr, mp_size_t, unsigned int));
809: unsigned long int mpn_scan0 _PROTO ((mp_srcptr, unsigned long int));
810: unsigned long int mpn_scan1 _PROTO ((mp_srcptr, unsigned long int));
1.1.1.2 maekawa 811: mp_size_t mpn_set_str _PROTO ((mp_ptr, __gmp_const unsigned char *, size_t, int));
812: void mpn_sqr_n _PROTO ((mp_ptr, mp_srcptr, mp_size_t));
813: void mpn_sqr_basecase _PROTO ((mp_ptr, mp_srcptr, mp_size_t));
1.1 maekawa 814: mp_size_t mpn_sqrtrem _PROTO ((mp_ptr, mp_ptr, mp_srcptr, mp_size_t));
815: mp_limb_t mpn_sub _PROTO ((mp_ptr, mp_srcptr, mp_size_t, mp_srcptr,mp_size_t));
816: mp_limb_t mpn_sub_1 _PROTO ((mp_ptr, mp_srcptr, mp_size_t, mp_limb_t));
817: mp_limb_t mpn_sub_n _PROTO ((mp_ptr, mp_srcptr, mp_srcptr, mp_size_t));
1.1.1.2 maekawa 818: mp_limb_t mpn_sub_nc _PROTO ((mp_ptr, mp_srcptr, mp_srcptr, mp_size_t, mp_limb_t));
1.1 maekawa 819: mp_limb_t mpn_submul_1 _PROTO ((mp_ptr, mp_srcptr, mp_size_t, mp_limb_t));
1.1.1.2 maekawa 820:
821: #define mpn_submul_1c __MPN(submul_1c)
822: mp_limb_t mpn_submul_1c _PROTO ((mp_ptr, mp_srcptr, mp_size_t, mp_limb_t, mp_limb_t));
823:
1.1.1.3 ! maekawa 824: #define mpn_tdiv_qr __MPN(tdiv_qr)
! 825: void mpn_tdiv_qr _PROTO ((mp_ptr, mp_ptr, mp_size_t, mp_srcptr, mp_size_t, mp_srcptr, mp_size_t));
! 826:
1.1 maekawa 827: #if defined (__cplusplus)
828: }
829: #endif
830:
1.1.1.2 maekawa 831: #define mpn_incr_u(p,incr) \
832: do { mp_limb_t __x; mp_ptr __p = p; \
833: __x = *__p + incr; \
834: *__p = __x; \
835: if (__x < incr) \
836: while (++(*(++__p)) == 0) \
837: ; \
838: } while (0)
839:
840: #define mpn_decr_u(p,incr) \
841: do { mp_limb_t __x; mp_ptr __p = p; \
842: __x = *__p; \
843: *__p = __x - incr; \
844: if (__x < incr) \
845: while ((*(++__p))-- == 0) \
846: ; \
847: } while (0)
848:
1.1 maekawa 849: #if defined (__GNUC__) || defined (_FORCE_INLINES)
850: _EXTERN_INLINE mp_limb_t
1.1.1.2 maekawa 851: #if (__STDC__-0) || defined (__cplusplus)
1.1 maekawa 852: mpn_add_1 (register mp_ptr res_ptr,
853: register mp_srcptr s1_ptr,
854: register mp_size_t s1_size,
855: register mp_limb_t s2_limb)
856: #else
857: mpn_add_1 (res_ptr, s1_ptr, s1_size, s2_limb)
858: register mp_ptr res_ptr;
859: register mp_srcptr s1_ptr;
860: register mp_size_t s1_size;
861: register mp_limb_t s2_limb;
862: #endif
863: {
864: register mp_limb_t x;
865:
866: x = *s1_ptr++;
867: s2_limb = x + s2_limb;
868: *res_ptr++ = s2_limb;
869: if (s2_limb < x)
870: {
871: while (--s1_size != 0)
872: {
873: x = *s1_ptr++ + 1;
874: *res_ptr++ = x;
875: if (x != 0)
876: goto fin;
877: }
878:
879: return 1;
880: }
881:
882: fin:
883: if (res_ptr != s1_ptr)
884: {
885: mp_size_t i;
886: for (i = 0; i < s1_size - 1; i++)
887: res_ptr[i] = s1_ptr[i];
888: }
889: return 0;
890: }
891:
892: _EXTERN_INLINE mp_limb_t
1.1.1.2 maekawa 893: #if (__STDC__-0) || defined (__cplusplus)
1.1 maekawa 894: mpn_add (register mp_ptr res_ptr,
895: register mp_srcptr s1_ptr,
896: register mp_size_t s1_size,
897: register mp_srcptr s2_ptr,
898: register mp_size_t s2_size)
899: #else
900: mpn_add (res_ptr, s1_ptr, s1_size, s2_ptr, s2_size)
901: register mp_ptr res_ptr;
902: register mp_srcptr s1_ptr;
903: register mp_size_t s1_size;
904: register mp_srcptr s2_ptr;
905: register mp_size_t s2_size;
906: #endif
907: {
908: mp_limb_t cy_limb = 0;
909:
910: if (s2_size != 0)
911: cy_limb = mpn_add_n (res_ptr, s1_ptr, s2_ptr, s2_size);
912:
913: if (s1_size - s2_size != 0)
914: cy_limb = mpn_add_1 (res_ptr + s2_size,
915: s1_ptr + s2_size,
916: s1_size - s2_size,
917: cy_limb);
918: return cy_limb;
919: }
920:
921: _EXTERN_INLINE mp_limb_t
1.1.1.2 maekawa 922: #if (__STDC__-0) || defined (__cplusplus)
1.1 maekawa 923: mpn_sub_1 (register mp_ptr res_ptr,
924: register mp_srcptr s1_ptr,
925: register mp_size_t s1_size,
926: register mp_limb_t s2_limb)
927: #else
928: mpn_sub_1 (res_ptr, s1_ptr, s1_size, s2_limb)
929: register mp_ptr res_ptr;
930: register mp_srcptr s1_ptr;
931: register mp_size_t s1_size;
932: register mp_limb_t s2_limb;
933: #endif
934: {
935: register mp_limb_t x;
936:
937: x = *s1_ptr++;
938: s2_limb = x - s2_limb;
939: *res_ptr++ = s2_limb;
940: if (s2_limb > x)
941: {
942: while (--s1_size != 0)
943: {
944: x = *s1_ptr++;
945: *res_ptr++ = x - 1;
946: if (x != 0)
947: goto fin;
948: }
949:
950: return 1;
951: }
952:
953: fin:
954: if (res_ptr != s1_ptr)
955: {
956: mp_size_t i;
957: for (i = 0; i < s1_size - 1; i++)
958: res_ptr[i] = s1_ptr[i];
959: }
960: return 0;
961: }
962:
963: _EXTERN_INLINE mp_limb_t
1.1.1.2 maekawa 964: #if (__STDC__-0) || defined (__cplusplus)
1.1 maekawa 965: mpn_sub (register mp_ptr res_ptr,
966: register mp_srcptr s1_ptr,
967: register mp_size_t s1_size,
968: register mp_srcptr s2_ptr,
969: register mp_size_t s2_size)
970: #else
971: mpn_sub (res_ptr, s1_ptr, s1_size, s2_ptr, s2_size)
972: register mp_ptr res_ptr;
973: register mp_srcptr s1_ptr;
974: register mp_size_t s1_size;
975: register mp_srcptr s2_ptr;
976: register mp_size_t s2_size;
977: #endif
978: {
979: mp_limb_t cy_limb = 0;
980:
981: if (s2_size != 0)
982: cy_limb = mpn_sub_n (res_ptr, s1_ptr, s2_ptr, s2_size);
983:
984: if (s1_size - s2_size != 0)
985: cy_limb = mpn_sub_1 (res_ptr + s2_size,
986: s1_ptr + s2_size,
987: s1_size - s2_size,
988: cy_limb);
989: return cy_limb;
990: }
991: #endif /* __GNUC__ */
992:
993: /* Allow faster testing for negative, zero, and positive. */
994: #define mpz_sgn(Z) ((Z)->_mp_size < 0 ? -1 : (Z)->_mp_size > 0)
995: #define mpf_sgn(F) ((F)->_mp_size < 0 ? -1 : (F)->_mp_size > 0)
996: #define mpq_sgn(Q) ((Q)->_mp_num._mp_size < 0 ? -1 : (Q)->_mp_num._mp_size > 0)
997:
998: /* When using GCC, optimize certain common comparisons. */
999: #if defined (__GNUC__)
1000: #define mpz_cmp_ui(Z,UI) \
1001: (__builtin_constant_p (UI) && (UI) == 0 \
1.1.1.2 maekawa 1002: ? mpz_sgn (Z) : _mpz_cmp_ui (Z,UI))
1003: #define mpz_cmp_si(Z,SI) \
1004: (__builtin_constant_p (SI) && (SI) == 0 ? mpz_sgn (Z) \
1005: : __builtin_constant_p (SI) && (SI) > 0 \
1006: ? _mpz_cmp_ui (Z, (unsigned long int) SI) \
1007: : _mpz_cmp_si (Z,SI))
1.1 maekawa 1008: #define mpq_cmp_ui(Q,NUI,DUI) \
1009: (__builtin_constant_p (NUI) && (NUI) == 0 \
1.1.1.2 maekawa 1010: ? mpq_sgn (Q) : _mpq_cmp_ui (Q,NUI,DUI))
1011: #else
1012: #define mpz_cmp_ui(Z,UI) _mpz_cmp_ui (Z,UI)
1013: #define mpz_cmp_si(Z,UI) _mpz_cmp_si (Z,UI)
1014: #define mpq_cmp_ui(Q,NUI,DUI) _mpq_cmp_ui (Q,NUI,DUI)
1.1 maekawa 1015: #endif
1016:
1.1.1.2 maekawa 1017:
1018: /* Using "&" rather than "&&" means these can come out branch-free. Every
1019: mpz_t has at least one limb allocated, so fetching the low limb is always
1020: allowed. */
1021: #define mpz_odd_p(z) ((int) ((z)->_mp_size != 0) & (int) (z)->_mp_d[0])
1022: #define mpz_even_p(z) (! mpz_odd_p (z))
1023:
1024:
1025: /* Allow direct user access to numerator and denominator of a mpq_t object. */
1026: #define mpq_numref(Q) (&((Q)->_mp_num))
1027: #define mpq_denref(Q) (&((Q)->_mp_den))
1028:
1029:
1030: /* Compatibility with GMP 2 and earlier. */
1.1 maekawa 1031: #define mpn_divmod(qp,np,nsize,dp,dsize) mpn_divrem (qp,0,np,nsize,dp,dsize)
1032:
1033: /* Compatibility with GMP 1. */
1034: #define mpz_mdiv mpz_fdiv_q
1035: #define mpz_mdivmod mpz_fdiv_qr
1036: #define mpz_mmod mpz_fdiv_r
1037: #define mpz_mdiv_ui mpz_fdiv_q_ui
1038: #define mpz_mdivmod_ui(q,r,n,d) \
1039: ((r == 0) ? mpz_fdiv_q_ui (q,n,d) : mpz_fdiv_qr_ui (q,r,n,d))
1040: #define mpz_mmod_ui(r,n,d) \
1041: ((r == 0) ? mpz_fdiv_ui (n,d) : mpz_fdiv_r_ui (r,n,d))
1042:
1043: /* Useful synonyms, but not quite compatible with GMP 1. */
1044: #define mpz_div mpz_fdiv_q
1045: #define mpz_divmod mpz_fdiv_qr
1046: #define mpz_div_ui mpz_fdiv_q_ui
1047: #define mpz_divmod_ui mpz_fdiv_qr_ui
1048: #define mpz_mod_ui mpz_fdiv_r_ui
1049: #define mpz_div_2exp mpz_fdiv_q_2exp
1050: #define mpz_mod_2exp mpz_fdiv_r_2exp
1051:
1.1.1.2 maekawa 1052: #define gmp_errno __gmp_errno
1053: extern int gmp_errno;
1054:
1055: enum
1056: {
1057: GMP_ERROR_NONE = 0,
1058: GMP_ERROR_UNSUPPORTED_ARGUMENT = 1,
1059: GMP_ERROR_DIVISION_BY_ZERO = 2,
1060: GMP_ERROR_SQRT_OF_NEGATIVE = 4,
1061: GMP_ERROR_INVALID_ARGUMENT = 8,
1062: GMP_ERROR_ALLOCATE = 16,
1063: GMP_ERROR_BAD_STRING = 32,
1064: GMP_ERROR_UNUSED_ERROR
1065: };
1066:
1067: /* Note: major version number is in mp.h too */
1068: #define __GNU_MP_VERSION 3
1069: #define __GNU_MP_VERSION_MINOR 1
1.1.1.3 ! maekawa 1070: #define __GNU_MP_VERSION_PATCHLEVEL 1
1.1.1.2 maekawa 1071:
1072: #define gmp_version __gmp_version
1073: extern __gmp_const char *gmp_version;
1074:
1.1 maekawa 1075: #define __GMP_H__
1076: #endif /* __GMP_H__ */
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>