-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathmpfr.idl
412 lines (348 loc) · 19.3 KB
/
mpfr.idl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
/* -*- mode: c -*- */
/* This file is part of the MLGmpIDL interface, released under LGPL license
with an exception allowing the redistribution of statically linked
executables.
Please read the COPYING file packaged in the distribution */
quote(C, "\n\
#include \"caml/custom.h\"\n\
#include \"gmp_caml.h\"\n\
")
import "mpz.idl";
import "mpq.idl";
import "mpf.idl";
typedef [abstract,c2ml(camlidl_mpfr_ptr_c2ml),ml2c(camlidl_mpfr_ptr_ml2c)] struct __mpfr_struct* mpfr_ptr;
typedef [abstract,c2ml(camlidl_mpfr_ptr_c2ml),ml2c(camlidl_mpfr_ptr_ml2c)] struct __mpfr_struct* mpfr_ptrm;
quote(MLMLI,"(** MPFR multi-precision floating-point numbers *)\n\n")
quote(MLMLI,"\n\
type m (** Mutable tag *)\n\
type f (** Functional (immutable) tag *)\n\
type t = m tt (** Mutable multi-precision floating-point numbers *)\n\
")
typedef [mltype("\n | Near\n | Zero\n | Up\n | Down\n | Away\n | Faith\n | NearAway"), c2ml(camlidl_mpfr_rnd_t_c2ml),ml2c(camlidl_mpfr_rnd_t_ml2c)] struct mpfr_rnd_t mpfr_rnd_t;
quote(MLMLI,"(** The following operations are mapped as much as possible to their C counterpart. In case of imperative functions (like [set], [add], ...) the first parameter of type [t] is an out-parameter and holds the result when the function returns. For instance, [add x y z] adds the values of [y] and [z] and stores the result in [x].\n\n These functions are as efficient as their C counterpart: they do not imply additional memory allocation. *)\n\n")
/* OUTOUTOUT is a reserved variable name ! (see Makefile and sedscript_c) */
quote(MLI,"\n(** {2 Pretty printing} *)\n")
quote(MLI,"val print : Format.formatter -> 'a tt -> unit")
quote(MLI,"val print_round : Format.formatter -> round -> unit")
quote(MLI,"val string_of_round : round -> string")
quote(MLMLI,"\n(** {2 Rounding Modes} *)")
quote(MLMLI,"(** {{:http://www.mpfr.org/mpfr-current/mpfr.html#Rounding-Related-Functions}C documentation} *)\n")
void mpfr_set_default_rounding_mode (mpfr_rnd_t RND);
mpfr_rnd_t mpfr_get_default_rounding_mode (void);
int mpfr_round_prec (mpfr_ptrm X, mpfr_rnd_t RND, unsigned long int PREC);
quote(MLMLI,"\n(** {2 Exceptions} *)")
quote(MLMLI,"(** {{:http://www.mpfr.org/mpfr-current/mpfr.html#Exception-Related-Functions}C documentation} *)\n")
long int mpfr_get_emin (void);
long int mpfr_get_emax (void);
void mpfr_set_emin (long int EXP)
quote(call,"{\n\
int n = mpfr_set_emin(EXP);\n\
if (n){ caml_invalid_argument(\"\"); }\n\
}");
void mpfr_set_emax (long int EXP)
quote(call,"{\n\
int n = mpfr_set_emax(EXP);\n\
if (n){ caml_invalid_argument(\"\"); }\n\
}");
int mpfr_check_range (mpfr_ptrm X, int T, mpfr_rnd_t RND);
int mpfr_subnormalize (mpfr_ptr X, int T, mpfr_rnd_t RND);
void mpfr_clear_underflow (void);
void mpfr_clear_overflow (void);
void mpfr_clear_nanflag (void);
void mpfr_clear_inexflag (void);
void mpfr_clear_flags (void);
boolean mpfr_underflow_p (void);
boolean mpfr_overflow_p (void);
boolean mpfr_nanflag_p (void);
boolean mpfr_inexflag_p (void);
quote(MLMLI,"\n(** {2 Initialization Functions} *)")
quote(MLMLI,"(** {{:http://www.mpfr.org/mpfr-current/mpfr.html#Initialization-Functions}C documentation} *)\n")
void mpfr_set_default_prec (unsigned long int PREC);
unsigned long int mpfr_get_default_prec (void);
void mpfr_init ([out] mpfr_ptr OUTOUTOUT);
void mpfr_init2 ([out] mpfr_ptr OUTOUTOUT, unsigned long int PREC);
unsigned long int mpfr_get_prec (mpfr_ptr OP);
void mpfr_set_prec (mpfr_ptrm ROP, unsigned long int PREC);
void mpfr_set_prec_raw (mpfr_ptrm ROP, unsigned long int PREC);
quote(MLMLI,"\n(** {2 Assignment Functions} *)")
quote(MLMLI,"(** {{:http://www.mpfr.org/mpfr-current/mpfr.html#Assignment-Functions}C documentation} *)\n")
int mpfr_set (mpfr_ptrm ROP, mpfr_ptr OP, mpfr_rnd_t RND);
int mpfr_set_si (mpfr_ptrm ROP, signed long int OP, mpfr_rnd_t RND);
int mpfr_set_d (mpfr_ptrm ROP, double OP, mpfr_rnd_t RND);
int mpfr_set_z (mpfr_ptrm ROP, mpz_ptr OP, mpfr_rnd_t RND);
int mpfr_set_q (mpfr_ptrm ROP, mpq_ptr OP, mpfr_rnd_t RND)
quote(call,"\n\
_res = (mpz_sgn(mpq_denref(OP)))\n\
? mpfr_set_q(ROP,OP,RND)\n\
: (mpfr_set_inf(ROP,mpq_sgn(OP)), 0);\n\
");
void mpfr__set_str (mpfr_ptrm ROP, [string]const char *STR, int BASE, mpfr_rnd_t RND)
quote(call,"{\n\
int n = mpfr_set_str(ROP,STR,BASE,RND);\n\
if (n){ caml_invalid_argument(\"\"); }\n\
}");
quote(MLI,"val set_str : t -> string -> base:int -> mpfr_rnd_t -> unit")
quote(ML,"let set_str a b ~base round = _set_str a b base round")
int mpfr__strtofr ([out]int ENDINDEX,mpfr_ptrm ROP, [string]const char *STR, int BASE, mpfr_rnd_t RND)
quote(call,"{\n\
char *endptr;\n \
_res = mpfr_strtofr(ROP,STR,&endptr,BASE,RND);\n \
ENDINDEX = (endptr == NULL) ? 0 : (endptr - STR);\n\
}");
quote(MLI,"val strtofr : t -> string -> base:int -> mpfr_rnd_t -> int * int\n\
(** As MPFR's strtofr, but returns a pair [(r,i)] where [r] is the usual\n\
ternary result, and [i] is the index in the string of the first not-read\n\
character. Thus, [i=0] when no number could be read at all, and is\n\
equal to the length of the string if everything was read.\n\
*)\n")
quote(ML,"let strtofr a b ~base round = _strtofr a b base round")
int mpfr_set_f (mpfr_ptrm X, mpf_ptr Y, mpfr_rnd_t RND);
int mpfr_set_si_2exp (mpfr_ptrm ROP, signed long int OP, signed long int EXPNT, mpfr_rnd_t RND);
void mpfr_set_inf (mpfr_ptrm X, int SIGN);
void mpfr_set_nan (mpfr_ptrm X);
void mpfr_swap (mpfr_ptrm ROP1, mpfr_ptrm ROP2);
quote(MLMLI,"\n(** {2 Combined Initialization and Assignment Functions} *)")
quote(MLMLI,"(** {{:http://www.mpfr.org/mpfr-current/mpfr.html#Combined-Initialization-and-Assignment-Functions}C documentation} *)\n")
int mpfr_init_set ([out] mpfr_ptr OUTOUTOUT, mpfr_ptr OP, mpfr_rnd_t RND);
int mpfr_init_set_si ([out] mpfr_ptr OUTOUTOUT, signed long int OP, mpfr_rnd_t RND);
int mpfr_init_set_d ([out] mpfr_ptr OUTOUTOUT, double OP, mpfr_rnd_t RND);
int mpfr_init_set_f ([out] mpfr_ptr OUTOUTOUT, mpf_ptr OP, mpfr_rnd_t RND);
int mpfr_init_set_z ([out] mpfr_ptr OUTOUTOUT, mpz_ptr OP, mpfr_rnd_t RND);
int mpfr_init_set_q ([out] mpfr_ptr OUTOUTOUT, mpq_ptr OP, mpfr_rnd_t RND)
quote(call,"\n\
if (mpz_sgn(mpq_denref(OP)))\n\
_res = mpfr_init_set_q(OUTOUTOUT,OP,RND);\n\
else {\n\
mpfr_init(OUTOUTOUT);\n\
mpfr_set_inf(OUTOUTOUT,mpq_sgn(OP));\n\
_res = 0;\n\
}");
void mpfr__init_set_str ([out] mpfr_ptr OUTOUTOUT, [string]const char *STR, int BASE, mpfr_rnd_t RND)
quote(call,"\
{\n\
int n = mpfr_init_set_str(OUTOUTOUT,STR,BASE,RND);\n\
if (n){ mpfr_clear(OUTOUTOUT); caml_invalid_argument(\"\"); }\n\
}");
quote(MLI,"val init_set_str : string -> base:int -> mpfr_rnd_t -> 'a tt")
quote(ML,"let init_set_str a ~base round = _init_set_str a base round")
quote(MLMLI,"\n(** {2 Conversion Functions} *)")
quote(MLMLI,"(** {{:http://www.mpfr.org/mpfr-current/mpfr.html#Conversion-Functions}C documentation} *)\n")
double mpfr_get_d (mpfr_ptr OP, mpfr_rnd_t RND);
double mpfr_get_d1 (mpfr_ptr OP);
int mpfr_get_z_exp (mpz_ptrm Z, mpfr_ptr OP);
void mpfr_get_z (mpz_ptrm Z, mpfr_ptr OP, mpfr_rnd_t RND);
[string]char* mpfr__get_str ([out]long int *EXPPTR, int BASE, int N_DIGITS, mpfr_ptr OP, mpfr_rnd_t RND)
quote(call,"_res = mpfr_get_str(NULL,EXPPTR,BASE,N_DIGITS,OP,RND);")
quote(dealloc,"mpfr_free_str(_res);");
quote(MLI,"val get_str : base:int -> digits:int -> t -> mpfr_rnd_t -> string * int")
quote(ML,"let get_str ~base ~digits a round = _get_str base digits a round")
quote(MLI,"\n(** {2 User Conversions} *)\n")
quote(MLI,"(** These functionss are additions to or renaming of functions offered by the C library. *)\n")
quote(MLI,"val to_string : 'a tt -> string")
quote(MLI,"val to_float : ?round:round -> 'a tt -> float")
quote(MLI,"val to_mpq : 'a tt -> 'b Mpq.tt")
quote(MLI,"val of_string : string -> round -> 'a tt")
quote(MLI,"val of_float : float -> round -> 'a tt")
quote(MLI,"val of_int : int -> round -> 'a tt")
quote(MLI,"val of_frac : int -> int -> round -> 'a tt")
quote(MLI,"val of_mpz : 'a Mpz.tt -> round -> 'b tt")
quote(MLI,"val of_mpz2 : 'a Mpz.tt -> 'b Mpz.tt -> round -> 'c tt")
quote(MLI,"val of_mpq : 'a Mpq.tt -> round -> 'b tt")
quote(MLMLI,"\n(** {2 Basic Arithmetic Functions} *)")
quote(MLMLI,"(** {{:http://www.mpfr.org/mpfr-current/mpfr.html#Basic-Arithmetic-Functions}C documentation} *)\n")
int mpfr_add (mpfr_ptrm ROP, mpfr_ptr OP1, mpfr_ptr OP2, mpfr_rnd_t RND);
int mpfr_add_ui (mpfr_ptrm ROP, mpfr_ptr OP1, unsigned long int OP2, mpfr_rnd_t RND);
int mpfr_add_z (mpfr_ptrm ROP, mpfr_ptr OP1, mpz_ptr OP2, mpfr_rnd_t RND);
int mpfr_add_q (mpfr_ptrm ROP, mpfr_ptr OP1, mpq_ptr OP2, mpfr_rnd_t RND);
int mpfr_sub (mpfr_ptrm ROP, mpfr_ptr OP1, mpfr_ptr OP2, mpfr_rnd_t RND);
int mpfr_ui_sub (mpfr_ptrm ROP, unsigned long int OP1, mpfr_ptr OP2, mpfr_rnd_t RND);
int mpfr_sub_ui (mpfr_ptrm ROP, mpfr_ptr OP1, unsigned long int OP2, mpfr_rnd_t RND);
int mpfr_sub_z (mpfr_ptrm ROP, mpfr_ptr OP1, mpz_ptr OP2, mpfr_rnd_t RND);
int mpfr_sub_q (mpfr_ptrm ROP, mpfr_ptr OP1, mpq_ptr OP2, mpfr_rnd_t RND);
int mpfr_mul (mpfr_ptrm ROP, mpfr_ptr OP1, mpfr_ptr OP2, mpfr_rnd_t RND);
int mpfr_mul_ui (mpfr_ptrm ROP, mpfr_ptr OP1, unsigned long int OP2, mpfr_rnd_t RND);
int mpfr_mul_si (mpfr_ptrm ROP, mpfr_ptr OP1, signed long int OP2, mpfr_rnd_t RND);
int mpfr_mul_d (mpfr_ptrm ROP, mpfr_ptr OP1, double OP2, mpfr_rnd_t RND);
int mpfr_mul_z (mpfr_ptrm ROP, mpfr_ptr OP1, mpz_ptr OP2, mpfr_rnd_t RND);
int mpfr_mul_q (mpfr_ptrm ROP, mpfr_ptr OP1, mpq_ptr OP2, mpfr_rnd_t RND);
int mpfr_mul_2ui (mpfr_ptrm ROP, mpfr_ptr OP1, unsigned long int OP2, mpfr_rnd_t RND);
int mpfr_mul_2si (mpfr_ptrm ROP, mpfr_ptr OP1, long int OP2, mpfr_rnd_t RND);
int mpfr_mul_2exp (mpfr_ptrm ROP, mpfr_ptr OP1, unsigned long int OP2, mpfr_rnd_t RND);
int mpfr_sqr (mpfr_ptrm ROP, mpfr_ptr OP, mpfr_rnd_t RND);
int mpfr_div (mpfr_ptrm ROP, mpfr_ptr OP1, mpfr_ptr OP2, mpfr_rnd_t RND);
int mpfr_ui_div (mpfr_ptrm ROP, unsigned long int OP1, mpfr_ptr OP2, mpfr_rnd_t RND);
int mpfr_div_ui (mpfr_ptrm ROP, mpfr_ptr OP1, unsigned long int OP2, mpfr_rnd_t RND);
int mpfr_div_z (mpfr_ptrm ROP, mpfr_ptr OP1, mpz_ptr OP2, mpfr_rnd_t RND);
int mpfr_div_q (mpfr_ptrm ROP, mpfr_ptr OP1, mpq_ptr OP2, mpfr_rnd_t RND);
int mpfr_div_2ui (mpfr_ptrm ROP, mpfr_ptr OP1, unsigned long int OP2, mpfr_rnd_t RND);
int mpfr_div_2si (mpfr_ptrm ROP, mpfr_ptr OP1, long int OP2, mpfr_rnd_t RND);
quote(MLI,"val div_2exp : t -> t -> int -> mpfr_rnd_t -> int")
quote(ML,"let div_2exp = div_2ui")
int mpfr_sqrt (mpfr_ptrm ROP, mpfr_ptr OP, mpfr_rnd_t RND);
int mpfr_sqrt_ui (mpfr_ptrm ROP, unsigned long int OP, mpfr_rnd_t RND);
int mpfr_rec_sqrt (mpfr_ptrm ROP, mpfr_ptr OP, mpfr_rnd_t RND);
int mpfr_pow_ui (mpfr_ptrm ROP, mpfr_ptr OP1, unsigned long int OP2, mpfr_rnd_t RND);
int mpfr_pow_si (mpfr_ptrm ROP, mpfr_ptr OP1, signed long int OP2, mpfr_rnd_t RND);
int mpfr_ui_pow_ui (mpfr_ptrm ROP, unsigned long int OP1, unsigned long int OP2, mpfr_rnd_t RND);
int mpfr_ui_pow (mpfr_ptrm ROP, unsigned long int OP1, mpfr_ptr OP2, mpfr_rnd_t RND);
int mpfr_pow (mpfr_ptrm ROP, mpfr_ptr OP1, mpfr_ptr OP2, mpfr_rnd_t RND);
int mpfr_neg (mpfr_ptrm ROP, mpfr_ptr OP, mpfr_rnd_t RND);
int mpfr_abs (mpfr_ptrm ROP, mpfr_ptr OP, mpfr_rnd_t RND);
int mpfr_cbrt (mpfr_ptrm ROP, mpfr_ptr OP, mpfr_rnd_t RND);
#if MPFR_VERSION_MAJOR >= 4
int mpfr_rootn_ui (mpfr_ptrm ROP, mpfr_ptr OP1, unsigned long int OP2, mpfr_rnd_t RND);
quote(MLI,"[@@ocaml.deprecated \"Please use `Mpfr.rootn_ui' instead!\"]");
#else
/* Provide `rootn_ui' anyways, for consistency of interface whatever the
underlying MPFR version, and convenience in upgrading to MPFR >= 4. */
int mpfr_rootn_ui (mpfr_ptrm ROP, mpfr_ptr OP1, unsigned long int OP2, mpfr_rnd_t RND)
quote(call, " _res = mpfr_root (ROP, OP1, OP2, RND);");
quote(MLI,"[@@ocaml.deprecated \"Binds to `mpfr_root', which is not IEEE 754-2008 compliant and is deprecated as of MPFR version 4. You should upgrade MPFR, and use `Mpfr.rootn_ui' instead.\"]");
#endif
int mpfr_root (mpfr_ptrm ROP, mpfr_ptr OP1, unsigned long int OP2, mpfr_rnd_t RND);
quote(MLMLI,"\n(** {2 Comparison Functions} *)")
quote(MLMLI,"(** {{:http://www.mpfr.org/mpfr-current/mpfr.html#Comparison-Functions}C documentation} *)\n")
int mpfr_cmp (mpfr_ptr OP1, mpfr_ptr OP2);
int mpfr_cmp_si (mpfr_ptr OP1, signed long int OP2);
int mpfr_cmp_si_2exp (mpfr_ptr OP1, long int OP2, int E);
int mpfr_sgn (mpfr_ptr OP);
int mpfr_signbit (mpfr_ptr OP);
boolean mpfr__equal (mpfr_ptr OP1, mpfr_ptr OP2, unsigned long int OP3)
quote(call,"_res=mpfr_eq(OP1,OP2,OP3);");
quote(MLI,"val equal : 'a tt -> 'b tt -> bits:int -> bool")
quote(ML,"let equal a b ~bits = _equal a b bits")
boolean mpfr_nan_p (mpfr_ptr OP);
boolean mpfr_inf_p (mpfr_ptr OP);
boolean mpfr_number_p (mpfr_ptr OP);
boolean mpfr_zero_p (mpfr_ptr OP);
void mpfr_reldiff (mpfr_ptrm ROP, mpfr_ptr OP1, mpfr_ptr OP2, mpfr_rnd_t RND);
quote(MLMLI,"\n(** {2 Special Functions} *)")
quote(MLMLI,"(** {{:http://www.mpfr.org/mpfr-current/mpfr.html#Special-Functions}C documentation} *)\n")
int mpfr_log (mpfr_ptrm ROP, mpfr_ptr OP, mpfr_rnd_t RND);
int mpfr_log2 (mpfr_ptrm ROP, mpfr_ptr OP, mpfr_rnd_t RND);
int mpfr_log10 (mpfr_ptrm ROP, mpfr_ptr OP, mpfr_rnd_t RND);
int mpfr_exp (mpfr_ptrm ROP, mpfr_ptr OP, mpfr_rnd_t RND);
int mpfr_exp2 (mpfr_ptrm ROP, mpfr_ptr OP, mpfr_rnd_t RND);
int mpfr_exp10 (mpfr_ptrm ROP, mpfr_ptr OP, mpfr_rnd_t RND);
int mpfr_cos (mpfr_ptr COP, mpfr_ptr OP, mpfr_rnd_t RND);
int mpfr_sin (mpfr_ptr SOP, mpfr_ptr OP, mpfr_rnd_t RND);
int mpfr_tan (mpfr_ptr TOP, mpfr_ptr OP, mpfr_rnd_t RND);
int mpfr_sec (mpfr_ptr COP, mpfr_ptr OP, mpfr_rnd_t RND);
int mpfr_csc (mpfr_ptr SOP, mpfr_ptr OP, mpfr_rnd_t RND);
int mpfr_cot (mpfr_ptr TOP, mpfr_ptr OP, mpfr_rnd_t RND);
int mpfr_sin_cos (mpfr_ptr SOP, mpfr_ptr COP, mpfr_ptr OP, mpfr_rnd_t RND);
int mpfr_acos (mpfr_ptrm ROP, mpfr_ptr OP, mpfr_rnd_t RND);
int mpfr_asin (mpfr_ptrm ROP, mpfr_ptr OP, mpfr_rnd_t RND);
int mpfr_atan (mpfr_ptrm ROP, mpfr_ptr OP, mpfr_rnd_t RND);
int mpfr_atan2 (mpfr_ptrm ROP, mpfr_ptr Y, mpfr_ptr X, mpfr_rnd_t RND);
int mpfr_cosh (mpfr_ptr COP, mpfr_ptr OP, mpfr_rnd_t RND);
int mpfr_sinh (mpfr_ptr SOP, mpfr_ptr OP, mpfr_rnd_t RND);
int mpfr_tanh (mpfr_ptr TOP, mpfr_ptr OP, mpfr_rnd_t RND);
int mpfr_sech (mpfr_ptr COP, mpfr_ptr OP, mpfr_rnd_t RND);
int mpfr_csch (mpfr_ptr SOP, mpfr_ptr OP, mpfr_rnd_t RND);
int mpfr_coth (mpfr_ptr TOP, mpfr_ptr OP, mpfr_rnd_t RND);
int mpfr_acosh (mpfr_ptrm ROP, mpfr_ptr OP, mpfr_rnd_t RND);
int mpfr_asinh (mpfr_ptrm ROP, mpfr_ptr OP, mpfr_rnd_t RND);
int mpfr_atanh (mpfr_ptrm ROP, mpfr_ptr OP, mpfr_rnd_t RND);
int mpfr_fac_ui (mpfr_ptrm ROP, unsigned long int OP, mpfr_rnd_t RND);
int mpfr_log1p (mpfr_ptrm ROP, mpfr_ptr OP, mpfr_rnd_t RND);
int mpfr_expm1 (mpfr_ptrm ROP, mpfr_ptr OP, mpfr_rnd_t RND);
int mpfr_eint (mpfr_ptrm Y, mpfr_ptr X, mpfr_rnd_t RND);
int mpfr_gamma (mpfr_ptrm ROP, mpfr_ptr OP, mpfr_rnd_t RND);
int mpfr_lngamma (mpfr_ptrm ROP, mpfr_ptr OP, mpfr_rnd_t RND);
int mpfr_lgamma (mpfr_ptrm ROP, [out]signed int *SIGNP, mpfr_ptr OP, mpfr_rnd_t RND);
int mpfr_zeta (mpfr_ptrm ROP, mpfr_ptr OP, mpfr_rnd_t RND);
int mpfr_erf (mpfr_ptrm ROP, mpfr_ptr OP, mpfr_rnd_t RND);
int mpfr_erfc (mpfr_ptrm ROP, mpfr_ptr OP, mpfr_rnd_t RND);
int mpfr_j0 (mpfr_ptrm ROP, mpfr_ptr OP, mpfr_rnd_t RND);
int mpfr_j1 (mpfr_ptrm ROP, mpfr_ptr OP, mpfr_rnd_t RND);
int mpfr_jn (mpfr_ptrm ROP, long int n, mpfr_ptr OP, mpfr_rnd_t RND);
int mpfr_y0 (mpfr_ptrm ROP, mpfr_ptr OP, mpfr_rnd_t RND);
int mpfr_y1 (mpfr_ptrm ROP, mpfr_ptr OP, mpfr_rnd_t RND);
int mpfr_yn (mpfr_ptrm ROP, long int n, mpfr_ptr OP, mpfr_rnd_t RND);
int mpfr_fma (mpfr_ptrm ROP, mpfr_ptr OPX,mpfr_ptr OPY, mpfr_ptr OPZ, mpfr_rnd_t RND);
int mpfr_fms (mpfr_ptrm ROP, mpfr_ptr OPX,mpfr_ptr OPY, mpfr_ptr OPZ, mpfr_rnd_t RND);
int mpfr_agm (mpfr_ptrm ROP, mpfr_ptr OP1, mpfr_ptr OP2, mpfr_rnd_t RND);
int mpfr_hypot (mpfr_ptrm ROP, mpfr_ptr X, mpfr_ptr Y, mpfr_rnd_t RND);
int mpfr_const_log2 (mpfr_ptrm ROP, mpfr_rnd_t RND);
int mpfr_const_pi (mpfr_ptrm ROP, mpfr_rnd_t RND);
int mpfr_const_euler (mpfr_ptrm ROP, mpfr_rnd_t RND);
int mpfr_const_catalan (mpfr_ptrm ROP, mpfr_rnd_t RND);
quote(MLMLI,"\n(** {2 Formatted Output Functions} *)\n")
quote(C, "\n\
signed int mpfr__sprintf(char *s, const char * s2, mpfr_rnd_t r, mpfr_ptr x){\n\
return mpfr_sprintf(s,s2,r, x);\n\
}\n\
")
quote(MLI,"[@@ocaml.deprecated \"Breaks safe strings assumption\"]");
signed int mpfr__sprintf ([string]char *STR, [string]const char *TEMPLATE, mpfr_rnd_t RND, mpfr_ptr OP);
quote(MLI,"[@@ocaml.deprecated \"Breaks safe strings assumption\"]");
quote(MLI,"val sprintf : buf:string -> template:string -> mpfr_rnd_t -> 'a tt -> int\n\
(** Call sprintf with the given format string and arguments. The format string must\n\
contain exactly one conversion specification, which must be of [mpfr_t] type and\n\
must take a rounding mode argument (i.e., it must use the '*' rounding specifier),\n\
for example: [\"%R*A\"].\n\
*)")
quote(ML,"let sprintf ~buf ~template round a = _sprintf buf template round a")
quote(MLMLI,"\n(** {2 Miscellaneous Float Functions} *)")
quote(MLMLI,"(** {{:http://www.mpfr.org/mpfr-current/mpfr.html#Rounding-Related-Functions}C documentation} *)\n")
int mpfr_rint (mpfr_ptrm ROP, mpfr_ptr OP, mpfr_rnd_t RND);
int mpfr_ceil (mpfr_ptrm ROP, mpfr_ptr OP);
int mpfr_floor (mpfr_ptrm ROP, mpfr_ptr OP);
int mpfr_round (mpfr_ptrm ROP, mpfr_ptr OP);
int mpfr_trunc (mpfr_ptrm ROP, mpfr_ptr OP);
int mpfr_frac (mpfr_ptrm ROP, mpfr_ptr OP, mpfr_rnd_t RND);
int mpfr_modf (mpfr_ptrm IOP, mpfr_ptrm FOP, mpfr_ptr OP, mpfr_rnd_t RND);
int mpfr_fmod (mpfr_ptrm ROP, mpfr_ptr OP1, mpfr_ptr OP2, mpfr_rnd_t RND);
int mpfr_remainder (mpfr_ptrm ROP, mpfr_ptr OP1, mpfr_ptr OP2, mpfr_rnd_t RND);
boolean mpfr_integer_p (mpfr_ptr OP);
void mpfr_nexttoward (mpfr_ptrm X, mpfr_ptr Y);
void mpfr_nextabove (mpfr_ptrm X);
void mpfr_nextbelow (mpfr_ptrm X);
int mpfr_min (mpfr_ptrm ROP, mpfr_ptr OP1, mpfr_ptr OP2, mpfr_rnd_t RND);
int mpfr_max (mpfr_ptrm ROP, mpfr_ptr OP1, mpfr_ptr OP2, mpfr_rnd_t RND);
int mpfr_get_exp (mpfr_ptr X);
int mpfr_set_exp (mpfr_ptrm X, signed long int E);
quote(ML,"\n(** {2 Additional functions} *)\n")
quote(ML,"let to_string x = \n \
let (s,e) = get_str ~base:10 ~digits:0 x Near in\n \
if not (number_p x) then s\n \
else if s = \"\" then \"0.\" \n \
else if s.[0] = '-'\n \
then Format.sprintf \"-0.%sE%i\" String.(sub s 1 (length s - 1)) e\n \
else Format.sprintf \"0.%sE%i\" s e\n \
")
quote(ML,"\n(** {2 Pretty printing} *)\n")
quote(ML,"let print fmt x = \n \
Format.pp_print_string fmt (to_string x)\n \
\n \
let string_of_round = function\n \
| Near -> \"Near\"\n \
| Zero -> \"Zero\"\n \
| Up -> \"Up\"\n \
| Down -> \"Down\"\n \
| Away -> \"Away\"\n \
| Faith -> \"Faith\"\n \
| NearAway -> \"NearAway\"\n \
let print_round fmt x = Format.pp_print_string fmt (string_of_round x)\n \
")
quote(ML,"let to_float ?round x = \n\
match round with\n\
| None -> get_d1 x\n\
| Some r -> get_d x r\n\
")
quote(ML,"let to_mpq x = \n\
let num,den = Mpz.init(), Mpz.init_set_si 1 in\n\
let e = get_z_exp num x in\n\
if e < 0\n\
then Mpz.mul_2exp den den ~-e\n\
else Mpz.mul_2exp num num e;\n\
Mpq.of_mpz2 num den\n\
")
quote(ML,"let of_int x r = snd (init_set_si x r)")
quote(ML,"let of_float x r = snd (init_set_d x r)")
quote(ML,"let of_mpz x r = snd (init_set_z x r)")
quote(ML,"let of_mpq x r = snd (init_set_q x r)")
quote(ML,"let of_string x r = init_set_str x ~base:10 r")
quote(ML,"let of_frac n d r = let mpq = Mpq.of_frac n d in of_mpq mpq r")
quote(ML,"let of_mpz2 n d r = let mpq = Mpq.of_mpz2 n d in of_mpq mpq r")