Back to index

glibc  2.9
gmp.h
Go to the documentation of this file.
00001 /* gmp.h -- Definitions for GNU multiple precision functions.
00002 
00003 Copyright (C) 1991, 1993, 1994, 1995, 1996, 2007 Free Software Foundation, Inc.
00004 
00005 This file is part of the GNU MP Library.
00006 
00007 The GNU MP Library is free software; you can redistribute it and/or modify
00008 it under the terms of the GNU Lesser General Public License as published by
00009 the Free Software Foundation; either version 2.1 of the License, or (at your
00010 option) any later version.
00011 
00012 The GNU MP Library is distributed in the hope that it will be useful, but
00013 WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
00014 or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public
00015 License for more details.
00016 
00017 You should have received a copy of the GNU Lesser General Public License
00018 along with the GNU MP Library; see the file COPYING.LIB.  If not, write to
00019 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
00020 MA 02111-1307, USA. */
00021 
00022 #ifndef __GMP_H__
00023 
00024 #include <features.h>
00025 
00026 #ifndef __GNU_MP__
00027 #define __GNU_MP__ 2
00028 #define __need_size_t
00029 #include <stddef.h>
00030 #undef __need_size_t
00031 
00032 #if defined (__STDC__) || defined (__cplusplus)
00033 #define __gmp_const const
00034 #else
00035 #define __gmp_const
00036 #endif
00037 
00038 #if defined (__GNUC__)
00039 #define __gmp_inline __inline__
00040 #else
00041 #define __gmp_inline
00042 #endif
00043 
00044 #ifndef _EXTERN_INLINE
00045 #ifdef __GNUC__
00046 #define _EXTERN_INLINE __extern_inline
00047 #else
00048 #define _EXTERN_INLINE static
00049 #endif
00050 #endif
00051 
00052 #ifdef _SHORT_LIMB
00053 typedef unsigned int        mp_limb_t;
00054 typedef int                 mp_limb_signed_t;
00055 #else
00056 #ifdef _LONG_LONG_LIMB
00057 typedef unsigned long long int     mp_limb_t;
00058 typedef long long int              mp_limb_signed_t;
00059 #else
00060 typedef unsigned long int   mp_limb_t;
00061 typedef long int            mp_limb_signed_t;
00062 #endif
00063 #endif
00064 
00065 typedef mp_limb_t *         mp_ptr;
00066 typedef __gmp_const mp_limb_t *    mp_srcptr;
00067 typedef long int            mp_size_t;
00068 typedef long int            mp_exp_t;
00069 
00070 #ifndef __MP_SMALL__
00071 typedef struct
00072 {
00073   int _mp_alloc;            /* Number of *limbs* allocated and pointed
00074                                to by the D field.  */
00075   int _mp_size;                    /* abs(SIZE) is the number of limbs
00076                                the last field points to.  If SIZE
00077                                is negative this is a negative
00078                                number.  */
00079   mp_limb_t *_mp_d;         /* Pointer to the limbs.  */
00080 } __mpz_struct;
00081 #else
00082 typedef struct
00083 {
00084   short int _mp_alloc;             /* Number of *limbs* allocated and pointed
00085                                to by the D field.  */
00086   short int _mp_size;              /* abs(SIZE) is the number of limbs
00087                                the last field points to.  If SIZE
00088                                is negative this is a negative
00089                                number.  */
00090   mp_limb_t *_mp_d;         /* Pointer to the limbs.  */
00091 } __mpz_struct;
00092 #endif
00093 #endif /* __GNU_MP__ */
00094 
00095 /* User-visible types.  */
00096 typedef __mpz_struct MP_INT;
00097 typedef __mpz_struct mpz_t[1];
00098 
00099 /* Structure for rational numbers.  Zero is represented as 0/any, i.e.
00100    the denominator is ignored.  Negative numbers have the sign in
00101    the numerator.  */
00102 typedef struct
00103 {
00104   __mpz_struct _mp_num;
00105   __mpz_struct _mp_den;
00106 #if 0
00107   int _mp_num_alloc;        /* Number of limbs allocated
00108                                for the numerator.  */
00109   int _mp_num_size;         /* The absolute value of this field is the
00110                                length of the numerator; the sign is the
00111                                sign of the entire rational number.  */
00112   mp_ptr _mp_num;           /* Pointer to the numerator limbs.  */
00113   int _mp_den_alloc;        /* Number of limbs allocated
00114                                for the denominator.  */
00115   int _mp_den_size;         /* Length of the denominator.  (This field
00116                                should always be positive.) */
00117   mp_ptr _mp_den;           /* Pointer to the denominator limbs.  */
00118 #endif
00119 } __mpq_struct;
00120 
00121 typedef __mpq_struct MP_RAT;
00122 typedef __mpq_struct mpq_t[1];
00123 
00124 typedef struct
00125 {
00126   int _mp_prec;                    /* Max precision, in number of `mp_limb_t's.
00127                                Set by mpf_init and modified by
00128                                mpf_set_prec.  The area pointed to
00129                                by the `d' field contains `prec' + 1
00130                                limbs.  */
00131   int _mp_size;                    /* abs(SIZE) is the number of limbs
00132                                the last field points to.  If SIZE
00133                                is negative this is a negative
00134                                number.  */
00135   mp_exp_t _mp_exp;         /* Exponent, in the base of `mp_limb_t'.  */
00136   mp_limb_t *_mp_d;         /* Pointer to the limbs.  */
00137 } __mpf_struct;
00138 
00139 /* typedef __mpf_struct MP_FLOAT; */
00140 typedef __mpf_struct mpf_t[1];
00141 
00142 /* Types for function declarations in gmp files.  */
00143 /* ??? Should not pollute user name space with these ??? */
00144 typedef __gmp_const __mpz_struct *mpz_srcptr;
00145 typedef __mpz_struct *mpz_ptr;
00146 typedef __gmp_const __mpf_struct *mpf_srcptr;
00147 typedef __mpf_struct *mpf_ptr;
00148 typedef __gmp_const __mpq_struct *mpq_srcptr;
00149 typedef __mpq_struct *mpq_ptr;
00150 
00151 #ifndef _PROTO
00152 #if defined (__STDC__) || defined (__cplusplus)
00153 #define _PROTO(x) x
00154 #else
00155 #define _PROTO(x) ()
00156 #endif
00157 #endif
00158 
00159 #ifndef __MPN
00160 #if defined (__STDC__) || defined (__cplusplus)
00161 #define __MPN(x) __mpn_##x
00162 #else
00163 #define __MPN(x) __mpn_x
00164 #endif
00165 #endif
00166 
00167 #if defined (FILE) || defined (_STDIO_H_) || defined (__STDIO_H__) || defined (H_STDIO)
00168 #define _GMP_H_HAVE_FILE 1
00169 #endif
00170 
00171 void mp_set_memory_functions _PROTO ((void *(*) (size_t),
00172                                   void *(*) (void *, size_t, size_t),
00173                                   void (*) (void *, size_t)));
00174 extern const int mp_bits_per_limb;
00175 
00176 /**************** Integer (i.e. Z) routines.  ****************/
00177 
00178 #if defined (__cplusplus)
00179 extern "C" {
00180 #endif
00181 void *_mpz_realloc _PROTO ((mpz_ptr, mp_size_t));
00182 
00183 void mpz_abs _PROTO ((mpz_ptr, mpz_srcptr));
00184 void mpz_add _PROTO ((mpz_ptr, mpz_srcptr, mpz_srcptr));
00185 void mpz_add_ui _PROTO ((mpz_ptr, mpz_srcptr, unsigned long int));
00186 void mpz_and _PROTO ((mpz_ptr, mpz_srcptr, mpz_srcptr));
00187 void mpz_array_init _PROTO ((mpz_ptr, mp_size_t, mp_size_t));
00188 void mpz_cdiv_q _PROTO ((mpz_ptr, mpz_srcptr, mpz_srcptr));
00189 unsigned long int mpz_cdiv_q_ui _PROTO ((mpz_ptr, mpz_srcptr, unsigned long int));
00190 void mpz_cdiv_qr _PROTO ((mpz_ptr, mpz_ptr, mpz_srcptr, mpz_srcptr));
00191 unsigned long int mpz_cdiv_qr_ui _PROTO ((mpz_ptr, mpz_ptr, mpz_srcptr, unsigned long int));
00192 void mpz_cdiv_r _PROTO ((mpz_ptr, mpz_srcptr, mpz_srcptr));
00193 unsigned long int mpz_cdiv_r_ui _PROTO ((mpz_ptr, mpz_srcptr, unsigned long int));
00194 unsigned long int mpz_cdiv_ui _PROTO ((mpz_srcptr, unsigned long int));
00195 void mpz_clear _PROTO ((mpz_ptr));
00196 void mpz_clrbit _PROTO ((mpz_ptr, unsigned long int));
00197 int mpz_cmp _PROTO ((mpz_srcptr, mpz_srcptr));
00198 int mpz_cmp_si _PROTO ((mpz_srcptr, signed long int));
00199 int mpz_cmp_ui _PROTO ((mpz_srcptr, unsigned long int));
00200 void mpz_com _PROTO ((mpz_ptr, mpz_srcptr));
00201 void mpz_divexact _PROTO ((mpz_ptr, mpz_srcptr, mpz_srcptr));
00202 void mpz_fac_ui _PROTO ((mpz_ptr, unsigned long int));
00203 void mpz_fdiv_q _PROTO ((mpz_ptr, mpz_srcptr, mpz_srcptr));
00204 void mpz_fdiv_q_2exp _PROTO ((mpz_ptr, mpz_srcptr, unsigned long int));
00205 unsigned long int mpz_fdiv_q_ui _PROTO ((mpz_ptr, mpz_srcptr, unsigned long int));
00206 void mpz_fdiv_qr _PROTO ((mpz_ptr, mpz_ptr, mpz_srcptr, mpz_srcptr));
00207 unsigned long int mpz_fdiv_qr_ui _PROTO ((mpz_ptr, mpz_ptr, mpz_srcptr, unsigned long int));
00208 void mpz_fdiv_r _PROTO ((mpz_ptr, mpz_srcptr, mpz_srcptr));
00209 void mpz_fdiv_r_2exp _PROTO ((mpz_ptr, mpz_srcptr, unsigned long int));
00210 unsigned long int mpz_fdiv_r_ui _PROTO ((mpz_ptr, mpz_srcptr, unsigned long int));
00211 unsigned long int mpz_fdiv_ui _PROTO ((mpz_srcptr, unsigned long int));
00212 void mpz_gcd _PROTO ((mpz_ptr, mpz_srcptr, mpz_srcptr));
00213 unsigned long int mpz_gcd_ui _PROTO ((mpz_ptr, mpz_srcptr, unsigned long int));
00214 void mpz_gcdext _PROTO ((mpz_ptr, mpz_ptr, mpz_ptr, mpz_srcptr, mpz_srcptr));
00215 /* signed */ long int mpz_get_si _PROTO ((mpz_srcptr));
00216 char *mpz_get_str _PROTO ((char *, int, mpz_srcptr));
00217 unsigned long int mpz_get_ui _PROTO ((mpz_srcptr));
00218 mp_limb_t mpz_getlimbn _PROTO ((mpz_srcptr, mp_size_t));
00219 unsigned long int mpz_hamdist _PROTO ((mpz_srcptr, mpz_srcptr));
00220 void mpz_init _PROTO ((mpz_ptr));
00221 #ifdef _GMP_H_HAVE_FILE
00222 size_t mpz_inp_binary _PROTO ((mpz_ptr, FILE *));
00223 size_t mpz_inp_raw _PROTO ((mpz_ptr, FILE *));
00224 size_t mpz_inp_str _PROTO ((mpz_ptr, FILE *, int));
00225 #endif
00226 void mpz_init_set _PROTO ((mpz_ptr, mpz_srcptr));
00227 void mpz_init_set_d _PROTO ((mpz_ptr, double));
00228 void mpz_init_set_si _PROTO ((mpz_ptr, signed long int));
00229 int mpz_init_set_str _PROTO ((mpz_ptr, const char *, int));
00230 void mpz_init_set_ui _PROTO ((mpz_ptr, unsigned long int));
00231 int mpz_invert _PROTO ((mpz_ptr, mpz_srcptr, mpz_srcptr));
00232 void mpz_ior _PROTO ((mpz_ptr, mpz_srcptr, mpz_srcptr));
00233 int mpz_jacobi _PROTO ((mpz_srcptr, mpz_srcptr));
00234 int mpz_legendre _PROTO ((mpz_srcptr, mpz_srcptr));
00235 void mpz_mod _PROTO ((mpz_ptr, mpz_srcptr, mpz_srcptr));
00236 void mpz_mul _PROTO ((mpz_ptr, mpz_srcptr, mpz_srcptr));
00237 void mpz_mul_2exp _PROTO ((mpz_ptr, mpz_srcptr, unsigned long int));
00238 void mpz_mul_ui _PROTO ((mpz_ptr, mpz_srcptr, unsigned long int));
00239 void mpz_neg _PROTO ((mpz_ptr, mpz_srcptr));
00240 #ifdef _GMP_H_HAVE_FILE
00241 size_t mpz_out_binary _PROTO ((FILE *, mpz_srcptr));
00242 size_t mpz_out_raw _PROTO ((FILE *, mpz_srcptr));
00243 size_t mpz_out_str _PROTO ((FILE *, int, mpz_srcptr));
00244 #endif
00245 int mpz_perfect_square_p _PROTO ((mpz_srcptr));
00246 unsigned long int mpz_popcount _PROTO ((mpz_srcptr));
00247 void mpz_pow_ui _PROTO ((mpz_ptr, mpz_srcptr, unsigned long int));
00248 void mpz_powm _PROTO ((mpz_ptr, mpz_srcptr, mpz_srcptr, mpz_srcptr));
00249 void mpz_powm_ui _PROTO ((mpz_ptr, mpz_srcptr, unsigned long int, mpz_srcptr));
00250 int mpz_probab_prime_p _PROTO ((mpz_srcptr, int));
00251 void mpz_random _PROTO ((mpz_ptr, mp_size_t));
00252 void mpz_random2 _PROTO ((mpz_ptr, mp_size_t));
00253 unsigned long int mpz_scan0 _PROTO ((mpz_srcptr, unsigned long int));
00254 unsigned long int mpz_scan1 _PROTO ((mpz_srcptr, unsigned long int));
00255 void mpz_set _PROTO ((mpz_ptr, mpz_srcptr));
00256 void mpz_set_d _PROTO ((mpz_ptr, double));
00257 void mpz_set_si _PROTO ((mpz_ptr, signed long int));
00258 int mpz_set_str _PROTO ((mpz_ptr, const char *, int));
00259 void mpz_set_ui _PROTO ((mpz_ptr, unsigned long int));
00260 void mpz_setbit _PROTO ((mpz_ptr, unsigned long int));
00261 size_t mpz_size _PROTO ((mpz_srcptr));
00262 size_t mpz_sizeinbase _PROTO ((mpz_srcptr, int));
00263 void mpz_sqrt _PROTO ((mpz_ptr, mpz_srcptr));
00264 void mpz_sqrtrem _PROTO ((mpz_ptr, mpz_ptr, mpz_srcptr));
00265 void mpz_sub _PROTO ((mpz_ptr, mpz_srcptr, mpz_srcptr));
00266 void mpz_sub_ui _PROTO ((mpz_ptr, mpz_srcptr, unsigned long int));
00267 void mpz_tdiv_q _PROTO ((mpz_ptr, mpz_srcptr, mpz_srcptr));
00268 void mpz_tdiv_q_2exp _PROTO ((mpz_ptr, mpz_srcptr, unsigned long int));
00269 void mpz_tdiv_q_ui _PROTO ((mpz_ptr, mpz_srcptr, unsigned long int));
00270 void mpz_tdiv_qr _PROTO ((mpz_ptr, mpz_ptr, mpz_srcptr, mpz_srcptr));
00271 void mpz_tdiv_qr_ui _PROTO ((mpz_ptr, mpz_ptr, mpz_srcptr, unsigned long int));
00272 void mpz_tdiv_r _PROTO ((mpz_ptr, mpz_srcptr, mpz_srcptr));
00273 void mpz_tdiv_r_2exp _PROTO ((mpz_ptr, mpz_srcptr, unsigned long int));
00274 void mpz_tdiv_r_ui _PROTO ((mpz_ptr, mpz_srcptr, unsigned long int));
00275 void mpz_ui_pow_ui _PROTO ((mpz_ptr, unsigned long int, unsigned long int));
00276 
00277 /**************** Rational (i.e. Q) routines.  ****************/
00278 
00279 void mpq_init _PROTO ((mpq_ptr));
00280 void mpq_clear _PROTO ((mpq_ptr));
00281 void mpq_set _PROTO ((mpq_ptr, mpq_srcptr));
00282 void mpq_set_ui _PROTO ((mpq_ptr, unsigned long int, unsigned long int));
00283 void mpq_set_si _PROTO ((mpq_ptr, signed long int, unsigned long int));
00284 void mpq_add _PROTO ((mpq_ptr, mpq_srcptr, mpq_srcptr));
00285 void mpq_sub _PROTO ((mpq_ptr, mpq_srcptr, mpq_srcptr));
00286 void mpq_mul _PROTO ((mpq_ptr, mpq_srcptr, mpq_srcptr));
00287 void mpq_div _PROTO ((mpq_ptr, mpq_srcptr, mpq_srcptr));
00288 void mpq_neg _PROTO ((mpq_ptr, mpq_srcptr));
00289 int mpq_cmp _PROTO ((mpq_srcptr, mpq_srcptr));
00290 int mpq_cmp_ui _PROTO ((mpq_srcptr, unsigned long int, unsigned long int));
00291 void mpq_inv _PROTO ((mpq_ptr, mpq_srcptr));
00292 void mpq_set_num _PROTO ((mpq_ptr, mpz_srcptr));
00293 void mpq_set_den _PROTO ((mpq_ptr, mpz_srcptr));
00294 void mpq_get_num _PROTO ((mpz_ptr, mpq_srcptr));
00295 void mpq_get_den _PROTO ((mpz_ptr, mpq_srcptr));
00296 double mpq_get_d _PROTO ((mpq_srcptr));
00297 void mpq_canonicalize _PROTO ((mpq_ptr));
00298 
00299 /**************** Float (i.e. F) routines.  ****************/
00300 
00301 void mpf_abs _PROTO ((mpf_ptr, mpf_srcptr));
00302 void mpf_add _PROTO ((mpf_ptr, mpf_srcptr, mpf_srcptr));
00303 void mpf_add_ui _PROTO ((mpf_ptr, mpf_srcptr, unsigned long int));
00304 void mpf_clear _PROTO ((mpf_ptr));
00305 int mpf_cmp _PROTO ((mpf_srcptr, mpf_srcptr));
00306 int mpf_cmp_si _PROTO ((mpf_srcptr, signed long int));
00307 int mpf_cmp_ui _PROTO ((mpf_srcptr, unsigned long int));
00308 void mpf_div _PROTO ((mpf_ptr, mpf_srcptr, mpf_srcptr));
00309 void mpf_div_2exp _PROTO ((mpf_ptr, mpf_srcptr, unsigned long int));
00310 void mpf_div_ui _PROTO ((mpf_ptr, mpf_srcptr, unsigned long int));
00311 void mpf_dump _PROTO ((mpf_srcptr));
00312 int mpf_eq _PROTO ((mpf_srcptr, mpf_srcptr, unsigned long int));
00313 unsigned long int mpf_get_prec _PROTO ((mpf_srcptr));
00314 char *mpf_get_str _PROTO ((char *, mp_exp_t *, int, size_t, mpf_srcptr));
00315 void mpf_init _PROTO ((mpf_ptr));
00316 void mpf_init2 _PROTO ((mpf_ptr, unsigned long int));
00317 #ifdef _GMP_H_HAVE_FILE
00318 size_t mpf_inp_str _PROTO ((mpf_ptr, FILE *, int));
00319 #endif
00320 void mpf_init_set _PROTO ((mpf_ptr, mpf_srcptr));
00321 void mpf_init_set_d _PROTO ((mpf_ptr, double));
00322 void mpf_init_set_si _PROTO ((mpf_ptr, signed long int));
00323 int mpf_init_set_str _PROTO ((mpf_ptr, char *, int));
00324 void mpf_init_set_ui _PROTO ((mpf_ptr, unsigned long int));
00325 void mpf_mul _PROTO ((mpf_ptr, mpf_srcptr, mpf_srcptr));
00326 void mpf_mul_2exp _PROTO ((mpf_ptr, mpf_srcptr, unsigned long int));
00327 void mpf_mul_ui _PROTO ((mpf_ptr, mpf_srcptr, unsigned long int));
00328 void mpf_neg _PROTO ((mpf_ptr, mpf_srcptr));
00329 #ifdef _GMP_H_HAVE_FILE
00330 size_t mpf_out_str _PROTO ((FILE *, int, size_t, mpf_srcptr));
00331 #endif
00332 void mpf_random2 _PROTO ((mpf_ptr, mp_size_t, mp_exp_t));
00333 void mpf_reldiff _PROTO ((mpf_ptr, mpf_srcptr, mpf_srcptr));
00334 void mpf_set _PROTO ((mpf_ptr, mpf_srcptr));
00335 void mpf_set_d _PROTO ((mpf_ptr, double));
00336 void mpf_set_default_prec _PROTO ((unsigned long int));
00337 void mpf_set_prec _PROTO ((mpf_ptr, unsigned long int));
00338 void mpf_set_prec_raw _PROTO ((mpf_ptr, unsigned long int));
00339 void mpf_set_si _PROTO ((mpf_ptr, signed long int));
00340 int mpf_set_str _PROTO ((mpf_ptr, const char *, int));
00341 void mpf_set_ui _PROTO ((mpf_ptr, unsigned long int));
00342 size_t mpf_size _PROTO ((mpf_srcptr));
00343 void mpf_sqrt _PROTO ((mpf_ptr, mpf_srcptr));
00344 void mpf_sqrt_ui _PROTO ((mpf_ptr, unsigned long int));
00345 void mpf_sub _PROTO ((mpf_ptr, mpf_srcptr, mpf_srcptr));
00346 void mpf_sub_ui _PROTO ((mpf_ptr, mpf_srcptr, unsigned long int));
00347 void mpf_ui_div _PROTO ((mpf_ptr, unsigned long int, mpf_srcptr));
00348 void mpf_ui_sub _PROTO ((mpf_ptr, unsigned long int, mpf_srcptr));
00349 #if defined (__cplusplus)
00350 }
00351 #endif
00352 /************ Low level positive-integer (i.e. N) routines.  ************/
00353 
00354 /* This is ugly, but we need to make usr calls reach the prefixed function.  */
00355 #define mpn_add                    __MPN(add)
00356 #define mpn_add_1           __MPN(add_1)
00357 #define mpn_add_n           __MPN(add_n)
00358 #define mpn_addmul_1        __MPN(addmul_1)
00359 #define mpn_bdivmod         __MPN(bdivmod)
00360 #define mpn_cmp                    __MPN(cmp)
00361 #define mpn_divmod_1        __MPN(divmod_1)
00362 #define mpn_divrem          __MPN(divrem)
00363 #define mpn_divrem_1        __MPN(divrem_1)
00364 #define mpn_dump            __MPN(dump)
00365 #define mpn_gcd                    __MPN(gcd)
00366 #define mpn_gcd_1           __MPN(gcd_1)
00367 #define mpn_gcdext          __MPN(gcdext)
00368 #define mpn_get_str         __MPN(get_str)
00369 #define mpn_hamdist         __MPN(hamdist)
00370 #define mpn_lshift          __MPN(lshift)
00371 #define mpn_mod_1           __MPN(mod_1)
00372 #define mpn_mul                    __MPN(mul)
00373 #define mpn_mul_1           __MPN(mul_1)
00374 #define mpn_mul_n           __MPN(mul_n)
00375 #define mpn_perfect_square_p       __MPN(perfect_square_p)
00376 #define mpn_popcount        __MPN(popcount)
00377 #define mpn_preinv_mod_1    __MPN(preinv_mod_1)
00378 #define mpn_random2         __MPN(random2)
00379 #define mpn_rshift          __MPN(rshift)
00380 #define mpn_scan0           __MPN(scan0)
00381 #define mpn_scan1           __MPN(scan1)
00382 #define mpn_set_str         __MPN(set_str)
00383 #define mpn_sqrtrem         __MPN(sqrtrem)
00384 #define mpn_sub                    __MPN(sub)
00385 #define mpn_sub_1           __MPN(sub_1)
00386 #define mpn_sub_n           __MPN(sub_n)
00387 #define mpn_submul_1        __MPN(submul_1)
00388 #define mpn_udiv_w_sdiv            __MPN(udiv_w_sdiv)
00389 
00390 #if defined (__cplusplus)
00391 extern "C" {
00392 #endif
00393 mp_limb_t mpn_add _PROTO ((mp_ptr, mp_srcptr, mp_size_t, mp_srcptr,mp_size_t));
00394 mp_limb_t mpn_add_1 _PROTO ((mp_ptr, mp_srcptr, mp_size_t, mp_limb_t));
00395 mp_limb_t mpn_add_n _PROTO ((mp_ptr, mp_srcptr, mp_srcptr, mp_size_t));
00396 mp_limb_t mpn_addmul_1 _PROTO ((mp_ptr, mp_srcptr, mp_size_t, mp_limb_t));
00397 mp_limb_t mpn_bdivmod _PROTO ((mp_ptr, mp_ptr, mp_size_t, mp_srcptr, mp_size_t, unsigned long int));
00398 int mpn_cmp _PROTO ((mp_srcptr, mp_srcptr, mp_size_t));
00399 mp_limb_t mpn_divmod_1 _PROTO ((mp_ptr, mp_srcptr, mp_size_t, mp_limb_t));
00400 mp_limb_t mpn_divrem _PROTO ((mp_ptr, mp_size_t, mp_ptr, mp_size_t, mp_srcptr, mp_size_t));
00401 mp_limb_t mpn_divrem_1 _PROTO ((mp_ptr, mp_size_t, mp_srcptr, mp_size_t, mp_limb_t));
00402 void mpn_dump _PROTO ((mp_srcptr, mp_size_t));
00403 mp_size_t mpn_gcd _PROTO ((mp_ptr, mp_ptr, mp_size_t, mp_ptr, mp_size_t));
00404 mp_limb_t mpn_gcd_1 _PROTO ((mp_srcptr, mp_size_t, mp_limb_t));
00405 mp_size_t mpn_gcdext _PROTO ((mp_ptr, mp_ptr, mp_ptr, mp_size_t, mp_ptr, mp_size_t));
00406 size_t mpn_get_str _PROTO ((unsigned char *, int, mp_ptr, mp_size_t));
00407 unsigned long int mpn_hamdist _PROTO ((mp_srcptr, mp_srcptr, mp_size_t));
00408 mp_limb_t mpn_lshift _PROTO ((mp_ptr, mp_srcptr, mp_size_t, unsigned int));
00409 mp_limb_t mpn_mod_1 _PROTO ((mp_srcptr, mp_size_t, mp_limb_t));
00410 mp_limb_t mpn_mul _PROTO ((mp_ptr, mp_srcptr, mp_size_t, mp_srcptr, mp_size_t));
00411 mp_limb_t mpn_mul_1 _PROTO ((mp_ptr, mp_srcptr, mp_size_t, mp_limb_t));
00412 void mpn_mul_n _PROTO ((mp_ptr, mp_srcptr, mp_srcptr, mp_size_t));
00413 int mpn_perfect_square_p _PROTO ((mp_srcptr, mp_size_t));
00414 unsigned long int mpn_popcount _PROTO ((mp_srcptr, mp_size_t));
00415 mp_limb_t mpn_preinv_mod_1 _PROTO ((mp_srcptr, mp_size_t, mp_limb_t, mp_limb_t));
00416 void mpn_random2 _PROTO ((mp_ptr, mp_size_t));
00417 mp_limb_t mpn_rshift _PROTO ((mp_ptr, mp_srcptr, mp_size_t, unsigned int));
00418 unsigned long int mpn_scan0 _PROTO ((mp_srcptr, unsigned long int));
00419 unsigned long int mpn_scan1 _PROTO ((mp_srcptr, unsigned long int));
00420 mp_size_t mpn_set_str _PROTO ((mp_ptr, const unsigned char *, size_t, int));
00421 mp_size_t mpn_sqrtrem _PROTO ((mp_ptr, mp_ptr, mp_srcptr, mp_size_t));
00422 mp_limb_t mpn_sub _PROTO ((mp_ptr, mp_srcptr, mp_size_t, mp_srcptr,mp_size_t));
00423 mp_limb_t mpn_sub_1 _PROTO ((mp_ptr, mp_srcptr, mp_size_t, mp_limb_t));
00424 mp_limb_t mpn_sub_n _PROTO ((mp_ptr, mp_srcptr, mp_srcptr, mp_size_t));
00425 mp_limb_t mpn_submul_1 _PROTO ((mp_ptr, mp_srcptr, mp_size_t, mp_limb_t));
00426 #if defined (__cplusplus)
00427 }
00428 #endif
00429 
00430 #if defined (__GNUC__) || defined (_FORCE_INLINES)
00431 _EXTERN_INLINE mp_limb_t
00432 #if defined (__STDC__) || defined (__cplusplus)
00433 mpn_add_1 (register mp_ptr res_ptr,
00434           register mp_srcptr s1_ptr,
00435           register mp_size_t s1_size,
00436           register mp_limb_t s2_limb)
00437 #else
00438 mpn_add_1 (res_ptr, s1_ptr, s1_size, s2_limb)
00439      register mp_ptr res_ptr;
00440      register mp_srcptr s1_ptr;
00441      register mp_size_t s1_size;
00442      register mp_limb_t s2_limb;
00443 #endif
00444 {
00445   register mp_limb_t x;
00446 
00447   x = *s1_ptr++;
00448   s2_limb = x + s2_limb;
00449   *res_ptr++ = s2_limb;
00450   if (s2_limb < x)
00451     {
00452       while (--s1_size != 0)
00453        {
00454          x = *s1_ptr++ + 1;
00455          *res_ptr++ = x;
00456          if (x != 0)
00457            goto fin;
00458        }
00459 
00460       return 1;
00461     }
00462 
00463  fin:
00464   if (res_ptr != s1_ptr)
00465     {
00466       mp_size_t i;
00467       for (i = 0; i < s1_size - 1; i++)
00468        res_ptr[i] = s1_ptr[i];
00469     }
00470   return 0;
00471 }
00472 
00473 _EXTERN_INLINE mp_limb_t
00474 #if defined (__STDC__) || defined (__cplusplus)
00475 mpn_add (register mp_ptr res_ptr,
00476         register mp_srcptr s1_ptr,
00477         register mp_size_t s1_size,
00478         register mp_srcptr s2_ptr,
00479         register mp_size_t s2_size)
00480 #else
00481 mpn_add (res_ptr, s1_ptr, s1_size, s2_ptr, s2_size)
00482      register mp_ptr res_ptr;
00483      register mp_srcptr s1_ptr;
00484      register mp_size_t s1_size;
00485      register mp_srcptr s2_ptr;
00486      register mp_size_t s2_size;
00487 #endif
00488 {
00489   mp_limb_t cy_limb = 0;
00490 
00491   if (s2_size != 0)
00492     cy_limb = mpn_add_n (res_ptr, s1_ptr, s2_ptr, s2_size);
00493 
00494   if (s1_size - s2_size != 0)
00495     cy_limb = mpn_add_1 (res_ptr + s2_size,
00496                       s1_ptr + s2_size,
00497                       s1_size - s2_size,
00498                       cy_limb);
00499   return cy_limb;
00500 }
00501 
00502 _EXTERN_INLINE mp_limb_t
00503 #if defined (__STDC__) || defined (__cplusplus)
00504 mpn_sub_1 (register mp_ptr res_ptr,
00505           register mp_srcptr s1_ptr,
00506           register mp_size_t s1_size,
00507           register mp_limb_t s2_limb)
00508 #else
00509 mpn_sub_1 (res_ptr, s1_ptr, s1_size, s2_limb)
00510      register mp_ptr res_ptr;
00511      register mp_srcptr s1_ptr;
00512      register mp_size_t s1_size;
00513      register mp_limb_t s2_limb;
00514 #endif
00515 {
00516   register mp_limb_t x;
00517 
00518   x = *s1_ptr++;
00519   s2_limb = x - s2_limb;
00520   *res_ptr++ = s2_limb;
00521   if (s2_limb > x)
00522     {
00523       while (--s1_size != 0)
00524        {
00525          x = *s1_ptr++;
00526          *res_ptr++ = x - 1;
00527          if (x != 0)
00528            goto fin;
00529        }
00530 
00531       return 1;
00532     }
00533 
00534  fin:
00535   if (res_ptr != s1_ptr)
00536     {
00537       mp_size_t i;
00538       for (i = 0; i < s1_size - 1; i++)
00539        res_ptr[i] = s1_ptr[i];
00540     }
00541   return 0;
00542 }
00543 
00544 _EXTERN_INLINE mp_limb_t
00545 #if defined (__STDC__) || defined (__cplusplus)
00546 mpn_sub (register mp_ptr res_ptr,
00547         register mp_srcptr s1_ptr,
00548         register mp_size_t s1_size,
00549         register mp_srcptr s2_ptr,
00550         register mp_size_t s2_size)
00551 #else
00552 mpn_sub (res_ptr, s1_ptr, s1_size, s2_ptr, s2_size)
00553      register mp_ptr res_ptr;
00554      register mp_srcptr s1_ptr;
00555      register mp_size_t s1_size;
00556      register mp_srcptr s2_ptr;
00557      register mp_size_t s2_size;
00558 #endif
00559 {
00560   mp_limb_t cy_limb = 0;
00561 
00562   if (s2_size != 0)
00563     cy_limb = mpn_sub_n (res_ptr, s1_ptr, s2_ptr, s2_size);
00564 
00565   if (s1_size - s2_size != 0)
00566     cy_limb = mpn_sub_1 (res_ptr + s2_size,
00567                       s1_ptr + s2_size,
00568                       s1_size - s2_size,
00569                       cy_limb);
00570   return cy_limb;
00571 }
00572 #endif /* __GNUC__ */
00573 
00574 /* Allow faster testing for negative, zero, and positive.  */
00575 #define mpz_sgn(Z) ((Z)->_mp_size < 0 ? -1 : (Z)->_mp_size > 0)
00576 #define mpf_sgn(F) ((F)->_mp_size < 0 ? -1 : (F)->_mp_size > 0)
00577 #define mpq_sgn(Q) ((Q)->_mp_num._mp_size < 0 ? -1 : (Q)->_mp_num._mp_size > 0)
00578 
00579 /* Allow direct user access to numerator and denominator of a mpq_t object.  */
00580 #define mpq_numref(Q) (&((Q)->_mp_num))
00581 #define mpq_denref(Q) (&((Q)->_mp_den))
00582 
00583 /* When using GCC, optimize certain common comparisons.  */
00584 #if defined (__GNUC__)
00585 #define mpz_cmp_ui(Z,UI) \
00586   (__builtin_constant_p (UI) && (UI) == 0                      \
00587    ? mpz_sgn (Z) : mpz_cmp_ui (Z,UI))
00588 #define mpz_cmp_si(Z,UI) \
00589   (__builtin_constant_p (UI) && (UI) == 0 ? mpz_sgn (Z)               \
00590    : __builtin_constant_p (UI) && (UI) > 0 ? mpz_cmp_ui (Z,UI)        \
00591    : mpz_cmp_si (Z,UI))
00592 #define mpq_cmp_ui(Q,NUI,DUI) \
00593   (__builtin_constant_p (NUI) && (NUI) == 0                           \
00594    ? mpq_sgn (Q) : mpq_cmp_ui (Q,NUI,DUI))
00595 #endif
00596 
00597 #define mpn_divmod(qp,np,nsize,dp,dsize) mpn_divrem (qp,0,np,nsize,dp,dsize)
00598 #if 0
00599 #define mpn_divmod_1(qp,np,nsize,dlimb) mpn_divrem_1 (qp,0,np,nsize,dlimb)
00600 #endif
00601 
00602 /* Compatibility with GMP 1.  */
00603 #define mpz_mdiv     mpz_fdiv_q
00604 #define mpz_mdivmod  mpz_fdiv_qr
00605 #define mpz_mmod     mpz_fdiv_r
00606 #define mpz_mdiv_ui  mpz_fdiv_q_ui
00607 #define mpz_mdivmod_ui(q,r,n,d) \
00608   ((r == 0) ? mpz_fdiv_q_ui (q,n,d) : mpz_fdiv_qr_ui (q,r,n,d))
00609 #define mpz_mmod_ui(r,n,d) \
00610   ((r == 0) ? mpz_fdiv_ui (n,d) : mpz_fdiv_r_ui (r,n,d))
00611 
00612 /* Useful synonyms, but not quite compatible with GMP 1.  */
00613 #define mpz_div             mpz_fdiv_q
00614 #define mpz_divmod   mpz_fdiv_qr
00615 #define mpz_div_ui   mpz_fdiv_q_ui
00616 #define mpz_divmod_ui       mpz_fdiv_qr_ui
00617 #define mpz_mod_ui   mpz_fdiv_r_ui
00618 #define mpz_div_2exp mpz_fdiv_q_2exp
00619 #define mpz_mod_2exp mpz_fdiv_r_2exp
00620 
00621 #define __GNU_MP_VERSION 2
00622 #define __GNU_MP_VERSION_MINOR 0
00623 #define __GMP_H__
00624 #endif /* __GMP_H__ */