1 /* -*- mode: C; indent-tabs-mode: t; tab-width: 8; c-basic-offset: 2; -*- */
4 * This file is part of Seed, the GObject Introspection<->Javascript bindings.
6 * Seed is free software: you can redistribute it and/or modify
7 * it under the terms of the GNU Lesser General Public License as
8 * published by the Free Software Foundation, either version 3 of
9 * the License, or (at your option) any later version.
10 * Seed is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU Lesser General Public License for more details.
14 * You should have received a copy of the GNU Lesser General Public License
15 * along with Seed. If not, see <http://www.gnu.org/licenses/>.
17 * Copyright (C) Matthew Arsenault 2009-2010 <arsenm2@rpi.edu>
22 #include "seed-mpfr.h"
24 SeedValue seed_mpfr_sin (SeedContext ctx,
26 SeedObject this_object,
28 const SeedValue args[],
29 SeedException * exception)
35 CHECK_ARG_COUNT("mpfr.sin", 2);
37 rop = seed_object_get_private(this_object);
38 rnd = seed_value_to_mpfr_rnd_t(ctx, args[1], exception);
40 if ( seed_value_is_object_of_class(ctx, args[0], mpfr_class) )
42 op = seed_object_get_private(args[0]);
46 TYPE_EXCEPTION("mpfr.sin", "mpfr_t");
49 ret = mpfr_sin(rop, op, rnd);
51 return seed_value_from_int(ctx, ret, exception);
54 SeedValue seed_mpfr_cos (SeedContext ctx,
56 SeedObject this_object,
58 const SeedValue args[],
59 SeedException * exception)
65 CHECK_ARG_COUNT("mpfr.cos", 2);
67 rop = seed_object_get_private(this_object);
68 rnd = seed_value_to_mpfr_rnd_t(ctx, args[1], exception);
70 if ( seed_value_is_object_of_class(ctx, args[0], mpfr_class) )
72 op = seed_object_get_private(args[0]);
76 TYPE_EXCEPTION("mpfr.cos", "mpfr_t");
79 ret = mpfr_cos(rop, op, rnd);
81 return seed_value_from_int(ctx, ret, exception);
84 SeedValue seed_mpfr_tan (SeedContext ctx,
86 SeedObject this_object,
88 const SeedValue args[],
89 SeedException * exception)
95 CHECK_ARG_COUNT("mpfr.tan", 2);
97 rop = seed_object_get_private(this_object);
98 rnd = seed_value_to_mpfr_rnd_t(ctx, args[1], exception);
100 if ( seed_value_is_object_of_class(ctx, args[0], mpfr_class) )
102 op = seed_object_get_private(args[0]);
106 TYPE_EXCEPTION("mpfr.tan", "mpfr_t");
109 ret = mpfr_tan(rop, op, rnd);
111 return seed_value_from_int(ctx, ret, exception);
114 SeedValue seed_mpfr_csc (SeedContext ctx,
116 SeedObject this_object,
117 gsize argument_count,
118 const SeedValue args[],
119 SeedException * exception)
125 CHECK_ARG_COUNT("mpfr.csc", 2);
127 rop = seed_object_get_private(this_object);
128 rnd = seed_value_to_mpfr_rnd_t(ctx, args[1], exception);
130 if ( seed_value_is_object_of_class(ctx, args[0], mpfr_class) )
132 op = seed_object_get_private(args[0]);
136 TYPE_EXCEPTION("mpfr.csc", "mpfr_t");
139 ret = mpfr_csc(rop, op, rnd);
141 return seed_value_from_int(ctx, ret, exception);
144 SeedValue seed_mpfr_sec (SeedContext ctx,
146 SeedObject this_object,
147 gsize argument_count,
148 const SeedValue args[],
149 SeedException * exception)
155 CHECK_ARG_COUNT("mpfr.sec", 2);
157 rop = seed_object_get_private(this_object);
158 rnd = seed_value_to_mpfr_rnd_t(ctx, args[1], exception);
160 if ( seed_value_is_object_of_class(ctx, args[0], mpfr_class) )
162 op = seed_object_get_private(args[0]);
166 TYPE_EXCEPTION("mpfr.sec", "mpfr_t");
169 ret = mpfr_sec(rop, op, rnd);
171 return seed_value_from_int(ctx, ret, exception);
174 SeedValue seed_mpfr_cot (SeedContext ctx,
176 SeedObject this_object,
177 gsize argument_count,
178 const SeedValue args[],
179 SeedException * exception)
185 CHECK_ARG_COUNT("mpfr.cot", 2);
187 rop = seed_object_get_private(this_object);
188 rnd = seed_value_to_mpfr_rnd_t(ctx, args[1], exception);
190 if ( seed_value_is_object_of_class(ctx, args[0], mpfr_class) )
192 op = seed_object_get_private(args[0]);
196 TYPE_EXCEPTION("mpfr.cot", "mpfr_t");
199 ret = mpfr_cot(rop, op, rnd);
201 return seed_value_from_int(ctx, ret, exception);
204 SeedValue seed_mpfr_asin (SeedContext ctx,
206 SeedObject this_object,
207 gsize argument_count,
208 const SeedValue args[],
209 SeedException * exception)
215 CHECK_ARG_COUNT("mpfr.asin", 2);
217 rop = seed_object_get_private(this_object);
218 rnd = seed_value_to_mpfr_rnd_t(ctx, args[1], exception);
220 if ( seed_value_is_object_of_class(ctx, args[0], mpfr_class) )
222 op = seed_object_get_private(args[0]);
226 TYPE_EXCEPTION("mpfr.asin", "mpfr_t");
229 ret = mpfr_asin(rop, op, rnd);
231 return seed_value_from_int(ctx, ret, exception);
235 SeedValue seed_mpfr_acos (SeedContext ctx,
237 SeedObject this_object,
238 gsize argument_count,
239 const SeedValue args[],
240 SeedException * exception)
246 CHECK_ARG_COUNT("mpfr.acos", 2);
248 rop = seed_object_get_private(this_object);
249 rnd = seed_value_to_mpfr_rnd_t(ctx, args[1], exception);
251 if ( seed_value_is_object_of_class(ctx, args[0], mpfr_class) )
253 op = seed_object_get_private(args[0]);
257 TYPE_EXCEPTION("mpfr.acos", "mpfr_t");
260 ret = mpfr_acos(rop, op, rnd);
262 return seed_value_from_int(ctx, ret, exception);
265 SeedValue seed_mpfr_atan (SeedContext ctx,
267 SeedObject this_object,
268 gsize argument_count,
269 const SeedValue args[],
270 SeedException * exception)
276 CHECK_ARG_COUNT("mpfr.atan", 2);
278 rop = seed_object_get_private(this_object);
279 rnd = seed_value_to_mpfr_rnd_t(ctx, args[1], exception);
281 if ( seed_value_is_object_of_class(ctx, args[0], mpfr_class) )
283 op = seed_object_get_private(args[0]);
287 TYPE_EXCEPTION("mpfr.atan", "mpfr_t");
290 ret = mpfr_atan(rop, op, rnd);
292 return seed_value_from_int(ctx, ret, exception);
298 SeedValue seed_mpfr_log (SeedContext ctx,
300 SeedObject this_object,
301 gsize argument_count,
302 const SeedValue args[],
303 SeedException * exception)
309 CHECK_ARG_COUNT("mpfr.log", 2);
311 rop = seed_object_get_private(this_object);
312 rnd = seed_value_to_mpfr_rnd_t(ctx, args[1], exception);
314 if ( seed_value_is_object_of_class(ctx, args[0], mpfr_class) )
316 op = seed_object_get_private(args[0]);
320 TYPE_EXCEPTION("mpfr.log", "mpfr_t");
323 ret = mpfr_log(rop, op, rnd);
325 return seed_value_from_int(ctx, ret, exception);
328 SeedValue seed_mpfr_log2 (SeedContext ctx,
330 SeedObject this_object,
331 gsize argument_count,
332 const SeedValue args[],
333 SeedException * exception)
339 CHECK_ARG_COUNT("mpfr.log2", 2);
341 rop = seed_object_get_private(this_object);
342 rnd = seed_value_to_mpfr_rnd_t(ctx, args[1], exception);
344 if ( seed_value_is_object_of_class(ctx, args[0], mpfr_class) )
346 op = seed_object_get_private(args[0]);
350 TYPE_EXCEPTION("mpfr.log2", "mpfr_t");
353 ret = mpfr_log2(rop, op, rnd);
355 return seed_value_from_int(ctx, ret, exception);
358 SeedValue seed_mpfr_log10 (SeedContext ctx,
360 SeedObject this_object,
361 gsize argument_count,
362 const SeedValue args[],
363 SeedException * exception)
369 CHECK_ARG_COUNT("mpfr.log10", 2);
371 rop = seed_object_get_private(this_object);
372 rnd = seed_value_to_mpfr_rnd_t(ctx, args[1], exception);
374 if ( seed_value_is_object_of_class(ctx, args[0], mpfr_class) )
376 op = seed_object_get_private(args[0]);
380 TYPE_EXCEPTION("mpfr.log10", "mpfr_t");
383 ret = mpfr_log10(rop, op, rnd);
385 return seed_value_from_int(ctx, ret, exception);
388 /* hyperbolic trig functions */
390 SeedValue seed_mpfr_sinh (SeedContext ctx,
392 SeedObject this_object,
393 gsize argument_count,
394 const SeedValue args[],
395 SeedException * exception)
401 CHECK_ARG_COUNT("mpfr.sinh", 2);
403 rop = seed_object_get_private(this_object);
404 rnd = seed_value_to_mpfr_rnd_t(ctx, args[1], exception);
406 if ( seed_value_is_object_of_class(ctx, args[0], mpfr_class) )
408 op = seed_object_get_private(args[0]);
412 TYPE_EXCEPTION("mpfr.sinh", "mpfr_t");
415 ret = mpfr_sinh(rop, op, rnd);
417 return seed_value_from_int(ctx, ret, exception);
420 SeedValue seed_mpfr_cosh (SeedContext ctx,
422 SeedObject this_object,
423 gsize argument_count,
424 const SeedValue args[],
425 SeedException * exception)
431 CHECK_ARG_COUNT("mpfr.cosh", 2);
433 rop = seed_object_get_private(this_object);
434 rnd = seed_value_to_mpfr_rnd_t(ctx, args[1], exception);
436 if ( seed_value_is_object_of_class(ctx, args[0], mpfr_class) )
438 op = seed_object_get_private(args[0]);
442 TYPE_EXCEPTION("mpfr.cosh", "mpfr_t");
445 ret = mpfr_cosh(rop, op, rnd);
447 return seed_value_from_int(ctx, ret, exception);
450 SeedValue seed_mpfr_tanh (SeedContext ctx,
452 SeedObject this_object,
453 gsize argument_count,
454 const SeedValue args[],
455 SeedException * exception)
461 CHECK_ARG_COUNT("mpfr.tanh", 2);
463 rop = seed_object_get_private(this_object);
464 rnd = seed_value_to_mpfr_rnd_t(ctx, args[1], exception);
466 if ( seed_value_is_object_of_class(ctx, args[0], mpfr_class) )
468 op = seed_object_get_private(args[0]);
472 TYPE_EXCEPTION("mpfr.tanh", "mpfr_t");
475 ret = mpfr_tanh(rop, op, rnd);
477 return seed_value_from_int(ctx, ret, exception);
481 SeedValue seed_mpfr_sech (SeedContext ctx,
483 SeedObject this_object,
484 gsize argument_count,
485 const SeedValue args[],
486 SeedException * exception)
492 CHECK_ARG_COUNT("mpfr.sech", 2);
494 rop = seed_object_get_private(this_object);
495 rnd = seed_value_to_mpfr_rnd_t(ctx, args[1], exception);
497 if ( seed_value_is_object_of_class(ctx, args[0], mpfr_class) )
499 op = seed_object_get_private(args[0]);
503 TYPE_EXCEPTION("mpfr.sech", "mpfr_t");
506 ret = mpfr_sech(rop, op, rnd);
508 return seed_value_from_int(ctx, ret, exception);
511 SeedValue seed_mpfr_csch (SeedContext ctx,
513 SeedObject this_object,
514 gsize argument_count,
515 const SeedValue args[],
516 SeedException * exception)
522 CHECK_ARG_COUNT("mpfr.csch", 2);
524 rop = seed_object_get_private(this_object);
525 rnd = seed_value_to_mpfr_rnd_t(ctx, args[1], exception);
527 if ( seed_value_is_object_of_class(ctx, args[0], mpfr_class) )
529 op = seed_object_get_private(args[0]);
533 TYPE_EXCEPTION("mpfr.csch", "mpfr_t");
536 ret = mpfr_csch(rop, op, rnd);
538 return seed_value_from_int(ctx, ret, exception);
541 SeedValue seed_mpfr_coth (SeedContext ctx,
543 SeedObject this_object,
544 gsize argument_count,
545 const SeedValue args[],
546 SeedException * exception)
552 CHECK_ARG_COUNT("mpfr.coth", 2);
554 rop = seed_object_get_private(this_object);
555 rnd = seed_value_to_mpfr_rnd_t(ctx, args[1], exception);
557 if ( seed_value_is_object_of_class(ctx, args[0], mpfr_class) )
559 op = seed_object_get_private(args[0]);
563 TYPE_EXCEPTION("mpfr.coth", "mpfr_t");
566 ret = mpfr_coth(rop, op, rnd);
568 return seed_value_from_int(ctx, ret, exception);
571 /* inverse hyperbolic trig */
573 SeedValue seed_mpfr_asinh (SeedContext ctx,
575 SeedObject this_object,
576 gsize argument_count,
577 const SeedValue args[],
578 SeedException * exception)
584 CHECK_ARG_COUNT("mpfr.asinh", 2);
586 rop = seed_object_get_private(this_object);
587 rnd = seed_value_to_mpfr_rnd_t(ctx, args[1], exception);
589 if ( seed_value_is_object_of_class(ctx, args[0], mpfr_class) )
591 op = seed_object_get_private(args[0]);
595 TYPE_EXCEPTION("mpfr.asinh", "mpfr_t");
598 ret = mpfr_asinh(rop, op, rnd);
600 return seed_value_from_int(ctx, ret, exception);
603 SeedValue seed_mpfr_acosh (SeedContext ctx,
605 SeedObject this_object,
606 gsize argument_count,
607 const SeedValue args[],
608 SeedException * exception)
614 CHECK_ARG_COUNT("mpfr.acosh", 2);
616 rop = seed_object_get_private(this_object);
617 rnd = seed_value_to_mpfr_rnd_t(ctx, args[1], exception);
619 if ( seed_value_is_object_of_class(ctx, args[0], mpfr_class) )
621 op = seed_object_get_private(args[0]);
625 TYPE_EXCEPTION("mpfr.acosh", "mpfr_t");
628 ret = mpfr_acosh(rop, op, rnd);
630 return seed_value_from_int(ctx, ret, exception);
633 SeedValue seed_mpfr_atanh (SeedContext ctx,
635 SeedObject this_object,
636 gsize argument_count,
637 const SeedValue args[],
638 SeedException * exception)
644 CHECK_ARG_COUNT("mpfr.atanh", 2);
646 rop = seed_object_get_private(this_object);
647 rnd = seed_value_to_mpfr_rnd_t(ctx, args[1], exception);
649 if ( seed_value_is_object_of_class(ctx, args[0], mpfr_class) )
651 op = seed_object_get_private(args[0]);
655 TYPE_EXCEPTION("mpfr.atanh", "mpfr_t");
658 ret = mpfr_atanh(rop, op, rnd);
660 return seed_value_from_int(ctx, ret, exception);
663 SeedValue seed_mpfr_log1p (SeedContext ctx,
665 SeedObject this_object,
666 gsize argument_count,
667 const SeedValue args[],
668 SeedException * exception)
674 CHECK_ARG_COUNT("mpfr.log1p", 2);
676 rop = seed_object_get_private(this_object);
677 rnd = seed_value_to_mpfr_rnd_t(ctx, args[1], exception);
679 if ( seed_value_is_object_of_class(ctx, args[0], mpfr_class) )
681 op = seed_object_get_private(args[0]);
685 TYPE_EXCEPTION("mpfr.log1p", "mpfr_t");
688 ret = mpfr_log1p(rop, op, rnd);
690 return seed_value_from_int(ctx, ret, exception);
693 SeedValue seed_mpfr_expm1 (SeedContext ctx,
695 SeedObject this_object,
696 gsize argument_count,
697 const SeedValue args[],
698 SeedException * exception)
704 CHECK_ARG_COUNT("mpfr.expm1", 2);
706 rop = seed_object_get_private(this_object);
707 rnd = seed_value_to_mpfr_rnd_t(ctx, args[1], exception);
709 if ( seed_value_is_object_of_class(ctx, args[0], mpfr_class) )
711 op = seed_object_get_private(args[0]);
715 TYPE_EXCEPTION("mpfr.expm1", "mpfr_t");
718 ret = mpfr_expm1(rop, op, rnd);
720 return seed_value_from_int(ctx, ret, exception);
723 SeedValue seed_mpfr_li2 (SeedContext ctx,
725 SeedObject this_object,
726 gsize argument_count,
727 const SeedValue args[],
728 SeedException * exception)
734 CHECK_ARG_COUNT("mpfr.li2", 2);
736 rop = seed_object_get_private(this_object);
737 rnd = seed_value_to_mpfr_rnd_t(ctx, args[1], exception);
739 if ( seed_value_is_object_of_class(ctx, args[0], mpfr_class) )
741 op = seed_object_get_private(args[0]);
745 TYPE_EXCEPTION("mpfr.li2", "mpfr_t");
748 ret = mpfr_li2(rop, op, rnd);
750 return seed_value_from_int(ctx, ret, exception);
753 SeedValue seed_mpfr_gamma (SeedContext ctx,
755 SeedObject this_object,
756 gsize argument_count,
757 const SeedValue args[],
758 SeedException * exception)
764 CHECK_ARG_COUNT("mpfr.gamma", 2);
766 rop = seed_object_get_private(this_object);
767 rnd = seed_value_to_mpfr_rnd_t(ctx, args[1], exception);
769 if ( seed_value_is_object_of_class(ctx, args[0], mpfr_class) )
771 op = seed_object_get_private(args[0]);
775 TYPE_EXCEPTION("mpfr.gamma", "mpfr_t");
778 ret = mpfr_gamma(rop, op, rnd);
780 return seed_value_from_int(ctx, ret, exception);
783 SeedValue seed_mpfr_lngamma (SeedContext ctx,
785 SeedObject this_object,
786 gsize argument_count,
787 const SeedValue args[],
788 SeedException * exception)
794 CHECK_ARG_COUNT("mpfr.lngamma", 2);
796 rop = seed_object_get_private(this_object);
797 rnd = seed_value_to_mpfr_rnd_t(ctx, args[1], exception);
799 if ( seed_value_is_object_of_class(ctx, args[0], mpfr_class) )
801 op = seed_object_get_private(args[0]);
805 TYPE_EXCEPTION("mpfr.lngamma", "mpfr_t");
808 ret = mpfr_lngamma(rop, op, rnd);
810 return seed_value_from_int(ctx, ret, exception);
813 SeedValue seed_mpfr_zeta (SeedContext ctx,
815 SeedObject this_object,
816 gsize argument_count,
817 const SeedValue args[],
818 SeedException * exception)
825 CHECK_ARG_COUNT("mpfr.zeta", 2);
827 rop = seed_object_get_private(this_object);
828 rnd = seed_value_to_mpfr_rnd_t(ctx, args[1], exception);
830 if ( seed_value_is_object_of_class(ctx, args[0], mpfr_class) )
832 op = seed_object_get_private(args[0]);
833 ret = mpfr_zeta(rop, op, rnd);
835 else if ( seed_value_is_number(ctx, args[0]) )
837 uiop = seed_value_to_ulong(ctx, args[0], exception);
838 ret = mpfr_zeta_ui(rop, uiop, rnd);
842 TYPE_EXCEPTION("mpfr.zeta", "mpfr_t or unsigned int");
845 return seed_value_from_int(ctx, ret, exception);
848 SeedValue seed_mpfr_erf (SeedContext ctx,
850 SeedObject this_object,
851 gsize argument_count,
852 const SeedValue args[],
853 SeedException * exception)
859 CHECK_ARG_COUNT("mpfr.erf", 2);
861 rop = seed_object_get_private(this_object);
862 rnd = seed_value_to_mpfr_rnd_t(ctx, args[1], exception);
864 if ( seed_value_is_object_of_class(ctx, args[0], mpfr_class) )
866 op = seed_object_get_private(args[0]);
870 TYPE_EXCEPTION("mpfr.erf", "mpfr_t");
873 ret = mpfr_erf(rop, op, rnd);
875 return seed_value_from_int(ctx, ret, exception);
878 SeedValue seed_mpfr_erfc (SeedContext ctx,
880 SeedObject this_object,
881 gsize argument_count,
882 const SeedValue args[],
883 SeedException * exception)
889 CHECK_ARG_COUNT("mpfr.erfc", 2);
891 rop = seed_object_get_private(this_object);
892 rnd = seed_value_to_mpfr_rnd_t(ctx, args[1], exception);
894 if ( seed_value_is_object_of_class(ctx, args[0], mpfr_class) )
896 op = seed_object_get_private(args[0]);
900 TYPE_EXCEPTION("mpfr.erfc", "mpfr_t");
903 ret = mpfr_erfc(rop, op, rnd);
905 return seed_value_from_int(ctx, ret, exception);
908 /* bessel functions */
909 SeedValue seed_mpfr_j0 (SeedContext ctx,
911 SeedObject this_object,
912 gsize argument_count,
913 const SeedValue args[],
914 SeedException * exception)
920 CHECK_ARG_COUNT("mpfr.j0", 2);
922 rop = seed_object_get_private(this_object);
923 rnd = seed_value_to_mpfr_rnd_t(ctx, args[1], exception);
925 if ( seed_value_is_object_of_class(ctx, args[0], mpfr_class) )
927 op = seed_object_get_private(args[0]);
931 TYPE_EXCEPTION("mpfr.j0", "mpfr_t");
934 ret = mpfr_j0(rop, op, rnd);
936 return seed_value_from_int(ctx, ret, exception);
939 SeedValue seed_mpfr_j1 (SeedContext ctx,
941 SeedObject this_object,
942 gsize argument_count,
943 const SeedValue args[],
944 SeedException * exception)
950 CHECK_ARG_COUNT("mpfr.j1", 2);
952 rop = seed_object_get_private(this_object);
953 rnd = seed_value_to_mpfr_rnd_t(ctx, args[1], exception);
955 if ( seed_value_is_object_of_class(ctx, args[0], mpfr_class) )
957 op = seed_object_get_private(args[0]);
961 TYPE_EXCEPTION("mpfr.j1", "mpfr_t");
964 ret = mpfr_j1(rop, op, rnd);
966 return seed_value_from_int(ctx, ret, exception);
969 SeedValue seed_mpfr_jn (SeedContext ctx,
971 SeedObject this_object,
972 gsize argument_count,
973 const SeedValue args[],
974 SeedException * exception)
980 CHECK_ARG_COUNT("mpfr.jn", 3);
982 rop = seed_object_get_private(this_object);
983 rnd = seed_value_to_mpfr_rnd_t(ctx, args[2], exception);
985 if ( seed_value_is_object_of_class(ctx, args[1], mpfr_class) )
987 op = seed_object_get_private(args[1]);
991 TYPE_EXCEPTION("mpfr.jn", "mpfr_t");
994 if ( seed_value_is_number(ctx, args[0]) )
996 n = seed_value_to_int(ctx, args[0], exception);
1000 TYPE_EXCEPTION("mpfr.jn", "int");
1003 ret = mpfr_jn(rop, n, op, rnd);
1005 return seed_value_from_int(ctx, ret, exception);
1008 SeedValue seed_mpfr_y0 (SeedContext ctx,
1009 SeedObject function,
1010 SeedObject this_object,
1011 gsize argument_count,
1012 const SeedValue args[],
1013 SeedException * exception)
1019 CHECK_ARG_COUNT("mpfr.y0", 2);
1021 rop = seed_object_get_private(this_object);
1022 rnd = seed_value_to_mpfr_rnd_t(ctx, args[1], exception);
1024 if ( seed_value_is_object_of_class(ctx, args[0], mpfr_class) )
1026 op = seed_object_get_private(args[0]);
1030 TYPE_EXCEPTION("mpfr.y0", "mpfr_t");
1033 ret = mpfr_y0(rop, op, rnd);
1035 return seed_value_from_int(ctx, ret, exception);
1038 SeedValue seed_mpfr_y1 (SeedContext ctx,
1039 SeedObject function,
1040 SeedObject this_object,
1041 gsize argument_count,
1042 const SeedValue args[],
1043 SeedException * exception)
1049 CHECK_ARG_COUNT("mpfr.y1", 2);
1051 rop = seed_object_get_private(this_object);
1052 rnd = seed_value_to_mpfr_rnd_t(ctx, args[1], exception);
1054 if ( seed_value_is_object_of_class(ctx, args[0], mpfr_class) )
1056 op = seed_object_get_private(args[0]);
1060 TYPE_EXCEPTION("mpfr.y1", "mpfr_t");
1063 ret = mpfr_y1(rop, op, rnd);
1065 return seed_value_from_int(ctx, ret, exception);
1068 SeedValue seed_mpfr_yn (SeedContext ctx,
1069 SeedObject function,
1070 SeedObject this_object,
1071 gsize argument_count,
1072 const SeedValue args[],
1073 SeedException * exception)
1079 CHECK_ARG_COUNT("mpfr.yn", 3);
1081 rop = seed_object_get_private(this_object);
1082 rnd = seed_value_to_mpfr_rnd_t(ctx, args[2], exception);
1084 if ( seed_value_is_object_of_class(ctx, args[1], mpfr_class) )
1086 op = seed_object_get_private(args[1]);
1090 TYPE_EXCEPTION("mpfr.yn", "mpfr_t");
1093 if ( seed_value_is_number(ctx, args[0]) )
1095 n = seed_value_to_int(ctx, args[0], exception);
1099 TYPE_EXCEPTION("mpfr.yn", "int");
1102 ret = mpfr_yn(rop, n, op, rnd);
1104 return seed_value_from_int(ctx, ret, exception);
1107 SeedValue seed_mpfr_fma (SeedContext ctx,
1108 SeedObject function,
1109 SeedObject this_object,
1110 gsize argument_count,
1111 const SeedValue args[],
1112 SeedException * exception)
1115 mpfr_ptr rop, op1, op2, op3;
1118 CHECK_ARG_COUNT("mpfr.fma", 4);
1120 rop = seed_object_get_private(this_object);
1121 rnd = seed_value_to_mpfr_rnd_t(ctx, args[3], exception);
1123 if ( seed_value_is_object_of_class(ctx, args[0], mpfr_class) &&
1124 seed_value_is_object_of_class(ctx, args[1], mpfr_class) &&
1125 seed_value_is_object_of_class(ctx, args[2], mpfr_class))
1127 op1 = seed_object_get_private(args[0]);
1128 op2 = seed_object_get_private(args[1]);
1129 op3 = seed_object_get_private(args[2]);
1133 TYPE_EXCEPTION("mpfr.fma", "mpfr_t");
1136 ret = mpfr_fma(rop, op1, op2, op3, rnd);
1138 return seed_value_from_int(ctx, ret, exception);
1141 SeedValue seed_mpfr_fms (SeedContext ctx,
1142 SeedObject function,
1143 SeedObject this_object,
1144 gsize argument_count,
1145 const SeedValue args[],
1146 SeedException * exception)
1149 mpfr_ptr rop, op1, op2, op3;
1152 CHECK_ARG_COUNT("mpfr.fms", 4);
1154 rop = seed_object_get_private(this_object);
1155 rnd = seed_value_to_mpfr_rnd_t(ctx, args[3], exception);
1157 if ( seed_value_is_object_of_class(ctx, args[0], mpfr_class) &&
1158 seed_value_is_object_of_class(ctx, args[1], mpfr_class) &&
1159 seed_value_is_object_of_class(ctx, args[2], mpfr_class))
1161 op1 = seed_object_get_private(args[0]);
1162 op2 = seed_object_get_private(args[1]);
1163 op3 = seed_object_get_private(args[2]);
1167 TYPE_EXCEPTION("mpfr.fms", "mpfr_t");
1170 ret = mpfr_fms(rop, op1, op2, op3, rnd);
1172 return seed_value_from_int(ctx, ret, exception);
1175 SeedValue seed_mpfr_agm (SeedContext ctx,
1176 SeedObject function,
1177 SeedObject this_object,
1178 gsize argument_count,
1179 const SeedValue args[],
1180 SeedException * exception)
1183 mpfr_ptr rop, op1, op2;
1186 CHECK_ARG_COUNT("mpfr.agm", 3);
1188 rop = seed_object_get_private(this_object);
1189 rnd = seed_value_to_mpfr_rnd_t(ctx, args[2], exception);
1191 if ( seed_value_is_object_of_class(ctx, args[0], mpfr_class) &&
1192 seed_value_is_object_of_class(ctx, args[1], mpfr_class))
1194 op1 = seed_object_get_private(args[0]);
1195 op2 = seed_object_get_private(args[1]);
1199 TYPE_EXCEPTION("mpfr.agm", "mpfr_t");
1202 ret = mpfr_agm(rop, op1, op2, rnd);
1204 return seed_value_from_int(ctx, ret, exception);
1207 SeedValue seed_mpfr_hypot (SeedContext ctx,
1208 SeedObject function,
1209 SeedObject this_object,
1210 gsize argument_count,
1211 const SeedValue args[],
1212 SeedException * exception)
1215 mpfr_ptr rop, op1, op2;
1218 CHECK_ARG_COUNT("mpfr.hypot", 3);
1220 rop = seed_object_get_private(this_object);
1221 rnd = seed_value_to_mpfr_rnd_t(ctx, args[2], exception);
1223 if ( seed_value_is_object_of_class(ctx, args[0], mpfr_class) &&
1224 seed_value_is_object_of_class(ctx, args[1], mpfr_class))
1226 op1 = seed_object_get_private(args[0]);
1227 op2 = seed_object_get_private(args[1]);
1231 TYPE_EXCEPTION("mpfr.hypot", "mpfr_t");
1234 ret = mpfr_hypot(rop, op1, op2, rnd);
1236 return seed_value_from_int(ctx, ret, exception);
1239 SeedValue seed_mpfr_free_cache (SeedContext ctx,
1240 SeedObject function,
1241 SeedObject this_object,
1242 gsize argument_count,
1243 const SeedValue args[],
1244 SeedException * exception)
1246 CHECK_ARG_COUNT("mpfr.free_cache", 0);
1248 return seed_make_null(ctx);
1251 SeedValue seed_mpfr_clear_flags (SeedContext ctx,
1252 SeedObject function,
1253 SeedObject this_object,
1254 gsize argument_count,
1255 const SeedValue args[],
1256 SeedException * exception)
1258 CHECK_ARG_COUNT("mpfr.clear_flags", 0);
1260 return seed_make_null(ctx);