Warning: That file was not part of the compilation database. It may have many parsing errors.
1 | /* mpfr.h -- Include file for mpfr. |
---|---|
2 | |
3 | Copyright 1999-2018 Free Software Foundation, Inc. |
4 | Contributed by the AriC and Caramba projects, INRIA. |
5 | |
6 | This file is part of the GNU MPFR Library. |
7 | |
8 | The GNU MPFR Library is free software; you can redistribute it and/or modify |
9 | it under the terms of the GNU Lesser General Public License as published by |
10 | the Free Software Foundation; either version 3 of the License, or (at your |
11 | option) any later version. |
12 | |
13 | The GNU MPFR Library is distributed in the hope that it will be useful, but |
14 | WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY |
15 | or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public |
16 | License for more details. |
17 | |
18 | You should have received a copy of the GNU Lesser General Public License |
19 | along with the GNU MPFR Library; see the file COPYING.LESSER. If not, see |
20 | http://www.gnu.org/licenses/ or write to the Free Software Foundation, Inc., |
21 | 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. */ |
22 | |
23 | #ifndef __MPFR_H |
24 | #define __MPFR_H |
25 | |
26 | /* Define MPFR version number */ |
27 | #define MPFR_VERSION_MAJOR 4 |
28 | #define MPFR_VERSION_MINOR 0 |
29 | #define MPFR_VERSION_PATCHLEVEL 1 |
30 | #define MPFR_VERSION_STRING "4.0.1" |
31 | |
32 | /* User macros: |
33 | MPFR_USE_FILE: Define it to make MPFR define functions dealing |
34 | with FILE* (auto-detect). |
35 | MPFR_USE_INTMAX_T: Define it to make MPFR define functions dealing |
36 | with intmax_t (auto-detect). |
37 | MPFR_USE_VA_LIST: Define it to make MPFR define functions dealing |
38 | with va_list (auto-detect). |
39 | MPFR_USE_C99_FEATURE: Define it to 1 to make MPFR support C99-feature |
40 | (auto-detect), to 0 to bypass the detection. |
41 | MPFR_USE_EXTENSION: Define it to make MPFR use GCC extension to |
42 | reduce warnings. |
43 | MPFR_USE_NO_MACRO: Define it to make MPFR remove any overriding |
44 | function macro. |
45 | */ |
46 | |
47 | /* Macros dealing with MPFR VERSION */ |
48 | #define MPFR_VERSION_NUM(a,b,c) (((a) << 16L) | ((b) << 8) | (c)) |
49 | #define MPFR_VERSION \ |
50 | MPFR_VERSION_NUM(MPFR_VERSION_MAJOR,MPFR_VERSION_MINOR,MPFR_VERSION_PATCHLEVEL) |
51 | |
52 | #include <gmp.h> |
53 | |
54 | /* Avoid some problems with macro expansion if the user defines macros |
55 | with the same name as keywords. By convention, identifiers and macro |
56 | names starting with mpfr_ are reserved by MPFR. */ |
57 | typedef void mpfr_void; |
58 | typedef int mpfr_int; |
59 | typedef unsigned int mpfr_uint; |
60 | typedef long mpfr_long; |
61 | typedef unsigned long mpfr_ulong; |
62 | typedef size_t mpfr_size_t; |
63 | |
64 | /* Global (possibly TLS) flags. Might also be used in an mpfr_t in the |
65 | future (there would be room as mpfr_sign_t just needs 1 byte). |
66 | TODO: The tests currently assume that the flags fits in an unsigned int; |
67 | this should be cleaned up, e.g. by defining a function that outputs the |
68 | flags as a string or by using the flags_out function (from tests/tests.c |
69 | directly). */ |
70 | typedef unsigned int mpfr_flags_t; |
71 | |
72 | /* Flags macros (in the public API) */ |
73 | #define MPFR_FLAGS_UNDERFLOW 1 |
74 | #define MPFR_FLAGS_OVERFLOW 2 |
75 | #define MPFR_FLAGS_NAN 4 |
76 | #define MPFR_FLAGS_INEXACT 8 |
77 | #define MPFR_FLAGS_ERANGE 16 |
78 | #define MPFR_FLAGS_DIVBY0 32 |
79 | #define MPFR_FLAGS_ALL (MPFR_FLAGS_UNDERFLOW | \ |
80 | MPFR_FLAGS_OVERFLOW | \ |
81 | MPFR_FLAGS_NAN | \ |
82 | MPFR_FLAGS_INEXACT | \ |
83 | MPFR_FLAGS_ERANGE | \ |
84 | MPFR_FLAGS_DIVBY0) |
85 | |
86 | /* Definition of rounding modes (DON'T USE MPFR_RNDNA!). |
87 | Warning! Changing the contents of this enum should be seen as an |
88 | interface change since the old and the new types are not compatible |
89 | (the integer type compatible with the enumerated type can even change, |
90 | see ISO C99, 6.7.2.2#4), and in Makefile.am, AGE should be set to 0. |
91 | |
92 | MPFR_RNDU must appear just before MPFR_RNDD (see |
93 | MPFR_IS_RNDUTEST_OR_RNDDNOTTEST in mpfr-impl.h). |
94 | |
95 | If you change the order of the rounding modes, please update the routines |
96 | in texceptions.c which assume 0=RNDN, 1=RNDZ, 2=RNDU, 3=RNDD, 4=RNDA. |
97 | */ |
98 | typedef enum { |
99 | MPFR_RNDN=0, /* round to nearest, with ties to even */ |
100 | MPFR_RNDZ, /* round toward zero */ |
101 | MPFR_RNDU, /* round toward +Inf */ |
102 | MPFR_RNDD, /* round toward -Inf */ |
103 | MPFR_RNDA, /* round away from zero */ |
104 | MPFR_RNDF, /* faithful rounding */ |
105 | MPFR_RNDNA=-1 /* round to nearest, with ties away from zero (mpfr_round) */ |
106 | } mpfr_rnd_t; |
107 | |
108 | /* kept for compatibility with MPFR 2.4.x and before */ |
109 | #define GMP_RNDN MPFR_RNDN |
110 | #define GMP_RNDZ MPFR_RNDZ |
111 | #define GMP_RNDU MPFR_RNDU |
112 | #define GMP_RNDD MPFR_RNDD |
113 | |
114 | /* Note: With the following default choices for _MPFR_PREC_FORMAT and |
115 | _MPFR_EXP_FORMAT, mpfr_exp_t will be the same as [mp_exp_t] (at least |
116 | up to GMP 5). */ |
117 | |
118 | /* Define precision: 1 (short), 2 (int) or 3 (long) (DON'T USE IT!) */ |
119 | #ifndef _MPFR_PREC_FORMAT |
120 | # if __GMP_MP_SIZE_T_INT |
121 | # define _MPFR_PREC_FORMAT 2 |
122 | # else |
123 | # define _MPFR_PREC_FORMAT 3 |
124 | # endif |
125 | #endif |
126 | |
127 | /* Define exponent: 1 (short), 2 (int), 3 (long) or 4 (intmax_t) |
128 | (DON'T USE IT!) */ |
129 | #ifndef _MPFR_EXP_FORMAT |
130 | # define _MPFR_EXP_FORMAT _MPFR_PREC_FORMAT |
131 | #endif |
132 | |
133 | #if _MPFR_PREC_FORMAT > _MPFR_EXP_FORMAT |
134 | # error "mpfr_prec_t must not be larger than mpfr_exp_t" |
135 | #endif |
136 | |
137 | /* Let's make mpfr_prec_t signed in order to avoid problems due to the |
138 | usual arithmetic conversions when mixing mpfr_prec_t and mpfr_exp_t |
139 | in an expression (for error analysis) if casts are forgotten. */ |
140 | #if _MPFR_PREC_FORMAT == 1 |
141 | typedef short mpfr_prec_t; |
142 | typedef unsigned short mpfr_uprec_t; |
143 | #elif _MPFR_PREC_FORMAT == 2 |
144 | typedef int mpfr_prec_t; |
145 | typedef unsigned int mpfr_uprec_t; |
146 | #elif _MPFR_PREC_FORMAT == 3 |
147 | typedef long mpfr_prec_t; |
148 | typedef unsigned long mpfr_uprec_t; |
149 | #else |
150 | # error "Invalid MPFR Prec format" |
151 | #endif |
152 | |
153 | /* Definition of precision limits without needing <limits.h> */ |
154 | /* Note: The casts allows the expression to yield the wanted behavior |
155 | for _MPFR_PREC_FORMAT == 1 (due to integer promotion rules). We |
156 | also make sure that MPFR_PREC_MIN and MPFR_PREC_MAX have a signed |
157 | integer type. The "- 256" allows more security, avoiding some |
158 | integer overflows in extreme cases; ideally it should be useless. */ |
159 | #define MPFR_PREC_MIN 1 |
160 | #define MPFR_PREC_MAX ((mpfr_prec_t) ((((mpfr_uprec_t) -1) >> 1) - 256)) |
161 | |
162 | /* Definition of sign */ |
163 | typedef int mpfr_sign_t; |
164 | |
165 | /* Definition of the exponent. _MPFR_EXP_FORMAT must be large enough |
166 | so that mpfr_exp_t has at least 32 bits. */ |
167 | #if _MPFR_EXP_FORMAT == 1 |
168 | typedef short mpfr_exp_t; |
169 | typedef unsigned short mpfr_uexp_t; |
170 | #elif _MPFR_EXP_FORMAT == 2 |
171 | typedef int mpfr_exp_t; |
172 | typedef unsigned int mpfr_uexp_t; |
173 | #elif _MPFR_EXP_FORMAT == 3 |
174 | typedef long mpfr_exp_t; |
175 | typedef unsigned long mpfr_uexp_t; |
176 | #elif _MPFR_EXP_FORMAT == 4 |
177 | /* Note: in this case, intmax_t and uintmax_t must be defined before |
178 | the inclusion of mpfr.h (we do not include <stdint.h> here because |
179 | of some non-ISO C99 implementations that support these types). */ |
180 | typedef intmax_t mpfr_exp_t; |
181 | typedef uintmax_t mpfr_uexp_t; |
182 | #else |
183 | # error "Invalid MPFR Exp format" |
184 | #endif |
185 | |
186 | /* Definition of the standard exponent limits */ |
187 | #define MPFR_EMAX_DEFAULT ((mpfr_exp_t) (((mpfr_ulong) 1 << 30) - 1)) |
188 | #define MPFR_EMIN_DEFAULT (-(MPFR_EMAX_DEFAULT)) |
189 | |
190 | /* DON'T USE THIS! (For MPFR-public macros only, see below.) |
191 | The mpfr_sgn macro uses the fact that __MPFR_EXP_NAN and __MPFR_EXP_ZERO |
192 | are the smallest values. For a n-bit type, EXP_MAX is 2^(n-1)-1, |
193 | EXP_ZERO is 1-2^(n-1), EXP_NAN is 2-2^(n-1), EXP_INF is 3-2^(n-1). |
194 | This may change in the future. MPFR code should not be based on these |
195 | representations (but if this is absolutely needed, protect the code |
196 | with a static assertion). */ |
197 | #define __MPFR_EXP_MAX ((mpfr_exp_t) (((mpfr_uexp_t) -1) >> 1)) |
198 | #define __MPFR_EXP_NAN (1 - __MPFR_EXP_MAX) |
199 | #define __MPFR_EXP_ZERO (0 - __MPFR_EXP_MAX) |
200 | #define __MPFR_EXP_INF (2 - __MPFR_EXP_MAX) |
201 | |
202 | /* Definition of the main structure */ |
203 | typedef struct { |
204 | mpfr_prec_t _mpfr_prec; |
205 | mpfr_sign_t _mpfr_sign; |
206 | mpfr_exp_t _mpfr_exp; |
207 | mp_limb_t *_mpfr_d; |
208 | } __mpfr_struct; |
209 | |
210 | /* Compatibility with previous types of MPFR */ |
211 | #ifndef mp_rnd_t |
212 | # define mp_rnd_t mpfr_rnd_t |
213 | #endif |
214 | #ifndef mp_prec_t |
215 | # define mp_prec_t mpfr_prec_t |
216 | #endif |
217 | |
218 | /* |
219 | The represented number is |
220 | _sign*(_d[k-1]/B+_d[k-2]/B^2+...+_d[0]/B^k)*2^_exp |
221 | where k=ceil(_mp_prec/GMP_NUMB_BITS) and B=2^GMP_NUMB_BITS. |
222 | |
223 | For the msb (most significant bit) normalized representation, we must have |
224 | _d[k-1]>=B/2, unless the number is singular. |
225 | |
226 | We must also have the last k*GMP_NUMB_BITS-_prec bits set to zero. |
227 | */ |
228 | |
229 | typedef __mpfr_struct mpfr_t[1]; |
230 | typedef __mpfr_struct *mpfr_ptr; |
231 | typedef const __mpfr_struct *mpfr_srcptr; |
232 | |
233 | /* For those who need a direct and fast access to the sign field. |
234 | However it is not in the API, thus use it at your own risk: it might |
235 | not be supported, or change name, in further versions! |
236 | Unfortunately, it must be defined here (instead of MPFR's internal |
237 | header file mpfr-impl.h) because it is used by some macros below. |
238 | */ |
239 | #define MPFR_SIGN(x) ((x)->_mpfr_sign) |
240 | |
241 | /* Stack interface */ |
242 | typedef enum { |
243 | MPFR_NAN_KIND = 0, |
244 | MPFR_INF_KIND = 1, |
245 | MPFR_ZERO_KIND = 2, |
246 | MPFR_REGULAR_KIND = 3 |
247 | } mpfr_kind_t; |
248 | |
249 | /* Free cache policy */ |
250 | typedef enum { |
251 | MPFR_FREE_LOCAL_CACHE = 1, /* 1 << 0 */ |
252 | MPFR_FREE_GLOBAL_CACHE = 2 /* 1 << 1 */ |
253 | } mpfr_free_cache_t; |
254 | |
255 | /* GMP defines: |
256 | + size_t: Standard size_t |
257 | + __GMP_NOTHROW For C++: can't throw . |
258 | + __GMP_EXTERN_INLINE Attribute for inline function. |
259 | + __GMP_DECLSPEC_EXPORT compiling to go into a DLL |
260 | + __GMP_DECLSPEC_IMPORT compiling to go into a application |
261 | */ |
262 | /* Extra MPFR defines */ |
263 | #define __MPFR_SENTINEL_ATTR |
264 | #if defined (__GNUC__) |
265 | # if __GNUC__ >= 4 |
266 | # undef __MPFR_SENTINEL_ATTR |
267 | # define __MPFR_SENTINEL_ATTR __attribute__ ((sentinel)) |
268 | # endif |
269 | #endif |
270 | |
271 | /* If the user hasn't requested his/her preference |
272 | and if the intension of support by the compiler is C99 |
273 | and if the compiler is known to support the C99 feature |
274 | then we can auto-detect the C99 support as OK. |
275 | __GNUC__ is used to detect GNU-C, ICC & CLANG compilers. |
276 | Currently we need only variadic macros, and they are present |
277 | since GCC >= 3. We don't test library version since we don't |
278 | use any feature present in the library too (except intmax_t, |
279 | but they use another detection).*/ |
280 | #ifndef MPFR_USE_C99_FEATURE |
281 | # if defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L) |
282 | # if defined (__GNUC__) |
283 | # if __GNUC__ >= 3 |
284 | # define MPFR_USE_C99_FEATURE 1 |
285 | # endif |
286 | # endif |
287 | # endif |
288 | # ifndef MPFR_USE_C99_FEATURE |
289 | # define MPFR_USE_C99_FEATURE 0 |
290 | # endif |
291 | #endif |
292 | |
293 | /* Support for WINDOWS Dll: |
294 | Check if we are inside a MPFR build, and if so export the functions. |
295 | Otherwise does the same thing as GMP */ |
296 | #if defined(__MPFR_WITHIN_MPFR) && __GMP_LIBGMP_DLL |
297 | # define __MPFR_DECLSPEC __GMP_DECLSPEC_EXPORT |
298 | #else |
299 | # ifndef __GMP_DECLSPEC |
300 | # define __GMP_DECLSPEC |
301 | # endif |
302 | # define __MPFR_DECLSPEC __GMP_DECLSPEC |
303 | #endif |
304 | |
305 | /* Use MPFR_DEPRECATED to mark MPFR functions, types or variables as |
306 | deprecated. Code inspired by Apache Subversion's svn_types.h file. |
307 | For compatibility with MSVC, MPFR_DEPRECATED must be put before |
308 | __MPFR_DECLSPEC (not at the end of the function declaration as |
309 | documented in the GCC manual); GCC does not seem to care. |
310 | Moreover, in order to avoid a warning when testing such functions, |
311 | do something like: |
312 | +------------------------------------------ |
313 | |#ifndef _MPFR_NO_DEPRECATED_funcname |
314 | |MPFR_DEPRECATED |
315 | |#endif |
316 | |__MPFR_DECLSPEC int mpfr_funcname (...); |
317 | +------------------------------------------ |
318 | and in the corresponding test program: |
319 | +------------------------------------------ |
320 | |#define _MPFR_NO_DEPRECATED_funcname |
321 | |#include "mpfr-test.h" |
322 | +------------------------------------------ |
323 | */ |
324 | #if defined(__GNUC__) && \ |
325 | (__GNUC__ >= 4 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 1)) |
326 | # define MPFR_DEPRECATED __attribute__ ((deprecated)) |
327 | #elif defined(_MSC_VER) && _MSC_VER >= 1300 |
328 | # define MPFR_DEPRECATED __declspec(deprecated) |
329 | #else |
330 | # define MPFR_DEPRECATED |
331 | #endif |
332 | /* TODO: Also define MPFR_EXPERIMENTAL for experimental functions? |
333 | See SVN_EXPERIMENTAL in Subversion 1.9+ as an example: |
334 | __attribute__((warning("..."))) can be used with GCC 4.3.1+ but |
335 | not __llvm__, and __declspec(deprecated("...")) can be used with |
336 | MSC as above. */ |
337 | |
338 | /* Note: In order to be declared, some functions need a specific |
339 | system header to be included *before* "mpfr.h". If the user |
340 | forgets to include the header, the MPFR function prototype in |
341 | the user object file is not correct. To avoid wrong results, |
342 | we raise a linker error in that case by changing their internal |
343 | name in the library (prefixed by __gmpfr instead of mpfr). See |
344 | the lines of the form "#define mpfr_xxx __gmpfr_xxx" below. */ |
345 | |
346 | #if defined (__cplusplus) |
347 | extern "C"{ |
348 | #endif |
349 | |
350 | __MPFR_DECLSPEC const char * mpfr_get_version (void); |
351 | __MPFR_DECLSPEC const char * mpfr_get_patches (void); |
352 | __MPFR_DECLSPEC int mpfr_buildopt_tls_p (void); |
353 | __MPFR_DECLSPEC int mpfr_buildopt_float128_p (void); |
354 | __MPFR_DECLSPEC int mpfr_buildopt_decimal_p (void); |
355 | __MPFR_DECLSPEC int mpfr_buildopt_gmpinternals_p (void); |
356 | __MPFR_DECLSPEC int mpfr_buildopt_sharedcache_p (void); |
357 | __MPFR_DECLSPEC const char * mpfr_buildopt_tune_case (void); |
358 | |
359 | __MPFR_DECLSPEC mpfr_exp_t mpfr_get_emin (void); |
360 | __MPFR_DECLSPEC int mpfr_set_emin (mpfr_exp_t); |
361 | __MPFR_DECLSPEC mpfr_exp_t mpfr_get_emin_min (void); |
362 | __MPFR_DECLSPEC mpfr_exp_t mpfr_get_emin_max (void); |
363 | __MPFR_DECLSPEC mpfr_exp_t mpfr_get_emax (void); |
364 | __MPFR_DECLSPEC int mpfr_set_emax (mpfr_exp_t); |
365 | __MPFR_DECLSPEC mpfr_exp_t mpfr_get_emax_min (void); |
366 | __MPFR_DECLSPEC mpfr_exp_t mpfr_get_emax_max (void); |
367 | |
368 | __MPFR_DECLSPEC void mpfr_set_default_rounding_mode (mpfr_rnd_t); |
369 | __MPFR_DECLSPEC mpfr_rnd_t mpfr_get_default_rounding_mode (void); |
370 | __MPFR_DECLSPEC const char * mpfr_print_rnd_mode (mpfr_rnd_t); |
371 | |
372 | __MPFR_DECLSPEC void mpfr_clear_flags (void); |
373 | __MPFR_DECLSPEC void mpfr_clear_underflow (void); |
374 | __MPFR_DECLSPEC void mpfr_clear_overflow (void); |
375 | __MPFR_DECLSPEC void mpfr_clear_divby0 (void); |
376 | __MPFR_DECLSPEC void mpfr_clear_nanflag (void); |
377 | __MPFR_DECLSPEC void mpfr_clear_inexflag (void); |
378 | __MPFR_DECLSPEC void mpfr_clear_erangeflag (void); |
379 | |
380 | __MPFR_DECLSPEC void mpfr_set_underflow (void); |
381 | __MPFR_DECLSPEC void mpfr_set_overflow (void); |
382 | __MPFR_DECLSPEC void mpfr_set_divby0 (void); |
383 | __MPFR_DECLSPEC void mpfr_set_nanflag (void); |
384 | __MPFR_DECLSPEC void mpfr_set_inexflag (void); |
385 | __MPFR_DECLSPEC void mpfr_set_erangeflag (void); |
386 | |
387 | __MPFR_DECLSPEC int mpfr_underflow_p (void); |
388 | __MPFR_DECLSPEC int mpfr_overflow_p (void); |
389 | __MPFR_DECLSPEC int mpfr_divby0_p (void); |
390 | __MPFR_DECLSPEC int mpfr_nanflag_p (void); |
391 | __MPFR_DECLSPEC int mpfr_inexflag_p (void); |
392 | __MPFR_DECLSPEC int mpfr_erangeflag_p (void); |
393 | |
394 | __MPFR_DECLSPEC void mpfr_flags_clear (mpfr_flags_t); |
395 | __MPFR_DECLSPEC void mpfr_flags_set (mpfr_flags_t); |
396 | __MPFR_DECLSPEC mpfr_flags_t mpfr_flags_test (mpfr_flags_t); |
397 | __MPFR_DECLSPEC mpfr_flags_t mpfr_flags_save (void); |
398 | __MPFR_DECLSPEC void mpfr_flags_restore (mpfr_flags_t, |
399 | mpfr_flags_t); |
400 | |
401 | __MPFR_DECLSPEC int mpfr_check_range (mpfr_ptr, int, mpfr_rnd_t); |
402 | |
403 | __MPFR_DECLSPEC void mpfr_init2 (mpfr_ptr, mpfr_prec_t); |
404 | __MPFR_DECLSPEC void mpfr_init (mpfr_ptr); |
405 | __MPFR_DECLSPEC void mpfr_clear (mpfr_ptr); |
406 | |
407 | __MPFR_DECLSPEC void |
408 | mpfr_inits2 (mpfr_prec_t, mpfr_ptr, ...) __MPFR_SENTINEL_ATTR; |
409 | __MPFR_DECLSPEC void |
410 | mpfr_inits (mpfr_ptr, ...) __MPFR_SENTINEL_ATTR; |
411 | __MPFR_DECLSPEC void |
412 | mpfr_clears (mpfr_ptr, ...) __MPFR_SENTINEL_ATTR; |
413 | |
414 | __MPFR_DECLSPEC int mpfr_prec_round (mpfr_ptr, mpfr_prec_t, mpfr_rnd_t); |
415 | __MPFR_DECLSPEC int mpfr_can_round (mpfr_srcptr, mpfr_exp_t, mpfr_rnd_t, |
416 | mpfr_rnd_t, mpfr_prec_t); |
417 | __MPFR_DECLSPEC mpfr_prec_t mpfr_min_prec (mpfr_srcptr); |
418 | |
419 | __MPFR_DECLSPEC mpfr_exp_t mpfr_get_exp (mpfr_srcptr); |
420 | __MPFR_DECLSPEC int mpfr_set_exp (mpfr_ptr, mpfr_exp_t); |
421 | __MPFR_DECLSPEC mpfr_prec_t mpfr_get_prec (mpfr_srcptr); |
422 | __MPFR_DECLSPEC void mpfr_set_prec (mpfr_ptr, mpfr_prec_t); |
423 | __MPFR_DECLSPEC void mpfr_set_prec_raw (mpfr_ptr, mpfr_prec_t); |
424 | __MPFR_DECLSPEC void mpfr_set_default_prec (mpfr_prec_t); |
425 | __MPFR_DECLSPEC mpfr_prec_t mpfr_get_default_prec (void); |
426 | |
427 | __MPFR_DECLSPEC int mpfr_set_d (mpfr_ptr, double, mpfr_rnd_t); |
428 | __MPFR_DECLSPEC int mpfr_set_flt (mpfr_ptr, float, mpfr_rnd_t); |
429 | #ifdef MPFR_WANT_DECIMAL_FLOATS |
430 | /* _Decimal64 is not defined in C++, |
431 | cf https://gcc.gnu.org/bugzilla/show_bug.cgi?id=51364 */ |
432 | __MPFR_DECLSPEC int mpfr_set_decimal64 (mpfr_ptr, _Decimal64, mpfr_rnd_t); |
433 | #endif |
434 | __MPFR_DECLSPEC int mpfr_set_ld (mpfr_ptr, long double, mpfr_rnd_t); |
435 | #ifdef MPFR_WANT_FLOAT128 |
436 | __MPFR_DECLSPEC int mpfr_set_float128 (mpfr_ptr, __float128, mpfr_rnd_t); |
437 | __MPFR_DECLSPEC __float128 mpfr_get_float128 (mpfr_srcptr, mpfr_rnd_t); |
438 | #endif |
439 | __MPFR_DECLSPEC int mpfr_set_z (mpfr_ptr, mpz_srcptr, mpfr_rnd_t); |
440 | __MPFR_DECLSPEC int mpfr_set_z_2exp (mpfr_ptr, mpz_srcptr, mpfr_exp_t, |
441 | mpfr_rnd_t); |
442 | __MPFR_DECLSPEC void mpfr_set_nan (mpfr_ptr); |
443 | __MPFR_DECLSPEC void mpfr_set_inf (mpfr_ptr, int); |
444 | __MPFR_DECLSPEC void mpfr_set_zero (mpfr_ptr, int); |
445 | |
446 | #ifndef MPFR_USE_MINI_GMP |
447 | /* mini-gmp does not provide mpf_t, we disable the following functions */ |
448 | __MPFR_DECLSPEC int mpfr_set_f (mpfr_ptr, mpf_srcptr, mpfr_rnd_t); |
449 | __MPFR_DECLSPEC int mpfr_cmp_f (mpfr_srcptr, mpf_srcptr); |
450 | __MPFR_DECLSPEC int mpfr_get_f (mpf_ptr, mpfr_srcptr, mpfr_rnd_t); |
451 | #endif |
452 | __MPFR_DECLSPEC int mpfr_set_si (mpfr_ptr, long, mpfr_rnd_t); |
453 | __MPFR_DECLSPEC int mpfr_set_ui (mpfr_ptr, unsigned long, mpfr_rnd_t); |
454 | __MPFR_DECLSPEC int mpfr_set_si_2exp (mpfr_ptr, long, mpfr_exp_t, mpfr_rnd_t); |
455 | __MPFR_DECLSPEC int mpfr_set_ui_2exp (mpfr_ptr, unsigned long, mpfr_exp_t, |
456 | mpfr_rnd_t); |
457 | #ifndef MPFR_USE_MINI_GMP |
458 | /* mini-gmp does not provide mpq_t, we disable the following functions */ |
459 | __MPFR_DECLSPEC int mpfr_set_q (mpfr_ptr, mpq_srcptr, mpfr_rnd_t); |
460 | __MPFR_DECLSPEC int mpfr_mul_q (mpfr_ptr, mpfr_srcptr, mpq_srcptr, mpfr_rnd_t); |
461 | __MPFR_DECLSPEC int mpfr_div_q (mpfr_ptr, mpfr_srcptr, mpq_srcptr, mpfr_rnd_t); |
462 | __MPFR_DECLSPEC int mpfr_add_q (mpfr_ptr, mpfr_srcptr, mpq_srcptr, mpfr_rnd_t); |
463 | __MPFR_DECLSPEC int mpfr_sub_q (mpfr_ptr, mpfr_srcptr, mpq_srcptr, mpfr_rnd_t); |
464 | __MPFR_DECLSPEC int mpfr_cmp_q (mpfr_srcptr, mpq_srcptr); |
465 | __MPFR_DECLSPEC void mpfr_get_q (mpq_ptr q, mpfr_srcptr f); |
466 | #endif |
467 | __MPFR_DECLSPEC int mpfr_set_str (mpfr_ptr, const char *, int, mpfr_rnd_t); |
468 | __MPFR_DECLSPEC int mpfr_init_set_str (mpfr_ptr, const char *, int, |
469 | mpfr_rnd_t); |
470 | __MPFR_DECLSPEC int mpfr_set4 (mpfr_ptr, mpfr_srcptr, mpfr_rnd_t, int); |
471 | __MPFR_DECLSPEC int mpfr_abs (mpfr_ptr, mpfr_srcptr, mpfr_rnd_t); |
472 | __MPFR_DECLSPEC int mpfr_set (mpfr_ptr, mpfr_srcptr, mpfr_rnd_t); |
473 | __MPFR_DECLSPEC int mpfr_neg (mpfr_ptr, mpfr_srcptr, mpfr_rnd_t); |
474 | __MPFR_DECLSPEC int mpfr_signbit (mpfr_srcptr); |
475 | __MPFR_DECLSPEC int mpfr_setsign (mpfr_ptr, mpfr_srcptr, int, mpfr_rnd_t); |
476 | __MPFR_DECLSPEC int mpfr_copysign (mpfr_ptr, mpfr_srcptr, mpfr_srcptr, |
477 | mpfr_rnd_t); |
478 | |
479 | __MPFR_DECLSPEC mpfr_exp_t mpfr_get_z_2exp (mpz_ptr, mpfr_srcptr); |
480 | __MPFR_DECLSPEC float mpfr_get_flt (mpfr_srcptr, mpfr_rnd_t); |
481 | __MPFR_DECLSPEC double mpfr_get_d (mpfr_srcptr, mpfr_rnd_t); |
482 | #ifdef MPFR_WANT_DECIMAL_FLOATS |
483 | __MPFR_DECLSPEC _Decimal64 mpfr_get_decimal64 (mpfr_srcptr, mpfr_rnd_t); |
484 | #endif |
485 | __MPFR_DECLSPEC long double mpfr_get_ld (mpfr_srcptr, mpfr_rnd_t); |
486 | __MPFR_DECLSPEC double mpfr_get_d1 (mpfr_srcptr); |
487 | __MPFR_DECLSPEC double mpfr_get_d_2exp (long*, mpfr_srcptr, mpfr_rnd_t); |
488 | __MPFR_DECLSPEC long double mpfr_get_ld_2exp (long*, mpfr_srcptr, mpfr_rnd_t); |
489 | __MPFR_DECLSPEC int mpfr_frexp (mpfr_exp_t*, mpfr_ptr, mpfr_srcptr, mpfr_rnd_t); |
490 | __MPFR_DECLSPEC long mpfr_get_si (mpfr_srcptr, mpfr_rnd_t); |
491 | __MPFR_DECLSPEC unsigned long mpfr_get_ui (mpfr_srcptr, mpfr_rnd_t); |
492 | __MPFR_DECLSPEC char * mpfr_get_str (char*, mpfr_exp_t*, int, size_t, |
493 | mpfr_srcptr, mpfr_rnd_t); |
494 | __MPFR_DECLSPEC int mpfr_get_z (mpz_ptr z, mpfr_srcptr f, mpfr_rnd_t); |
495 | |
496 | __MPFR_DECLSPEC void mpfr_free_str (char *); |
497 | |
498 | __MPFR_DECLSPEC int mpfr_urandom (mpfr_ptr, gmp_randstate_t, mpfr_rnd_t); |
499 | #ifndef _MPFR_NO_DEPRECATED_GRANDOM /* for the test of this function */ |
500 | MPFR_DEPRECATED |
501 | #endif |
502 | __MPFR_DECLSPEC int mpfr_grandom (mpfr_ptr, mpfr_ptr, gmp_randstate_t, |
503 | mpfr_rnd_t); |
504 | __MPFR_DECLSPEC int mpfr_nrandom (mpfr_ptr, gmp_randstate_t, mpfr_rnd_t); |
505 | __MPFR_DECLSPEC int mpfr_erandom (mpfr_ptr, gmp_randstate_t, mpfr_rnd_t); |
506 | __MPFR_DECLSPEC int mpfr_urandomb (mpfr_ptr, gmp_randstate_t); |
507 | |
508 | __MPFR_DECLSPEC void mpfr_nextabove (mpfr_ptr); |
509 | __MPFR_DECLSPEC void mpfr_nextbelow (mpfr_ptr); |
510 | __MPFR_DECLSPEC void mpfr_nexttoward (mpfr_ptr, mpfr_srcptr); |
511 | |
512 | #ifndef MPFR_USE_MINI_GMP |
513 | __MPFR_DECLSPEC int mpfr_printf (const char*, ...); |
514 | __MPFR_DECLSPEC int mpfr_asprintf (char**, const char*, ...); |
515 | __MPFR_DECLSPEC int mpfr_sprintf (char*, const char*, ...); |
516 | __MPFR_DECLSPEC int mpfr_snprintf (char*, size_t, const char*, ...); |
517 | #endif |
518 | |
519 | __MPFR_DECLSPEC int mpfr_pow (mpfr_ptr, mpfr_srcptr, mpfr_srcptr, mpfr_rnd_t); |
520 | __MPFR_DECLSPEC int mpfr_pow_si (mpfr_ptr, mpfr_srcptr, long, mpfr_rnd_t); |
521 | __MPFR_DECLSPEC int mpfr_pow_ui (mpfr_ptr, mpfr_srcptr, unsigned long, |
522 | mpfr_rnd_t); |
523 | __MPFR_DECLSPEC int mpfr_ui_pow_ui (mpfr_ptr, unsigned long, unsigned long, |
524 | mpfr_rnd_t); |
525 | __MPFR_DECLSPEC int mpfr_ui_pow (mpfr_ptr, unsigned long, mpfr_srcptr, |
526 | mpfr_rnd_t); |
527 | __MPFR_DECLSPEC int mpfr_pow_z (mpfr_ptr, mpfr_srcptr, mpz_srcptr, mpfr_rnd_t); |
528 | |
529 | __MPFR_DECLSPEC int mpfr_sqrt (mpfr_ptr, mpfr_srcptr, mpfr_rnd_t); |
530 | __MPFR_DECLSPEC int mpfr_sqrt_ui (mpfr_ptr, unsigned long, mpfr_rnd_t); |
531 | __MPFR_DECLSPEC int mpfr_rec_sqrt (mpfr_ptr, mpfr_srcptr, mpfr_rnd_t); |
532 | |
533 | __MPFR_DECLSPEC int mpfr_add (mpfr_ptr, mpfr_srcptr, mpfr_srcptr, mpfr_rnd_t); |
534 | __MPFR_DECLSPEC int mpfr_sub (mpfr_ptr, mpfr_srcptr, mpfr_srcptr, mpfr_rnd_t); |
535 | __MPFR_DECLSPEC int mpfr_mul (mpfr_ptr, mpfr_srcptr, mpfr_srcptr, mpfr_rnd_t); |
536 | __MPFR_DECLSPEC int mpfr_div (mpfr_ptr, mpfr_srcptr, mpfr_srcptr, mpfr_rnd_t); |
537 | |
538 | __MPFR_DECLSPEC int mpfr_add_ui (mpfr_ptr, mpfr_srcptr, unsigned long, |
539 | mpfr_rnd_t); |
540 | __MPFR_DECLSPEC int mpfr_sub_ui (mpfr_ptr, mpfr_srcptr, unsigned long, |
541 | mpfr_rnd_t); |
542 | __MPFR_DECLSPEC int mpfr_ui_sub (mpfr_ptr, unsigned long, mpfr_srcptr, |
543 | mpfr_rnd_t); |
544 | __MPFR_DECLSPEC int mpfr_mul_ui (mpfr_ptr, mpfr_srcptr, unsigned long, |
545 | mpfr_rnd_t); |
546 | __MPFR_DECLSPEC int mpfr_div_ui (mpfr_ptr, mpfr_srcptr, unsigned long, |
547 | mpfr_rnd_t); |
548 | __MPFR_DECLSPEC int mpfr_ui_div (mpfr_ptr, unsigned long, mpfr_srcptr, |
549 | mpfr_rnd_t); |
550 | |
551 | __MPFR_DECLSPEC int mpfr_add_si (mpfr_ptr, mpfr_srcptr, long, mpfr_rnd_t); |
552 | __MPFR_DECLSPEC int mpfr_sub_si (mpfr_ptr, mpfr_srcptr, long, mpfr_rnd_t); |
553 | __MPFR_DECLSPEC int mpfr_si_sub (mpfr_ptr, long, mpfr_srcptr, mpfr_rnd_t); |
554 | __MPFR_DECLSPEC int mpfr_mul_si (mpfr_ptr, mpfr_srcptr, long, mpfr_rnd_t); |
555 | __MPFR_DECLSPEC int mpfr_div_si (mpfr_ptr, mpfr_srcptr, long, mpfr_rnd_t); |
556 | __MPFR_DECLSPEC int mpfr_si_div (mpfr_ptr, long, mpfr_srcptr, mpfr_rnd_t); |
557 | |
558 | __MPFR_DECLSPEC int mpfr_add_d (mpfr_ptr, mpfr_srcptr, double, mpfr_rnd_t); |
559 | __MPFR_DECLSPEC int mpfr_sub_d (mpfr_ptr, mpfr_srcptr, double, mpfr_rnd_t); |
560 | __MPFR_DECLSPEC int mpfr_d_sub (mpfr_ptr, double, mpfr_srcptr, mpfr_rnd_t); |
561 | __MPFR_DECLSPEC int mpfr_mul_d (mpfr_ptr, mpfr_srcptr, double, mpfr_rnd_t); |
562 | __MPFR_DECLSPEC int mpfr_div_d (mpfr_ptr, mpfr_srcptr, double, mpfr_rnd_t); |
563 | __MPFR_DECLSPEC int mpfr_d_div (mpfr_ptr, double, mpfr_srcptr, mpfr_rnd_t); |
564 | |
565 | __MPFR_DECLSPEC int mpfr_sqr (mpfr_ptr, mpfr_srcptr, mpfr_rnd_t); |
566 | |
567 | __MPFR_DECLSPEC int mpfr_const_pi (mpfr_ptr, mpfr_rnd_t); |
568 | __MPFR_DECLSPEC int mpfr_const_log2 (mpfr_ptr, mpfr_rnd_t); |
569 | __MPFR_DECLSPEC int mpfr_const_euler (mpfr_ptr, mpfr_rnd_t); |
570 | __MPFR_DECLSPEC int mpfr_const_catalan (mpfr_ptr, mpfr_rnd_t); |
571 | |
572 | __MPFR_DECLSPEC int mpfr_agm (mpfr_ptr, mpfr_srcptr, mpfr_srcptr, mpfr_rnd_t); |
573 | |
574 | __MPFR_DECLSPEC int mpfr_log (mpfr_ptr, mpfr_srcptr, mpfr_rnd_t); |
575 | __MPFR_DECLSPEC int mpfr_log2 (mpfr_ptr, mpfr_srcptr, mpfr_rnd_t); |
576 | __MPFR_DECLSPEC int mpfr_log10 (mpfr_ptr, mpfr_srcptr, mpfr_rnd_t); |
577 | __MPFR_DECLSPEC int mpfr_log1p (mpfr_ptr, mpfr_srcptr, mpfr_rnd_t); |
578 | __MPFR_DECLSPEC int mpfr_log_ui (mpfr_ptr, unsigned long, mpfr_rnd_t); |
579 | |
580 | __MPFR_DECLSPEC int mpfr_exp (mpfr_ptr, mpfr_srcptr, mpfr_rnd_t); |
581 | __MPFR_DECLSPEC int mpfr_exp2 (mpfr_ptr, mpfr_srcptr, mpfr_rnd_t); |
582 | __MPFR_DECLSPEC int mpfr_exp10 (mpfr_ptr, mpfr_srcptr, mpfr_rnd_t); |
583 | __MPFR_DECLSPEC int mpfr_expm1 (mpfr_ptr, mpfr_srcptr, mpfr_rnd_t); |
584 | __MPFR_DECLSPEC int mpfr_eint (mpfr_ptr, mpfr_srcptr, mpfr_rnd_t); |
585 | __MPFR_DECLSPEC int mpfr_li2 (mpfr_ptr, mpfr_srcptr, mpfr_rnd_t); |
586 | |
587 | __MPFR_DECLSPEC int mpfr_cmp (mpfr_srcptr, mpfr_srcptr); |
588 | __MPFR_DECLSPEC int mpfr_cmp3 (mpfr_srcptr, mpfr_srcptr, int); |
589 | __MPFR_DECLSPEC int mpfr_cmp_d (mpfr_srcptr, double); |
590 | __MPFR_DECLSPEC int mpfr_cmp_ld (mpfr_srcptr, long double); |
591 | __MPFR_DECLSPEC int mpfr_cmpabs (mpfr_srcptr, mpfr_srcptr); |
592 | __MPFR_DECLSPEC int mpfr_cmp_ui (mpfr_srcptr, unsigned long); |
593 | __MPFR_DECLSPEC int mpfr_cmp_si (mpfr_srcptr, long); |
594 | __MPFR_DECLSPEC int mpfr_cmp_ui_2exp (mpfr_srcptr, unsigned long, mpfr_exp_t); |
595 | __MPFR_DECLSPEC int mpfr_cmp_si_2exp (mpfr_srcptr, long, mpfr_exp_t); |
596 | __MPFR_DECLSPEC void mpfr_reldiff (mpfr_ptr, mpfr_srcptr, mpfr_srcptr, |
597 | mpfr_rnd_t); |
598 | __MPFR_DECLSPEC int mpfr_eq (mpfr_srcptr, mpfr_srcptr, unsigned long); |
599 | __MPFR_DECLSPEC int mpfr_sgn (mpfr_srcptr); |
600 | |
601 | __MPFR_DECLSPEC int mpfr_mul_2exp (mpfr_ptr, mpfr_srcptr, unsigned long, |
602 | mpfr_rnd_t); |
603 | __MPFR_DECLSPEC int mpfr_div_2exp (mpfr_ptr, mpfr_srcptr, unsigned long, |
604 | mpfr_rnd_t); |
605 | __MPFR_DECLSPEC int mpfr_mul_2ui (mpfr_ptr, mpfr_srcptr, unsigned long, |
606 | mpfr_rnd_t); |
607 | __MPFR_DECLSPEC int mpfr_div_2ui (mpfr_ptr, mpfr_srcptr, unsigned long, |
608 | mpfr_rnd_t); |
609 | __MPFR_DECLSPEC int mpfr_mul_2si (mpfr_ptr, mpfr_srcptr, long, mpfr_rnd_t); |
610 | __MPFR_DECLSPEC int mpfr_div_2si (mpfr_ptr, mpfr_srcptr, long, mpfr_rnd_t); |
611 | |
612 | __MPFR_DECLSPEC int mpfr_rint (mpfr_ptr, mpfr_srcptr, mpfr_rnd_t); |
613 | __MPFR_DECLSPEC int mpfr_roundeven (mpfr_ptr, mpfr_srcptr); |
614 | __MPFR_DECLSPEC int mpfr_round (mpfr_ptr, mpfr_srcptr); |
615 | __MPFR_DECLSPEC int mpfr_trunc (mpfr_ptr, mpfr_srcptr); |
616 | __MPFR_DECLSPEC int mpfr_ceil (mpfr_ptr, mpfr_srcptr); |
617 | __MPFR_DECLSPEC int mpfr_floor (mpfr_ptr, mpfr_srcptr); |
618 | __MPFR_DECLSPEC int mpfr_rint_roundeven (mpfr_ptr, mpfr_srcptr, mpfr_rnd_t); |
619 | __MPFR_DECLSPEC int mpfr_rint_round (mpfr_ptr, mpfr_srcptr, mpfr_rnd_t); |
620 | __MPFR_DECLSPEC int mpfr_rint_trunc (mpfr_ptr, mpfr_srcptr, mpfr_rnd_t); |
621 | __MPFR_DECLSPEC int mpfr_rint_ceil (mpfr_ptr, mpfr_srcptr, mpfr_rnd_t); |
622 | __MPFR_DECLSPEC int mpfr_rint_floor (mpfr_ptr, mpfr_srcptr, mpfr_rnd_t); |
623 | __MPFR_DECLSPEC int mpfr_frac (mpfr_ptr, mpfr_srcptr, mpfr_rnd_t); |
624 | __MPFR_DECLSPEC int mpfr_modf (mpfr_ptr, mpfr_ptr, mpfr_srcptr, mpfr_rnd_t); |
625 | __MPFR_DECLSPEC int mpfr_remquo (mpfr_ptr, long*, mpfr_srcptr, mpfr_srcptr, |
626 | mpfr_rnd_t); |
627 | __MPFR_DECLSPEC int mpfr_remainder (mpfr_ptr, mpfr_srcptr, mpfr_srcptr, |
628 | mpfr_rnd_t); |
629 | __MPFR_DECLSPEC int mpfr_fmod (mpfr_ptr, mpfr_srcptr, mpfr_srcptr, mpfr_rnd_t); |
630 | __MPFR_DECLSPEC int mpfr_fmodquo (mpfr_ptr, long*, mpfr_srcptr, mpfr_srcptr, |
631 | mpfr_rnd_t); |
632 | |
633 | __MPFR_DECLSPEC int mpfr_fits_ulong_p (mpfr_srcptr, mpfr_rnd_t); |
634 | __MPFR_DECLSPEC int mpfr_fits_slong_p (mpfr_srcptr, mpfr_rnd_t); |
635 | __MPFR_DECLSPEC int mpfr_fits_uint_p (mpfr_srcptr, mpfr_rnd_t); |
636 | __MPFR_DECLSPEC int mpfr_fits_sint_p (mpfr_srcptr, mpfr_rnd_t); |
637 | __MPFR_DECLSPEC int mpfr_fits_ushort_p (mpfr_srcptr, mpfr_rnd_t); |
638 | __MPFR_DECLSPEC int mpfr_fits_sshort_p (mpfr_srcptr, mpfr_rnd_t); |
639 | __MPFR_DECLSPEC int mpfr_fits_uintmax_p (mpfr_srcptr, mpfr_rnd_t); |
640 | __MPFR_DECLSPEC int mpfr_fits_intmax_p (mpfr_srcptr, mpfr_rnd_t); |
641 | |
642 | __MPFR_DECLSPEC void mpfr_extract (mpz_ptr, mpfr_srcptr, unsigned int); |
643 | __MPFR_DECLSPEC void mpfr_swap (mpfr_ptr, mpfr_ptr); |
644 | __MPFR_DECLSPEC void mpfr_dump (mpfr_srcptr); |
645 | |
646 | __MPFR_DECLSPEC int mpfr_nan_p (mpfr_srcptr); |
647 | __MPFR_DECLSPEC int mpfr_inf_p (mpfr_srcptr); |
648 | __MPFR_DECLSPEC int mpfr_number_p (mpfr_srcptr); |
649 | __MPFR_DECLSPEC int mpfr_integer_p (mpfr_srcptr); |
650 | __MPFR_DECLSPEC int mpfr_zero_p (mpfr_srcptr); |
651 | __MPFR_DECLSPEC int mpfr_regular_p (mpfr_srcptr); |
652 | |
653 | __MPFR_DECLSPEC int mpfr_greater_p (mpfr_srcptr, mpfr_srcptr); |
654 | __MPFR_DECLSPEC int mpfr_greaterequal_p (mpfr_srcptr, mpfr_srcptr); |
655 | __MPFR_DECLSPEC int mpfr_less_p (mpfr_srcptr, mpfr_srcptr); |
656 | __MPFR_DECLSPEC int mpfr_lessequal_p (mpfr_srcptr, mpfr_srcptr); |
657 | __MPFR_DECLSPEC int mpfr_lessgreater_p (mpfr_srcptr, mpfr_srcptr); |
658 | __MPFR_DECLSPEC int mpfr_equal_p (mpfr_srcptr, mpfr_srcptr); |
659 | __MPFR_DECLSPEC int mpfr_unordered_p (mpfr_srcptr, mpfr_srcptr); |
660 | |
661 | __MPFR_DECLSPEC int mpfr_atanh (mpfr_ptr, mpfr_srcptr, mpfr_rnd_t); |
662 | __MPFR_DECLSPEC int mpfr_acosh (mpfr_ptr, mpfr_srcptr, mpfr_rnd_t); |
663 | __MPFR_DECLSPEC int mpfr_asinh (mpfr_ptr, mpfr_srcptr, mpfr_rnd_t); |
664 | __MPFR_DECLSPEC int mpfr_cosh (mpfr_ptr, mpfr_srcptr, mpfr_rnd_t); |
665 | __MPFR_DECLSPEC int mpfr_sinh (mpfr_ptr, mpfr_srcptr, mpfr_rnd_t); |
666 | __MPFR_DECLSPEC int mpfr_tanh (mpfr_ptr, mpfr_srcptr, mpfr_rnd_t); |
667 | __MPFR_DECLSPEC int mpfr_sinh_cosh (mpfr_ptr, mpfr_ptr, mpfr_srcptr, |
668 | mpfr_rnd_t); |
669 | |
670 | __MPFR_DECLSPEC int mpfr_sech (mpfr_ptr, mpfr_srcptr, mpfr_rnd_t); |
671 | __MPFR_DECLSPEC int mpfr_csch (mpfr_ptr, mpfr_srcptr, mpfr_rnd_t); |
672 | __MPFR_DECLSPEC int mpfr_coth (mpfr_ptr, mpfr_srcptr, mpfr_rnd_t); |
673 | |
674 | __MPFR_DECLSPEC int mpfr_acos (mpfr_ptr, mpfr_srcptr, mpfr_rnd_t); |
675 | __MPFR_DECLSPEC int mpfr_asin (mpfr_ptr, mpfr_srcptr, mpfr_rnd_t); |
676 | __MPFR_DECLSPEC int mpfr_atan (mpfr_ptr, mpfr_srcptr, mpfr_rnd_t); |
677 | __MPFR_DECLSPEC int mpfr_sin (mpfr_ptr, mpfr_srcptr, mpfr_rnd_t); |
678 | __MPFR_DECLSPEC int mpfr_sin_cos (mpfr_ptr, mpfr_ptr, mpfr_srcptr, mpfr_rnd_t); |
679 | __MPFR_DECLSPEC int mpfr_cos (mpfr_ptr, mpfr_srcptr, mpfr_rnd_t); |
680 | __MPFR_DECLSPEC int mpfr_tan (mpfr_ptr, mpfr_srcptr, mpfr_rnd_t); |
681 | __MPFR_DECLSPEC int mpfr_atan2 (mpfr_ptr, mpfr_srcptr, mpfr_srcptr, mpfr_rnd_t); |
682 | __MPFR_DECLSPEC int mpfr_sec (mpfr_ptr, mpfr_srcptr, mpfr_rnd_t); |
683 | __MPFR_DECLSPEC int mpfr_csc (mpfr_ptr, mpfr_srcptr, mpfr_rnd_t); |
684 | __MPFR_DECLSPEC int mpfr_cot (mpfr_ptr, mpfr_srcptr, mpfr_rnd_t); |
685 | |
686 | __MPFR_DECLSPEC int mpfr_hypot (mpfr_ptr, mpfr_srcptr, mpfr_srcptr, mpfr_rnd_t); |
687 | __MPFR_DECLSPEC int mpfr_erf (mpfr_ptr, mpfr_srcptr, mpfr_rnd_t); |
688 | __MPFR_DECLSPEC int mpfr_erfc (mpfr_ptr, mpfr_srcptr, mpfr_rnd_t); |
689 | __MPFR_DECLSPEC int mpfr_cbrt (mpfr_ptr, mpfr_srcptr, mpfr_rnd_t); |
690 | #ifndef _MPFR_NO_DEPRECATED_ROOT /* for the test of this function */ |
691 | MPFR_DEPRECATED |
692 | #endif |
693 | __MPFR_DECLSPEC int mpfr_root (mpfr_ptr, mpfr_srcptr, unsigned long, |
694 | mpfr_rnd_t); |
695 | __MPFR_DECLSPEC int mpfr_rootn_ui (mpfr_ptr, mpfr_srcptr, unsigned long, |
696 | mpfr_rnd_t); |
697 | __MPFR_DECLSPEC int mpfr_gamma (mpfr_ptr, mpfr_srcptr, mpfr_rnd_t); |
698 | __MPFR_DECLSPEC int mpfr_gamma_inc (mpfr_ptr, mpfr_srcptr, mpfr_srcptr, |
699 | mpfr_rnd_t); |
700 | __MPFR_DECLSPEC int mpfr_beta (mpfr_ptr, mpfr_srcptr, mpfr_srcptr, mpfr_rnd_t); |
701 | __MPFR_DECLSPEC int mpfr_lngamma (mpfr_ptr, mpfr_srcptr, mpfr_rnd_t); |
702 | __MPFR_DECLSPEC int mpfr_lgamma (mpfr_ptr, int *, mpfr_srcptr, mpfr_rnd_t); |
703 | __MPFR_DECLSPEC int mpfr_digamma (mpfr_ptr, mpfr_srcptr, mpfr_rnd_t); |
704 | __MPFR_DECLSPEC int mpfr_zeta (mpfr_ptr, mpfr_srcptr, mpfr_rnd_t); |
705 | __MPFR_DECLSPEC int mpfr_zeta_ui (mpfr_ptr, unsigned long, mpfr_rnd_t); |
706 | __MPFR_DECLSPEC int mpfr_fac_ui (mpfr_ptr, unsigned long, mpfr_rnd_t); |
707 | __MPFR_DECLSPEC int mpfr_j0 (mpfr_ptr, mpfr_srcptr, mpfr_rnd_t); |
708 | __MPFR_DECLSPEC int mpfr_j1 (mpfr_ptr, mpfr_srcptr, mpfr_rnd_t); |
709 | __MPFR_DECLSPEC int mpfr_jn (mpfr_ptr, long, mpfr_srcptr, mpfr_rnd_t); |
710 | __MPFR_DECLSPEC int mpfr_y0 (mpfr_ptr, mpfr_srcptr, mpfr_rnd_t); |
711 | __MPFR_DECLSPEC int mpfr_y1 (mpfr_ptr, mpfr_srcptr, mpfr_rnd_t); |
712 | __MPFR_DECLSPEC int mpfr_yn (mpfr_ptr, long, mpfr_srcptr, mpfr_rnd_t); |
713 | |
714 | __MPFR_DECLSPEC int mpfr_ai (mpfr_ptr, mpfr_srcptr, mpfr_rnd_t); |
715 | |
716 | __MPFR_DECLSPEC int mpfr_min (mpfr_ptr, mpfr_srcptr, mpfr_srcptr, mpfr_rnd_t); |
717 | __MPFR_DECLSPEC int mpfr_max (mpfr_ptr, mpfr_srcptr, mpfr_srcptr, mpfr_rnd_t); |
718 | __MPFR_DECLSPEC int mpfr_dim (mpfr_ptr, mpfr_srcptr, mpfr_srcptr, mpfr_rnd_t); |
719 | |
720 | __MPFR_DECLSPEC int mpfr_mul_z (mpfr_ptr, mpfr_srcptr, mpz_srcptr, mpfr_rnd_t); |
721 | __MPFR_DECLSPEC int mpfr_div_z (mpfr_ptr, mpfr_srcptr, mpz_srcptr, mpfr_rnd_t); |
722 | __MPFR_DECLSPEC int mpfr_add_z (mpfr_ptr, mpfr_srcptr, mpz_srcptr, mpfr_rnd_t); |
723 | __MPFR_DECLSPEC int mpfr_sub_z (mpfr_ptr, mpfr_srcptr, mpz_srcptr, mpfr_rnd_t); |
724 | __MPFR_DECLSPEC int mpfr_z_sub (mpfr_ptr, mpz_srcptr, mpfr_srcptr, mpfr_rnd_t); |
725 | __MPFR_DECLSPEC int mpfr_cmp_z (mpfr_srcptr, mpz_srcptr); |
726 | |
727 | __MPFR_DECLSPEC int mpfr_fma (mpfr_ptr, mpfr_srcptr, mpfr_srcptr, mpfr_srcptr, |
728 | mpfr_rnd_t); |
729 | __MPFR_DECLSPEC int mpfr_fms (mpfr_ptr, mpfr_srcptr, mpfr_srcptr, mpfr_srcptr, |
730 | mpfr_rnd_t); |
731 | __MPFR_DECLSPEC int mpfr_fmma (mpfr_ptr, mpfr_srcptr, mpfr_srcptr, mpfr_srcptr, |
732 | mpfr_srcptr, mpfr_rnd_t); |
733 | __MPFR_DECLSPEC int mpfr_fmms (mpfr_ptr, mpfr_srcptr, mpfr_srcptr, mpfr_srcptr, |
734 | mpfr_srcptr, mpfr_rnd_t); |
735 | __MPFR_DECLSPEC int mpfr_sum (mpfr_ptr, const mpfr_ptr *, unsigned long, |
736 | mpfr_rnd_t); |
737 | |
738 | __MPFR_DECLSPEC void mpfr_free_cache (void); |
739 | __MPFR_DECLSPEC void mpfr_free_cache2 (mpfr_free_cache_t); |
740 | __MPFR_DECLSPEC void mpfr_free_pool (void); |
741 | __MPFR_DECLSPEC int mpfr_mp_memory_cleanup (void); |
742 | |
743 | __MPFR_DECLSPEC int mpfr_subnormalize (mpfr_ptr, int, mpfr_rnd_t); |
744 | |
745 | __MPFR_DECLSPEC int mpfr_strtofr (mpfr_ptr, const char *, char **, int, |
746 | mpfr_rnd_t); |
747 | |
748 | __MPFR_DECLSPEC void mpfr_round_nearest_away_begin (mpfr_t); |
749 | __MPFR_DECLSPEC int mpfr_round_nearest_away_end (mpfr_t, int); |
750 | |
751 | __MPFR_DECLSPEC size_t mpfr_custom_get_size (mpfr_prec_t); |
752 | __MPFR_DECLSPEC void mpfr_custom_init (void *, mpfr_prec_t); |
753 | __MPFR_DECLSPEC void * mpfr_custom_get_significand (mpfr_srcptr); |
754 | __MPFR_DECLSPEC mpfr_exp_t mpfr_custom_get_exp (mpfr_srcptr); |
755 | __MPFR_DECLSPEC void mpfr_custom_move (mpfr_ptr, void *); |
756 | __MPFR_DECLSPEC void mpfr_custom_init_set (mpfr_ptr, int, mpfr_exp_t, |
757 | mpfr_prec_t, void *); |
758 | __MPFR_DECLSPEC int mpfr_custom_get_kind (mpfr_srcptr); |
759 | |
760 | #if defined (__cplusplus) |
761 | } |
762 | #endif |
763 | |
764 | /* Define MPFR_USE_EXTENSION to avoid "gcc -pedantic" warnings. */ |
765 | #ifndef MPFR_EXTENSION |
766 | # if defined(MPFR_USE_EXTENSION) |
767 | # define MPFR_EXTENSION __extension__ |
768 | # else |
769 | # define MPFR_EXTENSION |
770 | # endif |
771 | #endif |
772 | |
773 | /* Warning! This macro doesn't work with K&R C (e.g., compare the "gcc -E" |
774 | output with and without -traditional) and shouldn't be used internally. |
775 | For public use only, but see the MPFR manual. */ |
776 | #define MPFR_DECL_INIT(_x, _p) \ |
777 | MPFR_EXTENSION mp_limb_t __gmpfr_local_tab_##_x[((_p)-1)/GMP_NUMB_BITS+1]; \ |
778 | MPFR_EXTENSION mpfr_t _x = {{(_p),1,__MPFR_EXP_NAN,__gmpfr_local_tab_##_x}} |
779 | |
780 | #if MPFR_USE_C99_FEATURE |
781 | /* C99 & C11 version: functions with multiple inputs supported */ |
782 | #define mpfr_round_nearest_away(func, rop, ...) \ |
783 | (mpfr_round_nearest_away_begin(rop), \ |
784 | mpfr_round_nearest_away_end((rop), func((rop), __VA_ARGS__, MPFR_RNDN))) |
785 | #else |
786 | /* C89 version: function with one input supported */ |
787 | #define mpfr_round_nearest_away(func, rop, op) \ |
788 | (mpfr_round_nearest_away_begin(rop), \ |
789 | mpfr_round_nearest_away_end((rop), func((rop), (op), MPFR_RNDN))) |
790 | #endif |
791 | |
792 | /* Fast access macros to replace function interface. |
793 | If the USER don't want to use the macro interface, let him make happy |
794 | even if it produces faster and smaller code. */ |
795 | #ifndef MPFR_USE_NO_MACRO |
796 | |
797 | /* Inlining theses functions is both faster and smaller */ |
798 | #define mpfr_nan_p(_x) ((_x)->_mpfr_exp == __MPFR_EXP_NAN) |
799 | #define mpfr_inf_p(_x) ((_x)->_mpfr_exp == __MPFR_EXP_INF) |
800 | #define mpfr_zero_p(_x) ((_x)->_mpfr_exp == __MPFR_EXP_ZERO) |
801 | #define mpfr_regular_p(_x) ((_x)->_mpfr_exp > __MPFR_EXP_INF) |
802 | #define mpfr_sgn(_x) \ |
803 | ((_x)->_mpfr_exp < __MPFR_EXP_INF ? \ |
804 | (mpfr_nan_p (_x) ? mpfr_set_erangeflag () : (mpfr_void) 0), 0 : \ |
805 | MPFR_SIGN (_x)) |
806 | |
807 | /* Prevent them from using as lvalues */ |
808 | #define MPFR_VALUE_OF(x) (0 ? (x) : (x)) |
809 | #define mpfr_get_prec(_x) MPFR_VALUE_OF((_x)->_mpfr_prec) |
810 | #define mpfr_get_exp(_x) MPFR_VALUE_OF((_x)->_mpfr_exp) |
811 | /* Note 1: If need be, the MPFR_VALUE_OF can be used for other expressions |
812 | (of any type). Thanks to Wojtek Lerch and Tim Rentsch for the idea. |
813 | Note 2: Defining mpfr_get_exp() as a macro has the effect to disable |
814 | the check that the argument is a pure FP number (done in the function); |
815 | this increases the risk of undetected error and makes debugging more |
816 | complex. Is it really worth in practice? (Potential FIXME) */ |
817 | |
818 | #define mpfr_round(a,b) mpfr_rint((a), (b), MPFR_RNDNA) |
819 | #define mpfr_trunc(a,b) mpfr_rint((a), (b), MPFR_RNDZ) |
820 | #define mpfr_ceil(a,b) mpfr_rint((a), (b), MPFR_RNDU) |
821 | #define mpfr_floor(a,b) mpfr_rint((a), (b), MPFR_RNDD) |
822 | |
823 | #define mpfr_cmp_ui(b,i) mpfr_cmp_ui_2exp((b),(i),0) |
824 | #define mpfr_cmp_si(b,i) mpfr_cmp_si_2exp((b),(i),0) |
825 | #define mpfr_set(a,b,r) mpfr_set4(a,b,r,MPFR_SIGN(b)) |
826 | #define mpfr_abs(a,b,r) mpfr_set4(a,b,r,1) |
827 | #define mpfr_copysign(a,b,c,r) mpfr_set4(a,b,r,MPFR_SIGN(c)) |
828 | #define mpfr_setsign(a,b,s,r) mpfr_set4(a,b,r,(s) ? -1 : 1) |
829 | #define mpfr_signbit(x) (MPFR_SIGN(x) < 0) |
830 | #define mpfr_cmp(b, c) mpfr_cmp3(b, c, 1) |
831 | #define mpfr_mul_2exp(y,x,n,r) mpfr_mul_2ui((y),(x),(n),(r)) |
832 | #define mpfr_div_2exp(y,x,n,r) mpfr_div_2ui((y),(x),(n),(r)) |
833 | |
834 | |
835 | /* When using GCC, optimize certain common comparisons and affectations. |
836 | + Remove some Intel C/C++ (ICC) versions since they now define __GNUC__ |
837 | but produce a huge number of warnings if you use this code. |
838 | VL: I couldn't reproduce a single warning when enabling these macros |
839 | with icc 10.1 20080212 on Itanium. But with this version, the obsolete |
840 | __ICC macro isn't defined (__INTEL_COMPILER is, though), so that these |
841 | macros are enabled anyway. Checking with other ICC versions is needed. |
842 | For now, !defined(__ICC) seems to be the right test. Possibly detect |
843 | whether warnings are produced or not with a configure test. |
844 | + Remove C++ too, since it complains too much. */ |
845 | /* Added casts to improve robustness in case of undefined behavior and |
846 | compiler extensions based on UB (in particular -fwrapv). MPFR doesn't |
847 | use such extensions, but these macros will be used by 3rd-party code, |
848 | where such extensions may be required. |
849 | Moreover casts to unsigned long have been added to avoid warnings in |
850 | programs that use MPFR and are compiled with -Wconversion; such casts |
851 | are OK since if X is a constant expression, then (unsigned long) X is |
852 | also a constant expression, so that the optimizations still work. The |
853 | warnings are probably related to the following two bugs: |
854 | https://gcc.gnu.org/bugzilla/show_bug.cgi?id=4210 |
855 | https://gcc.gnu.org/bugzilla/show_bug.cgi?id=38470 (possibly a variant) |
856 | and the casts could be removed once these bugs are fixed. |
857 | Casts shouldn't be used on the generic calls (to the ..._2exp functions), |
858 | where implicit conversions are performed. Indeed, having at least one |
859 | implicit conversion in the macro allows the compiler to emit diagnostics |
860 | when normally expected, for instance in the following call: |
861 | mpfr_set_ui (x, "foo", MPFR_RNDN); |
862 | If this is not possible (for future macros), one of the tricks described |
863 | on http://groups.google.com/group/comp.std.c/msg/e92abd24bf9eaf7b could |
864 | be used. */ |
865 | #if defined (__GNUC__) && !defined(__ICC) && !defined(__cplusplus) |
866 | #if (__GNUC__ >= 2) |
867 | |
868 | #undef mpfr_cmp_ui |
869 | /* We use the fact that mpfr_sgn on NaN sets the erange flag and returns 0. |
870 | But warning! mpfr_sgn is specified as a macro in the API, thus the macro |
871 | mustn't be used if side effects are possible, like here. */ |
872 | #define mpfr_cmp_ui(_f,_u) \ |
873 | (__builtin_constant_p (_u) && (mpfr_ulong) (_u) == 0 ? \ |
874 | (mpfr_sgn) (_f) : \ |
875 | mpfr_cmp_ui_2exp ((_f), (_u), 0)) |
876 | |
877 | #undef mpfr_cmp_si |
878 | #define mpfr_cmp_si(_f,_s) \ |
879 | (__builtin_constant_p (_s) && (mpfr_long) (_s) >= 0 ? \ |
880 | mpfr_cmp_ui ((_f), (mpfr_ulong) (mpfr_long) (_s)) : \ |
881 | mpfr_cmp_si_2exp ((_f), (_s), 0)) |
882 | |
883 | #if __GNUC__ > 2 || __GNUC_MINOR__ >= 95 |
884 | #undef mpfr_set_ui |
885 | #define mpfr_set_ui(_f,_u,_r) \ |
886 | (__builtin_constant_p (_u) && (mpfr_ulong) (_u) == 0 ? \ |
887 | __extension__ ({ \ |
888 | mpfr_ptr _p = (_f); \ |
889 | _p->_mpfr_sign = 1; \ |
890 | _p->_mpfr_exp = __MPFR_EXP_ZERO; \ |
891 | (mpfr_void) (_r); 0; }) : \ |
892 | mpfr_set_ui_2exp ((_f), (_u), 0, (_r))) |
893 | #endif |
894 | |
895 | #undef mpfr_set_si |
896 | #define mpfr_set_si(_f,_s,_r) \ |
897 | (__builtin_constant_p (_s) && (mpfr_long) (_s) >= 0 ? \ |
898 | mpfr_set_ui ((_f), (mpfr_ulong) (mpfr_long) (_s), (_r)) : \ |
899 | mpfr_set_si_2exp ((_f), (_s), 0, (_r))) |
900 | |
901 | #if __GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) |
902 | /* If the source is a constant number that is a power of 2, |
903 | optimize the call */ |
904 | #undef mpfr_mul_ui |
905 | #define mpfr_mul_ui(_f, _g, _u,_r) \ |
906 | (__builtin_constant_p (_u) && (mpfr_ulong) (_u) >= 1 && \ |
907 | ((mpfr_ulong) (_u) & ((mpfr_ulong) (_u) - 1)) == 0 ? \ |
908 | mpfr_mul_2si((_f), (_g), __builtin_ctzl (_u), (_r)) : \ |
909 | mpfr_mul_ui ((_f), (_g), (_u), (_r))) |
910 | #undef mpfr_div_ui |
911 | #define mpfr_div_ui(_f, _g, _u,_r) \ |
912 | (__builtin_constant_p (_u) && (mpfr_ulong) (_u) >= 1 && \ |
913 | ((mpfr_ulong) (_u) & ((mpfr_ulong) (_u) - 1)) == 0 ? \ |
914 | mpfr_mul_2si((_f), (_g), - __builtin_ctzl (_u), (_r)) : \ |
915 | mpfr_div_ui ((_f), (_g), (_u), (_r))) |
916 | #endif |
917 | |
918 | /* If the source is a constant number that is non-negative, |
919 | optimize the call */ |
920 | #undef mpfr_mul_si |
921 | #define mpfr_mul_si(_f, _g, _s,_r) \ |
922 | (__builtin_constant_p (_s) && (mpfr_long) (_s) >= 0 ? \ |
923 | mpfr_mul_ui ((_f), (_g), (mpfr_ulong) (mpfr_long) (_s), (_r)) : \ |
924 | mpfr_mul_si ((_f), (_g), (_s), (_r))) |
925 | #undef mpfr_div_si |
926 | #define mpfr_div_si(_f, _g, _s,_r) \ |
927 | (__builtin_constant_p (_s) && (mpfr_long) (_s) >= 0 ? \ |
928 | mpfr_div_ui ((_f), (_g), (mpfr_ulong) (mpfr_long) (_s), (_r)) : \ |
929 | mpfr_div_si ((_f), (_g), (_s), (_r))) |
930 | |
931 | #endif |
932 | #endif |
933 | |
934 | /* Macro version of mpfr_stack interface for fast access */ |
935 | #define mpfr_custom_get_size(p) ((mpfr_size_t) \ |
936 | (((p)+GMP_NUMB_BITS-1)/GMP_NUMB_BITS*sizeof (mp_limb_t))) |
937 | #define mpfr_custom_init(m,p) do {} while (0) |
938 | #define mpfr_custom_get_significand(x) ((mpfr_void*)((x)->_mpfr_d)) |
939 | #define mpfr_custom_get_exp(x) ((x)->_mpfr_exp) |
940 | #define mpfr_custom_move(x,m) do { ((x)->_mpfr_d = (mp_limb_t*)(m)); } while (0) |
941 | #define mpfr_custom_init_set(x,k,e,p,m) do { \ |
942 | mpfr_ptr _x = (x); \ |
943 | mpfr_exp_t _e; \ |
944 | mpfr_kind_t _t; \ |
945 | mpfr_int _s, _k; \ |
946 | _k = (k); \ |
947 | if (_k >= 0) { \ |
948 | _t = (mpfr_kind_t) _k; \ |
949 | _s = 1; \ |
950 | } else { \ |
951 | _t = (mpfr_kind_t) - _k; \ |
952 | _s = -1; \ |
953 | } \ |
954 | _e = _t == MPFR_REGULAR_KIND ? (e) : \ |
955 | _t == MPFR_NAN_KIND ? __MPFR_EXP_NAN : \ |
956 | _t == MPFR_INF_KIND ? __MPFR_EXP_INF : __MPFR_EXP_ZERO; \ |
957 | _x->_mpfr_prec = (p); \ |
958 | _x->_mpfr_sign = _s; \ |
959 | _x->_mpfr_exp = _e; \ |
960 | _x->_mpfr_d = (mp_limb_t*) (m); \ |
961 | } while (0) |
962 | #define mpfr_custom_get_kind(x) \ |
963 | ( (x)->_mpfr_exp > __MPFR_EXP_INF ? \ |
964 | (mpfr_int) MPFR_REGULAR_KIND * MPFR_SIGN (x) \ |
965 | : (x)->_mpfr_exp == __MPFR_EXP_INF ? \ |
966 | (mpfr_int) MPFR_INF_KIND * MPFR_SIGN (x) \ |
967 | : (x)->_mpfr_exp == __MPFR_EXP_NAN ? (mpfr_int) MPFR_NAN_KIND \ |
968 | : (mpfr_int) MPFR_ZERO_KIND * MPFR_SIGN (x) ) |
969 | |
970 | |
971 | #endif /* MPFR_USE_NO_MACRO */ |
972 | |
973 | /* Theses are defined to be macros */ |
974 | #define mpfr_init_set_si(x, i, rnd) \ |
975 | ( mpfr_init(x), mpfr_set_si((x), (i), (rnd)) ) |
976 | #define mpfr_init_set_ui(x, i, rnd) \ |
977 | ( mpfr_init(x), mpfr_set_ui((x), (i), (rnd)) ) |
978 | #define mpfr_init_set_d(x, d, rnd) \ |
979 | ( mpfr_init(x), mpfr_set_d((x), (d), (rnd)) ) |
980 | #define mpfr_init_set_ld(x, d, rnd) \ |
981 | ( mpfr_init(x), mpfr_set_ld((x), (d), (rnd)) ) |
982 | #define mpfr_init_set_z(x, i, rnd) \ |
983 | ( mpfr_init(x), mpfr_set_z((x), (i), (rnd)) ) |
984 | #ifndef MPFR_USE_MINI_GMP |
985 | #define mpfr_init_set_q(x, i, rnd) \ |
986 | ( mpfr_init(x), mpfr_set_q((x), (i), (rnd)) ) |
987 | #define mpfr_init_set_f(x, y, rnd) \ |
988 | ( mpfr_init(x), mpfr_set_f((x), (y), (rnd)) ) |
989 | #endif |
990 | #define mpfr_init_set(x, y, rnd) \ |
991 | ( mpfr_init(x), mpfr_set((x), (y), (rnd)) ) |
992 | |
993 | /* Compatibility layer -- obsolete functions and macros */ |
994 | /* Note: it is not possible to output warnings, unless one defines |
995 | * a deprecated variable and uses it, e.g. |
996 | * MPFR_DEPRECATED extern int mpfr_deprecated_feature; |
997 | * #define MPFR_EMIN_MIN ((void)mpfr_deprecated_feature,mpfr_get_emin_min()) |
998 | * (the cast to void avoids a warning because the left-hand operand |
999 | * has no effect). |
1000 | */ |
1001 | #define mpfr_cmp_abs mpfr_cmpabs |
1002 | #define mpfr_round_prec(x,r,p) mpfr_prec_round(x,p,r) |
1003 | #define __gmp_default_rounding_mode (mpfr_get_default_rounding_mode()) |
1004 | #define __mpfr_emin (mpfr_get_emin()) |
1005 | #define __mpfr_emax (mpfr_get_emax()) |
1006 | #define __mpfr_default_fp_bit_precision (mpfr_get_default_fp_bit_precision()) |
1007 | #define MPFR_EMIN_MIN mpfr_get_emin_min() |
1008 | #define MPFR_EMIN_MAX mpfr_get_emin_max() |
1009 | #define MPFR_EMAX_MIN mpfr_get_emax_min() |
1010 | #define MPFR_EMAX_MAX mpfr_get_emax_max() |
1011 | #define mpfr_version (mpfr_get_version()) |
1012 | #ifndef mpz_set_fr |
1013 | # define mpz_set_fr mpfr_get_z |
1014 | #endif |
1015 | #define mpfr_get_z_exp mpfr_get_z_2exp |
1016 | #define mpfr_custom_get_mantissa mpfr_custom_get_significand |
1017 | |
1018 | #endif /* __MPFR_H */ |
1019 | |
1020 | |
1021 | /* Check if <stdint.h> / <inttypes.h> is included or if the user |
1022 | explicitly wants intmax_t. Automatical detection is done by |
1023 | checking: |
1024 | - INTMAX_C and UINTMAX_C, but not if the compiler is a C++ one |
1025 | (as suggested by Patrick Pelissier) because the test does not |
1026 | work well in this case. See: |
1027 | https://sympa.inria.fr/sympa/arc/mpfr/2010-02/msg00025.html |
1028 | We do not check INTMAX_MAX and UINTMAX_MAX because under Solaris, |
1029 | these macros are always defined by <limits.h> (i.e. even when |
1030 | <stdint.h> and <inttypes.h> are not included). |
1031 | - _STDINT_H (defined by the glibc), _STDINT_H_ (defined under |
1032 | Mac OS X) and _STDINT (defined under MS Visual Studio), but |
1033 | this test may not work with all implementations. |
1034 | Portable software should not rely on these tests. |
1035 | */ |
1036 | #if (defined (INTMAX_C) && defined (UINTMAX_C) && !defined(__cplusplus)) || \ |
1037 | defined (MPFR_USE_INTMAX_T) || \ |
1038 | defined (_STDINT_H) || defined (_STDINT_H_) || defined (_STDINT) || \ |
1039 | defined (_SYS_STDINT_H_) /* needed for FreeBSD */ |
1040 | # ifndef _MPFR_H_HAVE_INTMAX_T |
1041 | # define _MPFR_H_HAVE_INTMAX_T 1 |
1042 | |
1043 | #if defined (__cplusplus) |
1044 | extern "C"{ |
1045 | #endif |
1046 | |
1047 | #define mpfr_set_sj __gmpfr_set_sj |
1048 | #define mpfr_set_sj_2exp __gmpfr_set_sj_2exp |
1049 | #define mpfr_set_uj __gmpfr_set_uj |
1050 | #define mpfr_set_uj_2exp __gmpfr_set_uj_2exp |
1051 | #define mpfr_get_sj __gmpfr_mpfr_get_sj |
1052 | #define mpfr_get_uj __gmpfr_mpfr_get_uj |
1053 | __MPFR_DECLSPEC int mpfr_set_sj (mpfr_t, intmax_t, mpfr_rnd_t); |
1054 | __MPFR_DECLSPEC int mpfr_set_sj_2exp (mpfr_t, intmax_t, intmax_t, mpfr_rnd_t); |
1055 | __MPFR_DECLSPEC int mpfr_set_uj (mpfr_t, uintmax_t, mpfr_rnd_t); |
1056 | __MPFR_DECLSPEC int mpfr_set_uj_2exp (mpfr_t, uintmax_t, intmax_t, mpfr_rnd_t); |
1057 | __MPFR_DECLSPEC intmax_t mpfr_get_sj (mpfr_srcptr, mpfr_rnd_t); |
1058 | __MPFR_DECLSPEC uintmax_t mpfr_get_uj (mpfr_srcptr, mpfr_rnd_t); |
1059 | |
1060 | #if defined (__cplusplus) |
1061 | } |
1062 | #endif |
1063 | |
1064 | # endif /* _MPFR_H_HAVE_INTMAX_T */ |
1065 | #endif |
1066 | |
1067 | |
1068 | /* Check if <stdio.h> has been included or if the user wants FILE */ |
1069 | #if defined (_GMP_H_HAVE_FILE) || defined (MPFR_USE_FILE) |
1070 | # ifndef _MPFR_H_HAVE_FILE |
1071 | # define _MPFR_H_HAVE_FILE 1 |
1072 | |
1073 | #if defined (__cplusplus) |
1074 | extern "C"{ |
1075 | #endif |
1076 | |
1077 | #define mpfr_inp_str __gmpfr_inp_str |
1078 | #define mpfr_out_str __gmpfr_out_str |
1079 | __MPFR_DECLSPEC size_t mpfr_inp_str (mpfr_ptr, FILE*, int, mpfr_rnd_t); |
1080 | __MPFR_DECLSPEC size_t mpfr_out_str (FILE*, int, size_t, mpfr_srcptr, |
1081 | mpfr_rnd_t); |
1082 | #ifndef MPFR_USE_MINI_GMP |
1083 | #define mpfr_fprintf __gmpfr_fprintf |
1084 | __MPFR_DECLSPEC int mpfr_fprintf (FILE*, const char*, ...); |
1085 | #endif |
1086 | #define mpfr_fpif_export __gmpfr_fpif_export |
1087 | #define mpfr_fpif_import __gmpfr_fpif_import |
1088 | __MPFR_DECLSPEC int mpfr_fpif_export (FILE*, mpfr_ptr); |
1089 | __MPFR_DECLSPEC int mpfr_fpif_import (mpfr_ptr, FILE*); |
1090 | |
1091 | #if defined (__cplusplus) |
1092 | } |
1093 | #endif |
1094 | |
1095 | # endif /* _MPFR_H_HAVE_FILE */ |
1096 | #endif |
1097 | |
1098 | |
1099 | /* check if <stdarg.h> has been included or if the user wants va_list */ |
1100 | #if defined (_GMP_H_HAVE_VA_LIST) || defined (MPFR_USE_VA_LIST) |
1101 | # ifndef _MPFR_H_HAVE_VA_LIST |
1102 | # define _MPFR_H_HAVE_VA_LIST 1 |
1103 | |
1104 | #if defined (__cplusplus) |
1105 | extern "C"{ |
1106 | #endif |
1107 | |
1108 | #define mpfr_vprintf __gmpfr_vprintf |
1109 | #define mpfr_vasprintf __gmpfr_vasprintf |
1110 | #define mpfr_vsprintf __gmpfr_vsprintf |
1111 | #define mpfr_vsnprintf __gmpfr_vsnprintf |
1112 | __MPFR_DECLSPEC int mpfr_vprintf (const char*, va_list); |
1113 | __MPFR_DECLSPEC int mpfr_vasprintf (char**, const char*, va_list); |
1114 | __MPFR_DECLSPEC int mpfr_vsprintf (char*, const char*, va_list); |
1115 | __MPFR_DECLSPEC int mpfr_vsnprintf (char*, size_t, const char*, va_list); |
1116 | |
1117 | #if defined (__cplusplus) |
1118 | } |
1119 | #endif |
1120 | |
1121 | # endif /* _MPFR_H_HAVE_VA_LIST */ |
1122 | #endif |
1123 | |
1124 | |
1125 | /* check if <stdarg.h> has been included and if FILE is available |
1126 | (see above) */ |
1127 | #if defined (_MPFR_H_HAVE_VA_LIST) && defined (_MPFR_H_HAVE_FILE) |
1128 | # ifndef _MPFR_H_HAVE_VA_LIST_FILE |
1129 | # define _MPFR_H_HAVE_VA_LIST_FILE 1 |
1130 | |
1131 | #if defined (__cplusplus) |
1132 | extern "C"{ |
1133 | #endif |
1134 | |
1135 | #define mpfr_vfprintf __gmpfr_vfprintf |
1136 | __MPFR_DECLSPEC int mpfr_vfprintf (FILE*, const char*, va_list); |
1137 | |
1138 | #if defined (__cplusplus) |
1139 | } |
1140 | #endif |
1141 | |
1142 | # endif /* _MPFR_H_HAVE_VA_LIST_FILE */ |
1143 | #endif |
1144 |
Warning: That file was not part of the compilation database. It may have many parsing errors.