Build Fix -- compatibility issue with newer autoconf
[sxemacs] / src / ent / ent-mpc.c
1 /*
2   ent-mpc.c -- Numeric types for SXEmacs
3   Copyright (C) 2005, 2006 Sebastian Freundt
4
5   Author:  Sebastian Freundt
6
7 This file is part of SXEmacs
8
9 SXEmacs is free software: you can redistribute it and/or modify
10 it under the terms of the GNU General Public License as published by
11 the Free Software Foundation, either version 3 of the License, or
12 (at your option) any later version.
13
14 SXEmacs is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17 GNU General Public License for more details.
18
19 You should have received a copy of the GNU General Public License
20 along with this program.  If not, see <http://www.gnu.org/licenses/>. */
21
22
23 #include <config.h>
24 #include <limits.h>
25 #include <math.h>
26 #include "lisp.h"
27 #include "sysproc.h"    /* For qxe_getpid */
28
29 #include "ent.h"
30 #include "ent-mpfr.h"
31 #include "ent-mpc.h"
32
33 bigc ent_scratch_bigc;
34 static ase_nullary_operation_f Qent_mpc_zero, Qent_mpc_one;
35
36 \f
37 static void
38 bigc_print (Lisp_Object obj, Lisp_Object printcharfun, int SXE_UNUSED(escapeflag))
39 {
40         Bufbyte *fstr = bigc_to_string(XBIGC_DATA(obj), 10);
41         write_c_string((char*)fstr, printcharfun);
42         xfree(fstr);
43         fstr = (Bufbyte *)NULL;
44         return;
45 }
46
47 static int
48 bigc_equal (Lisp_Object obj1, Lisp_Object obj2, int SXE_UNUSED(depth))
49 {
50         return bigc_eq(XBIGC_DATA(obj1), XBIGC_DATA(obj2));
51 }
52
53 static unsigned long
54 bigc_hash (Lisp_Object obj, int SXE_UNUSED(depth))
55 {
56         return bigc_hashcode(XBIGC_DATA(obj));
57 }
58
59 static Lisp_Object
60 bigc_mark (Lisp_Object SXE_UNUSED(obj))
61 {
62         return Qnil;
63 }
64
65 static void
66 bigc_finalise (void *SXE_UNUSED(header), int for_disksave)
67 {
68         if (for_disksave)
69                 signal_simple_error
70                         ("Can't dump an emacs containing MPC objects",Qt);
71 }
72
73 static const struct lrecord_description bigc_description[] = {
74         { XD_OPAQUE_DATA_PTR, offsetof(Lisp_Bigc, data) },
75         { XD_END }
76 };
77
78 #if ! defined(HAVE_MPC_SET_UI_FR) || ! HAVE_MPC_SET_UI_FR
79 #if defined(MPC_SET_X_Y)
80 int mpc_set_ui_fr (mpc_t rop, unsigned long int re, mpfr_t im, mpc_rnd_t rnd)
81               MPC_SET_X_Y (ui, fr, rop, re, im, rnd);
82 #else
83 #error Cannot derived mpc_set_ui_fr without MPC_SET_X_Y!
84 #endif
85 #endif
86
87 DEFINE_BASIC_LRECORD_IMPLEMENTATION("bigc", bigc,
88                                     bigc_mark, bigc_print, bigc_finalise,
89                                     bigc_equal, bigc_hash,
90                                     bigc_description, Lisp_Bigc);
91
92
93
94 DEFUN ("bigc-get-precision", Fbigc_get_precision, 1, 1, 0, /*
95 Return the precision of bigc C as an integer.
96 */
97        (c))
98 {
99         CHECK_BIGC(c);
100         return make_integer((signed long)XBIGC_GET_PREC(c));
101 }
102
103 DEFUN ("bigc-set-precision", Fbigc_set_precision, 2, 2, 0, /*
104 Set the precision of C, a bigc, to PRECISION, a nonnegative integer.
105 The new precision of C is returned.  Note that the return value may differ
106 from PRECISION if the underlying library is unable to support exactly
107 PRECISION bits of precision.
108 */
109        (c, precision))
110 {
111         unsigned long prec;
112
113         CHECK_BIGC(c);
114         if (INTP(precision)) {
115                 prec = (XINT(precision) <= 0)
116                         ? MPFR_PREC_MIN : (unsigned long)XINT(precision);
117         }
118 #if defined HAVE_MPZ && (defined WITH_GMP || defined WITH_MP)
119         else if (BIGZP(precision)) {
120                 prec = bigz_fits_ulong_p(XBIGZ_DATA(precision))
121                         ? bigz_to_ulong(XBIGZ_DATA(precision))
122                         : UINT_MAX;
123         }
124 #endif  /* HAVE_MPZ */
125         else {
126                 dead_wrong_type_argument(Qintegerp, c);
127                 return Qnil;
128         }
129
130         XBIGC_SET_PREC(c, prec);
131         return Fbigc_get_precision(c);
132 }
133
134 DEFUN ("make-bigc", Fmake_bigc, 2, 2, 0, /*
135 Return the bigc number whose real component is REAL-PART and
136 whose imaginary component is IMAGINARY-PART.
137 */
138        (real_part, imaginary_part))
139 {
140         Lisp_Object result;
141
142         CHECK_COMPARABLE(real_part);
143         CHECK_COMPARABLE(imaginary_part);
144
145         real_part = Fcoerce_number(
146                 real_part, Qbigfr, Qnil);
147         imaginary_part = Fcoerce_number(
148                 imaginary_part, Qbigfr, Qnil);
149
150         /* check if one of the components is not-a-number
151          * set both components NaN in that case
152          */
153         if (bigfr_nan_p(XBIGFR_DATA(real_part)) ||
154             bigfr_nan_p(XBIGFR_DATA(imaginary_part))) {
155                 bigfr_set_nan(XBIGFR_DATA(real_part));
156                 bigfr_set_nan(XBIGFR_DATA(imaginary_part));
157         } else if (bigfr_inf_p(XBIGFR_DATA(real_part)) ||
158                    bigfr_inf_p(XBIGFR_DATA(imaginary_part))) {
159                 bigfr_set_pinf(XBIGFR_DATA(real_part));
160                 bigfr_set_pinf(XBIGFR_DATA(imaginary_part));
161         }
162
163         result =  make_bigc_bfr(XBIGFR_DATA(real_part),
164                                 XBIGFR_DATA(imaginary_part),
165                                 internal_get_precision(Qnil));
166
167         return result;
168 }
169
170 \f
171 int bigc_nan_p(bigc c)
172 {
173         return (bigfr_nan_p(bigc_re(c)) ||
174                 bigfr_nan_p(bigc_im(c)));
175 }
176
177 int bigc_inf_p(bigc c)
178 {
179         return (bigfr_inf_p(bigc_re(c)) ||
180                 bigfr_inf_p(bigc_im(c)));
181 }
182
183 \f
184 Bufbyte *bigc_to_string(mpc_t c, int base)
185 {
186         Bufbyte *re_str;
187         Bufbyte *im_str;
188         int re_len, im_len;
189
190         /* if one of the components is infinity or not a number,
191          * just print the respective component
192          * +infinity+2i does not really make sense, that's why!
193          */
194         if (bigc_nan_p(c)) {
195                 re_str = indef_to_string((indef)NOT_A_NUMBER);
196                 return re_str;
197         } else if (bigc_inf_p(c)) {
198                 re_str = indef_to_string((indef)COMPLEX_INFINITY);
199                 return re_str;
200         } else {
201                 /* fetch the components' strings */
202                 re_str = bigfr_to_string(bigc_re(c), base);
203                 im_str = bigfr_to_string(bigc_im(c), base);
204
205                 re_len = strlen((char*)re_str);
206                 im_len = strlen((char*)im_str);
207
208                 const int sign = bigfr_sign(bigc_im(c));
209                 const int neg = (sign >= 0) ? 1 : 0;
210
211                 /* now append the imaginary string */
212                 XREALLOC_ARRAY(re_str, Bufbyte, re_len + neg + im_len + 2);
213                 if (neg)
214                         re_str[re_len] = '+';
215                 memmove(&re_str[re_len + neg],
216                         &im_str[0],
217                         im_len);
218                 re_str[re_len+neg+im_len] = 'i';
219                 re_str[re_len+neg+im_len+1] = '\0';
220                 free(im_str);
221
222                 return re_str;
223         }
224 }
225
226
227 void bigc_pow(bigc res, bigc g1, unsigned long g2)
228 {
229 #if defined(HAVE_MPZ) && defined(WITH_GMP)
230         unsigned long i;
231         bigz bin;
232         bigfr binfr, resintg, resimag, tmpbz1, tmpbz2, tmpbz3, intg, imag;
233
234         bigz_init(bin);
235         bigfr_init(binfr);
236         bigfr_init(resintg);
237         bigfr_init(resimag);
238         bigfr_init(intg);
239         bigfr_init(imag);
240         bigfr_init(tmpbz1);
241         bigfr_init(tmpbz2);
242         bigfr_init(tmpbz3);
243
244         bigfr_set_long(resintg, 0L);
245         bigfr_set_long(resimag, 0L);
246
247         bigfr_set(intg, bigc_re(g1));
248         bigfr_set(imag, bigc_im(g1));
249
250         /* we compute using the binomial coefficients */
251         for (i=0; i<=g2; i++) {
252                 mpz_bin_uiui(bin, g2, i);
253                 bigfr_set_bigz(binfr, bin);
254                 if (i % 2 == 0) {
255                         /* real part changes */
256                         bigfr_pow(tmpbz1, intg, g2-i);
257                         bigfr_pow(tmpbz2, imag, i);
258                         bigfr_mul(tmpbz3, tmpbz1, tmpbz2);
259                         bigfr_mul(binfr, binfr, tmpbz3);
260                         if (i % 4 == 0) {
261                                 bigfr_add(resintg, resintg, binfr);
262                         } else if (i % 4 == 2) {
263                                 bigfr_sub(resintg, resintg, binfr);
264                         }
265                 } else {
266                         /* imag part changes */
267                         bigfr_pow(tmpbz1, intg, g2-i);
268                         bigfr_pow(tmpbz2, imag, i);
269                         bigfr_mul(tmpbz3, tmpbz1, tmpbz2);
270                         bigfr_mul(binfr, binfr, tmpbz3);
271                         if (i % 4 == 1) {
272                                 bigfr_add(resimag, resimag, binfr);
273                         } else if (i % 4 == 3) {
274                                 bigfr_sub(resimag, resimag, binfr);
275                         }
276                 }
277         }
278
279         bigc_set_bigfr_bigfr(res, resintg, resimag);
280
281         bigz_fini(bin);
282         bigfr_fini(binfr);
283         bigfr_fini(intg);
284         bigfr_fini(imag);
285         bigfr_init(resintg);
286         bigfr_init(resimag);
287         bigfr_fini(tmpbz1);
288         bigfr_fini(tmpbz2);
289         bigfr_fini(tmpbz3);
290 #else  /* !WITH_GMP */
291         bigc_set_long_long(res, 0L, 0L);
292 #endif  /* WITH_GMP */
293 }
294
295
296 /* bigc ops */
297 static int
298 ent_mpc_zerop(Lisp_Object l)
299 {
300         return (bigfr_sign(bigc_re(XBIGC_DATA(l))) == 0 &&
301                 bigfr_sign(bigc_im(XBIGC_DATA(l))) == 0);
302 }
303
304 static int
305 ent_mpc_onep(Lisp_Object l)
306 {
307         return (bigfr_to_fpfloat(bigc_re(XBIGC_DATA(l))) == 1.0f &&
308                 bigfr_sign(bigc_im(XBIGC_DATA(l))) == 0);
309 }
310
311 static int
312 ent_mpc_unitp(Lisp_Object SXE_UNUSED(unused))
313 {
314         return 1;
315 }
316
317 static Lisp_Object
318 ent_sum_BIGC_T(Lisp_Object l, Lisp_Object r)
319 {
320         bigc_set_prec(ent_scratch_bigc,
321                        max(XBIGC_GET_PREC(l), XBIGC_GET_PREC(r)));
322         bigc_add(ent_scratch_bigc, XBIGC_DATA(l), XBIGC_DATA(r));
323         return make_bigc_bc(ent_scratch_bigc);
324 }
325
326 static Lisp_Object
327 ent_sum_BIGC_T_COMPARABLE(Lisp_Object l, Lisp_Object r)
328 {
329         struct ent_lift_args_s la;
330
331         CHECK_COMPARABLE(r);
332
333         la.precision = XBIGC_GET_PREC(l);
334         r = ent_lift(r, BIGFR_T, &la);
335
336         bigc_set_prec(ent_scratch_bigc, XBIGC_GET_PREC(l));
337         bigc_set_bigfr(ent_scratch_bigc, XBIGFR_DATA(r));
338         bigc_add(ent_scratch_bigc, XBIGC_DATA(l), ent_scratch_bigc);
339         return make_bigc_bc(ent_scratch_bigc);
340 }
341
342 static Lisp_Object
343 ent_sum_COMPARABLE_BIGC_T(Lisp_Object l, Lisp_Object r)
344 {
345         return ent_sum_BIGC_T_COMPARABLE(r, l);
346 }
347
348 static Lisp_Object
349 ent_sum_BIGC_T_COMPLEX(Lisp_Object l, Lisp_Object r)
350 {
351         struct ent_lift_args_s la;
352
353         CHECK_COMPLEX(r);
354
355         la.precision = XBIGC_GET_PREC(l);
356         r = ent_lift(r, BIGC_T, &la);
357
358         return ent_sum_BIGC_T(l, r);
359 }
360
361 static Lisp_Object
362 ent_sum_COMPLEX_BIGC_T(Lisp_Object l, Lisp_Object r)
363 {
364         return ent_sum_BIGC_T_COMPLEX(r, l);
365 }
366
367 static Lisp_Object
368 ent_diff_BIGC_T(Lisp_Object l, Lisp_Object r)
369 {
370         bigc_set_prec(ent_scratch_bigc,
371                        max(XBIGC_GET_PREC(l), XBIGC_GET_PREC(r)));
372         bigc_sub(ent_scratch_bigc, XBIGC_DATA(l), XBIGC_DATA(r));
373         return make_bigc_bc(ent_scratch_bigc);
374 }
375
376 static Lisp_Object
377 ent_diff_BIGC_T_COMPARABLE(Lisp_Object l, Lisp_Object r)
378 {
379         struct ent_lift_args_s la;
380
381         CHECK_COMPARABLE(r);
382
383         la.precision = XBIGC_GET_PREC(l);
384         r = ent_lift(r, BIGFR_T, &la);
385
386         bigc_set_prec(ent_scratch_bigc, XBIGC_GET_PREC(l));
387         bigc_set_bigfr(ent_scratch_bigc, XBIGFR_DATA(r));
388         bigc_sub(ent_scratch_bigc, XBIGC_DATA(l), ent_scratch_bigc);
389         return make_bigc_bc(ent_scratch_bigc);
390 }
391
392 static Lisp_Object
393 ent_diff_COMPARABLE_BIGC_T(Lisp_Object l, Lisp_Object r)
394 {
395         struct ent_lift_args_s la;
396
397         CHECK_COMPARABLE(l);
398
399         la.precision = XBIGC_GET_PREC(r);
400         l = ent_lift(l, BIGFR_T, &la);
401
402         bigc_set_prec(ent_scratch_bigc, XBIGC_GET_PREC(r));
403         bigc_set_bigfr(ent_scratch_bigc, XBIGFR_DATA(l));
404         bigc_sub(ent_scratch_bigc, ent_scratch_bigc, XBIGC_DATA(r));
405         return make_bigc_bc(ent_scratch_bigc);
406 }
407
408 static Lisp_Object
409 ent_diff_BIGC_T_COMPLEX(Lisp_Object l, Lisp_Object r)
410 {
411         struct ent_lift_args_s la;
412
413         CHECK_COMPLEX(r);
414
415         la.precision = XBIGC_GET_PREC(l);
416         r = ent_lift(r, BIGC_T, &la);
417
418         return ent_diff_BIGC_T(l, r);
419 }
420
421 static Lisp_Object
422 ent_diff_COMPLEX_BIGC_T(Lisp_Object l, Lisp_Object r)
423 {
424         struct ent_lift_args_s la;
425
426         CHECK_COMPLEX(l);
427
428         la.precision = XBIGC_GET_PREC(r);
429         l = ent_lift(l, BIGC_T, &la);
430
431         return ent_diff_BIGC_T(l, r);
432 }
433
434 static Lisp_Object
435 ent_neg_BIGC_T(Lisp_Object l)
436 {
437         bigc_set_prec(ent_scratch_bigc, XBIGC_GET_PREC(l));
438         bigc_neg(ent_scratch_bigc, XBIGC_DATA(l));
439         return make_bigc_bc(ent_scratch_bigc);
440 }
441
442 static Lisp_Object
443 ent_prod_BIGC_T(Lisp_Object l, Lisp_Object r)
444 {
445         bigc_set_prec(ent_scratch_bigc,
446                        max(XBIGC_GET_PREC(l), XBIGC_GET_PREC(r)));
447         bigc_mul(ent_scratch_bigc, XBIGC_DATA(l), XBIGC_DATA(r));
448         return make_bigc_bc(ent_scratch_bigc);
449 }
450
451 static Lisp_Object
452 ent_prod_BIGC_T_COMPARABLE(Lisp_Object l, Lisp_Object r)
453 {
454         struct ent_lift_args_s la;
455
456         CHECK_COMPARABLE(r);
457
458         la.precision = XBIGC_GET_PREC(l);
459         r = ent_lift(r, BIGFR_T, &la);
460
461         bigc_set_prec(ent_scratch_bigc, XBIGC_GET_PREC(l));
462         bigc_set_bigfr(ent_scratch_bigc, XBIGFR_DATA(r));
463         bigc_mul(ent_scratch_bigc, XBIGC_DATA(l), ent_scratch_bigc);
464         return make_bigc_bc(ent_scratch_bigc);
465 }
466
467 static Lisp_Object
468 ent_prod_COMPARABLE_BIGC_T(Lisp_Object l, Lisp_Object r)
469 {
470         return ent_prod_BIGC_T_COMPARABLE(r, l);
471 }
472
473 static Lisp_Object
474 ent_prod_BIGC_T_COMPLEX(Lisp_Object l, Lisp_Object r)
475 {
476         struct ent_lift_args_s la;
477
478         CHECK_COMPLEX(r);
479
480         la.precision = XBIGC_GET_PREC(l);
481         r = ent_lift(r, BIGC_T, &la);
482
483         return ent_prod_BIGC_T(l, r);
484 }
485
486 static Lisp_Object
487 ent_prod_COMPLEX_BIGC_T(Lisp_Object l, Lisp_Object r)
488 {
489         return ent_prod_BIGC_T_COMPLEX(r, l);
490 }
491
492 static Lisp_Object
493 ent_div_BIGC_T(Lisp_Object l, Lisp_Object r)
494 {
495         if (ent_mpc_zerop(r)) {
496                 if (!ent_mpc_zerop(l)) {
497                         return make_indef(COMPLEX_INFINITY);
498                 } else {
499                         return make_indef(NOT_A_NUMBER);
500                 }
501         }
502         bigc_set_prec(ent_scratch_bigc,
503                       max(XBIGC_GET_PREC(l), XBIGC_GET_PREC(r)));
504         bigc_div(ent_scratch_bigc, XBIGC_DATA(l), XBIGC_DATA(r));
505         return make_bigc_bc(ent_scratch_bigc);
506 }
507
508 static Lisp_Object
509 ent_div_BIGC_T_COMPARABLE(Lisp_Object l, Lisp_Object r)
510 {
511         struct ent_lift_args_s la;
512
513         CHECK_COMPARABLE(r);
514
515         if (ent_unrel(ASE_UNARY_REL_ZEROP, r)) {
516                 if (!ent_mpc_zerop(l)) {
517                         return make_indef(COMPLEX_INFINITY);
518                 } else {
519                         return make_indef(NOT_A_NUMBER);
520                 }
521         }
522
523         la.precision = XBIGC_GET_PREC(l);
524         r = ent_lift(r, BIGFR_T, &la);
525
526         bigc_set_prec(ent_scratch_bigc, XBIGC_GET_PREC(l));
527         bigc_set_bigfr(ent_scratch_bigc, XBIGFR_DATA(r));
528         bigc_div(ent_scratch_bigc, XBIGC_DATA(l), ent_scratch_bigc);
529         return make_bigc_bc(ent_scratch_bigc);
530 }
531
532 static Lisp_Object
533 ent_div_COMPARABLE_BIGC_T(Lisp_Object l, Lisp_Object r)
534 {
535         struct ent_lift_args_s la;
536
537         CHECK_COMPARABLE(l);
538
539         if (ent_mpc_zerop(r)) {
540                 if (!ent_unrel(ASE_UNARY_REL_ZEROP, l)) {
541                         return make_indef(COMPLEX_INFINITY);
542                 } else {
543                         return make_indef(NOT_A_NUMBER);
544                 }
545         }
546
547         la.precision = XBIGC_GET_PREC(r);
548         l = ent_lift(l, BIGFR_T, &la);
549
550         bigc_set_prec(ent_scratch_bigc, XBIGC_GET_PREC(r));
551         bigc_set_bigfr(ent_scratch_bigc, XBIGFR_DATA(l));
552         bigc_div(ent_scratch_bigc, ent_scratch_bigc, XBIGC_DATA(r));
553         return make_bigc_bc(ent_scratch_bigc);
554 }
555
556 static Lisp_Object
557 ent_div_BIGC_T_COMPLEX(Lisp_Object l, Lisp_Object r)
558 {
559         struct ent_lift_args_s la;
560
561         CHECK_COMPLEX(r);
562
563         if (ent_unrel(ASE_UNARY_REL_ZEROP, r)) {
564                 if (!ent_mpc_zerop(l)) {
565                         return make_indef(COMPLEX_INFINITY);
566                 } else {
567                         return make_indef(NOT_A_NUMBER);
568                 }
569         }
570
571         la.precision = XBIGC_GET_PREC(l);
572         r = ent_lift(r, BIGC_T, &la);
573
574         return ent_div_BIGC_T(l, r);
575 }
576
577 static Lisp_Object
578 ent_div_COMPLEX_BIGC_T(Lisp_Object l, Lisp_Object r)
579 {
580         struct ent_lift_args_s la;
581
582         CHECK_COMPLEX(l);
583
584         if (ent_mpc_zerop(r)) {
585                 if (!ent_unrel(ASE_UNARY_REL_ZEROP, l)) {
586                         return make_indef(COMPLEX_INFINITY);
587                 } else {
588                         return make_indef(NOT_A_NUMBER);
589                 }
590         }
591
592         la.precision = XBIGC_GET_PREC(r);
593         l = ent_lift(l, BIGC_T, &la);
594
595         return ent_div_BIGC_T(l, r);
596 }
597
598 static Lisp_Object
599 ent_inv_BIGC_T(Lisp_Object r)
600 {
601         if (ent_mpc_zerop(r)) {
602                 return make_indef(COMPLEX_INFINITY);
603         }
604         bigc_set_long(ent_scratch_bigc, 1L);
605         bigc_set_prec(ent_scratch_bigc, XBIGC_GET_PREC(r));
606         bigc_div(ent_scratch_bigc, ent_scratch_bigc, XBIGC_DATA(r));
607         return make_bigc_bc(ent_scratch_bigc);
608 }
609
610 static Lisp_Object
611 ent_rem_BIGC_T(Lisp_Object SXE_UNUSED(unused), Lisp_Object r)
612 {
613         return Qent_mpc_zero;
614 }
615
616 static Lisp_Object
617 ent_mod_BIGC_T(Lisp_Object l, Lisp_Object r)
618 {
619         if (ent_mpc_zerop(r)) {
620                 return Qent_mpc_zero;
621         }
622         bigc_set_prec(ent_scratch_bigc,
623                       max(XBIGC_GET_PREC(l), XBIGC_GET_PREC(r)));
624         bigc_div(ent_scratch_bigc, XBIGC_DATA(l), XBIGC_DATA(r));
625         bigfr_trunc(bigc_re(ent_scratch_bigc), bigc_re(ent_scratch_bigc));
626         bigfr_trunc(bigc_im(ent_scratch_bigc), bigc_im(ent_scratch_bigc));
627         bigc_mul(ent_scratch_bigc, ent_scratch_bigc, XBIGC_DATA(r));
628         bigc_sub(ent_scratch_bigc, XBIGC_DATA(l), ent_scratch_bigc);
629         return make_bigc_bc(ent_scratch_bigc);
630 }
631
632 /* relations */
633 static int
634 ent_eq_BIGC_T(Lisp_Object l, Lisp_Object r)
635 {
636         return (bigfr_eq(bigc_re(XBIGC_DATA(l)), bigc_re(XBIGC_DATA(r))) &&
637                 bigfr_eq(bigc_im(XBIGC_DATA(l)), bigc_im(XBIGC_DATA(r))));
638 }
639
640 static int
641 ent_ne_BIGC_T(Lisp_Object l, Lisp_Object r)
642 {
643         return (bigfr_eq(bigc_re(XBIGC_DATA(l)), bigc_re(XBIGC_DATA(r))) &&
644                 bigfr_eq(bigc_im(XBIGC_DATA(l)), bigc_im(XBIGC_DATA(r))));
645 }
646
647 #if 0
648 static inline Lisp_Object
649 ent_vallt_BIGC_T(Lisp_Object l, Lisp_Object r)
650 {
651         bigfr b2;
652         int result;
653
654         bigfr_init(b2);
655         bigfr_set_prec(ent_scratch_bigfr, internal_get_precision(Qnil));
656         bigfr_set_prec(b2, internal_get_precision(Qnil));
657         bigc_norm(ent_scratch_bigfr, XBIGC_DATA(l));
658         bigc_norm(b2, XBIGC_DATA(r));
659         result = bigfr_lt(ent_scratch_bigfr, b2);
660
661         bigfr_fini(b2);
662         return (result) ? Qt : Qnil;
663 }
664 static inline Lisp_Object
665 ent_valgt_BIGC_T(Lisp_Object l, Lisp_Object r)
666 {
667         bigfr b2;
668         int result;
669
670         bigfr_init(b2);
671         bigfr_set_prec(ent_scratch_bigfr, internal_get_precision(Qnil));
672         bigfr_set_prec(b2, internal_get_precision(Qnil));
673         bigc_norm(ent_scratch_bigfr, XBIGC_DATA(l));
674         bigc_norm(b2, XBIGC_DATA(r));
675         result = bigfr_gt(ent_scratch_bigfr, b2);
676
677         bigfr_fini(b2);
678         return (result) ? Qt : Qnil;
679 }
680 static inline Lisp_Object
681 ent_valeq_BIGC_T(Lisp_Object l, Lisp_Object r)
682 {
683         bigfr b2;
684         int result;
685
686         bigfr_init(b2);
687         bigfr_set_prec(ent_scratch_bigfr, internal_get_precision(Qnil));
688         bigfr_set_prec(b2, internal_get_precision(Qnil));
689         bigc_norm(ent_scratch_bigfr, XBIGC_DATA(l));
690         bigc_norm(b2, XBIGC_DATA(r));
691         result = bigfr_eq(ent_scratch_bigfr, b2);
692
693         bigfr_fini(b2);
694         return (result) ? Qt : Qnil;
695 }
696 static inline Lisp_Object
697 ent_valne_BIGC_T(Lisp_Object l, Lisp_Object r)
698 {
699         bigfr b2;
700         int result;
701
702         bigfr_init(b2);
703         bigfr_set_prec(ent_scratch_bigfr, internal_get_precision(Qnil));
704         bigfr_set_prec(b2, internal_get_precision(Qnil));
705         bigc_norm(ent_scratch_bigfr, XBIGC_DATA(l));
706         bigc_norm(b2, XBIGC_DATA(r));
707         result = bigfr_eq(ent_scratch_bigfr, b2);
708
709         bigfr_fini(b2);
710         return (result) ? Qnil : Qt;
711 }
712 #endif
713
714 \f
715 static Lisp_Object
716 ent_lift_INT_T_BIGC_T(Lisp_Object number, ent_lift_args_t la)
717 {
718         unsigned long precision = la->precision;
719
720         bigc_set_prec(ent_scratch_bigc, precision);
721         bigc_set_long(ent_scratch_bigc, ent_int(number));
722         return make_bigc_bc(ent_scratch_bigc);
723 }
724
725 #if defined HAVE_MPZ && (defined WITH_GMP || defined WITH_MP)
726 static Lisp_Object
727 ent_lift_BIGZ_T_BIGC_T(Lisp_Object number, ent_lift_args_t la)
728 {
729         unsigned long precision = la->precision;
730
731         bigfr_set_prec(ent_scratch_bigfr, precision);
732         bigfr_set_bigz(ent_scratch_bigfr, XBIGZ_DATA(number));
733         bigc_set_prec(ent_scratch_bigc, precision);
734         bigc_set_bigfr(ent_scratch_bigc, ent_scratch_bigfr);
735         return make_bigc_bc(ent_scratch_bigc);
736 }
737 #endif  /* HAVE_MPZ */
738
739 #if defined HAVE_MPQ && defined WITH_GMP
740 static Lisp_Object
741 ent_lift_BIGQ_T_BIGC_T(Lisp_Object number, ent_lift_args_t la)
742 {
743         unsigned long precision = la->precision;
744
745         bigfr_set_prec(ent_scratch_bigfr, precision);
746         bigfr_set_bigq(ent_scratch_bigfr, XBIGQ_DATA(number));
747         bigc_set_prec(ent_scratch_bigc, precision);
748         bigc_set_bigfr(ent_scratch_bigc, ent_scratch_bigfr);
749         return make_bigc_bc(ent_scratch_bigc);
750 }
751 #endif  /* HAVE_MPQ */
752
753 #if defined HAVE_MPF && defined WITH_GMP
754 static Lisp_Object
755 ent_lift_BIGF_T_BIGC_T(Lisp_Object number, ent_lift_args_t la)
756 {
757         unsigned long precision = la->precision;
758
759         bigfr_set_prec(ent_scratch_bigfr, precision);
760         bigfr_set_bigf(ent_scratch_bigfr, XBIGF_DATA(number));
761         bigc_set_prec(ent_scratch_bigc, precision);
762         bigc_set_bigfr(ent_scratch_bigc, ent_scratch_bigfr);
763         return make_bigc_bc(ent_scratch_bigc);
764 }
765 #endif  /* HAVE_MPF */
766
767 #if defined HAVE_MPFR && defined WITH_MPFR
768 static Lisp_Object
769 ent_lift_BIGFR_T_BIGC_T(Lisp_Object number, ent_lift_args_t la)
770 {
771         unsigned long precision = la->precision;
772
773         /* warn about coercions of indefinite symbols */
774         if (bigfr_inf_p(XBIGFR_DATA(number)))
775                 return make_indef(COMPLEX_INFINITY);
776         if (bigfr_nan_p(XBIGFR_DATA(number)))
777                 return make_indef(NOT_A_NUMBER);
778
779         bigc_set_prec(ent_scratch_bigc, precision);
780         bigc_set_bigfr(ent_scratch_bigc, XBIGFR_DATA(number));
781         return make_bigc_bc(ent_scratch_bigc);
782 }
783 #endif  /* HAVE_MPF */
784
785 #ifdef HAVE_FPFLOAT
786 static Lisp_Object
787 ent_lift_FLOAT_T_BIGC_T(Lisp_Object number, ent_lift_args_t la)
788 {
789         unsigned long precision = la->precision;
790
791         bigc_set_prec(ent_scratch_bigc, precision);
792         bigc_set_fpfloat(ent_scratch_bigc, XFLOAT_DATA(number));
793         return make_bigc_bc(ent_scratch_bigc);
794 }
795 #endif
796
797 #if defined HAVE_PSEUG && defined WITH_PSEUG
798 static Lisp_Object
799 ent_lift_BIGG_T_BIGC_T(Lisp_Object number, ent_lift_args_t la)
800 {
801         unsigned long precision = la->precision;
802         bigfr bfr_im, bfr_re;
803         Lisp_Object result, re, im;
804
805         re = Freal_part(number);
806         re = ent_lift(re, BIGFR_T, la);
807         im = Fimaginary_part(number);
808         im = ent_lift(im, BIGFR_T, la);
809
810         bigfr_init(bfr_re);
811         bigfr_init(bfr_im);
812
813         bigfr_set(bfr_re, XBIGFR_DATA(re));
814         bigfr_set(bfr_im, XBIGFR_DATA(im));
815         result = make_bigc_bfr(bfr_re, bfr_im, precision);
816
817         bigfr_fini(bfr_re);
818         bigfr_fini(bfr_im);
819
820         return result;
821 }
822 #endif
823
824 static Lisp_Object
825 ent_lift_BIGC_T_BIGC_T(Lisp_Object number, ent_lift_args_t la)
826 {
827         unsigned long precision = la->precision;
828
829         bigc_set_prec(ent_scratch_bigc, precision);
830         bigc_set(ent_scratch_bigc, XBIGC_DATA(number));
831         return make_bigc_bc(ent_scratch_bigc);
832 }
833
834 \f
835 static inline void
836 ent_mpc_nullary_optable_init(void)
837 {
838         Qent_mpc_zero = make_bigc(0.0f, 0.0f, internal_get_precision(Qnil));
839         Qent_mpc_one = make_bigc(1.0f, 0.0f, internal_get_precision(Qnil));
840         staticpro(&Qent_mpc_zero);
841         staticpro(&Qent_mpc_one);
842
843         ent_nullop_register(ASE_NULLARY_OP_ZERO, BIGC_T, Qent_mpc_zero);
844         ent_nullop_register(ASE_NULLARY_OP_ONE, BIGC_T, Qent_mpc_one);
845 }
846
847 static inline void
848 ent_mpc_unary_optable_init(void)
849 {
850         ent_unop_register(ASE_UNARY_OP_NEG, BIGC_T, ent_neg_BIGC_T);
851         ent_unop_register(ASE_UNARY_OP_INV, BIGC_T, ent_inv_BIGC_T);
852 }
853
854 static inline void
855 ent_mpc_binary_optable_init(void)
856 {
857         /* sums */
858         ent_binop_register(ASE_BINARY_OP_SUM,
859                            BIGC_T, BIGC_T, ent_sum_BIGC_T);
860         ent_binop_register(ASE_BINARY_OP_SUM,
861                            BIGC_T, INT_T, ent_sum_BIGC_T_COMPARABLE);
862         ent_binop_register(ASE_BINARY_OP_SUM,
863                            INT_T, BIGC_T, ent_sum_COMPARABLE_BIGC_T);
864 #if defined HAVE_MPZ && (defined WITH_GMP || defined WITH_MP)
865         ent_binop_register(ASE_BINARY_OP_SUM,
866                            BIGC_T, BIGZ_T, ent_sum_BIGC_T_COMPARABLE);
867         ent_binop_register(ASE_BINARY_OP_SUM,
868                            BIGZ_T, BIGC_T, ent_sum_COMPARABLE_BIGC_T);
869 #endif
870 #if defined HAVE_MPQ && defined WITH_GMP
871         ent_binop_register(ASE_BINARY_OP_SUM,
872                            BIGC_T, BIGQ_T, ent_sum_BIGC_T_COMPARABLE);
873         ent_binop_register(ASE_BINARY_OP_SUM,
874                            BIGQ_T, BIGC_T, ent_sum_COMPARABLE_BIGC_T);
875 #endif
876 #if defined HAVE_MPF && defined WITH_GMP
877         ent_binop_register(ASE_BINARY_OP_SUM,
878                            BIGC_T, BIGF_T, ent_sum_BIGC_T_COMPARABLE);
879         ent_binop_register(ASE_BINARY_OP_SUM,
880                            BIGF_T, BIGC_T, ent_sum_COMPARABLE_BIGC_T);
881 #endif
882 #if defined HAVE_MPFR && defined WITH_MPFR
883         ent_binop_register(ASE_BINARY_OP_SUM,
884                            BIGC_T, BIGFR_T, ent_sum_BIGC_T_COMPARABLE);
885         ent_binop_register(ASE_BINARY_OP_SUM,
886                            BIGFR_T, BIGC_T, ent_sum_COMPARABLE_BIGC_T);
887 #endif
888 #ifdef HAVE_FPFLOAT
889         ent_binop_register(ASE_BINARY_OP_SUM,
890                            BIGC_T, FLOAT_T, ent_sum_BIGC_T_COMPARABLE);
891         ent_binop_register(ASE_BINARY_OP_SUM,
892                            FLOAT_T, BIGC_T, ent_sum_COMPARABLE_BIGC_T);
893 #endif
894 #if defined HAVE_PSEUG && defined WITH_PSEUG
895         ent_binop_register(ASE_BINARY_OP_SUM,
896                            BIGC_T, BIGG_T, ent_sum_BIGC_T_COMPLEX);
897         ent_binop_register(ASE_BINARY_OP_SUM,
898                            BIGG_T, BIGC_T, ent_sum_COMPLEX_BIGC_T);
899 #endif
900         /* diffs */
901         ent_binop_register(ASE_BINARY_OP_DIFF,
902                            BIGC_T, BIGC_T, ent_diff_BIGC_T);
903         ent_binop_register(ASE_BINARY_OP_DIFF,
904                            BIGC_T, INT_T, ent_diff_BIGC_T_COMPARABLE);
905         ent_binop_register(ASE_BINARY_OP_DIFF,
906                            INT_T, BIGC_T, ent_diff_COMPARABLE_BIGC_T);
907 #if defined HAVE_MPZ && (defined WITH_GMP || defined WITH_MP)
908         ent_binop_register(ASE_BINARY_OP_DIFF,
909                            BIGC_T, BIGZ_T, ent_diff_BIGC_T_COMPARABLE);
910         ent_binop_register(ASE_BINARY_OP_DIFF,
911                            BIGZ_T, BIGC_T, ent_diff_COMPARABLE_BIGC_T);
912 #endif
913 #if defined HAVE_MPQ && defined WITH_GMP
914         ent_binop_register(ASE_BINARY_OP_DIFF,
915                            BIGC_T, BIGQ_T, ent_diff_BIGC_T_COMPARABLE);
916         ent_binop_register(ASE_BINARY_OP_DIFF,
917                            BIGQ_T, BIGC_T, ent_diff_COMPARABLE_BIGC_T);
918 #endif
919 #if defined HAVE_MPF && defined WITH_GMP
920         ent_binop_register(ASE_BINARY_OP_DIFF,
921                            BIGC_T, BIGF_T, ent_diff_BIGC_T_COMPARABLE);
922         ent_binop_register(ASE_BINARY_OP_DIFF,
923                            BIGF_T, BIGC_T, ent_diff_COMPARABLE_BIGC_T);
924 #endif
925 #if defined HAVE_MPFR && defined WITH_MPFR
926         ent_binop_register(ASE_BINARY_OP_DIFF,
927                            BIGC_T, BIGFR_T, ent_diff_BIGC_T_COMPARABLE);
928         ent_binop_register(ASE_BINARY_OP_DIFF,
929                            BIGFR_T, BIGC_T, ent_diff_COMPARABLE_BIGC_T);
930 #endif
931 #ifdef HAVE_FPFLOAT
932         ent_binop_register(ASE_BINARY_OP_DIFF,
933                            BIGC_T, FLOAT_T, ent_diff_BIGC_T_COMPARABLE);
934         ent_binop_register(ASE_BINARY_OP_DIFF,
935                            FLOAT_T, BIGC_T, ent_diff_COMPARABLE_BIGC_T);
936 #endif
937 #if defined HAVE_PSEUG && defined WITH_PSEUG
938         ent_binop_register(ASE_BINARY_OP_DIFF,
939                            BIGC_T, BIGG_T, ent_diff_BIGC_T_COMPLEX);
940         ent_binop_register(ASE_BINARY_OP_DIFF,
941                            BIGG_T, BIGC_T, ent_diff_COMPLEX_BIGC_T);
942 #endif
943         /* prods */
944         ent_binop_register(ASE_BINARY_OP_PROD,
945                            BIGC_T, BIGC_T, ent_prod_BIGC_T);
946         ent_binop_register(ASE_BINARY_OP_PROD,
947                            BIGC_T, INT_T, ent_prod_BIGC_T_COMPARABLE);
948         ent_binop_register(ASE_BINARY_OP_PROD,
949                            INT_T, BIGC_T, ent_prod_COMPARABLE_BIGC_T);
950 #if defined HAVE_MPZ && (defined WITH_GMP || defined WITH_MP)
951         ent_binop_register(ASE_BINARY_OP_PROD,
952                            BIGC_T, BIGZ_T, ent_prod_BIGC_T_COMPARABLE);
953         ent_binop_register(ASE_BINARY_OP_PROD,
954                            BIGZ_T, BIGC_T, ent_prod_COMPARABLE_BIGC_T);
955 #endif
956 #if defined HAVE_MPQ && defined WITH_GMP
957         ent_binop_register(ASE_BINARY_OP_PROD,
958                            BIGC_T, BIGQ_T, ent_prod_BIGC_T_COMPARABLE);
959         ent_binop_register(ASE_BINARY_OP_PROD,
960                            BIGQ_T, BIGC_T, ent_prod_COMPARABLE_BIGC_T);
961 #endif
962 #if defined HAVE_MPF && defined WITH_GMP
963         ent_binop_register(ASE_BINARY_OP_PROD,
964                            BIGC_T, BIGF_T, ent_prod_BIGC_T_COMPARABLE);
965         ent_binop_register(ASE_BINARY_OP_PROD,
966                            BIGF_T, BIGC_T, ent_prod_COMPARABLE_BIGC_T);
967 #endif
968 #if defined HAVE_MPFR && defined WITH_MPFR
969         ent_binop_register(ASE_BINARY_OP_PROD,
970                            BIGC_T, BIGFR_T, ent_prod_BIGC_T_COMPARABLE);
971         ent_binop_register(ASE_BINARY_OP_PROD,
972                            BIGFR_T, BIGC_T, ent_prod_COMPARABLE_BIGC_T);
973 #endif
974 #ifdef HAVE_FPFLOAT
975         ent_binop_register(ASE_BINARY_OP_PROD,
976                            BIGC_T, FLOAT_T, ent_prod_BIGC_T_COMPARABLE);
977         ent_binop_register(ASE_BINARY_OP_PROD,
978                            FLOAT_T, BIGC_T, ent_prod_COMPARABLE_BIGC_T);
979 #endif
980 #if defined HAVE_PSEUG && defined WITH_PSEUG
981         ent_binop_register(ASE_BINARY_OP_PROD,
982                            BIGC_T, BIGG_T, ent_prod_BIGC_T_COMPLEX);
983         ent_binop_register(ASE_BINARY_OP_PROD,
984                            BIGG_T, BIGC_T, ent_prod_COMPLEX_BIGC_T);
985 #endif
986
987         /* divisions and quotients */
988         ent_binop_register(ASE_BINARY_OP_DIV,
989                            BIGC_T, BIGC_T, ent_div_BIGC_T);
990         ent_binop_register(ASE_BINARY_OP_DIV,
991                            BIGC_T, INT_T, ent_div_BIGC_T_COMPARABLE);
992         ent_binop_register(ASE_BINARY_OP_DIV,
993                            INT_T, BIGC_T, ent_div_COMPARABLE_BIGC_T);
994 #if defined HAVE_MPZ && (defined WITH_GMP || defined WITH_MP)
995         ent_binop_register(ASE_BINARY_OP_DIV,
996                            BIGC_T, BIGZ_T, ent_div_BIGC_T_COMPARABLE);
997         ent_binop_register(ASE_BINARY_OP_DIV,
998                            BIGZ_T, BIGC_T, ent_div_COMPARABLE_BIGC_T);
999 #endif
1000 #if defined HAVE_MPQ && defined WITH_GMP
1001         ent_binop_register(ASE_BINARY_OP_DIV,
1002                            BIGC_T, BIGQ_T, ent_div_BIGC_T_COMPARABLE);
1003         ent_binop_register(ASE_BINARY_OP_DIV,
1004                            BIGQ_T, BIGC_T, ent_div_COMPARABLE_BIGC_T);
1005 #endif
1006 #if defined HAVE_MPF && defined WITH_GMP
1007         ent_binop_register(ASE_BINARY_OP_DIV,
1008                            BIGC_T, BIGF_T, ent_div_BIGC_T_COMPARABLE);
1009         ent_binop_register(ASE_BINARY_OP_DIV,
1010                            BIGF_T, BIGC_T, ent_div_COMPARABLE_BIGC_T);
1011 #endif
1012 #if defined HAVE_MPFR && defined WITH_MPFR
1013         ent_binop_register(ASE_BINARY_OP_DIV,
1014                            BIGC_T, BIGFR_T, ent_div_BIGC_T_COMPARABLE);
1015         ent_binop_register(ASE_BINARY_OP_DIV,
1016                            BIGFR_T, BIGC_T, ent_div_COMPARABLE_BIGC_T);
1017 #endif
1018 #ifdef HAVE_FPFLOAT
1019         ent_binop_register(ASE_BINARY_OP_DIV,
1020                            BIGC_T, FLOAT_T, ent_div_BIGC_T_COMPARABLE);
1021         ent_binop_register(ASE_BINARY_OP_DIV,
1022                            FLOAT_T, BIGC_T, ent_div_COMPARABLE_BIGC_T);
1023 #endif
1024 #if defined HAVE_PSEUG && defined WITH_PSEUG
1025         ent_binop_register(ASE_BINARY_OP_DIV,
1026                            BIGC_T, BIGG_T, ent_div_BIGC_T_COMPLEX);
1027         ent_binop_register(ASE_BINARY_OP_DIV,
1028                            BIGG_T, BIGC_T, ent_div_COMPLEX_BIGC_T);
1029 #endif
1030         ent_binop_register(ASE_BINARY_OP_QUO,
1031                            BIGC_T, BIGC_T, ent_div_BIGC_T);
1032 #if defined HAVE_MPZ && (defined WITH_GMP || defined WITH_MP)
1033         ent_binop_register(ASE_BINARY_OP_QUO,
1034                            BIGC_T, BIGZ_T, ent_div_BIGC_T_COMPARABLE);
1035         ent_binop_register(ASE_BINARY_OP_QUO,
1036                            BIGZ_T, BIGC_T, ent_div_COMPARABLE_BIGC_T);
1037 #endif
1038 #if defined HAVE_MPQ && defined WITH_GMP
1039         ent_binop_register(ASE_BINARY_OP_QUO,
1040                            BIGC_T, BIGQ_T, ent_div_BIGC_T_COMPARABLE);
1041         ent_binop_register(ASE_BINARY_OP_QUO,
1042                            BIGQ_T, BIGC_T, ent_div_COMPARABLE_BIGC_T);
1043 #endif
1044 #if defined HAVE_MPF && defined WITH_GMP
1045         ent_binop_register(ASE_BINARY_OP_QUO,
1046                            BIGC_T, BIGF_T, ent_div_BIGC_T_COMPARABLE);
1047         ent_binop_register(ASE_BINARY_OP_QUO,
1048                            BIGF_T, BIGC_T, ent_div_COMPARABLE_BIGC_T);
1049 #endif
1050 #if defined HAVE_MPFR && defined WITH_MPFR
1051         ent_binop_register(ASE_BINARY_OP_QUO,
1052                            BIGC_T, BIGFR_T, ent_div_BIGC_T_COMPARABLE);
1053         ent_binop_register(ASE_BINARY_OP_QUO,
1054                            BIGFR_T, BIGC_T, ent_div_COMPARABLE_BIGC_T);
1055 #endif
1056 #ifdef HAVE_FPFLOAT
1057         ent_binop_register(ASE_BINARY_OP_QUO,
1058                            BIGC_T, FLOAT_T, ent_div_BIGC_T_COMPARABLE);
1059         ent_binop_register(ASE_BINARY_OP_QUO,
1060                            FLOAT_T, BIGC_T, ent_div_COMPARABLE_BIGC_T);
1061 #endif
1062 #if defined HAVE_PSEUG && defined WITH_PSEUG
1063         ent_binop_register(ASE_BINARY_OP_QUO,
1064                            BIGC_T, BIGG_T, ent_div_BIGC_T_COMPLEX);
1065         ent_binop_register(ASE_BINARY_OP_QUO,
1066                            BIGG_T, BIGC_T, ent_div_COMPLEX_BIGC_T);
1067 #endif
1068         ent_binop_register(ASE_BINARY_OP_REM,
1069                            BIGC_T, BIGC_T, ent_rem_BIGC_T);
1070         ent_binop_register(ASE_BINARY_OP_MOD,
1071                            BIGC_T, BIGC_T, ent_mod_BIGC_T);
1072 }
1073
1074 static inline void
1075 ent_mpc_unary_reltable_init(void)
1076 {
1077         ent_unrel_register(ASE_UNARY_REL_ZEROP, BIGC_T, ent_mpc_zerop);
1078         ent_unrel_register(ASE_UNARY_REL_ONEP, BIGC_T, ent_mpc_onep);
1079         ent_unrel_register(ASE_UNARY_REL_UNITP, BIGC_T, ent_mpc_unitp);
1080 }
1081
1082 static inline void
1083 ent_mpc_binary_reltable_init(void)
1084 {
1085         ent_binrel_register(ASE_BINARY_REL_EQUALP,
1086                             BIGC_T, BIGC_T, ent_eq_BIGC_T);
1087         ent_binrel_register(ASE_BINARY_REL_NEQP,
1088                             BIGC_T, BIGC_T, ent_ne_BIGC_T);
1089 }
1090
1091 static inline void
1092 ent_mpc_lifttable_init(void)
1093 {
1094         ent_lift_register(INT_T, BIGC_T, ent_lift_INT_T_BIGC_T);
1095 #if defined HAVE_MPZ && (defined WITH_GMP || defined WITH_MP)
1096         ent_lift_register(BIGZ_T, BIGC_T, ent_lift_BIGZ_T_BIGC_T);
1097 #endif
1098 #if defined HAVE_MPQ && defined WITH_GMP
1099         ent_lift_register(BIGQ_T, BIGC_T, ent_lift_BIGQ_T_BIGC_T);
1100 #endif
1101 #if defined HAVE_MPF && defined WITH_GMP
1102         ent_lift_register(BIGF_T, BIGC_T, ent_lift_BIGF_T_BIGC_T);
1103 #endif
1104 #if defined HAVE_MPFR && defined WITH_MPFR
1105         ent_lift_register(BIGFR_T, BIGC_T, ent_lift_BIGFR_T_BIGC_T);
1106 #endif
1107 #ifdef HAVE_FPFLOAT
1108         ent_lift_register(FLOAT_T, BIGC_T, ent_lift_FLOAT_T_BIGC_T);
1109 #endif
1110         ent_lift_register(BIGG_T, BIGC_T, ent_lift_BIGG_T_BIGC_T);
1111         ent_lift_register(BIGC_T, BIGC_T, ent_lift_BIGC_T_BIGC_T);
1112 }
1113
1114 void init_optables_BIGC_T(void)
1115 {
1116         ent_mpc_nullary_optable_init();
1117         ent_mpc_unary_optable_init();
1118         ent_mpc_binary_optable_init();
1119         ent_mpc_unary_reltable_init();
1120         ent_mpc_binary_reltable_init();
1121         ent_mpc_lifttable_init();
1122 }
1123
1124 void init_ent_mpc(void)
1125 {
1126         bigc_init(ent_scratch_bigc);
1127 }
1128
1129 void syms_of_ent_mpc(void)
1130 {
1131         INIT_LRECORD_IMPLEMENTATION(bigc);
1132
1133         DEFSUBR(Fbigc_get_precision);
1134         DEFSUBR(Fbigc_set_precision);
1135         DEFSUBR(Fmake_bigc);
1136 }
1137
1138 void vars_of_ent_mpc(void)
1139 {
1140         Fprovide(intern("bigc"));
1141 }