@@ -1,150 +1,157 @@
-1.01
- - Alter the way that strEQ gets hold of HvNAME(SvSTASH(SvRV(sv))) - so that -Wall
- doesn't emit "null argument" warnings. (Thanks Daniel Kahn Gillmor.)
- - Alter test 5 of t/complex_c.t to accommodate version 0.07 (and later) of
- Math::Complex_C.
-
-1.00
- - Add Rmpc_log10, Rmpc_mul2si and Rmpc-div_2si (new in 1.0.0)
- - Accommodate namechange of mpc_mul_2exp and mpc_div_2exp to mpc_mul_2ui
- and mpc_div_2ui (respectively) in mpc-1.0.0.
- - Rewrite the detecting of availability of double _Complex and long double _Complex
- types by looking for _Complex_I instead of _MPC_H_HAVE_COMPLEX (in line with
- the way mpc.h currently does it).
-
-0.93
- - Remove 'not' from overloads. Apparently achieved nothing anyway, and 5.16
- warns that it's invalid.
-
-0.92
- - The default rounding mode and default precision globals are now thread-safe.
- Consequently at least 5.008008 is required.
-
-0.91
- - overload_equiv and overload_not_equiv weren't correctly handling the
- case where the NV is a NaN. (Add tests in mpc_overload.t.)
-
-0.90
- - Add Rmpc_sin_cos, Rmpc_set_dc, Rmpc_set_ldc, Rmpc_get_dc, Rmpc_get_ldc
- (new in mpc-0.9).
- - Add documentation of gmp_v and mpfr_v (previously missed).
- - In the documentation, elaborate on the way that Rmpc_get-version() and
- MPC_VERSION & friends determine their values. (Thanks Vincent Lefevre.)
- - In MPC.xs change mpfr_v() to return mpfr_get_version() instead of
- MPC_VERSION_STRING.
- - In t/aab_basic.t print out the mpfr and mpc library versions from
- the libraries, instead of from the headers (as had been the case)
- - Some of the croak() messages in MPC.xs finished with "\n" - which
- has now been removed from those messages.
- - Releases of the MPC library (after 0.8.2) will require gmp-4.3.2
- and mpfr-2.4.2. README and Makefile.PL have now been changed.
-
-0.83
- - Add some warn() statements to t/bool.t, to try and see why test 2
- fails - as reported by one of the cpan-testers. (That done, I
- received an email from Jean-Louis Morel, with a patch that fixes
- the issue ... I'll retain t/bool.t in its modified state.)
- - Patch overload_not, overload_not_equiv and overload_equiv (in
- MPC.xs) so that NaNs do not get passed on to the MPC comparison
- functions (as this is something forbidden by the documentation).
- Thanks to Jean-Louis Morel.
-
-0.82
- - Implement '#include <inttypes.h>'. (Should have been done for 0.81.)
- See https://rt.cpan.org/Ticket/Display.html?id=58564
-
-0.81
- - Change the overload_string() and _get_str() functions to match the
- formatting provided by mpc_out_str().
- - Fix the signed zero problem with overloaded mul and div operations,
- and add t/signed_zero.t as a check. Thanks Paul Zimmerman and
- Philippe Theveny.
- - Add Rmpc_mul_sj, Rmpc_mul_ld, Rmpc_mul_d, Rmpc_div_sj, Rmpc_sj_div,
- Rmpc_div_ld, Rmpc_ld_div, Rmpc_div_d and Rmpc_d_div. These simply
- wrap the the XSubs created to fix the signed zero anomaly (above).
-
-0.80
- - Requires version 0.8 of the mpc library.
- - Add Rmpc_asin, Rmpc_acos, Rmpc_atan, Rmpc_asinh, Rmpc_acosh and
- Rmpc_atanh (new in mpc-0.8).
- - Add Rmpc_pow_d, Rmpc_pow_ld, Rmpc_pow_si, Rmpc_pow_ui, Rmpc_pow_z
- and Rmpc_pow_fr (new in mpc-0.8).
- - Add overloaded atan2 function.
-
-0.70
- - Requires version 0.7 of the mpc library. (Change to MPC_SET_X_Y.)
- - Remove Rmpc_random and Rmpc_random2 (as the functions that they
- wrap have been removed in mpc-0.7. (And remove t/mpc_random.t.)
- - Add Rmpc_pow, Rmpc_set_nan and Rmpc_swap (new in mpc-0.7).
- - Overload the ** and **= operators.
- - Improve the efficiency of some of the overload routines by
- eliminating the need to use a temporary mpfr object (using the
- already existing *mpc_t_obj instead).
- - Remove the rounding arg from RMPC_RE() and RMPC_IM() as it does
- nothing, anyway.
-
-0.60
- - Requires version 0.6 of the mpc library.
- - Now a complete range of Rmpc_set_*_* functions (where '*' can be any
- one of 'ui', 'si', 'd', 'uj', 'sj', 'ld', 'f', 'q', 'z' and 'fr').
- - Add Rmpc_set_z, Rmpc_set_q, Rmpc_set_f and Rmpc_set_fr.
- - Add Rmpc_set_z_z, Rmpc_set_q_q and Rmpc_set_f_f.
- - In keeping with changes to the mpc library, all of the Rmpc_init*
- functions have been removed except for Rmpc_init2 and Rmpc_init3
- (and their "_nobless" forms).
- - mpc-0.60 has removed mpc_get_default_prec and mpc_set_default_prec.
- Rmpc_get_default_prec and Rmpc_set_default_prec remain (but the
- former has changed to return 0 if default real and imaginary
- precisions are different. With earlier versions, real and imaginary
- default precisions were always the same, but this is no longer the
- case). Rmpc_get_default_prec2 and Rmpc_set_default_prec2 have now
- been added. The former returns an array of 2 values(real,
- imaginary) and the latter requires 2 arguments (real, imaginary).
- - The overload_copy sub now preserves the precision of the copied object
- (instead of assigning default precision as was previously the case).
- - Rmpc_get_str now wraps mpc_get_str (available in 0.6). The (pure perl)
- sub that was formerly "Rmpc_get_str" has been renamed "_get_str".
- The "overload_string" sub is unchanged.
- - Add Rmpc_set_uj, Rmpc_set_sj and Rmpc_set_ld (available in mpc-0.6).
- - Add Rmpc_strtoc and Rmpc_set_str (available in 0.6), and add set_str.t
- test script.
-
-0.52
- - Requires version 0.5.2 of the mpc library.
- - Add MPC_VERSION, MPC_VERSION_NUM and Rmpc_get_version.
-
-0.51
- - Requires version 0.5.1 of the mpc library.
- - Add MPC_VERSION_STRING, MPC_VERSION_MAJOR, MPC_VERSION_MINOR
- and MPC_VERSION_PATCHLEVEL.
- - Replace pre-existing Rmpc_set_fr_fr with a function that wraps
- the mpc_set_fr_fr function (which became available in 0.5.1)
- - Add Rmpc_real, Rmpc_imag, Rmpc_arg, Rmpc_proj (new in 0.5.1)
-
-0.50
- - Requires version 0.50 of the mpc library.
- - Add Rmpc_log, Rmpc_cos, Rmpc_tan, Rmpc_sinh, Rmpc_cosh, and
- Rmpc_tanh - all of which became available with mpc-0.5.
- - Add log and cos overloading.
- - Remove (the need for) INLINE.h
- - Add mpfr_v and gmp_v functions (not exported).
- - mpc_out_str changed with mpc-0.5. The tests in out_str1.t and
- out_str2.t were changed accordingly.
- - Bring Rmpc_get_str in line with the changed formatting of
- mpc_out_str that occurred with mpc-0.5.
-
-0.46
- - Add overloading of 'bool'.
- - Change Rmpc_out_str and Rmpc_inp_str to allow use of streams other
- than STDOUT and STDIN.
- - For compatibility with my other MPFR/GMP based perl modules, add
- TRmpc_out_str and TRmpc_inp_str (which, for Math::MPC only, are
- aliased to Rmpc_out_str and Rmpc_inp_str respectively).
- - Change 'Rmpc_get_prec' return to match 'mpc_get_prec' (which is a new
- inclusion in mpc-0.4.6).
- - Add 'Rmpc_get_prec2' and 'Rmpc_sin' (new in mpc-0.4.6).
- - Remove the tests in the Makefile.PL that test for the presence of
- a suitable compiler, GMP library, MPFR library and MPC library.
-
-0.45
- - First release
\ No newline at end of file
+1.02
+ - _has_inttypes() no longer checks for whether USE_LONG_DOUBLE is defined.
+ (Was harmless ... but didn't make much sense.)
+ - Define PERL_NO_GET_CONTEXT.
+ - Tweak to Math::MPC::gmp_v().
+ - Add metadata to Makefile.PL.
+
+1.01
+ - Alter the way that strEQ gets hold of HvNAME(SvSTASH(SvRV(sv))) - so that -Wall
+ doesn't emit "null argument" warnings. (Thanks Daniel Kahn Gillmor.)
+ - Alter test 5 of t/complex_c.t to accommodate version 0.07 (and later) of
+ Math::Complex_C.
+
+1.00
+ - Add Rmpc_log10, Rmpc_mul2si and Rmpc-div_2si (new in 1.0.0)
+ - Accommodate namechange of mpc_mul_2exp and mpc_div_2exp to mpc_mul_2ui
+ and mpc_div_2ui (respectively) in mpc-1.0.0.
+ - Rewrite the detecting of availability of double _Complex and long double _Complex
+ types by looking for _Complex_I instead of _MPC_H_HAVE_COMPLEX (in line with
+ the way mpc.h currently does it).
+
+0.93
+ - Remove 'not' from overloads. Apparently achieved nothing anyway, and 5.16
+ warns that it's invalid.
+
+0.92
+ - The default rounding mode and default precision globals are now thread-safe.
+ Consequently at least 5.008008 is required.
+
+0.91
+ - overload_equiv and overload_not_equiv weren't correctly handling the
+ case where the NV is a NaN. (Add tests in mpc_overload.t.)
+
+0.90
+ - Add Rmpc_sin_cos, Rmpc_set_dc, Rmpc_set_ldc, Rmpc_get_dc, Rmpc_get_ldc
+ (new in mpc-0.9).
+ - Add documentation of gmp_v and mpfr_v (previously missed).
+ - In the documentation, elaborate on the way that Rmpc_get-version() and
+ MPC_VERSION & friends determine their values. (Thanks Vincent Lefevre.)
+ - In MPC.xs change mpfr_v() to return mpfr_get_version() instead of
+ MPC_VERSION_STRING.
+ - In t/aab_basic.t print out the mpfr and mpc library versions from
+ the libraries, instead of from the headers (as had been the case)
+ - Some of the croak() messages in MPC.xs finished with "\n" - which
+ has now been removed from those messages.
+ - Releases of the MPC library (after 0.8.2) will require gmp-4.3.2
+ and mpfr-2.4.2. README and Makefile.PL have now been changed.
+
+0.83
+ - Add some warn() statements to t/bool.t, to try and see why test 2
+ fails - as reported by one of the cpan-testers. (That done, I
+ received an email from Jean-Louis Morel, with a patch that fixes
+ the issue ... I'll retain t/bool.t in its modified state.)
+ - Patch overload_not, overload_not_equiv and overload_equiv (in
+ MPC.xs) so that NaNs do not get passed on to the MPC comparison
+ functions (as this is something forbidden by the documentation).
+ Thanks to Jean-Louis Morel.
+
+0.82
+ - Implement '#include <inttypes.h>'. (Should have been done for 0.81.)
+ See https://rt.cpan.org/Ticket/Display.html?id=58564
+
+0.81
+ - Change the overload_string() and _get_str() functions to match the
+ formatting provided by mpc_out_str().
+ - Fix the signed zero problem with overloaded mul and div operations,
+ and add t/signed_zero.t as a check. Thanks Paul Zimmerman and
+ Philippe Theveny.
+ - Add Rmpc_mul_sj, Rmpc_mul_ld, Rmpc_mul_d, Rmpc_div_sj, Rmpc_sj_div,
+ Rmpc_div_ld, Rmpc_ld_div, Rmpc_div_d and Rmpc_d_div. These simply
+ wrap the the XSubs created to fix the signed zero anomaly (above).
+
+0.80
+ - Requires version 0.8 of the mpc library.
+ - Add Rmpc_asin, Rmpc_acos, Rmpc_atan, Rmpc_asinh, Rmpc_acosh and
+ Rmpc_atanh (new in mpc-0.8).
+ - Add Rmpc_pow_d, Rmpc_pow_ld, Rmpc_pow_si, Rmpc_pow_ui, Rmpc_pow_z
+ and Rmpc_pow_fr (new in mpc-0.8).
+ - Add overloaded atan2 function.
+
+0.70
+ - Requires version 0.7 of the mpc library. (Change to MPC_SET_X_Y.)
+ - Remove Rmpc_random and Rmpc_random2 (as the functions that they
+ wrap have been removed in mpc-0.7. (And remove t/mpc_random.t.)
+ - Add Rmpc_pow, Rmpc_set_nan and Rmpc_swap (new in mpc-0.7).
+ - Overload the ** and **= operators.
+ - Improve the efficiency of some of the overload routines by
+ eliminating the need to use a temporary mpfr object (using the
+ already existing *mpc_t_obj instead).
+ - Remove the rounding arg from RMPC_RE() and RMPC_IM() as it does
+ nothing, anyway.
+
+0.60
+ - Requires version 0.6 of the mpc library.
+ - Now a complete range of Rmpc_set_*_* functions (where '*' can be any
+ one of 'ui', 'si', 'd', 'uj', 'sj', 'ld', 'f', 'q', 'z' and 'fr').
+ - Add Rmpc_set_z, Rmpc_set_q, Rmpc_set_f and Rmpc_set_fr.
+ - Add Rmpc_set_z_z, Rmpc_set_q_q and Rmpc_set_f_f.
+ - In keeping with changes to the mpc library, all of the Rmpc_init*
+ functions have been removed except for Rmpc_init2 and Rmpc_init3
+ (and their "_nobless" forms).
+ - mpc-0.60 has removed mpc_get_default_prec and mpc_set_default_prec.
+ Rmpc_get_default_prec and Rmpc_set_default_prec remain (but the
+ former has changed to return 0 if default real and imaginary
+ precisions are different. With earlier versions, real and imaginary
+ default precisions were always the same, but this is no longer the
+ case). Rmpc_get_default_prec2 and Rmpc_set_default_prec2 have now
+ been added. The former returns an array of 2 values(real,
+ imaginary) and the latter requires 2 arguments (real, imaginary).
+ - The overload_copy sub now preserves the precision of the copied object
+ (instead of assigning default precision as was previously the case).
+ - Rmpc_get_str now wraps mpc_get_str (available in 0.6). The (pure perl)
+ sub that was formerly "Rmpc_get_str" has been renamed "_get_str".
+ The "overload_string" sub is unchanged.
+ - Add Rmpc_set_uj, Rmpc_set_sj and Rmpc_set_ld (available in mpc-0.6).
+ - Add Rmpc_strtoc and Rmpc_set_str (available in 0.6), and add set_str.t
+ test script.
+
+0.52
+ - Requires version 0.5.2 of the mpc library.
+ - Add MPC_VERSION, MPC_VERSION_NUM and Rmpc_get_version.
+
+0.51
+ - Requires version 0.5.1 of the mpc library.
+ - Add MPC_VERSION_STRING, MPC_VERSION_MAJOR, MPC_VERSION_MINOR
+ and MPC_VERSION_PATCHLEVEL.
+ - Replace pre-existing Rmpc_set_fr_fr with a function that wraps
+ the mpc_set_fr_fr function (which became available in 0.5.1)
+ - Add Rmpc_real, Rmpc_imag, Rmpc_arg, Rmpc_proj (new in 0.5.1)
+
+0.50
+ - Requires version 0.50 of the mpc library.
+ - Add Rmpc_log, Rmpc_cos, Rmpc_tan, Rmpc_sinh, Rmpc_cosh, and
+ Rmpc_tanh - all of which became available with mpc-0.5.
+ - Add log and cos overloading.
+ - Remove (the need for) INLINE.h
+ - Add mpfr_v and gmp_v functions (not exported).
+ - mpc_out_str changed with mpc-0.5. The tests in out_str1.t and
+ out_str2.t were changed accordingly.
+ - Bring Rmpc_get_str in line with the changed formatting of
+ mpc_out_str that occurred with mpc-0.5.
+
+0.46
+ - Add overloading of 'bool'.
+ - Change Rmpc_out_str and Rmpc_inp_str to allow use of streams other
+ than STDOUT and STDIN.
+ - For compatibility with my other MPFR/GMP based perl modules, add
+ TRmpc_out_str and TRmpc_inp_str (which, for Math::MPC only, are
+ aliased to Rmpc_out_str and Rmpc_inp_str respectively).
+ - Change 'Rmpc_get_prec' return to match 'mpc_get_prec' (which is a new
+ inclusion in mpc-0.4.6).
+ - Add 'Rmpc_get_prec2' and 'Rmpc_sin' (new in mpc-0.4.6).
+ - Remove the tests in the Makefile.PL that test for the presence of
+ a suitable compiler, GMP library, MPFR library and MPC library.
+
+0.45
+ - First release
@@ -1,33 +1,35 @@
-MANIFEST
-Makefile.PL
-MPC.pm
-MPC.xs
-README
-CHANGES
-t/aaa_compat.t
-t/aab_basic.t
-t/bool.t
-t/complex_c.t
-t/get_str.t
-t/mpc_64.t
-t/mpc_add.t
-t/mpc_cmp.t
-t/mpc_mpfr.t
-t/mpc_mul.t
-t/mpc_nan.t
-t/mpc_new.t
-t/mpc_overload.t
-t/mpc_pow.t
-t/mpc_prec.t
-t/mpc_round.t
-t/mpc_set.t
-t/mpc_swap.t
-t/mpc_trig.t
-t/out_str1.t
-t/out_str2.t
-t/pod.t
-t/set_str.t
-t/signed_zero.t
-t/special.t
-t/tls.t
-typemap
\ No newline at end of file
+MANIFEST
+Makefile.PL
+MPC.pm
+MPC.xs
+README
+CHANGES
+t/aaa_compat.t
+t/aab_basic.t
+t/bool.t
+t/complex_c.t
+t/get_str.t
+t/mpc_64.t
+t/mpc_add.t
+t/mpc_cmp.t
+t/mpc_mpfr.t
+t/mpc_mul.t
+t/mpc_nan.t
+t/mpc_new.t
+t/mpc_overload.t
+t/mpc_pow.t
+t/mpc_prec.t
+t/mpc_round.t
+t/mpc_set.t
+t/mpc_swap.t
+t/mpc_trig.t
+t/out_str1.t
+t/out_str2.t
+t/pod.t
+t/set_str.t
+t/signed_zero.t
+t/special.t
+t/tls.t
+typemap
+META.yml Module YAML meta-data (added by MakeMaker)
+META.json Module JSON meta-data (added by MakeMaker)
@@ -0,0 +1,31 @@
+{
+ "abstract" : "Perl interface to the MPC (multi precision complex) library",
+ "author" : [
+ "Sisyphus (sisyphus at (@) cpan dot (.) org)"
+ ],
+ "dynamic_config" : 1,
+ "generated_by" : "ExtUtils::MakeMaker version 6.6302, CPAN::Meta::Converter version 2.120630",
+ "license" : [
+ "perl_5"
+ ],
+ "meta-spec" : {
+ "url" : "http://search.cpan.org/perldoc?CPAN::Meta::Spec",
+ "version" : "2"
+ },
+ "name" : "Math-MPC",
+ "no_index" : {
+ "directory" : [
+ "t",
+ "inc"
+ ]
+ },
+ "release_status" : "stable",
+ "resources" : {
+ "repository" : {
+ "type" : "git",
+ "url" : "https://github.com/sisyphus/math-mpc.git",
+ "web" : "https://github.com/sisyphus/math-mpc"
+ }
+ },
+ "version" : "1.02"
+}
@@ -0,0 +1,19 @@
+---
+abstract: 'Perl interface to the MPC (multi precision complex) library'
+author:
+ - 'Sisyphus (sisyphus at (@) cpan dot (.) org)'
+build_requires: {}
+dynamic_config: 1
+generated_by: 'ExtUtils::MakeMaker version 6.6302, CPAN::Meta::Converter version 2.120630'
+license: perl
+meta-spec:
+ url: http://module-build.sourceforge.net/META-spec-v1.4.html
+ version: 1.4
+name: Math-MPC
+no_index:
+ directory:
+ - t
+ - inc
+resources:
+ repository: https://github.com/sisyphus/math-mpc.git
+version: 1.02
@@ -1,1213 +1,1213 @@
- package Math::MPC;
- use strict;
- use warnings;
-
- use constant MPC_RNDNN => 0;
- use constant MPC_RNDZN => 1;
- use constant MPC_RNDUN => 2;
- use constant MPC_RNDDN => 3;
-
- use constant MPC_RNDNZ => 16;
- use constant MPC_RNDZZ => 17;
- use constant MPC_RNDUZ => 18;
- use constant MPC_RNDDZ => 19;
-
- use constant MPC_RNDNU => 32;
- use constant MPC_RNDZU => 33;
- use constant MPC_RNDUU => 34;
- use constant MPC_RNDDU => 35;
-
- use constant MPC_RNDND => 48;
- use constant MPC_RNDZD => 49;
- use constant MPC_RNDUD => 50;
- use constant MPC_RNDDD => 51;
-
- use constant _UOK_T => 1;
- use constant _IOK_T => 2;
- use constant _NOK_T => 3;
- use constant _POK_T => 4;
- use constant _MATH_MPFR_T => 5;
- use constant _MATH_GMPf_T => 6;
- use constant _MATH_GMPq_T => 7;
- use constant _MATH_GMPz_T => 8;
- use constant _MATH_GMP_T => 9;
- use constant _MATH_MPC_T => 10;
-
- use subs qw(MPC_VERSION MPC_VERSION_MAJOR MPC_VERSION_MINOR
- MPC_VERSION_PATCHLEVEL MPC_VERSION_STRING
- MPC_VERSION MPC_VERSION_NUM);
-
- use overload
- '+' => \&overload_add,
- '-' => \&overload_sub,
- '*' => \&overload_mul,
- '/' => \&overload_div,
- '**' => \&overload_pow,
- '+=' => \&overload_add_eq,
- '-=' => \&overload_sub_eq,
- '*=' => \&overload_mul_eq,
- '/=' => \&overload_div_eq,
- '**=' => \&overload_pow_eq,
- '==' => \&overload_equiv,
- '!=' => \&overload_not_equiv,
- '!' => \&overload_not,
- '=' => \&overload_copy,
- '""' => \&overload_string,
- 'abs' => \&overload_abs,
- 'bool' => \&overload_true,
- 'exp' => \&overload_exp,
- 'log' => \&overload_log,
- 'sqrt' => \&overload_sqrt,
- 'sin' => \&overload_sin,
- 'cos' => \&overload_cos,
- 'atan2'=> \&overload_atan2;
-
- require Exporter;
- *import = \&Exporter::import;
- require DynaLoader;
-
- @Math::MPC::EXPORT_OK = qw(
-MPC_RNDNN MPC_RNDND MPC_RNDNU MPC_RNDNZ MPC_RNDDN MPC_RNDUN MPC_RNDZN MPC_RNDDD
-MPC_RNDDU MPC_RNDDZ MPC_RNDZD MPC_RNDUD MPC_RNDUU MPC_RNDUZ MPC_RNDZU MPC_RNDZZ
-MPC_VERSION_MAJOR MPC_VERSION_MINOR MPC_VERSION_PATCHLEVEL MPC_VERSION_STRING
-MPC_VERSION MPC_VERSION_NUM Rmpc_get_version
-Rmpc_set_default_rounding_mode Rmpc_get_default_rounding_mode
-Rmpc_set_prec Rmpc_set_default_prec Rmpc_get_default_prec
-Rmpc_set_default_prec2 Rmpc_get_default_prec2
-Rmpc_set_re_prec Rmpc_set_im_prec
-Rmpc_get_prec Rmpc_get_prec2 Rmpc_get_re_prec Rmpc_get_im_prec
-Rmpc_get_dc Rmpc_get_ldc
-RMPC_RE RMPC_IM RMPC_INEX_RE RMPC_INEX_IM
-Rmpc_clear Rmpc_clear_ptr Rmpc_clear_mpc
-Rmpc_deref4 Rmpc_get_str
-Rmpc_init2 Rmpc_init3
-Rmpc_init2_nobless Rmpc_init3_nobless
-Rmpc_strtoc Rmpc_set_str
-Rmpc_set Rmpc_set_ui Rmpc_set_si Rmpc_set_d Rmpc_set_uj Rmpc_set_sj Rmpc_set_ld
-Rmpc_set_z Rmpc_set_q Rmpc_set_f Rmpc_set_fr
-Rmpc_set_z_z Rmpc_set_q_q Rmpc_set_f_f
-Rmpc_set_ui_ui Rmpc_set_ui_si Rmpc_set_ui_d Rmpc_set_ui_uj Rmpc_set_ui_sj Rmpc_set_ui_ld Rmpc_set_ui_fr
-Rmpc_set_si_ui Rmpc_set_si_si Rmpc_set_si_d Rmpc_set_si_uj Rmpc_set_si_sj Rmpc_set_si_ld Rmpc_set_si_fr
-Rmpc_set_d_ui Rmpc_set_d_si Rmpc_set_d_d Rmpc_set_d_uj Rmpc_set_d_sj Rmpc_set_d_ld Rmpc_set_d_fr
-Rmpc_set_uj_ui Rmpc_set_uj_si Rmpc_set_uj_d Rmpc_set_uj_uj Rmpc_set_uj_sj Rmpc_set_uj_ld Rmpc_set_uj_ld Rmpc_set_uj_fr
-Rmpc_set_sj_ui Rmpc_set_sj_si Rmpc_set_sj_d Rmpc_set_sj_uj Rmpc_set_sj_sj Rmpc_set_sj_ld Rmpc_set_sj_fr
-Rmpc_set_ld_ui Rmpc_set_ld_si Rmpc_set_ld_uj Rmpc_set_ld_d Rmpc_set_ld_sj Rmpc_set_ld_ld Rmpc_set_ld_fr
-Rmpc_set_fr_ui Rmpc_set_fr_si Rmpc_set_fr_d Rmpc_set_fr_uj Rmpc_set_fr_sj Rmpc_set_fr_ld Rmpc_set_fr_fr
-
-Rmpc_set_f_ui Rmpc_set_q_ui Rmpc_set_z_ui Rmpc_set_ui_f Rmpc_set_ui_q Rmpc_set_ui_z
-Rmpc_set_f_si Rmpc_set_q_si Rmpc_set_z_si Rmpc_set_si_f Rmpc_set_si_q Rmpc_set_si_z
-Rmpc_set_f_d Rmpc_set_q_d Rmpc_set_z_d Rmpc_set_d_f Rmpc_set_d_q Rmpc_set_d_z
-Rmpc_set_f_uj Rmpc_set_q_uj Rmpc_set_z_uj Rmpc_set_uj_f Rmpc_set_uj_q Rmpc_set_uj_z
-Rmpc_set_f_sj Rmpc_set_q_sj Rmpc_set_z_sj Rmpc_set_sj_f Rmpc_set_sj_q Rmpc_set_sj_z
-Rmpc_set_f_ld Rmpc_set_q_ld Rmpc_set_z_ld Rmpc_set_ld_f Rmpc_set_ld_q Rmpc_set_ld_z
-Rmpc_set_f_q Rmpc_set_q_f Rmpc_set_f_z Rmpc_set_z_f Rmpc_set_z_q Rmpc_set_q_z
-Rmpc_set_f_fr Rmpc_set_q_fr Rmpc_set_z_fr Rmpc_set_fr_f Rmpc_set_fr_q Rmpc_set_fr_z
-
-Rmpc_set_dc Rmpc_set_ldc
-
-Rmpc_add Rmpc_add_ui Rmpc_add_fr
-Rmpc_sub Rmpc_sub_ui Rmpc_ui_sub Rmpc_ui_ui_sub
-Rmpc_mul Rmpc_mul_ui Rmpc_mul_si Rmpc_mul_fr Rmpc_mul_i Rmpc_sqr Rmpc_mul_2exp
-Rmpc_mul_2si Rmpc_mul_2ui
-Rmpc_div Rmpc_div_ui Rmpc_ui_div Rmpc_div_fr Rmpc_sqrt Rmpc_div_2exp
-Rmpc_div_2si Rmpc_div_2ui
-Rmpc_neg Rmpc_abs Rmpc_conj Rmpc_norm Rmpc_exp Rmpc_log Rmpc_log10
-Rmpc_cmp Rmpc_cmp_si Rmpc_cmp_si_si
-Rmpc_out_str Rmpc_inp_str c_string r_string i_string
-TRmpc_out_str TRmpc_inp_str
-Rmpc_sin Rmpc_cos Rmpc_sin_cos Rmpc_tan Rmpc_sinh Rmpc_cosh Rmpc_tanh
-Rmpc_asin Rmpc_acos Rmpc_atan Rmpc_asinh Rmpc_acosh Rmpc_atanh
-Rmpc_real Rmpc_imag Rmpc_arg Rmpc_proj
-Rmpc_pow Rmpc_pow_d Rmpc_pow_ld Rmpc_pow_si Rmpc_pow_ui Rmpc_pow_z Rmpc_pow_fr
-Rmpc_set_nan Rmpc_swap
-Rmpc_mul_sj Rmpc_mul_ld Rmpc_mul_d Rmpc_div_sj Rmpc_sj_div Rmpc_div_ld Rmpc_ld_div Rmpc_div_d Rmpc_d_div
-);
-
- our $VERSION = '1.01';
- $VERSION = eval $VERSION;
-
- DynaLoader::bootstrap Math::MPC $VERSION;
-
- %Math::MPC::EXPORT_TAGS =(mpc => [qw(
-MPC_RNDNN MPC_RNDND MPC_RNDNU MPC_RNDNZ MPC_RNDDN MPC_RNDUN MPC_RNDZN MPC_RNDDD
-MPC_RNDDU MPC_RNDDZ MPC_RNDZD MPC_RNDUD MPC_RNDUU MPC_RNDUZ MPC_RNDZU MPC_RNDZZ
-MPC_VERSION_MAJOR MPC_VERSION_MINOR MPC_VERSION_PATCHLEVEL MPC_VERSION_STRING
-MPC_VERSION MPC_VERSION_NUM Rmpc_get_version
-Rmpc_set_default_rounding_mode Rmpc_get_default_rounding_mode
-Rmpc_set_prec Rmpc_set_default_prec Rmpc_get_default_prec
-Rmpc_set_default_prec2 Rmpc_get_default_prec2
-Rmpc_set_re_prec Rmpc_set_im_prec
-Rmpc_get_prec Rmpc_get_prec2 Rmpc_get_re_prec Rmpc_get_im_prec
-Rmpc_get_dc Rmpc_get_ldc
-RMPC_RE RMPC_IM RMPC_INEX_RE RMPC_INEX_IM
-Rmpc_clear Rmpc_clear_ptr Rmpc_clear_mpc
-Rmpc_deref4 Rmpc_get_str
-Rmpc_init2 Rmpc_init3
-Rmpc_init2_nobless Rmpc_init3_nobless
-Rmpc_strtoc Rmpc_set_str
-Rmpc_set Rmpc_set_ui Rmpc_set_si Rmpc_set_d Rmpc_set_uj Rmpc_set_sj Rmpc_set_ld
-Rmpc_set_z Rmpc_set_q Rmpc_set_f Rmpc_set_fr
-Rmpc_set_z_z Rmpc_set_q_q Rmpc_set_f_f
-Rmpc_set_ui_ui Rmpc_set_ui_si Rmpc_set_ui_d Rmpc_set_ui_uj Rmpc_set_ui_sj Rmpc_set_ui_ld Rmpc_set_ui_fr
-Rmpc_set_si_ui Rmpc_set_si_si Rmpc_set_si_d Rmpc_set_si_uj Rmpc_set_si_sj Rmpc_set_si_ld Rmpc_set_si_fr
-Rmpc_set_d_ui Rmpc_set_d_si Rmpc_set_d_d Rmpc_set_d_uj Rmpc_set_d_sj Rmpc_set_d_ld Rmpc_set_d_fr
-Rmpc_set_uj_ui Rmpc_set_uj_si Rmpc_set_uj_d Rmpc_set_uj_uj Rmpc_set_uj_sj Rmpc_set_uj_ld Rmpc_set_uj_ld Rmpc_set_uj_fr
-Rmpc_set_sj_ui Rmpc_set_sj_si Rmpc_set_sj_d Rmpc_set_sj_uj Rmpc_set_sj_sj Rmpc_set_sj_ld Rmpc_set_sj_fr
-Rmpc_set_ld_ui Rmpc_set_ld_si Rmpc_set_ld_uj Rmpc_set_ld_d Rmpc_set_ld_sj Rmpc_set_ld_ld Rmpc_set_ld_fr
-Rmpc_set_fr_ui Rmpc_set_fr_si Rmpc_set_fr_d Rmpc_set_fr_uj Rmpc_set_fr_sj Rmpc_set_fr_ld Rmpc_set_fr_fr
-
-Rmpc_set_f_ui Rmpc_set_q_ui Rmpc_set_z_ui Rmpc_set_ui_f Rmpc_set_ui_q Rmpc_set_ui_z
-Rmpc_set_f_si Rmpc_set_q_si Rmpc_set_z_si Rmpc_set_si_f Rmpc_set_si_q Rmpc_set_si_z
-Rmpc_set_f_d Rmpc_set_q_d Rmpc_set_z_d Rmpc_set_d_f Rmpc_set_d_q Rmpc_set_d_z
-Rmpc_set_f_uj Rmpc_set_q_uj Rmpc_set_z_uj Rmpc_set_uj_f Rmpc_set_uj_q Rmpc_set_uj_z
-Rmpc_set_f_sj Rmpc_set_q_sj Rmpc_set_z_sj Rmpc_set_sj_f Rmpc_set_sj_q Rmpc_set_sj_z
-Rmpc_set_f_ld Rmpc_set_q_ld Rmpc_set_z_ld Rmpc_set_ld_f Rmpc_set_ld_q Rmpc_set_ld_z
-Rmpc_set_f_q Rmpc_set_q_f Rmpc_set_f_z Rmpc_set_z_f Rmpc_set_z_q Rmpc_set_q_z
-Rmpc_set_f_fr Rmpc_set_q_fr Rmpc_set_z_fr Rmpc_set_fr_f Rmpc_set_fr_q Rmpc_set_fr_z
-
-Rmpc_set_dc Rmpc_set_ldc
-
-Rmpc_add Rmpc_add_ui Rmpc_add_fr
-Rmpc_sub Rmpc_sub_ui Rmpc_ui_sub Rmpc_ui_ui_sub
-Rmpc_mul Rmpc_mul_ui Rmpc_mul_si Rmpc_mul_fr Rmpc_mul_i Rmpc_sqr Rmpc_mul_2exp
-Rmpc_mul_2si Rmpc_mul_2ui
-Rmpc_div Rmpc_div_ui Rmpc_ui_div Rmpc_div_fr Rmpc_sqrt Rmpc_div_2exp
-Rmpc_div_2si Rmpc_div_2ui
-Rmpc_neg Rmpc_abs Rmpc_conj Rmpc_norm Rmpc_exp Rmpc_log Rmpc_log10
-Rmpc_cmp Rmpc_cmp_si Rmpc_cmp_si_si
-Rmpc_out_str Rmpc_inp_str c_string r_string i_string
-TRmpc_out_str TRmpc_inp_str
-Rmpc_sin Rmpc_cos Rmpc_sin_cos Rmpc_tan Rmpc_sinh Rmpc_cosh Rmpc_tanh
-Rmpc_asin Rmpc_acos Rmpc_atan Rmpc_asinh Rmpc_acosh Rmpc_atanh
-Rmpc_real Rmpc_imag Rmpc_arg Rmpc_proj
-Rmpc_pow Rmpc_pow_d Rmpc_pow_ld Rmpc_pow_si Rmpc_pow_ui Rmpc_pow_z Rmpc_pow_fr
-Rmpc_set_nan Rmpc_swap
-Rmpc_mul_sj Rmpc_mul_ld Rmpc_mul_d Rmpc_div_sj Rmpc_sj_div Rmpc_div_ld Rmpc_ld_div Rmpc_div_d Rmpc_d_div
-)]);
-
-*TRmpc_out_str = \&Rmpc_out_str;
-*TRmpc_inp_str = \&Rmpc_inp_str;
-
-*Rmpc_set_uj_si = \&Rmpc_set_uj_sj;
-*Rmpc_set_ui_sj = \&Rmpc_set_uj_sj;
-
-*Rmpc_set_sj_ui = \&Rmpc_set_sj_uj;
-*Rmpc_set_si_uj = \&Rmpc_set_sj_uj;
-
-*Rmpc_set_uj_ui = \&Rmpc_set_uj_uj;
-*Rmpc_set_ui_uj = \&Rmpc_set_uj_uj;
-
-*Rmpc_set_sj_si = \&Rmpc_set_sj_sj;
-*Rmpc_set_si_sj = \&Rmpc_set_sj_sj;
-
-*Rmpc_set_d_ld = \&Rmpc_set_ld_ld;
-*Rmpc_set_ld_d = \&Rmpc_set_ld_ld;
-
-*Rmpc_mul_sj = \&Math::MPC::_mpc_mul_sj;
-*Rmpc_mul_ld = \&Math::MPC::_mpc_mul_ld;
-*Rmpc_mul_d = \&Math::MPC::_mpc_mul_d;
-*Rmpc_div_sj = \&Math::MPC::_mpc_div_sj;
-*Rmpc_sj_div = \&Math::MPC::_mpc_sj_div;
-*Rmpc_div_ld = \&Math::MPC::_mpc_div_ld;
-*Rmpc_ld_div = \&Math::MPC::_mpc_ld_div;
-*Rmpc_div_d = \&Math::MPC::_mpc_div_d;
-*Rmpc_d_div = \&Math::MPC::_mpc_d_div;
-
-# Beginning with mpc-1.0, mpc_mul_2exp and mpc_div_2exp
-# were renamed to mpc_mul_2ui and mpc_div_2ui.
-*Rmpc_mul_2exp = \&Rmpc_mul_2ui;
-*Rmpc_div_2exp = \&Rmpc_div_2ui;
-
-sub dl_load_flags {0} # Prevent DynaLoader from complaining and croaking
-
-sub overload_string {
- return "(" . _get_str($_[0], 10, 0, Rmpc_get_default_rounding_mode()) . ")";
-
-}
-
-### Was originally called Rmpc_get_str ###
-sub _get_str {
- my ($r_s, $i_s) = c_string($_[0], $_[1], $_[2], $_[3]);
- # Changed to stay in step with change to mpc_out_str() format
- #my $sep = $i_s =~ /\-/ ? ' -I*' : ' +I*';
- #$i_s =~ s/\-//;
- #my $s = $r_s . $sep . $i_s;
- #return $s;
- return $r_s . " " . $i_s;
-}
-
-sub c_string {
- my $r_s = r_string($_[0], $_[1], $_[2], $_[3]);
- my $i_s = i_string($_[0], $_[1], $_[2], $_[3]);
- return ($r_s, $i_s);
-}
-
-sub r_string {
- my($mantissa, $exponent) = _get_r_string($_[0], $_[1], $_[2], $_[3]);
- if($mantissa =~ /\@nan\@/i || $mantissa =~ /\@inf\@/i) {return $mantissa}
- if($mantissa =~ /\-/ && $mantissa !~ /[^0,\-]/) {return '-0'}
- if($mantissa !~ /[^0,\-]/ ) {return '0'}
- my $sep = $_[1] <= 10 ? 'e' : '@';
-
- my $len = substr($mantissa, 0, 1) eq '-' ? 2 : 1;
-
- if(!$_[2]) {
- while(length($mantissa) > $len && substr($mantissa, -1, 1) eq '0') {
- substr($mantissa, -1, 1, '');
- }
- }
-
- $exponent--;
-
- if(length($mantissa) == $len) {
- if($exponent) {return $mantissa . $sep . $exponent}
- return $mantissa;
- }
-
- substr($mantissa, $len, 0, '.');
- if($exponent) {return $mantissa . $sep . $exponent}
- return $mantissa;
-}
-
-sub i_string {
- my($mantissa, $exponent) = _get_i_string($_[0], $_[1], $_[2], $_[3]);
- if($mantissa =~ /\@nan\@/i || $mantissa =~ /\@inf\@/i) {return $mantissa}
- if($mantissa =~ /\-/ && $mantissa !~ /[^0,\-]/) {return '-0'}
- if($mantissa !~ /[^0,\-]/ ) {return '0'}
-
- my $sep = $_[1] <= 10 ? 'e' : '@';
-
- my $len = substr($mantissa, 0, 1) eq '-' ? 2 : 1;
-
- if(!$_[2]) {
- while(length($mantissa) > $len && substr($mantissa, -1, 1) eq '0') {
- substr($mantissa, -1, 1, '');
- }
- }
-
- $exponent--;
-
- if(length($mantissa) == $len) {
- if($exponent) {return $mantissa . $sep . $exponent}
- return $mantissa;
- }
-
- substr($mantissa, $len, 0, '.');
- if($exponent) {return $mantissa . $sep . $exponent}
- return $mantissa;
-}
-
-sub Rmpc_deref4 {
- my ($r_m, $r_e) = _get_r_string($_[0], $_[1], $_[2], $_[3]);
- my ($i_m, $i_e) = _get_i_string($_[0], $_[1], $_[2], $_[3]);
- return ($r_m, $r_e, $i_m, $i_e);
-}
-
-
-sub new {
-
- # This function caters for 2 possibilities:
- # 1) that 'new' has been called OOP style - in which
- # case there will be a maximum of 3 args
- # 2) that 'new' has been called as a function - in
- # which case there will be a maximum of 2 args.
- # If there are no args, then we just want to return an
- # initialized Math::MPC object
- my @prec = Rmpc_get_default_prec2();
- if(!@_) {return Rmpc_init3(@prec)}
-
- if(@_ > 3) {die "Too many arguments supplied to new()"}
-
- # If 'new' has been called OOP style, the first arg is the string "Math::MPC"
- # which we don't need - so let's remove it. However, if the first
- # arg is a Math::MPFR or Math::MPC object (which is a possibility),
- # then we'll get a fatal error when we check it for equivalence to
- # the string "Math::MPC". So we first need to check that it's not
- # an object - which we'll do by using the ref() function:
- if(!ref($_[0]) && $_[0] eq "Math::MPC") {
- shift;
- if(!@_) {return Rmpc_init3(@prec)}
- }
-
- if(_itsa($_[0]) == _MATH_MPC_T) {
- if(@_ > 1) {die "Too many arguments supplied to new() - expected no more than one"}
- my $mpc = Rmpc_init3(@prec);
- Rmpc_set($mpc, $_[0], Rmpc_get_default_rounding_mode());
- return $mpc;
- }
-
- # @_ can now contain a maximum of 2 args - the real and (optionally)
- # the imaginary components.
- if(@_ > 2) {die "Too many arguments supplied to new() - expected no more than two"}
-
- my ($arg1, $arg2, $type1, $type2);
-
- # $_[0] is the real component, $_[1] (if supplied)
- # is the imaginary component.
- $arg1 = shift;
- $type1 = _itsa($arg1);
-
- $arg2 = 0;
- if(@_) {$arg2 = shift}
- $type2 = _itsa($arg2);
-
- # Die if either of the args are unacceptable.
- if($type1 == 0)
- {die "First argument to new() is inappropriate"}
- if($type2 == 0)
- {die "Second argument to new() is inappropriate"}
-
- # Create a Math::MPC object that has $arg1 as its
- # real component, and zero as its imaginary component.
- my $mpc1 = _new_real($arg1);
-
- # Create a Math::MPC object that has $arg2 as its
- # imaginary component, and zero as its real component.
- my $mpc2 = _new_im($arg2);
-
- # Add the 2 created Math::MPC objects together and return
- # the result
- Rmpc_add($mpc1, $mpc1, $mpc2, MPC_RNDNN);
- return $mpc1;
-}
-
-sub Rmpc_out_str {
- if(@_ == 5) {
- die "Inappropriate 4th arg supplied to Rmpc_out_str" if _itsa($_[3]) != _MATH_MPC_T;
- return _Rmpc_out_str($_[0], $_[1], $_[2], $_[3], $_[4]);
- }
- if(@_ == 6) {
- if(_itsa($_[3]) == _MATH_MPC_T) {return _Rmpc_out_strS($_[0], $_[1], $_[2], $_[3], $_[4], $_[5])}
- die "Incorrect args supplied to Rmpc_out_str" if _itsa($_[4]) != _MATH_MPC_T;
- return _Rmpc_out_strP($_[0], $_[1], $_[2], $_[3], $_[4], $_[5]);
- }
- if(@_ == 7) {
- die "Inappropriate 5th arg supplied to Rmpc_out_str" if _itsa($_[4]) != _MATH_MPC_T;
- return _Rmpc_out_strPS($_[0], $_[1], $_[2], $_[3], $_[4], $_[5], $_[6]);
- }
- die "Wrong number of arguments supplied to Rmpc_out_str()";
-}
-
-sub MPC_VERSION {return _MPC_VERSION()}
-sub MPC_VERSION_MAJOR {return _MPC_VERSION_MAJOR()}
-sub MPC_VERSION_MINOR {return _MPC_VERSION_MINOR()}
-sub MPC_VERSION_PATCHLEVEL {return _MPC_VERSION_PATCHLEVEL()}
-sub MPC_VERSION_STRING {return _MPC_VERSION_STRING()}
-sub MPC_VERSION_NUM {return _MPC_VERSION_NUM(@_)}
-
-1;
-
-__END__
-
-=head1 NAME
-
-Math::MPC - perl interface to the MPC (multi precision complex) library.
-
-=head1 DEPENDENCIES
-
- This module needs the MPC, MPFR and GMP C libraries. (Install GMP
- first, followed by MPFR, followed by MPC.)
-
- The GMP library is availble from http://gmplib.org
- The MPFR library is available from http://www.mpfr.org/
- The MPC library is available from
- http://www.multiprecision.org/mpc/
-
-=head1 DESCRIPTION
-
- A multiple precision complex number module utilising the MPC library.
- Basically, this module simply wraps the 'mpc' complex number functions
- provided by that library.
- Operator overloading is also available.
- The following documentation heavily plagiarises the mpc documentation.
-
- use warnings;
- use Math::MPC qw(:mpc);
- Rmpc_set_default_prec(500); # Set default precision to 500 bits
- my $mpc1 = Math::MPC->new(12.5, 1125); # 12.5 + 1125*i
- $mpc2 = sqrt($mpc1);
- print "Square root of $mpc1 is $mpc2\n";
-
- See also the Math::MPC test suite for some (simplistic) examples of
- usage.
-
-
-=head1 ROUNDING MODE
-
- A complex rounding mode is of the form MPC_RNDxy where "x" and "y"
- are one of "N" (to nearest), "Z" (towards zero), "U" (towards plus
- infinity), "D" (towards minus infinity). The first letter refers to
- the rounding mode for the real part, and the second one for the
- imaginary part.
- For example MPC_RNDZU indicates to round the real part towards
- zero, and the imaginary part towards plus infinity.
- The default rounding mode is MPC_RNDNN, but this can be changed
- using the Rmpc_set_default_rounding_mode() function.
-
-=head1 MEMORY MANAGEMENT
-
- Objects can be created with the Rmpc_init2 and Rmpc_init3 functions,
- which return an object that has been blessed into the package
- Math::MPC. Alternatively, blessed objects can also be created by
- calling the new() function (either as a function or as a method).
- These objects will be automatically cleaned up by the DESTROY()
- function whenever they go out of scope.
-
- Rmpc_init2_nobless and Rmpc_init3_nobless are the same as Rmpc_init2
- and Rmpc_init3, except that they return an unblessed object.
- If you create Math::MPC objects using the '_nobless' versions,
- it will then be up to you to clean up the memory associated with
- these objects by calling Rmpc_clear($op) for each object.
- Alternatively such objects will be cleaned up when the script ends.
- I don't know why you would want to create unblessed objects. The
- point is that you can if you want to.
-
-=head1 MIXING MPC OBJECTS WITH MPFR & GMP OBJECTS
-
- Some of the Math::MPC functions below take Math::MPFR, Math::GMP,
- Math::GMPz, Math::GMPq, or Math::GMPf objects as arguments.
- Obviously, to make use of these functions, you'll need to have
- loaded the appropriate module.
-
-=head1 FUNCTIONS
-
- Most of the following functions are simply wrappers around an mpc
- function of the same name. eg. Rmpc_neg() is a wrapper around
- mpc_neg().
-
- "$rop", "$op1", "$op2", etc. are Math::MPC objects - the
- return value of one of the Rmpc_init* functions. They are in fact
- references to mpc structures. The "$op" variables are the operands
- and "$rop" is the variable that stores the result of the operation.
- Generally, $rop, $op1, $op2, etc. can be the same perl variable
- referencing the same mpc structure, though often they will be
- distinct perl variables referencing distinct mpc structures.
- Eg something like Rmpc_add($r1, $r1, $r1, $rnd),
- where $r1 *is* the same reference to the same mpc structure,
- would add $r1 to itself and store the result in $r1. Alternatively,
- you could (courtesy of operator overloading) simply code it
- as $r1 += $r1. Otoh, Rmpc_add($r1, $r2, $r3, $rnd), where each of the
- arguments is a different reference to a different mpc structure
- would add $r2 to $r3 and store the result in $r1. Alternatively
- it could be coded as $r1 = $r2 + $r3.
-
- In the documentation that follows:
-
- "$ui" means an integer that will fit into a C 'unsigned long int',
-
- "$si" means an integer that will fit into a C 'signed long int'.
-
- "$uj" means an integer that will fit into a C 'uintmax_t'. Don't
- use the _uj functions unless your perl was compiled with 64
- bit integer support.
-
- "$sj" means an integer that will fit into a C 'intmax_t'. Don't
- use the _sj functions unless your perl was compiled with 64
- bit integer support.
-
- "$double" is a C double.
-
- "$ld" is a C long double. Don't use the _ld functions unless your
- perl was compiled with long double support.
-
- "$bool" means a value (usually a 'signed long int') in which
- the only interest is whether it evaluates as false or true.
-
- "$str" simply means a string of symbols that represent a number,
- eg '1234567890987654321234567@7' which might be a base 10 number,
- or 'zsa34760sdfgq123r5@11' which would have to represent at least
- a base 36 number (because "z" is a valid digit only in bases 36
- and above). Valid bases for MPC numbers are 2 to 36 (inclusive).
-
- "$rnd" is simply one of the 16 rounding mode values (discussed above).
-
- "$p" is the (unsigned long) value for precision.
-
- "$mpf" is a Math::GMPf object (floating point). You'll need Math::GMPf
- installed in order to create $mpf.
-
- "$mpq" is a Math::GMPq object (rational). You'll need Nath::GMPq
- installed in order to create $mpq.
-
- "$mpz" is a Math::GMP or Math::GMPz object (integer). You'll need
- Math::GMPz or Math::GMP installed in order to create $mpz.
-
- "$mpfr" is a Math::MPFR object (floating point). You'll need to
- 'use Math::MPFR;' in order to create $mpfr. (Math::MPFR
- a pre-requisite module for Math::MPC.)
-
- "$cc" is a Math::Complex_C (double _Complex) object. You'll need to
- 'use Math::Complex_C' (or create your own double _Complex
- object) in order to create $cc, and to use the functions that
- take such an argument. (Math::Complex_C is *not* a
- pre-requisite module for Math::MPC.)
-
- "$lcc" is a Math::Complex_C::Long (long double _Complex) object.
- You'll need to 'use Math::Complex_C' (or create your own
- long double _Complex object in order to create $lcc, and
- to use the functions that take such an argument.
-
- ######################
-
- FUNCTION RETURN VALUES
-
- Most MPC functions have a return value ($si) which is used to
- indicate the position of the rounded real or imaginary parts with
- respect to the exact (infinite precision) values. The functions
- RMPC_INEX_RE($si) and RMPC_INEX_IM($si) return 0 if the corresponding
- rounded value is exact, a negative value if the rounded value is less
- than the exact one, and a positive value if it is greater than the
- exact one. However, some functions do not completely fulfill this -
- in some cases the sign is not guaranteed, and in some cases a
- non-zero value is returned although the result is exact. In these
- cases the function documentation explains the exact meaning of the
- return value. However, the return value never wrongly indicates an
- exact computation.
-
- ###########################
-
- MANIPULATING ROUNDING MODES
-
- Rmpc_set_default_rounding_mode($rnd);
- Sets the default rounding mode to $rnd.
- The default rounding mode is to nearest initially (MPC_RNDNN).
- The default rounding mode is the rounding mode that is used in
- overloaded operations.
-
- $ui = Rmpc_get_default_rounding_mode();
- Returns the numeric value of the current default rounding mode.
- This will initially be 0 (MPC_RNDNN).
-
- ##########
-
- INITIALIZATION
-
- Normally, a variable should be initialized once only or at least
- be cleared, using `Rmpc_clear', between initializations - but
- don't explicitly call Rmpc_clear() on blessed objects. 'DESTROY'
- (which calls 'Rmpc_clear') is automatically called on blessed
- objects whenever they go out of scope.
-
- First read the section 'MEMORY MANAGEMENT' (above).
-
- Rmpc_set_default_prec($p);
- Rmpc_set_default_prec2($p_re, $p_im);
- Rmpc_set_default_prec sets the default precision to exactly $p
- bits for both the real and imaginary parts. Rmpc_set_default_prec
- sets the default precision to be *exactly* $p_re bits for the real
- part, and *exactly* $p_im bits for the imaginary part. The
- precision of a variable means the number of bits used to store its
- mantissa. All subsequent calls to `new' will use this precision,
- but previously initialized variables are unaffected. This is also
- the precision that will be used during some overloaded operations
- (see OPERATOR OVERLOADING below).
- The default precision is set to 53 bits initially (for both
- real and imaginary components).
-
- $ui = Rmpc_get_default_prec();
- ($ui_re, $ui_im) = Rmpc_get_default_prec2();
- Rmpc_get_default_prec returns the current default real precision
- iff the default real precision is the same as the current default
- imaginary precision. Otherwise it returns zero.
- Rmpc_get_default_prec2 returns both current default real precision
- and current default imaginary precision (in bits).
-
- $ui = Rmpc_get_prec($op);
- If the real and imaginary part of $op have the same precision,
- it is returned. Otherwise 0 is returned.
-
- $ui = Rmpc_get_re_prec($op);
- $ui = Rmpc_get_im_prec($op)
- ($re_prec, $im_prec) = Rmpc_get_prec2($op);
- Get (respectively) the precision of the real part of $op, the
- precision of the imaginary part of $op, or an array containing
- precision of both real and imaginary parts of $op.
-
- $rop = Math::MPC->new();
- $rop = Math::MPC::new();
- $rop = new Math::MPC();
- Initialize $rop, and set its real and imaginary parts to NaN.
- The precision of $rop is the default precision, which can be
- changed by a call to `Rmpc_set_default_prec' or
- `Rmpc_set_default_prec2' (documented above).
-
- $rop = Rmpc_init2($p);
- $rop = Rmpc_init2_nobless($p);
- Initialize $rop, set the precision (of both real and imaginary
- parts) to be *exactly* $p bits, and set its real and imaginary
- parts to NaN.
-
- $rop = Rmpc_init3($p_re, $p_im);
- $rop = Rmpc_init3_nobless($p_r, $p_i);
- Initialize $rop, set the precision of the real part to be
- *exactly* $p_re bits, set the precision of the imaginary part to
- be *exactly* $p_im bits, and set its real and imaginary parts to
- NaN.
-
- Rmpc_set_prec($op, $p);
- Reset the precision of $op to be exactly $p bits, and set its
- real/imaginary parts to NaN.
-
- Rmpc_set_re_prec($op, $p);
- Rmpc_set_im_prec($op, $p);
- Set (respectively) the precision of the real part of $op to be
- exactly $p bits and the precision of the imaginary part of $op
- to be exactly $p bits. In both cases the value is set to NaN.
- (There are currently no corresponding MPC library functions.)
-
- ##########
-
- ASSIGNMENT
-
- $si = Rmpc_set($rop, $op, $rnd);
- $si = Rmpc_set_ui($rop, $ui, $rnd);
- $si2 = Rmpc_set_si($rop, $si1, $rnd);
- $si = Rmpc_set_d($rop, $double, $rnd);
- $si = Rmpc_set_uj($rop, $uj, $rnd);
- $si = Rmpc_set_sj($rop, $sj, $rnd);
- $si = Rmpc_set_ld($rop, $ld, $rnd);
- $si = Rmpc_set_f($rop, $mpf, $rnd);
- $si = Rmpc_set_q($rop, $mpq, $rnd);
- $si = Rmpc_set_z($rop, $mpz, $rnd);
- $si = Rmpc_set_fr($rop, $mpfr, $rnd);
- $si = Rmpc_set_dc($rop, $cc, $rnd);
- $si = Rmpc_set_ldc($rop, $lcc, $rnd);
- Set the value of $rop from 2nd arg, rounded to the precision of
- $rop towards the given direction $rnd.
- Don't use Rmpc_set_ld unless perl has been built with long
- double support. Don't use Rmpc_set_uj or Rmpc_set_sj unless
- perl has been built with long long int support.
- For Rmpc_set_dc and Rmpc_set_ldc, an mpc library (version 0.9
- or later) that has been built with support for these data types
- is needed.
-
- $si = Rmpc_set_str($rop, $string, $base, $rnd);
- $si = Rmpc_strtoc($rop, $string, $base, $rnd);
- Set $rop to the value represented in $string (in base $base), rounded
- in accordance with $rnd. See the mpc documentation for details.
-
- $si = Rmpc_set_ui_ui($rop, $ui1, $ui2, $rnd);
- $si3 = Rmpc_set_si_si($rop, $si1, $si2, $rnd);
- $si = Rmpc_set_d_d($rop, $double1, $double2, $rnd);
- $si = Rmpc_set_f_f($rop, $mpf1, $mpf2, $rnd);
- $si = Rmpc_set_q_q($rop, $mpq1, $mpq2, $rnd);
- $si = Rmpc_set_z_z($rop, $mpz1, $mpz2, $rnd);
- $si = Rmpc_set_fr_fr($rop, $mpfr1, $mpfr2, $rnd);
- Sets the real part of $rop from 2nd arg, and the imaginary part
- of $rop from 3rd arg, according to the rounding mode $rnd.
-
- $si = Rmpc_set_uj_uj($rop, $uj1, $uj2, $rnd);
- $si = Rmpc_set_sj_sj($rop, $sj1, $sj2, $rnd);
- $si = Rmpc_set_ld_ld($rop, $ld1, $ld2, $rnd);
- Don't use the first 2 functions unless Math::MPC::_has_longlong()
- returns a true value. Don't use the 3rd function unless
- Math::MPC::_has_longdouble() returns true.
- Sets the real part of $rop from 2nd arg, and the imaginary part
- of $rop from 3rd arg, according to the rounding mode $rnd.
-
- $si = Rmpc_set_x_y($rop, $op1, $op2, $rnd);
- You need to replace the 'x' and the 'y' with any one of 'ui',
- 'si', 'd', 'uj', 'sj', 'ld', 'f', 'q', 'z' and 'fr' - eg:
- Rmpc_set_ui_d($rop, $ui, $double, $rnd);
- Don't use the 'uj' or 'sj' variants if Math::MPC::_has_longlong()
- doesn't return a true value. And don't use the 'ld' variants if
- Math::MPC_haslongdouble() doesn't return a true value.
- Sets the real part of $rop from 2nd arg, and the imaginary part
- of $rop from 3rd arg, according to the rounding mode $rnd.
-
- ################################################
-
- COMBINED INITIALIZATION AND ASSIGNMENT
-
- NOTE: Do NOT use these functions if $rop has already been initialised
- or created by calling new(). Instead use the Rmpc_set* functions in
- the section 'ASSIGNMENT' (above).
-
- First read the section 'MEMORY MANAGEMENT' (above).
-
- $rop = Math::MPC->new($arg1 [, $arg2]);
- $rop = Math::MPC::new($arg1 [, $arg2]);
- $rop = new Math::MPC($arg1, [, $arg2]);
- Returns a Math::MPC object whose real component has a value of $arg1,
- rounded in the default rounding direction, with default precision.
- If $arg2 is supplied, the imaginary component of the returned
- Math::MPC object is set to $arg2, rounded in the default rounding
- direction, with default precision. Otherwise the imaginary component
- of the returned Math::MPC object is set to zero. $arg1 & $arg2 can be
- either a number (signed integer, unsigned integer, signed fraction or
- unsigned fraction), a string that represents a numeric value, a
- Math::MPFR object, a Math::GMP object, a Math::GMPz object, a
- Math::GMPq object or a Math::GMPf object.
- If a string argument begins with "0b" or "0B", then the string is
- treated as a base 2 string. Elsif it begins with "0x" or "0X" it is
- treated as a base 16 string. Else it is treated as a base 10 string.
-
- ##########
-
- ARITHMETIC
-
- $si = Rmpc_add($rop, $op1, $op2, $rnd);
- $si = Rmpc_add_ui($rop, $op, $ui, $rnd);
- $si = Rmpc_add_fr($rop, $op, $mpfr, $rnd);
- Set $rop to 2nd arg + 3rd arg rounded in the direction $rnd.
-
-
- $si = Rmpc_sub($rop, $op1, $op2, $rnd);
- $si = Rmpc_sub_ui($rop, $op, $ui, $rnd);
- $si = Rmpc_ui_sub($rop, $ui, $op, $rnd);
- Set $rop to 2nd arg - 3rd arg rounded in the direction $rnd.
-
- $si = Rmpc_ui_ui_sub($rop, $ui_r, $ui_i, $op, $rnd);
- The real part of $rop is set to $ui_r minus the real part of $op
- (rounded in the direction $rnd) - and the imaginary part of $rop
- is set to $ui_r minus the imaginary part of $op (rounded in the
- direction $rnd)
-
-
- $si = Rmpc_mul($rop, $op1, $op2, $rnd);
- $si = Rmpc_mul_ui($rop, $op, $ui, $rnd);
- $si = Rmpc_mul_si($rop, $op, $si1, $rnd);
- $si = Rmpc_mul_sj($rop, $op, $sj, $rnd); # Math::MPC XSub
- $si = Rmpc_mul_d($rop, $op, $double, $rnd);# Math::MPC XSub
- $si = Rmpc_mul_ld($rop, $op, $ld, $rnd); # Math::MPC XSub
- $si = Rmpc_mul_fr($rop, $op, $mpfr, $rnd);
- Set $rop to 2nd arg * 3rd arg rounded in the direction $rnd.
- The 'sj'/'ld' versions are available only on perls built with
- '64 bit int'/'long double' support.
-
- $si = Rmpc_mul_i($rop, $op, $si1, $rnd);
- If $si1 >= 0 (non-negative), set $rop to $op times the
- imaginary unit i - else set $rop to $op times -i.
-
-
- $si = Rmpc_div($rop, $op1, $op2, $rnd);
- $si = Rmpc_div_ui($rop, $op, $ui, $rnd);
- $si = Rmpc_ui_div($rop, $ui, $op, $rnd);
- $si = Rmpc_div_d($rop, $op, $double, $rnd); # Math::MPC XSub
- $si = Rmpc_d_div($rop, $double, $op, $rnd); # Math::MPC XSub
- $si = Rmpc_div_sj($rop, $op, $sj, $rnd); # Math::MPC XSub
- $si = Rmpc_sj_div($rop, $sj, $op, $rnd); # Math::MPC XSub
- $si = Rmpc_div_ld($rop, $op, $ld, $rnd); # Math::MPC XSub
- $si = Rmpc_ld_div($rop, $ld, $op, $rnd); # Math::MPC XSub
- $si = Rmpc_div_fr($rop, $op, $mpfr, $rnd);
- Set $rop to 2nd arg / 3rd arg rounded in the direction $rnd.
- The 'sj'/'ld' versions are available only on perls built with
- '64 bit int'/'long double' support.
-
- $si = Rmpc_sqr($rop, $op, $rnd);
- Set $rop to the square of $op, rounded in direction $rnd.
-
- $si = Rmpc_sqrt($rop, $op, $rnd);
- Set $rop to the square root of the 2nd arg rounded in the
- direction $rnd. When the return value is 0, it means the result
- is exact. Else it's unknown whether the result is exact or not.
-
- $si = Rmpc_pow($rop, $op1, $op2, $rnd);
- $si = Rmpc_pow_d($rop, $op1, $double, $rnd);
- $si = Rmpc_pow_ld($rop, $op1, $ld, $rnd);
- $si2 = Rmpc_pow_si($rop, $op1, $si, $rnd);
- $si = Rmpc_pow_ui($rop, $op1, $ui, $rnd);
- $si = Rmpc_pow_z($rop, $op1, $mpz, $rnd);
- $si = Rmpc_pow_fr($rop, $op1, $mpfr, $rnd);
- Set $op to ($op1 ** 3rd arg) rounded in the direction $rnd.
- Rmpc_pow_ld is available only on perls that have "long double"
- support.
-
- $si = Rmpc_neg($rop, $op, $rnd);
- Set $rop to -$op rounded in the direction $rnd. Just
- changes the sign if $rop and $op are the same variable.
-
- $si = Rmpc_conj($rop, $op, $rnd);
- Set $rop to the conjugate of $op rounded in the direction $rnd.
- Just changes the sign of the imaginary part if $rop and $op are
- the same variable.
-
- $si = Rmpc_abs($mpfr, $op, $rnd);
- Set the floating-point number $mpfr to the absolute value of $op,
- rounded in the direction $rnd. Return 0 iff the result is exact.
-
- $si = Rmpc_norm($mpfr, $op, $rnd);
- Set the floating-point number $mpfr to the norm of $op (ie the
- square of its absolute value), rounded in the direction $rnd.
- Return 0 iff the result is exact.
-
- $si = Rmpc_mul_2exp($rop, $op, $ui, $rnd);
- $si = Rmpc_mul_2ui ($rop, $op, $ui, $rnd);#same as Rmpc_mul_2exp
- $si1 = Rmpc_mul_2si ($rop, $op, $si2, $rnd);
- Set $rop to $op times 2 raised to 3rd arg rounded according to
- $rnd. Just increases the exponents of the real and imaginary
- parts by value of 3rd arg when $rop and $op are identical.
-
- $si = Rmpc_div_2exp($rop, $op, $ui, $rnd);
- $si = Rmpc_div_2ui ($rop, $op, $ui, $rnd);#same as Rmpc_div_2exp
- $si1 = Rmpc_div_2si ($rop, $op, $si2, $rnd);
- Set $rop to $op divided by 2 raised to 3rd arg rounded according
- to $rnd. Just decreases the exponents of the real and imaginary
- parts by value of 3rd arg when $rop and $op are identical.
-
- Rmpc_swap($op1, $op2);
- Swap the values (and precisions) of op1 and op2 efficiently.
-
- ##########
-
- COMPARISON
-
- $si = Rmpc_cmp($op1, $op2);
- $si = Rmpc_cmp_si($op, $si1);
- Compare 1st and 2nd args. The return value $si can be decomposed
- into $x = RMPC_INEX_RE($si) and $y = RMPC_INEX_IM($si), such that $x
- is positive if the real part of the 1st arg is greater than that of
- the 2nd arg, zero if both real parts are equal, and negative if the
- real part of the 1st arg is less than that of the 2nd arg.
- Likewise for $y.
- Both 1st and 2nd args are considered to their full own precision,
- which may differ.
- It is not allowed that one of the operands has a NaN (Not-a-Number)
- part.
- The storage of the return value is such that equality can be simply
- checked with Rmpc_cmp($first_arg, $second_arg) == 0.
-
- $si = Rmpc_cmp_si_si($op, $si1, $si2);
- As for the above comparison functions - except that $op is being
- compared with $si1 + ($si2 * i).
-
- #######
-
- SPECIAL
-
- $si = Rmpc_exp($rop, $op, $rnd);
- Set $rop to the exponential of $op, rounded according to $rnd
- with the precision of $rop.
-
- $si = Rmpc_log($rop, $op, $rnd);
- Set $rop to the log of $op, rounded according to $rnd with the
- precision of $rop.
-
- $si = Rmpc_log10($rop, $op, $rnd);
- Set $rop to the base 10 log of $op, rounded according to $rnd with
- the precision of $rop.
-
- $si = Rmpc_arg ($mpfr, $op, $rnd);
- Set $mpfr to the argument of $op, with a branch cut along the
- negative real axis. ($mpfr is a Math::MPFR object.)
-
- $si = Rmpc_proj ($rop, $op, $rnd);
- Compute a projection of $op onto the Riemann sphere. Set $rop
- to $op, rounded in the direction $rnd, except when at least one
- part of $op is infinite (even if the other part is a NaN) in
- which case the real part of $rop is set to plus infinity and its
- imaginary part to a signed zero with the same sign as the
- imaginary part of $op.
-
- Rmpc_set_nan($op);
- Set $op to 'NaN +I*NaN'.
-
- ##########
-
- TRIGONOMETRIC
-
- $si = Rmpc_sin($rop, $op, $rnd);
- Set $rop to the sine of $op, rounded according to $rnd with the
- precision of $rop.
-
- $si = Rmpc_cos($rop, $op, $rnd);
- Set $rop to the cosine of $op, rounded according to $rnd with
- the precision of $rop.
-
- $si = Rmpc_sin_cos($r_sin, $r_cos, $op, $rnd_sin, $rnd_cos);
- Needs version 0.9 or later of the mpc C library.
- Set $r_sin/$r_cos to the sin/cos of $op, rounded according to
- $rnd_sin/$rnd_cos.
- (If the mpc C library is pre version 0.9, calling this
- function will cause the program to die with an appropriate
- error message.)
-
- $si = Rmpc_tan($rop, $op, $rnd);
- Set $rop to the tangent of $op, rounded according to $rnd with
- the precision of $rop.
-
- $si = Rmpc_sinh($rop, $op, $rnd);
- Set $rop to the hyperbolic sine of $op, rounded according to
- $rnd with the precision of $rop.
-
- $si = Rmpc_cosh($rop, $op, $rnd);
- Set $rop to the hyperbolic cosine of $op, rounded according to
- $rnd with the precision of $rop.
-
- $si = Rmpc_tanh($rop, $op, $rnd);
- Set $rop to the hyperbolic tangent of $op, rounded according to
- $rnd with the precision of $rop.
-
- $si = Rmpc_asin ($rop, $op, $rnd);
- Set $rop to the inverse sine of $op, rounded according to
- $rnd with the precision of $rop.
-
- $si = Rmpc_acos ($rop, $op, $rnd);
- Set $rop to the inverse cosine of $op, rounded according to
- $rnd with the precision of $rop.
-
- $si = Rmpc_atan ($rop, $op, $rnd);
- Set $rop to the inverse tangent of $op, rounded according to
- $rnd with the precision of $rop.
-
- $si = Rmpc_asinh ($rop, $op, $rnd);
- Set $rop to the inverse hyperbolic sine of $op, rounded
- according to $rnd with the precision of $rop.
-
- $si = Rmpc_acosh ($rop, $op, $rnd);
- Set $rop to the inverse hyperbolic cosine of $op, rounded
- according to$rnd with the precision of $rop.
-
- $si = Rmpc_atanh ($rop, $op, $rnd);
- Set $rop to the inverse hyperbolic tangent of $op, rounded
- according to$rnd with the precision of $rop.
-
- ##########
-
- CONVERSION
-
- ($real, $im) = c_string($op, $base, $digits, $rnd);
- $real = r_string($op, $base, $digits, $rnd);
- $im = i_string($op, $base, $digits, $rnd);
- $real is a string containing the value of the real part of $op.
- $im is a string containing the value of the imaginary part of $op.
- $real and $im will be of the form XeY (X@Y for bases greater than 10)
- - where X is the mantissa (in base $base) and Y is the exponent (in
- base 10).
- For example, -31.4132' would be returned as -3.14132e1. $digits is the
- number of digits that will be written in the mantissa. If $digits is
- zero, the mantissa will contain the maximum number of digits
- accurately representable. The mantissa will be rounded in the
- direction specified by $rnd.
-
- @vals = Rmpc_deref4($op, $base, $digits, $rnd);
- @vals contains (in order) the real mantissa, the real exponent, the
- imaginary mantissa, and the imaginary exponent of $op.The mantissas,
- expressed in base $base and rounded according to $rnd), contain an
- implicit radix point to the left of the first (ie leftmost) digit.
- The exponents are always expressed in base 10. $digits is the number
- of digits that will be written in the mantissa. If $digits is zero
- the mantissa will contain the maximum number of digits accurately
- representable.
-
- RMPC_RE($mpfr, $op);
- RMPC_IM($mpfr, $op);
- Set $mpfr to the value of the real (respectively imaginary) component
- of $op. $mpfr will be an exact copy of the real/imaginary component
- of op - ie the precision of $mpfr will be set to the precision of the
- real/imaginary component of $op before the copy is made. Hence no need
- for a rounding arg to be supplied.
-
- $si = Rmpc_real($mpfr, $op, $rnd);
- $si = Rmpc_imag($mpfr, $op, $rnd);
- Set $mpfr to the value of the real (respectively imaginary) part of
- $op, rounded in the direction $rnd. ($mpfr is a Math::MPFR object.)
-
- #############
-
- I-O FUNCTIONS
-
- $ul = Rmpc_inp_str($rop, $stream, $base, $rnd);
- Input a string in base $base from $stream, rounded according to $rnd,
- and put the read complex in $rop. Each of the real and imaginary
- parts should be of the form X@Ym or, if the base is 10 or less,
- alternatively XeY or XEY. (X is the mantissa, Y is the exponent.
- The mantissa is always in the specified base. The exponent is always
- read in decimal. This function first reads the real part, followed by
- the imaginary part. The argument $base may be in the range 0,2..36.
- Return the number of bytes read, or if an error occurred, return 0.
-
- $ul =
- Rmpc_out_str([$pre,] $stream, $base, $digits, $op, $rnd [, $suf]);
- This function changed from 1st release (version 0.45) of Math::MPC.
- Output $op to $stream, in base $base, rounded according to $rnd. First
- the real part is printed, followed by the imaginary part. The base may
- be 0,2..36. Print at most $digits significant digits for each
- part, or if $digits is 0, the maximum number of digits accurately
- representable by $op. In addition to the significant digits, a decimal
- point at the right of the first digit and a trailing exponent, in the
- form eYYY , are printed. (If $base is greater than 10, "@" will be
- used as exponent delimiter.) $pre and $suf are optional arguments
- containing a string that will be prepended/appended to the output.
- Return the number of bytes written. (The contents of $pre and $suf
- are not included in the count.)
-
- $string = Rmpc_get_str($base, $how_many, $op, $rnd);
- Convert $op to a string containing the real and imaginary parts of
- $op. The number of significant digits for both real and imaginary
- parts is specified by $how_many. It is also possible to let
- $how_many be zero, in which case the number of digits is chosen large
- enough so that re-reading the printed value with the same precision,
- assuming both output and input use rounding to nearest, will recover
- the original value of $op. See the mpc documentation for details.
-
- Rmpc_get_dc($cc, $op, $rnd);
- Rmpc_get_ldc($lcc, $op, $rnd);
- Set the 'double _Complex'/'long double _Complex' object to the value
- of $op, rounded according to $rnd. Needs an mpc library (version 0.9
- or later) that has been built with support for these data types.
-
- ####################
-
- OPERATOR OVERLOADING
-
- Overloading works with numbers, strings (bases 2, 10, and 16
- only - see step '4.' below) and Math::MPC objects.
- Overloaded operations are performed using the current
- "default rounding mode" (which you can determine using the
- 'Rmpc_get_default_rounding_mode' function, and change using
- the 'Rmpc_set_default_rounding_mode' function).
-
- Be aware that when you use overloading with a string operand,
- the overload subroutine converts that string operand to a
- Math::MPC object with *current default precision*, and using
- the *current default rounding mode*.
-
- Be aware also, that the sign of zero is not always handled
- correctly by the overload subroutines. If it's important to you
- that the sign of zero be handled correctly, don't use the
- overloaded operators. (For multiplication, division, addition
- and subtraction the sign of zero will be handled correctly by the
- overloaded operators if both operands are Math::MPC objects.)
-
- For the purposes of the overloaded 'not', '!' and 'bool'
- operators, a "false" Math::MPC object is one with real and
- imaginary parts that are both "false" - where "false" currently
- means either 0 or NaN.
- (A "true" Math::MPC object is, of course, simply one that is not
- "false".)
-
- The following operators are overloaded:
- + - * / ** sqrt (Return object has default precision)
- += -= *= /= **= (Precision remains unchanged)
- == !=
- ! bool
- abs (Returns an MPFR object, blessed into package Math::MPFR)
- exp log (Return object has default precision)
- sin cos (Return object has default precision)
- = (The copy has the same precision as the copied object.)
- ""
-
- Attempting to use the overloaded operators with objects that
- have been blessed into some package other than 'Math::MPC'
- will not work. The workaround is to convert this "foreign"
- object to a Math::MPC object - thus allowing it to work with
- the overloaded operator.
-
- In those situations where the overload subroutine operates on 2
- perl variables, then obviously one of those perl variables is
- a Math::MPC object. To determine the value of the other variable
- the subroutine works through the following steps (in order),
- using the first value it finds, or croaking if it gets
- to step 6:
-
- 1. If the variable is an unsigned long then that value is used.
- The variable is considered to be an unsigned long if
- (perl 5.8 on) the UOK flag is set or if (perl 5.6) SvIsUV()
- returns true.(In the case of perls built with -Duse64bitint,
- the variable is treated as an unsigned long long int if the
- UOK flag is set.)
-
- 2. If the variable is a signed long int, then that value is used.
- The variable is considered to be a signed long int if the
- IOK flag is set. (In the case of perls built with
- -Duse64bitint, the variable is treated as a signed long long
- int if the IOK flag is set.)
-
- 3. If the variable is a double, then that value is used. The
- variable is considered to be a double if the NOK flag is set.
- (In the case of perls built with -Duselongdouble, the variable
- is treated as a long double if the NOK flag is set.)
-
- 4. If the variable is a string (ie the POK flag is set) then the
- value of that string is used. If the POK flag is set, but the
- string is not a valid number, the subroutine croaks with an
- appropriate error message. If the string starts with '0b' or
- '0B' it is regarded as a base 2 number. If it starts with '0x'
- or '0X' it is regarded as a base 16 number. Otherwise it is
- regarded as a base 10 number.
-
- 5. If the variable is a Math::MPC object then the value of that
- object is used.
-
- 6. If none of the above is true, then the second variable is
- deemed to be of an invalid type. The subroutine croaks with
- an appropriate error message.
-
- #####################
-
- MISCELLANEOUS
-
- $ui = MPC_VERSION_MAJOR;
- Returns the 'x' in the 'x.y.z' of the MPC library version.
- Value is as specified by the header file (mpc.h) that was
- used to build Math::MPC.
-
- $ui =MPC_VERSION_MINOR;
- Returns the 'y' in the 'x.y.z' of the MPC library version.
- Value is as specified by the header file (mpc.h) that was
- used to build Math::MPC.
-
- $ui = MPC_VERSION_PATCHLEVEL;
- Returns the 'z' in the 'x.y.z' of the MPC library version.
- Value is as specified by the header file (mpc.h) that was
- used to build Math::MPC.
-
- $ui = MPC_VERSION();
- An integer value derived from the library's major, minor and
- patchlevel values. Value is as specified by the header file
- (mpc.h) that was used to build Math::MPC.
-
- $ui = MPC_VERSION_NUM($major, $minor, $patchlevel);
- Returns an integer in the same format as used by MPC_VERSION,
- using the given $major, $minor and $patchlevel. Value is as
- specified by the header file (mpc.h) that was used to build
- Math::MPC.
-
- $string = MPC_VERSION_STRING;
- $string contains the MPC library version ('x.y.z'), as defined
- by the header file (mpc.h) that was used to build Math::MPC
-
- $string = Rmpc_get_version();
- $string contains the MPC library version ('x.y.z'), as defined
- by the mpc library being used by Math::MPC.
-
- $MPFR_version = Math::MPC::mpfr_v();
- $MPFR_version is set to the version of the mpfr library
- being used by the mpc library that Math::MPC uses.
- (The function is not exportable.)
-
- $GMP_version = Math::MPC::gmp_v();
- $GMP_version is set to the version of the gmp library being
- used by the mpc library that Math::MPC uses.
- (The function is not exportable.)
-
- ####################
-
-=head1 TODO
-
- For completeness, we probably should wrap mpc_realref and
- mpc_imagref - though I don't think there's much to be
- achieved by doing this in a *perl* context.
-
-=head1 BUGS
-
- You can get segfaults if you pass the wrong type of
- argument to the functions - so if you get a segfault, the
- first thing to do is to check that the argument types
- you have supplied are appropriate.
- Also, as mentioned above in the "OPERATOR OVERLOADING" section,
- the overloaded operators are not guaranteed to handle the sign
- of zero correctly.
-
-=head1 LICENSE
-
- This program is free software; you may redistribute it and/or
- modify it under the same terms as Perl itself.
- Copyright 2006-2009, 2010, 2011 Sisyphus
-
-=head1 AUTHOR
-
- Sisyphus <sisyphus at(@) cpan dot (.) org>
-
-=cut
\ No newline at end of file
+ package Math::MPC;
+ use strict;
+ use warnings;
+
+ use constant MPC_RNDNN => 0;
+ use constant MPC_RNDZN => 1;
+ use constant MPC_RNDUN => 2;
+ use constant MPC_RNDDN => 3;
+
+ use constant MPC_RNDNZ => 16;
+ use constant MPC_RNDZZ => 17;
+ use constant MPC_RNDUZ => 18;
+ use constant MPC_RNDDZ => 19;
+
+ use constant MPC_RNDNU => 32;
+ use constant MPC_RNDZU => 33;
+ use constant MPC_RNDUU => 34;
+ use constant MPC_RNDDU => 35;
+
+ use constant MPC_RNDND => 48;
+ use constant MPC_RNDZD => 49;
+ use constant MPC_RNDUD => 50;
+ use constant MPC_RNDDD => 51;
+
+ use constant _UOK_T => 1;
+ use constant _IOK_T => 2;
+ use constant _NOK_T => 3;
+ use constant _POK_T => 4;
+ use constant _MATH_MPFR_T => 5;
+ use constant _MATH_GMPf_T => 6;
+ use constant _MATH_GMPq_T => 7;
+ use constant _MATH_GMPz_T => 8;
+ use constant _MATH_GMP_T => 9;
+ use constant _MATH_MPC_T => 10;
+
+ use subs qw(MPC_VERSION MPC_VERSION_MAJOR MPC_VERSION_MINOR
+ MPC_VERSION_PATCHLEVEL MPC_VERSION_STRING
+ MPC_VERSION MPC_VERSION_NUM);
+
+ use overload
+ '+' => \&overload_add,
+ '-' => \&overload_sub,
+ '*' => \&overload_mul,
+ '/' => \&overload_div,
+ '**' => \&overload_pow,
+ '+=' => \&overload_add_eq,
+ '-=' => \&overload_sub_eq,
+ '*=' => \&overload_mul_eq,
+ '/=' => \&overload_div_eq,
+ '**=' => \&overload_pow_eq,
+ '==' => \&overload_equiv,
+ '!=' => \&overload_not_equiv,
+ '!' => \&overload_not,
+ '=' => \&overload_copy,
+ '""' => \&overload_string,
+ 'abs' => \&overload_abs,
+ 'bool' => \&overload_true,
+ 'exp' => \&overload_exp,
+ 'log' => \&overload_log,
+ 'sqrt' => \&overload_sqrt,
+ 'sin' => \&overload_sin,
+ 'cos' => \&overload_cos,
+ 'atan2'=> \&overload_atan2;
+
+ require Exporter;
+ *import = \&Exporter::import;
+ require DynaLoader;
+
+ @Math::MPC::EXPORT_OK = qw(
+MPC_RNDNN MPC_RNDND MPC_RNDNU MPC_RNDNZ MPC_RNDDN MPC_RNDUN MPC_RNDZN MPC_RNDDD
+MPC_RNDDU MPC_RNDDZ MPC_RNDZD MPC_RNDUD MPC_RNDUU MPC_RNDUZ MPC_RNDZU MPC_RNDZZ
+MPC_VERSION_MAJOR MPC_VERSION_MINOR MPC_VERSION_PATCHLEVEL MPC_VERSION_STRING
+MPC_VERSION MPC_VERSION_NUM Rmpc_get_version
+Rmpc_set_default_rounding_mode Rmpc_get_default_rounding_mode
+Rmpc_set_prec Rmpc_set_default_prec Rmpc_get_default_prec
+Rmpc_set_default_prec2 Rmpc_get_default_prec2
+Rmpc_set_re_prec Rmpc_set_im_prec
+Rmpc_get_prec Rmpc_get_prec2 Rmpc_get_re_prec Rmpc_get_im_prec
+Rmpc_get_dc Rmpc_get_ldc
+RMPC_RE RMPC_IM RMPC_INEX_RE RMPC_INEX_IM
+Rmpc_clear Rmpc_clear_ptr Rmpc_clear_mpc
+Rmpc_deref4 Rmpc_get_str
+Rmpc_init2 Rmpc_init3
+Rmpc_init2_nobless Rmpc_init3_nobless
+Rmpc_strtoc Rmpc_set_str
+Rmpc_set Rmpc_set_ui Rmpc_set_si Rmpc_set_d Rmpc_set_uj Rmpc_set_sj Rmpc_set_ld
+Rmpc_set_z Rmpc_set_q Rmpc_set_f Rmpc_set_fr
+Rmpc_set_z_z Rmpc_set_q_q Rmpc_set_f_f
+Rmpc_set_ui_ui Rmpc_set_ui_si Rmpc_set_ui_d Rmpc_set_ui_uj Rmpc_set_ui_sj Rmpc_set_ui_ld Rmpc_set_ui_fr
+Rmpc_set_si_ui Rmpc_set_si_si Rmpc_set_si_d Rmpc_set_si_uj Rmpc_set_si_sj Rmpc_set_si_ld Rmpc_set_si_fr
+Rmpc_set_d_ui Rmpc_set_d_si Rmpc_set_d_d Rmpc_set_d_uj Rmpc_set_d_sj Rmpc_set_d_ld Rmpc_set_d_fr
+Rmpc_set_uj_ui Rmpc_set_uj_si Rmpc_set_uj_d Rmpc_set_uj_uj Rmpc_set_uj_sj Rmpc_set_uj_ld Rmpc_set_uj_ld Rmpc_set_uj_fr
+Rmpc_set_sj_ui Rmpc_set_sj_si Rmpc_set_sj_d Rmpc_set_sj_uj Rmpc_set_sj_sj Rmpc_set_sj_ld Rmpc_set_sj_fr
+Rmpc_set_ld_ui Rmpc_set_ld_si Rmpc_set_ld_uj Rmpc_set_ld_d Rmpc_set_ld_sj Rmpc_set_ld_ld Rmpc_set_ld_fr
+Rmpc_set_fr_ui Rmpc_set_fr_si Rmpc_set_fr_d Rmpc_set_fr_uj Rmpc_set_fr_sj Rmpc_set_fr_ld Rmpc_set_fr_fr
+
+Rmpc_set_f_ui Rmpc_set_q_ui Rmpc_set_z_ui Rmpc_set_ui_f Rmpc_set_ui_q Rmpc_set_ui_z
+Rmpc_set_f_si Rmpc_set_q_si Rmpc_set_z_si Rmpc_set_si_f Rmpc_set_si_q Rmpc_set_si_z
+Rmpc_set_f_d Rmpc_set_q_d Rmpc_set_z_d Rmpc_set_d_f Rmpc_set_d_q Rmpc_set_d_z
+Rmpc_set_f_uj Rmpc_set_q_uj Rmpc_set_z_uj Rmpc_set_uj_f Rmpc_set_uj_q Rmpc_set_uj_z
+Rmpc_set_f_sj Rmpc_set_q_sj Rmpc_set_z_sj Rmpc_set_sj_f Rmpc_set_sj_q Rmpc_set_sj_z
+Rmpc_set_f_ld Rmpc_set_q_ld Rmpc_set_z_ld Rmpc_set_ld_f Rmpc_set_ld_q Rmpc_set_ld_z
+Rmpc_set_f_q Rmpc_set_q_f Rmpc_set_f_z Rmpc_set_z_f Rmpc_set_z_q Rmpc_set_q_z
+Rmpc_set_f_fr Rmpc_set_q_fr Rmpc_set_z_fr Rmpc_set_fr_f Rmpc_set_fr_q Rmpc_set_fr_z
+
+Rmpc_set_dc Rmpc_set_ldc
+
+Rmpc_add Rmpc_add_ui Rmpc_add_fr
+Rmpc_sub Rmpc_sub_ui Rmpc_ui_sub Rmpc_ui_ui_sub
+Rmpc_mul Rmpc_mul_ui Rmpc_mul_si Rmpc_mul_fr Rmpc_mul_i Rmpc_sqr Rmpc_mul_2exp
+Rmpc_mul_2si Rmpc_mul_2ui
+Rmpc_div Rmpc_div_ui Rmpc_ui_div Rmpc_div_fr Rmpc_sqrt Rmpc_div_2exp
+Rmpc_div_2si Rmpc_div_2ui
+Rmpc_neg Rmpc_abs Rmpc_conj Rmpc_norm Rmpc_exp Rmpc_log Rmpc_log10
+Rmpc_cmp Rmpc_cmp_si Rmpc_cmp_si_si
+Rmpc_out_str Rmpc_inp_str c_string r_string i_string
+TRmpc_out_str TRmpc_inp_str
+Rmpc_sin Rmpc_cos Rmpc_sin_cos Rmpc_tan Rmpc_sinh Rmpc_cosh Rmpc_tanh
+Rmpc_asin Rmpc_acos Rmpc_atan Rmpc_asinh Rmpc_acosh Rmpc_atanh
+Rmpc_real Rmpc_imag Rmpc_arg Rmpc_proj
+Rmpc_pow Rmpc_pow_d Rmpc_pow_ld Rmpc_pow_si Rmpc_pow_ui Rmpc_pow_z Rmpc_pow_fr
+Rmpc_set_nan Rmpc_swap
+Rmpc_mul_sj Rmpc_mul_ld Rmpc_mul_d Rmpc_div_sj Rmpc_sj_div Rmpc_div_ld Rmpc_ld_div Rmpc_div_d Rmpc_d_div
+);
+
+ our $VERSION = '1.02';
+ #$VERSION = eval $VERSION;
+
+ DynaLoader::bootstrap Math::MPC $VERSION;
+
+ %Math::MPC::EXPORT_TAGS =(mpc => [qw(
+MPC_RNDNN MPC_RNDND MPC_RNDNU MPC_RNDNZ MPC_RNDDN MPC_RNDUN MPC_RNDZN MPC_RNDDD
+MPC_RNDDU MPC_RNDDZ MPC_RNDZD MPC_RNDUD MPC_RNDUU MPC_RNDUZ MPC_RNDZU MPC_RNDZZ
+MPC_VERSION_MAJOR MPC_VERSION_MINOR MPC_VERSION_PATCHLEVEL MPC_VERSION_STRING
+MPC_VERSION MPC_VERSION_NUM Rmpc_get_version
+Rmpc_set_default_rounding_mode Rmpc_get_default_rounding_mode
+Rmpc_set_prec Rmpc_set_default_prec Rmpc_get_default_prec
+Rmpc_set_default_prec2 Rmpc_get_default_prec2
+Rmpc_set_re_prec Rmpc_set_im_prec
+Rmpc_get_prec Rmpc_get_prec2 Rmpc_get_re_prec Rmpc_get_im_prec
+Rmpc_get_dc Rmpc_get_ldc
+RMPC_RE RMPC_IM RMPC_INEX_RE RMPC_INEX_IM
+Rmpc_clear Rmpc_clear_ptr Rmpc_clear_mpc
+Rmpc_deref4 Rmpc_get_str
+Rmpc_init2 Rmpc_init3
+Rmpc_init2_nobless Rmpc_init3_nobless
+Rmpc_strtoc Rmpc_set_str
+Rmpc_set Rmpc_set_ui Rmpc_set_si Rmpc_set_d Rmpc_set_uj Rmpc_set_sj Rmpc_set_ld
+Rmpc_set_z Rmpc_set_q Rmpc_set_f Rmpc_set_fr
+Rmpc_set_z_z Rmpc_set_q_q Rmpc_set_f_f
+Rmpc_set_ui_ui Rmpc_set_ui_si Rmpc_set_ui_d Rmpc_set_ui_uj Rmpc_set_ui_sj Rmpc_set_ui_ld Rmpc_set_ui_fr
+Rmpc_set_si_ui Rmpc_set_si_si Rmpc_set_si_d Rmpc_set_si_uj Rmpc_set_si_sj Rmpc_set_si_ld Rmpc_set_si_fr
+Rmpc_set_d_ui Rmpc_set_d_si Rmpc_set_d_d Rmpc_set_d_uj Rmpc_set_d_sj Rmpc_set_d_ld Rmpc_set_d_fr
+Rmpc_set_uj_ui Rmpc_set_uj_si Rmpc_set_uj_d Rmpc_set_uj_uj Rmpc_set_uj_sj Rmpc_set_uj_ld Rmpc_set_uj_ld Rmpc_set_uj_fr
+Rmpc_set_sj_ui Rmpc_set_sj_si Rmpc_set_sj_d Rmpc_set_sj_uj Rmpc_set_sj_sj Rmpc_set_sj_ld Rmpc_set_sj_fr
+Rmpc_set_ld_ui Rmpc_set_ld_si Rmpc_set_ld_uj Rmpc_set_ld_d Rmpc_set_ld_sj Rmpc_set_ld_ld Rmpc_set_ld_fr
+Rmpc_set_fr_ui Rmpc_set_fr_si Rmpc_set_fr_d Rmpc_set_fr_uj Rmpc_set_fr_sj Rmpc_set_fr_ld Rmpc_set_fr_fr
+
+Rmpc_set_f_ui Rmpc_set_q_ui Rmpc_set_z_ui Rmpc_set_ui_f Rmpc_set_ui_q Rmpc_set_ui_z
+Rmpc_set_f_si Rmpc_set_q_si Rmpc_set_z_si Rmpc_set_si_f Rmpc_set_si_q Rmpc_set_si_z
+Rmpc_set_f_d Rmpc_set_q_d Rmpc_set_z_d Rmpc_set_d_f Rmpc_set_d_q Rmpc_set_d_z
+Rmpc_set_f_uj Rmpc_set_q_uj Rmpc_set_z_uj Rmpc_set_uj_f Rmpc_set_uj_q Rmpc_set_uj_z
+Rmpc_set_f_sj Rmpc_set_q_sj Rmpc_set_z_sj Rmpc_set_sj_f Rmpc_set_sj_q Rmpc_set_sj_z
+Rmpc_set_f_ld Rmpc_set_q_ld Rmpc_set_z_ld Rmpc_set_ld_f Rmpc_set_ld_q Rmpc_set_ld_z
+Rmpc_set_f_q Rmpc_set_q_f Rmpc_set_f_z Rmpc_set_z_f Rmpc_set_z_q Rmpc_set_q_z
+Rmpc_set_f_fr Rmpc_set_q_fr Rmpc_set_z_fr Rmpc_set_fr_f Rmpc_set_fr_q Rmpc_set_fr_z
+
+Rmpc_set_dc Rmpc_set_ldc
+
+Rmpc_add Rmpc_add_ui Rmpc_add_fr
+Rmpc_sub Rmpc_sub_ui Rmpc_ui_sub Rmpc_ui_ui_sub
+Rmpc_mul Rmpc_mul_ui Rmpc_mul_si Rmpc_mul_fr Rmpc_mul_i Rmpc_sqr Rmpc_mul_2exp
+Rmpc_mul_2si Rmpc_mul_2ui
+Rmpc_div Rmpc_div_ui Rmpc_ui_div Rmpc_div_fr Rmpc_sqrt Rmpc_div_2exp
+Rmpc_div_2si Rmpc_div_2ui
+Rmpc_neg Rmpc_abs Rmpc_conj Rmpc_norm Rmpc_exp Rmpc_log Rmpc_log10
+Rmpc_cmp Rmpc_cmp_si Rmpc_cmp_si_si
+Rmpc_out_str Rmpc_inp_str c_string r_string i_string
+TRmpc_out_str TRmpc_inp_str
+Rmpc_sin Rmpc_cos Rmpc_sin_cos Rmpc_tan Rmpc_sinh Rmpc_cosh Rmpc_tanh
+Rmpc_asin Rmpc_acos Rmpc_atan Rmpc_asinh Rmpc_acosh Rmpc_atanh
+Rmpc_real Rmpc_imag Rmpc_arg Rmpc_proj
+Rmpc_pow Rmpc_pow_d Rmpc_pow_ld Rmpc_pow_si Rmpc_pow_ui Rmpc_pow_z Rmpc_pow_fr
+Rmpc_set_nan Rmpc_swap
+Rmpc_mul_sj Rmpc_mul_ld Rmpc_mul_d Rmpc_div_sj Rmpc_sj_div Rmpc_div_ld Rmpc_ld_div Rmpc_div_d Rmpc_d_div
+)]);
+
+*TRmpc_out_str = \&Rmpc_out_str;
+*TRmpc_inp_str = \&Rmpc_inp_str;
+
+*Rmpc_set_uj_si = \&Rmpc_set_uj_sj;
+*Rmpc_set_ui_sj = \&Rmpc_set_uj_sj;
+
+*Rmpc_set_sj_ui = \&Rmpc_set_sj_uj;
+*Rmpc_set_si_uj = \&Rmpc_set_sj_uj;
+
+*Rmpc_set_uj_ui = \&Rmpc_set_uj_uj;
+*Rmpc_set_ui_uj = \&Rmpc_set_uj_uj;
+
+*Rmpc_set_sj_si = \&Rmpc_set_sj_sj;
+*Rmpc_set_si_sj = \&Rmpc_set_sj_sj;
+
+*Rmpc_set_d_ld = \&Rmpc_set_ld_ld;
+*Rmpc_set_ld_d = \&Rmpc_set_ld_ld;
+
+*Rmpc_mul_sj = \&Math::MPC::_mpc_mul_sj;
+*Rmpc_mul_ld = \&Math::MPC::_mpc_mul_ld;
+*Rmpc_mul_d = \&Math::MPC::_mpc_mul_d;
+*Rmpc_div_sj = \&Math::MPC::_mpc_div_sj;
+*Rmpc_sj_div = \&Math::MPC::_mpc_sj_div;
+*Rmpc_div_ld = \&Math::MPC::_mpc_div_ld;
+*Rmpc_ld_div = \&Math::MPC::_mpc_ld_div;
+*Rmpc_div_d = \&Math::MPC::_mpc_div_d;
+*Rmpc_d_div = \&Math::MPC::_mpc_d_div;
+
+# Beginning with mpc-1.0, mpc_mul_2exp and mpc_div_2exp
+# were renamed to mpc_mul_2ui and mpc_div_2ui.
+*Rmpc_mul_2exp = \&Rmpc_mul_2ui;
+*Rmpc_div_2exp = \&Rmpc_div_2ui;
+
+sub dl_load_flags {0} # Prevent DynaLoader from complaining and croaking
+
+sub overload_string {
+ return "(" . _get_str($_[0], 10, 0, Rmpc_get_default_rounding_mode()) . ")";
+
+}
+
+### Was originally called Rmpc_get_str ###
+sub _get_str {
+ my ($r_s, $i_s) = c_string($_[0], $_[1], $_[2], $_[3]);
+ # Changed to stay in step with change to mpc_out_str() format
+ #my $sep = $i_s =~ /\-/ ? ' -I*' : ' +I*';
+ #$i_s =~ s/\-//;
+ #my $s = $r_s . $sep . $i_s;
+ #return $s;
+ return $r_s . " " . $i_s;
+}
+
+sub c_string {
+ my $r_s = r_string($_[0], $_[1], $_[2], $_[3]);
+ my $i_s = i_string($_[0], $_[1], $_[2], $_[3]);
+ return ($r_s, $i_s);
+}
+
+sub r_string {
+ my($mantissa, $exponent) = _get_r_string($_[0], $_[1], $_[2], $_[3]);
+ if($mantissa =~ /\@nan\@/i || $mantissa =~ /\@inf\@/i) {return $mantissa}
+ if($mantissa =~ /\-/ && $mantissa !~ /[^0,\-]/) {return '-0'}
+ if($mantissa !~ /[^0,\-]/ ) {return '0'}
+ my $sep = $_[1] <= 10 ? 'e' : '@';
+
+ my $len = substr($mantissa, 0, 1) eq '-' ? 2 : 1;
+
+ if(!$_[2]) {
+ while(length($mantissa) > $len && substr($mantissa, -1, 1) eq '0') {
+ substr($mantissa, -1, 1, '');
+ }
+ }
+
+ $exponent--;
+
+ if(length($mantissa) == $len) {
+ if($exponent) {return $mantissa . $sep . $exponent}
+ return $mantissa;
+ }
+
+ substr($mantissa, $len, 0, '.');
+ if($exponent) {return $mantissa . $sep . $exponent}
+ return $mantissa;
+}
+
+sub i_string {
+ my($mantissa, $exponent) = _get_i_string($_[0], $_[1], $_[2], $_[3]);
+ if($mantissa =~ /\@nan\@/i || $mantissa =~ /\@inf\@/i) {return $mantissa}
+ if($mantissa =~ /\-/ && $mantissa !~ /[^0,\-]/) {return '-0'}
+ if($mantissa !~ /[^0,\-]/ ) {return '0'}
+
+ my $sep = $_[1] <= 10 ? 'e' : '@';
+
+ my $len = substr($mantissa, 0, 1) eq '-' ? 2 : 1;
+
+ if(!$_[2]) {
+ while(length($mantissa) > $len && substr($mantissa, -1, 1) eq '0') {
+ substr($mantissa, -1, 1, '');
+ }
+ }
+
+ $exponent--;
+
+ if(length($mantissa) == $len) {
+ if($exponent) {return $mantissa . $sep . $exponent}
+ return $mantissa;
+ }
+
+ substr($mantissa, $len, 0, '.');
+ if($exponent) {return $mantissa . $sep . $exponent}
+ return $mantissa;
+}
+
+sub Rmpc_deref4 {
+ my ($r_m, $r_e) = _get_r_string($_[0], $_[1], $_[2], $_[3]);
+ my ($i_m, $i_e) = _get_i_string($_[0], $_[1], $_[2], $_[3]);
+ return ($r_m, $r_e, $i_m, $i_e);
+}
+
+
+sub new {
+
+ # This function caters for 2 possibilities:
+ # 1) that 'new' has been called OOP style - in which
+ # case there will be a maximum of 3 args
+ # 2) that 'new' has been called as a function - in
+ # which case there will be a maximum of 2 args.
+ # If there are no args, then we just want to return an
+ # initialized Math::MPC object
+ my @prec = Rmpc_get_default_prec2();
+ if(!@_) {return Rmpc_init3(@prec)}
+
+ if(@_ > 3) {die "Too many arguments supplied to new()"}
+
+ # If 'new' has been called OOP style, the first arg is the string "Math::MPC"
+ # which we don't need - so let's remove it. However, if the first
+ # arg is a Math::MPFR or Math::MPC object (which is a possibility),
+ # then we'll get a fatal error when we check it for equivalence to
+ # the string "Math::MPC". So we first need to check that it's not
+ # an object - which we'll do by using the ref() function:
+ if(!ref($_[0]) && $_[0] eq "Math::MPC") {
+ shift;
+ if(!@_) {return Rmpc_init3(@prec)}
+ }
+
+ if(_itsa($_[0]) == _MATH_MPC_T) {
+ if(@_ > 1) {die "Too many arguments supplied to new() - expected no more than one"}
+ my $mpc = Rmpc_init3(@prec);
+ Rmpc_set($mpc, $_[0], Rmpc_get_default_rounding_mode());
+ return $mpc;
+ }
+
+ # @_ can now contain a maximum of 2 args - the real and (optionally)
+ # the imaginary components.
+ if(@_ > 2) {die "Too many arguments supplied to new() - expected no more than two"}
+
+ my ($arg1, $arg2, $type1, $type2);
+
+ # $_[0] is the real component, $_[1] (if supplied)
+ # is the imaginary component.
+ $arg1 = shift;
+ $type1 = _itsa($arg1);
+
+ $arg2 = 0;
+ if(@_) {$arg2 = shift}
+ $type2 = _itsa($arg2);
+
+ # Die if either of the args are unacceptable.
+ if($type1 == 0)
+ {die "First argument to new() is inappropriate"}
+ if($type2 == 0)
+ {die "Second argument to new() is inappropriate"}
+
+ # Create a Math::MPC object that has $arg1 as its
+ # real component, and zero as its imaginary component.
+ my $mpc1 = _new_real($arg1);
+
+ # Create a Math::MPC object that has $arg2 as its
+ # imaginary component, and zero as its real component.
+ my $mpc2 = _new_im($arg2);
+
+ # Add the 2 created Math::MPC objects together and return
+ # the result
+ Rmpc_add($mpc1, $mpc1, $mpc2, MPC_RNDNN);
+ return $mpc1;
+}
+
+sub Rmpc_out_str {
+ if(@_ == 5) {
+ die "Inappropriate 4th arg supplied to Rmpc_out_str" if _itsa($_[3]) != _MATH_MPC_T;
+ return _Rmpc_out_str($_[0], $_[1], $_[2], $_[3], $_[4]);
+ }
+ if(@_ == 6) {
+ if(_itsa($_[3]) == _MATH_MPC_T) {return _Rmpc_out_strS($_[0], $_[1], $_[2], $_[3], $_[4], $_[5])}
+ die "Incorrect args supplied to Rmpc_out_str" if _itsa($_[4]) != _MATH_MPC_T;
+ return _Rmpc_out_strP($_[0], $_[1], $_[2], $_[3], $_[4], $_[5]);
+ }
+ if(@_ == 7) {
+ die "Inappropriate 5th arg supplied to Rmpc_out_str" if _itsa($_[4]) != _MATH_MPC_T;
+ return _Rmpc_out_strPS($_[0], $_[1], $_[2], $_[3], $_[4], $_[5], $_[6]);
+ }
+ die "Wrong number of arguments supplied to Rmpc_out_str()";
+}
+
+sub MPC_VERSION {return _MPC_VERSION()}
+sub MPC_VERSION_MAJOR {return _MPC_VERSION_MAJOR()}
+sub MPC_VERSION_MINOR {return _MPC_VERSION_MINOR()}
+sub MPC_VERSION_PATCHLEVEL {return _MPC_VERSION_PATCHLEVEL()}
+sub MPC_VERSION_STRING {return _MPC_VERSION_STRING()}
+sub MPC_VERSION_NUM {return _MPC_VERSION_NUM(@_)}
+
+1;
+
+__END__
+
+=head1 NAME
+
+Math::MPC - perl interface to the MPC (multi precision complex) library.
+
+=head1 DEPENDENCIES
+
+ This module needs the MPC, MPFR and GMP C libraries. (Install GMP
+ first, followed by MPFR, followed by MPC.)
+
+ The GMP library is availble from http://gmplib.org
+ The MPFR library is available from http://www.mpfr.org/
+ The MPC library is available from
+ http://www.multiprecision.org/mpc/
+
+=head1 DESCRIPTION
+
+ A multiple precision complex number module utilising the MPC library.
+ Basically, this module simply wraps the 'mpc' complex number functions
+ provided by that library.
+ Operator overloading is also available.
+ The following documentation heavily plagiarises the mpc documentation.
+
+ use warnings;
+ use Math::MPC qw(:mpc);
+ Rmpc_set_default_prec(500); # Set default precision to 500 bits
+ my $mpc1 = Math::MPC->new(12.5, 1125); # 12.5 + 1125*i
+ $mpc2 = sqrt($mpc1);
+ print "Square root of $mpc1 is $mpc2\n";
+
+ See also the Math::MPC test suite for some (simplistic) examples of
+ usage.
+
+
+=head1 ROUNDING MODE
+
+ A complex rounding mode is of the form MPC_RNDxy where "x" and "y"
+ are one of "N" (to nearest), "Z" (towards zero), "U" (towards plus
+ infinity), "D" (towards minus infinity). The first letter refers to
+ the rounding mode for the real part, and the second one for the
+ imaginary part.
+ For example MPC_RNDZU indicates to round the real part towards
+ zero, and the imaginary part towards plus infinity.
+ The default rounding mode is MPC_RNDNN, but this can be changed
+ using the Rmpc_set_default_rounding_mode() function.
+
+=head1 MEMORY MANAGEMENT
+
+ Objects can be created with the Rmpc_init2 and Rmpc_init3 functions,
+ which return an object that has been blessed into the package
+ Math::MPC. Alternatively, blessed objects can also be created by
+ calling the new() function (either as a function or as a method).
+ These objects will be automatically cleaned up by the DESTROY()
+ function whenever they go out of scope.
+
+ Rmpc_init2_nobless and Rmpc_init3_nobless are the same as Rmpc_init2
+ and Rmpc_init3, except that they return an unblessed object.
+ If you create Math::MPC objects using the '_nobless' versions,
+ it will then be up to you to clean up the memory associated with
+ these objects by calling Rmpc_clear($op) for each object.
+ Alternatively such objects will be cleaned up when the script ends.
+ I don't know why you would want to create unblessed objects. The
+ point is that you can if you want to.
+
+=head1 MIXING MPC OBJECTS WITH MPFR & GMP OBJECTS
+
+ Some of the Math::MPC functions below take Math::MPFR, Math::GMP,
+ Math::GMPz, Math::GMPq, or Math::GMPf objects as arguments.
+ Obviously, to make use of these functions, you'll need to have
+ loaded the appropriate module.
+
+=head1 FUNCTIONS
+
+ Most of the following functions are simply wrappers around an mpc
+ function of the same name. eg. Rmpc_neg() is a wrapper around
+ mpc_neg().
+
+ "$rop", "$op1", "$op2", etc. are Math::MPC objects - the
+ return value of one of the Rmpc_init* functions. They are in fact
+ references to mpc structures. The "$op" variables are the operands
+ and "$rop" is the variable that stores the result of the operation.
+ Generally, $rop, $op1, $op2, etc. can be the same perl variable
+ referencing the same mpc structure, though often they will be
+ distinct perl variables referencing distinct mpc structures.
+ Eg something like Rmpc_add($r1, $r1, $r1, $rnd),
+ where $r1 *is* the same reference to the same mpc structure,
+ would add $r1 to itself and store the result in $r1. Alternatively,
+ you could (courtesy of operator overloading) simply code it
+ as $r1 += $r1. Otoh, Rmpc_add($r1, $r2, $r3, $rnd), where each of the
+ arguments is a different reference to a different mpc structure
+ would add $r2 to $r3 and store the result in $r1. Alternatively
+ it could be coded as $r1 = $r2 + $r3.
+
+ In the documentation that follows:
+
+ "$ui" means an integer that will fit into a C 'unsigned long int',
+
+ "$si" means an integer that will fit into a C 'signed long int'.
+
+ "$uj" means an integer that will fit into a C 'uintmax_t'. Don't
+ use the _uj functions unless your perl was compiled with 64
+ bit integer support.
+
+ "$sj" means an integer that will fit into a C 'intmax_t'. Don't
+ use the _sj functions unless your perl was compiled with 64
+ bit integer support.
+
+ "$double" is a C double.
+
+ "$ld" is a C long double. Don't use the _ld functions unless your
+ perl was compiled with long double support.
+
+ "$bool" means a value (usually a 'signed long int') in which
+ the only interest is whether it evaluates as false or true.
+
+ "$str" simply means a string of symbols that represent a number,
+ eg '1234567890987654321234567@7' which might be a base 10 number,
+ or 'zsa34760sdfgq123r5@11' which would have to represent at least
+ a base 36 number (because "z" is a valid digit only in bases 36
+ and above). Valid bases for MPC numbers are 2 to 36 (inclusive).
+
+ "$rnd" is simply one of the 16 rounding mode values (discussed above).
+
+ "$p" is the (unsigned long) value for precision.
+
+ "$mpf" is a Math::GMPf object (floating point). You'll need Math::GMPf
+ installed in order to create $mpf.
+
+ "$mpq" is a Math::GMPq object (rational). You'll need Nath::GMPq
+ installed in order to create $mpq.
+
+ "$mpz" is a Math::GMP or Math::GMPz object (integer). You'll need
+ Math::GMPz or Math::GMP installed in order to create $mpz.
+
+ "$mpfr" is a Math::MPFR object (floating point). You'll need to
+ 'use Math::MPFR;' in order to create $mpfr. (Math::MPFR
+ a pre-requisite module for Math::MPC.)
+
+ "$cc" is a Math::Complex_C (double _Complex) object. You'll need to
+ 'use Math::Complex_C' (or create your own double _Complex
+ object) in order to create $cc, and to use the functions that
+ take such an argument. (Math::Complex_C is *not* a
+ pre-requisite module for Math::MPC.)
+
+ "$lcc" is a Math::Complex_C::Long (long double _Complex) object.
+ You'll need to 'use Math::Complex_C' (or create your own
+ long double _Complex object in order to create $lcc, and
+ to use the functions that take such an argument.
+
+ ######################
+
+ FUNCTION RETURN VALUES
+
+ Most MPC functions have a return value ($si) which is used to
+ indicate the position of the rounded real or imaginary parts with
+ respect to the exact (infinite precision) values. The functions
+ RMPC_INEX_RE($si) and RMPC_INEX_IM($si) return 0 if the corresponding
+ rounded value is exact, a negative value if the rounded value is less
+ than the exact one, and a positive value if it is greater than the
+ exact one. However, some functions do not completely fulfill this -
+ in some cases the sign is not guaranteed, and in some cases a
+ non-zero value is returned although the result is exact. In these
+ cases the function documentation explains the exact meaning of the
+ return value. However, the return value never wrongly indicates an
+ exact computation.
+
+ ###########################
+
+ MANIPULATING ROUNDING MODES
+
+ Rmpc_set_default_rounding_mode($rnd);
+ Sets the default rounding mode to $rnd.
+ The default rounding mode is to nearest initially (MPC_RNDNN).
+ The default rounding mode is the rounding mode that is used in
+ overloaded operations.
+
+ $ui = Rmpc_get_default_rounding_mode();
+ Returns the numeric value of the current default rounding mode.
+ This will initially be 0 (MPC_RNDNN).
+
+ ##########
+
+ INITIALIZATION
+
+ Normally, a variable should be initialized once only or at least
+ be cleared, using `Rmpc_clear', between initializations - but
+ don't explicitly call Rmpc_clear() on blessed objects. 'DESTROY'
+ (which calls 'Rmpc_clear') is automatically called on blessed
+ objects whenever they go out of scope.
+
+ First read the section 'MEMORY MANAGEMENT' (above).
+
+ Rmpc_set_default_prec($p);
+ Rmpc_set_default_prec2($p_re, $p_im);
+ Rmpc_set_default_prec sets the default precision to exactly $p
+ bits for both the real and imaginary parts. Rmpc_set_default_prec
+ sets the default precision to be *exactly* $p_re bits for the real
+ part, and *exactly* $p_im bits for the imaginary part. The
+ precision of a variable means the number of bits used to store its
+ mantissa. All subsequent calls to `new' will use this precision,
+ but previously initialized variables are unaffected. This is also
+ the precision that will be used during some overloaded operations
+ (see OPERATOR OVERLOADING below).
+ The default precision is set to 53 bits initially (for both
+ real and imaginary components).
+
+ $ui = Rmpc_get_default_prec();
+ ($ui_re, $ui_im) = Rmpc_get_default_prec2();
+ Rmpc_get_default_prec returns the current default real precision
+ iff the default real precision is the same as the current default
+ imaginary precision. Otherwise it returns zero.
+ Rmpc_get_default_prec2 returns both current default real precision
+ and current default imaginary precision (in bits).
+
+ $ui = Rmpc_get_prec($op);
+ If the real and imaginary part of $op have the same precision,
+ it is returned. Otherwise 0 is returned.
+
+ $ui = Rmpc_get_re_prec($op);
+ $ui = Rmpc_get_im_prec($op)
+ ($re_prec, $im_prec) = Rmpc_get_prec2($op);
+ Get (respectively) the precision of the real part of $op, the
+ precision of the imaginary part of $op, or an array containing
+ precision of both real and imaginary parts of $op.
+
+ $rop = Math::MPC->new();
+ $rop = Math::MPC::new();
+ $rop = new Math::MPC();
+ Initialize $rop, and set its real and imaginary parts to NaN.
+ The precision of $rop is the default precision, which can be
+ changed by a call to `Rmpc_set_default_prec' or
+ `Rmpc_set_default_prec2' (documented above).
+
+ $rop = Rmpc_init2($p);
+ $rop = Rmpc_init2_nobless($p);
+ Initialize $rop, set the precision (of both real and imaginary
+ parts) to be *exactly* $p bits, and set its real and imaginary
+ parts to NaN.
+
+ $rop = Rmpc_init3($p_re, $p_im);
+ $rop = Rmpc_init3_nobless($p_r, $p_i);
+ Initialize $rop, set the precision of the real part to be
+ *exactly* $p_re bits, set the precision of the imaginary part to
+ be *exactly* $p_im bits, and set its real and imaginary parts to
+ NaN.
+
+ Rmpc_set_prec($op, $p);
+ Reset the precision of $op to be exactly $p bits, and set its
+ real/imaginary parts to NaN.
+
+ Rmpc_set_re_prec($op, $p);
+ Rmpc_set_im_prec($op, $p);
+ Set (respectively) the precision of the real part of $op to be
+ exactly $p bits and the precision of the imaginary part of $op
+ to be exactly $p bits. In both cases the value is set to NaN.
+ (There are currently no corresponding MPC library functions.)
+
+ ##########
+
+ ASSIGNMENT
+
+ $si = Rmpc_set($rop, $op, $rnd);
+ $si = Rmpc_set_ui($rop, $ui, $rnd);
+ $si2 = Rmpc_set_si($rop, $si1, $rnd);
+ $si = Rmpc_set_d($rop, $double, $rnd);
+ $si = Rmpc_set_uj($rop, $uj, $rnd);
+ $si = Rmpc_set_sj($rop, $sj, $rnd);
+ $si = Rmpc_set_ld($rop, $ld, $rnd);
+ $si = Rmpc_set_f($rop, $mpf, $rnd);
+ $si = Rmpc_set_q($rop, $mpq, $rnd);
+ $si = Rmpc_set_z($rop, $mpz, $rnd);
+ $si = Rmpc_set_fr($rop, $mpfr, $rnd);
+ $si = Rmpc_set_dc($rop, $cc, $rnd);
+ $si = Rmpc_set_ldc($rop, $lcc, $rnd);
+ Set the value of $rop from 2nd arg, rounded to the precision of
+ $rop towards the given direction $rnd.
+ Don't use Rmpc_set_ld unless perl has been built with long
+ double support. Don't use Rmpc_set_uj or Rmpc_set_sj unless
+ perl has been built with long long int support.
+ For Rmpc_set_dc and Rmpc_set_ldc, an mpc library (version 0.9
+ or later) that has been built with support for these data types
+ is needed.
+
+ $si = Rmpc_set_str($rop, $string, $base, $rnd);
+ $si = Rmpc_strtoc($rop, $string, $base, $rnd);
+ Set $rop to the value represented in $string (in base $base), rounded
+ in accordance with $rnd. See the mpc documentation for details.
+
+ $si = Rmpc_set_ui_ui($rop, $ui1, $ui2, $rnd);
+ $si3 = Rmpc_set_si_si($rop, $si1, $si2, $rnd);
+ $si = Rmpc_set_d_d($rop, $double1, $double2, $rnd);
+ $si = Rmpc_set_f_f($rop, $mpf1, $mpf2, $rnd);
+ $si = Rmpc_set_q_q($rop, $mpq1, $mpq2, $rnd);
+ $si = Rmpc_set_z_z($rop, $mpz1, $mpz2, $rnd);
+ $si = Rmpc_set_fr_fr($rop, $mpfr1, $mpfr2, $rnd);
+ Sets the real part of $rop from 2nd arg, and the imaginary part
+ of $rop from 3rd arg, according to the rounding mode $rnd.
+
+ $si = Rmpc_set_uj_uj($rop, $uj1, $uj2, $rnd);
+ $si = Rmpc_set_sj_sj($rop, $sj1, $sj2, $rnd);
+ $si = Rmpc_set_ld_ld($rop, $ld1, $ld2, $rnd);
+ Don't use the first 2 functions unless Math::MPC::_has_longlong()
+ returns a true value. Don't use the 3rd function unless
+ Math::MPC::_has_longdouble() returns true.
+ Sets the real part of $rop from 2nd arg, and the imaginary part
+ of $rop from 3rd arg, according to the rounding mode $rnd.
+
+ $si = Rmpc_set_x_y($rop, $op1, $op2, $rnd);
+ You need to replace the 'x' and the 'y' with any one of 'ui',
+ 'si', 'd', 'uj', 'sj', 'ld', 'f', 'q', 'z' and 'fr' - eg:
+ Rmpc_set_ui_d($rop, $ui, $double, $rnd);
+ Don't use the 'uj' or 'sj' variants if Math::MPC::_has_longlong()
+ doesn't return a true value. And don't use the 'ld' variants if
+ Math::MPC_haslongdouble() doesn't return a true value.
+ Sets the real part of $rop from 2nd arg, and the imaginary part
+ of $rop from 3rd arg, according to the rounding mode $rnd.
+
+ ################################################
+
+ COMBINED INITIALIZATION AND ASSIGNMENT
+
+ NOTE: Do NOT use these functions if $rop has already been initialised
+ or created by calling new(). Instead use the Rmpc_set* functions in
+ the section 'ASSIGNMENT' (above).
+
+ First read the section 'MEMORY MANAGEMENT' (above).
+
+ $rop = Math::MPC->new($arg1 [, $arg2]);
+ $rop = Math::MPC::new($arg1 [, $arg2]);
+ $rop = new Math::MPC($arg1, [, $arg2]);
+ Returns a Math::MPC object whose real component has a value of $arg1,
+ rounded in the default rounding direction, with default precision.
+ If $arg2 is supplied, the imaginary component of the returned
+ Math::MPC object is set to $arg2, rounded in the default rounding
+ direction, with default precision. Otherwise the imaginary component
+ of the returned Math::MPC object is set to zero. $arg1 & $arg2 can be
+ either a number (signed integer, unsigned integer, signed fraction or
+ unsigned fraction), a string that represents a numeric value, a
+ Math::MPFR object, a Math::GMP object, a Math::GMPz object, a
+ Math::GMPq object or a Math::GMPf object.
+ If a string argument begins with "0b" or "0B", then the string is
+ treated as a base 2 string. Elsif it begins with "0x" or "0X" it is
+ treated as a base 16 string. Else it is treated as a base 10 string.
+
+ ##########
+
+ ARITHMETIC
+
+ $si = Rmpc_add($rop, $op1, $op2, $rnd);
+ $si = Rmpc_add_ui($rop, $op, $ui, $rnd);
+ $si = Rmpc_add_fr($rop, $op, $mpfr, $rnd);
+ Set $rop to 2nd arg + 3rd arg rounded in the direction $rnd.
+
+
+ $si = Rmpc_sub($rop, $op1, $op2, $rnd);
+ $si = Rmpc_sub_ui($rop, $op, $ui, $rnd);
+ $si = Rmpc_ui_sub($rop, $ui, $op, $rnd);
+ Set $rop to 2nd arg - 3rd arg rounded in the direction $rnd.
+
+ $si = Rmpc_ui_ui_sub($rop, $ui_r, $ui_i, $op, $rnd);
+ The real part of $rop is set to $ui_r minus the real part of $op
+ (rounded in the direction $rnd) - and the imaginary part of $rop
+ is set to $ui_r minus the imaginary part of $op (rounded in the
+ direction $rnd)
+
+
+ $si = Rmpc_mul($rop, $op1, $op2, $rnd);
+ $si = Rmpc_mul_ui($rop, $op, $ui, $rnd);
+ $si = Rmpc_mul_si($rop, $op, $si1, $rnd);
+ $si = Rmpc_mul_sj($rop, $op, $sj, $rnd); # Math::MPC XSub
+ $si = Rmpc_mul_d($rop, $op, $double, $rnd);# Math::MPC XSub
+ $si = Rmpc_mul_ld($rop, $op, $ld, $rnd); # Math::MPC XSub
+ $si = Rmpc_mul_fr($rop, $op, $mpfr, $rnd);
+ Set $rop to 2nd arg * 3rd arg rounded in the direction $rnd.
+ The 'sj'/'ld' versions are available only on perls built with
+ '64 bit int'/'long double' support.
+
+ $si = Rmpc_mul_i($rop, $op, $si1, $rnd);
+ If $si1 >= 0 (non-negative), set $rop to $op times the
+ imaginary unit i - else set $rop to $op times -i.
+
+
+ $si = Rmpc_div($rop, $op1, $op2, $rnd);
+ $si = Rmpc_div_ui($rop, $op, $ui, $rnd);
+ $si = Rmpc_ui_div($rop, $ui, $op, $rnd);
+ $si = Rmpc_div_d($rop, $op, $double, $rnd); # Math::MPC XSub
+ $si = Rmpc_d_div($rop, $double, $op, $rnd); # Math::MPC XSub
+ $si = Rmpc_div_sj($rop, $op, $sj, $rnd); # Math::MPC XSub
+ $si = Rmpc_sj_div($rop, $sj, $op, $rnd); # Math::MPC XSub
+ $si = Rmpc_div_ld($rop, $op, $ld, $rnd); # Math::MPC XSub
+ $si = Rmpc_ld_div($rop, $ld, $op, $rnd); # Math::MPC XSub
+ $si = Rmpc_div_fr($rop, $op, $mpfr, $rnd);
+ Set $rop to 2nd arg / 3rd arg rounded in the direction $rnd.
+ The 'sj'/'ld' versions are available only on perls built with
+ '64 bit int'/'long double' support.
+
+ $si = Rmpc_sqr($rop, $op, $rnd);
+ Set $rop to the square of $op, rounded in direction $rnd.
+
+ $si = Rmpc_sqrt($rop, $op, $rnd);
+ Set $rop to the square root of the 2nd arg rounded in the
+ direction $rnd. When the return value is 0, it means the result
+ is exact. Else it's unknown whether the result is exact or not.
+
+ $si = Rmpc_pow($rop, $op1, $op2, $rnd);
+ $si = Rmpc_pow_d($rop, $op1, $double, $rnd);
+ $si = Rmpc_pow_ld($rop, $op1, $ld, $rnd);
+ $si2 = Rmpc_pow_si($rop, $op1, $si, $rnd);
+ $si = Rmpc_pow_ui($rop, $op1, $ui, $rnd);
+ $si = Rmpc_pow_z($rop, $op1, $mpz, $rnd);
+ $si = Rmpc_pow_fr($rop, $op1, $mpfr, $rnd);
+ Set $op to ($op1 ** 3rd arg) rounded in the direction $rnd.
+ Rmpc_pow_ld is available only on perls that have "long double"
+ support.
+
+ $si = Rmpc_neg($rop, $op, $rnd);
+ Set $rop to -$op rounded in the direction $rnd. Just
+ changes the sign if $rop and $op are the same variable.
+
+ $si = Rmpc_conj($rop, $op, $rnd);
+ Set $rop to the conjugate of $op rounded in the direction $rnd.
+ Just changes the sign of the imaginary part if $rop and $op are
+ the same variable.
+
+ $si = Rmpc_abs($mpfr, $op, $rnd);
+ Set the floating-point number $mpfr to the absolute value of $op,
+ rounded in the direction $rnd. Return 0 iff the result is exact.
+
+ $si = Rmpc_norm($mpfr, $op, $rnd);
+ Set the floating-point number $mpfr to the norm of $op (ie the
+ square of its absolute value), rounded in the direction $rnd.
+ Return 0 iff the result is exact.
+
+ $si = Rmpc_mul_2exp($rop, $op, $ui, $rnd);
+ $si = Rmpc_mul_2ui ($rop, $op, $ui, $rnd);#same as Rmpc_mul_2exp
+ $si1 = Rmpc_mul_2si ($rop, $op, $si2, $rnd);
+ Set $rop to $op times 2 raised to 3rd arg rounded according to
+ $rnd. Just increases the exponents of the real and imaginary
+ parts by value of 3rd arg when $rop and $op are identical.
+
+ $si = Rmpc_div_2exp($rop, $op, $ui, $rnd);
+ $si = Rmpc_div_2ui ($rop, $op, $ui, $rnd);#same as Rmpc_div_2exp
+ $si1 = Rmpc_div_2si ($rop, $op, $si2, $rnd);
+ Set $rop to $op divided by 2 raised to 3rd arg rounded according
+ to $rnd. Just decreases the exponents of the real and imaginary
+ parts by value of 3rd arg when $rop and $op are identical.
+
+ Rmpc_swap($op1, $op2);
+ Swap the values (and precisions) of op1 and op2 efficiently.
+
+ ##########
+
+ COMPARISON
+
+ $si = Rmpc_cmp($op1, $op2);
+ $si = Rmpc_cmp_si($op, $si1);
+ Compare 1st and 2nd args. The return value $si can be decomposed
+ into $x = RMPC_INEX_RE($si) and $y = RMPC_INEX_IM($si), such that $x
+ is positive if the real part of the 1st arg is greater than that of
+ the 2nd arg, zero if both real parts are equal, and negative if the
+ real part of the 1st arg is less than that of the 2nd arg.
+ Likewise for $y.
+ Both 1st and 2nd args are considered to their full own precision,
+ which may differ.
+ It is not allowed that one of the operands has a NaN (Not-a-Number)
+ part.
+ The storage of the return value is such that equality can be simply
+ checked with Rmpc_cmp($first_arg, $second_arg) == 0.
+
+ $si = Rmpc_cmp_si_si($op, $si1, $si2);
+ As for the above comparison functions - except that $op is being
+ compared with $si1 + ($si2 * i).
+
+ #######
+
+ SPECIAL
+
+ $si = Rmpc_exp($rop, $op, $rnd);
+ Set $rop to the exponential of $op, rounded according to $rnd
+ with the precision of $rop.
+
+ $si = Rmpc_log($rop, $op, $rnd);
+ Set $rop to the log of $op, rounded according to $rnd with the
+ precision of $rop.
+
+ $si = Rmpc_log10($rop, $op, $rnd);
+ Set $rop to the base 10 log of $op, rounded according to $rnd with
+ the precision of $rop.
+
+ $si = Rmpc_arg ($mpfr, $op, $rnd);
+ Set $mpfr to the argument of $op, with a branch cut along the
+ negative real axis. ($mpfr is a Math::MPFR object.)
+
+ $si = Rmpc_proj ($rop, $op, $rnd);
+ Compute a projection of $op onto the Riemann sphere. Set $rop
+ to $op, rounded in the direction $rnd, except when at least one
+ part of $op is infinite (even if the other part is a NaN) in
+ which case the real part of $rop is set to plus infinity and its
+ imaginary part to a signed zero with the same sign as the
+ imaginary part of $op.
+
+ Rmpc_set_nan($op);
+ Set $op to 'NaN +I*NaN'.
+
+ ##########
+
+ TRIGONOMETRIC
+
+ $si = Rmpc_sin($rop, $op, $rnd);
+ Set $rop to the sine of $op, rounded according to $rnd with the
+ precision of $rop.
+
+ $si = Rmpc_cos($rop, $op, $rnd);
+ Set $rop to the cosine of $op, rounded according to $rnd with
+ the precision of $rop.
+
+ $si = Rmpc_sin_cos($r_sin, $r_cos, $op, $rnd_sin, $rnd_cos);
+ Needs version 0.9 or later of the mpc C library.
+ Set $r_sin/$r_cos to the sin/cos of $op, rounded according to
+ $rnd_sin/$rnd_cos.
+ (If the mpc C library is pre version 0.9, calling this
+ function will cause the program to die with an appropriate
+ error message.)
+
+ $si = Rmpc_tan($rop, $op, $rnd);
+ Set $rop to the tangent of $op, rounded according to $rnd with
+ the precision of $rop.
+
+ $si = Rmpc_sinh($rop, $op, $rnd);
+ Set $rop to the hyperbolic sine of $op, rounded according to
+ $rnd with the precision of $rop.
+
+ $si = Rmpc_cosh($rop, $op, $rnd);
+ Set $rop to the hyperbolic cosine of $op, rounded according to
+ $rnd with the precision of $rop.
+
+ $si = Rmpc_tanh($rop, $op, $rnd);
+ Set $rop to the hyperbolic tangent of $op, rounded according to
+ $rnd with the precision of $rop.
+
+ $si = Rmpc_asin ($rop, $op, $rnd);
+ Set $rop to the inverse sine of $op, rounded according to
+ $rnd with the precision of $rop.
+
+ $si = Rmpc_acos ($rop, $op, $rnd);
+ Set $rop to the inverse cosine of $op, rounded according to
+ $rnd with the precision of $rop.
+
+ $si = Rmpc_atan ($rop, $op, $rnd);
+ Set $rop to the inverse tangent of $op, rounded according to
+ $rnd with the precision of $rop.
+
+ $si = Rmpc_asinh ($rop, $op, $rnd);
+ Set $rop to the inverse hyperbolic sine of $op, rounded
+ according to $rnd with the precision of $rop.
+
+ $si = Rmpc_acosh ($rop, $op, $rnd);
+ Set $rop to the inverse hyperbolic cosine of $op, rounded
+ according to$rnd with the precision of $rop.
+
+ $si = Rmpc_atanh ($rop, $op, $rnd);
+ Set $rop to the inverse hyperbolic tangent of $op, rounded
+ according to$rnd with the precision of $rop.
+
+ ##########
+
+ CONVERSION
+
+ ($real, $im) = c_string($op, $base, $digits, $rnd);
+ $real = r_string($op, $base, $digits, $rnd);
+ $im = i_string($op, $base, $digits, $rnd);
+ $real is a string containing the value of the real part of $op.
+ $im is a string containing the value of the imaginary part of $op.
+ $real and $im will be of the form XeY (X@Y for bases greater than 10)
+ - where X is the mantissa (in base $base) and Y is the exponent (in
+ base 10).
+ For example, -31.4132' would be returned as -3.14132e1. $digits is the
+ number of digits that will be written in the mantissa. If $digits is
+ zero, the mantissa will contain the maximum number of digits
+ accurately representable. The mantissa will be rounded in the
+ direction specified by $rnd.
+
+ @vals = Rmpc_deref4($op, $base, $digits, $rnd);
+ @vals contains (in order) the real mantissa, the real exponent, the
+ imaginary mantissa, and the imaginary exponent of $op.The mantissas,
+ expressed in base $base and rounded according to $rnd), contain an
+ implicit radix point to the left of the first (ie leftmost) digit.
+ The exponents are always expressed in base 10. $digits is the number
+ of digits that will be written in the mantissa. If $digits is zero
+ the mantissa will contain the maximum number of digits accurately
+ representable.
+
+ RMPC_RE($mpfr, $op);
+ RMPC_IM($mpfr, $op);
+ Set $mpfr to the value of the real (respectively imaginary) component
+ of $op. $mpfr will be an exact copy of the real/imaginary component
+ of op - ie the precision of $mpfr will be set to the precision of the
+ real/imaginary component of $op before the copy is made. Hence no need
+ for a rounding arg to be supplied.
+
+ $si = Rmpc_real($mpfr, $op, $rnd);
+ $si = Rmpc_imag($mpfr, $op, $rnd);
+ Set $mpfr to the value of the real (respectively imaginary) part of
+ $op, rounded in the direction $rnd. ($mpfr is a Math::MPFR object.)
+
+ #############
+
+ I-O FUNCTIONS
+
+ $ul = Rmpc_inp_str($rop, $stream, $base, $rnd);
+ Input a string in base $base from $stream, rounded according to $rnd,
+ and put the read complex in $rop. Each of the real and imaginary
+ parts should be of the form X@Ym or, if the base is 10 or less,
+ alternatively XeY or XEY. (X is the mantissa, Y is the exponent.
+ The mantissa is always in the specified base. The exponent is always
+ read in decimal. This function first reads the real part, followed by
+ the imaginary part. The argument $base may be in the range 0,2..36.
+ Return the number of bytes read, or if an error occurred, return 0.
+
+ $ul =
+ Rmpc_out_str([$pre,] $stream, $base, $digits, $op, $rnd [, $suf]);
+ This function changed from 1st release (version 0.45) of Math::MPC.
+ Output $op to $stream, in base $base, rounded according to $rnd. First
+ the real part is printed, followed by the imaginary part. The base may
+ be 0,2..36. Print at most $digits significant digits for each
+ part, or if $digits is 0, the maximum number of digits accurately
+ representable by $op. In addition to the significant digits, a decimal
+ point at the right of the first digit and a trailing exponent, in the
+ form eYYY , are printed. (If $base is greater than 10, "@" will be
+ used as exponent delimiter.) $pre and $suf are optional arguments
+ containing a string that will be prepended/appended to the output.
+ Return the number of bytes written. (The contents of $pre and $suf
+ are not included in the count.)
+
+ $string = Rmpc_get_str($base, $how_many, $op, $rnd);
+ Convert $op to a string containing the real and imaginary parts of
+ $op. The number of significant digits for both real and imaginary
+ parts is specified by $how_many. It is also possible to let
+ $how_many be zero, in which case the number of digits is chosen large
+ enough so that re-reading the printed value with the same precision,
+ assuming both output and input use rounding to nearest, will recover
+ the original value of $op. See the mpc documentation for details.
+
+ Rmpc_get_dc($cc, $op, $rnd);
+ Rmpc_get_ldc($lcc, $op, $rnd);
+ Set the 'double _Complex'/'long double _Complex' object to the value
+ of $op, rounded according to $rnd. Needs an mpc library (version 0.9
+ or later) that has been built with support for these data types.
+
+ ####################
+
+ OPERATOR OVERLOADING
+
+ Overloading works with numbers, strings (bases 2, 10, and 16
+ only - see step '4.' below) and Math::MPC objects.
+ Overloaded operations are performed using the current
+ "default rounding mode" (which you can determine using the
+ 'Rmpc_get_default_rounding_mode' function, and change using
+ the 'Rmpc_set_default_rounding_mode' function).
+
+ Be aware that when you use overloading with a string operand,
+ the overload subroutine converts that string operand to a
+ Math::MPC object with *current default precision*, and using
+ the *current default rounding mode*.
+
+ Be aware also, that the sign of zero is not always handled
+ correctly by the overload subroutines. If it's important to you
+ that the sign of zero be handled correctly, don't use the
+ overloaded operators. (For multiplication, division, addition
+ and subtraction the sign of zero will be handled correctly by the
+ overloaded operators if both operands are Math::MPC objects.)
+
+ For the purposes of the overloaded 'not', '!' and 'bool'
+ operators, a "false" Math::MPC object is one with real and
+ imaginary parts that are both "false" - where "false" currently
+ means either 0 or NaN.
+ (A "true" Math::MPC object is, of course, simply one that is not
+ "false".)
+
+ The following operators are overloaded:
+ + - * / ** sqrt (Return object has default precision)
+ += -= *= /= **= (Precision remains unchanged)
+ == !=
+ ! bool
+ abs (Returns an MPFR object, blessed into package Math::MPFR)
+ exp log (Return object has default precision)
+ sin cos (Return object has default precision)
+ = (The copy has the same precision as the copied object.)
+ ""
+
+ Attempting to use the overloaded operators with objects that
+ have been blessed into some package other than 'Math::MPC'
+ will not work. The workaround is to convert this "foreign"
+ object to a Math::MPC object - thus allowing it to work with
+ the overloaded operator.
+
+ In those situations where the overload subroutine operates on 2
+ perl variables, then obviously one of those perl variables is
+ a Math::MPC object. To determine the value of the other variable
+ the subroutine works through the following steps (in order),
+ using the first value it finds, or croaking if it gets
+ to step 6:
+
+ 1. If the variable is an unsigned long then that value is used.
+ The variable is considered to be an unsigned long if
+ (perl 5.8 on) the UOK flag is set or if (perl 5.6) SvIsUV()
+ returns true.(In the case of perls built with -Duse64bitint,
+ the variable is treated as an unsigned long long int if the
+ UOK flag is set.)
+
+ 2. If the variable is a signed long int, then that value is used.
+ The variable is considered to be a signed long int if the
+ IOK flag is set. (In the case of perls built with
+ -Duse64bitint, the variable is treated as a signed long long
+ int if the IOK flag is set.)
+
+ 3. If the variable is a double, then that value is used. The
+ variable is considered to be a double if the NOK flag is set.
+ (In the case of perls built with -Duselongdouble, the variable
+ is treated as a long double if the NOK flag is set.)
+
+ 4. If the variable is a string (ie the POK flag is set) then the
+ value of that string is used. If the POK flag is set, but the
+ string is not a valid number, the subroutine croaks with an
+ appropriate error message. If the string starts with '0b' or
+ '0B' it is regarded as a base 2 number. If it starts with '0x'
+ or '0X' it is regarded as a base 16 number. Otherwise it is
+ regarded as a base 10 number.
+
+ 5. If the variable is a Math::MPC object then the value of that
+ object is used.
+
+ 6. If none of the above is true, then the second variable is
+ deemed to be of an invalid type. The subroutine croaks with
+ an appropriate error message.
+
+ #####################
+
+ MISCELLANEOUS
+
+ $ui = MPC_VERSION_MAJOR;
+ Returns the 'x' in the 'x.y.z' of the MPC library version.
+ Value is as specified by the header file (mpc.h) that was
+ used to build Math::MPC.
+
+ $ui =MPC_VERSION_MINOR;
+ Returns the 'y' in the 'x.y.z' of the MPC library version.
+ Value is as specified by the header file (mpc.h) that was
+ used to build Math::MPC.
+
+ $ui = MPC_VERSION_PATCHLEVEL;
+ Returns the 'z' in the 'x.y.z' of the MPC library version.
+ Value is as specified by the header file (mpc.h) that was
+ used to build Math::MPC.
+
+ $ui = MPC_VERSION();
+ An integer value derived from the library's major, minor and
+ patchlevel values. Value is as specified by the header file
+ (mpc.h) that was used to build Math::MPC.
+
+ $ui = MPC_VERSION_NUM($major, $minor, $patchlevel);
+ Returns an integer in the same format as used by MPC_VERSION,
+ using the given $major, $minor and $patchlevel. Value is as
+ specified by the header file (mpc.h) that was used to build
+ Math::MPC.
+
+ $string = MPC_VERSION_STRING;
+ $string contains the MPC library version ('x.y.z'), as defined
+ by the header file (mpc.h) that was used to build Math::MPC
+
+ $string = Rmpc_get_version();
+ $string contains the MPC library version ('x.y.z'), as defined
+ by the mpc library being used by Math::MPC.
+
+ $MPFR_version = Math::MPC::mpfr_v();
+ $MPFR_version is set to the version of the mpfr library
+ being used by the mpc library that Math::MPC uses.
+ (The function is not exportable.)
+
+ $GMP_version = Math::MPC::gmp_v();
+ $GMP_version is set to the version of the gmp library being
+ used by the mpc library that Math::MPC uses.
+ (The function is not exportable.)
+
+ ####################
+
+=head1 TODO
+
+ For completeness, we probably should wrap mpc_realref and
+ mpc_imagref - though I don't think there's much to be
+ achieved by doing this in a *perl* context.
+
+=head1 BUGS
+
+ You can get segfaults if you pass the wrong type of
+ argument to the functions - so if you get a segfault, the
+ first thing to do is to check that the argument types
+ you have supplied are appropriate.
+ Also, as mentioned above in the "OPERATOR OVERLOADING" section,
+ the overloaded operators are not guaranteed to handle the sign
+ of zero correctly.
+
+=head1 LICENSE
+
+ This program is free software; you may redistribute it and/or
+ modify it under the same terms as Perl itself.
+ Copyright 2006-2009, 2010, 2011 Sisyphus
+
+=head1 AUTHOR
+
+ Sisyphus <sisyphus at(@) cpan dot (.) org>
+
+=cut
@@ -1,4899 +1,5566 @@
-#include "EXTERN.h"
-#include "perl.h"
-#include "XSUB.h"
-
-#include <stdio.h>
-
-#ifndef _MSC_VER
-#include <inttypes.h>
-#include <limits.h>
-#ifdef _DO_COMPLEX_H
-#include <complex.h>
-#endif
-#endif
-
-#include <gmp.h>
-#include <mpfr.h>
-#include <mpc.h>
-
-#ifndef _MPC_H_HAVE_COMPLEX
-#ifndef _Complex_I
-#undef _DO_COMPLEX_H
-#endif
-#endif
-
-#ifdef _MSC_VER
-#pragma warning(disable:4700 4715 4716)
-#define intmax_t __int64
-#endif
-
-#ifdef OLDPERL
-#define SvUOK SvIsUV
-#endif
-
-#ifndef Newx
-# define Newx(v,n,t) New(0,v,n,t)
-#endif
-
-#ifndef Newxz
-# define Newxz(v,n,t) Newz(0,v,n,t)
-#endif
-
-#if MPC_VERSION_MAJOR > 0 || MPC_VERSION_MINOR > 8
-#define SIN_COS_AVAILABLE 1
-#endif
-
-#define MPC_RE(x) ((x)->re)
-#define MPC_IM(x) ((x)->im)
-
-#define VOID_MPC_SET_X_Y(real_t, imag_t, z, real_value, imag_value, rnd) \
- { \
- int _inex_re, _inex_im; \
- _inex_re = (mpfr_set_ ## real_t) (MPC_RE (z), (real_value), MPC_RND_RE (rnd)); \
- _inex_im = (mpfr_set_ ## imag_t) (MPC_IM (z), (imag_value), MPC_RND_IM (rnd)); \
- }
-
-#define MY_CXT_KEY "Math::MPC::_guts" XS_VERSION
-
-typedef struct {
- mp_prec_t _perl_default_prec_re;
- mp_prec_t _perl_default_prec_im;
- mpc_rnd_t _perl_default_rounding_mode;
-} my_cxt_t;
-
-START_MY_CXT
-
-#define DEFAULT_PREC MY_CXT._perl_default_prec_re,MY_CXT._perl_default_prec_im
-#define DEFAULT_PREC_RE MY_CXT._perl_default_prec_re
-#define DEFAULT_PREC_IM MY_CXT._perl_default_prec_im
-#define DEFAULT_ROUNDING_MODE MY_CXT._perl_default_rounding_mode
-
-/* These (CXT) values set at boot ... MPC_RNDNN == 0 */
-/*
-mpc_rnd_t _perl_default_rounding_mode = MPC_RNDNN;
-mp_prec_t _perl_default_prec_re = 53;
-mp_prec_t _perl_default_prec_im = 53;
-*/
-
-
-
-/* This function is used by overload_mul and overload_mul_eq whenn */
-/* USE_64_BIT_INT is defined. */
-/* It is based on some code posted by Philippe Theveny. */
-
-int _mpc_mul_sj (mpc_ptr rop, mpc_ptr op, intmax_t i, mpc_rnd_t rnd) {
-
-#ifdef USE_64_BIT_INT
-
- mpfr_t x;
- int inex;
-
- mpfr_init2 (x, sizeof(intmax_t) * CHAR_BIT);
- mpfr_set_sj (x, i, GMP_RNDN);
-
- inex = mpc_mul_fr (rop, op, x, rnd);
-
- mpfr_clear (x);
- return inex;
-}
-
-#else
-
- croak("_mpc_mul_sj not implememnted on this build of perl");
-}
-
-#endif
-
-
-/* This function is used by overload_mul and overload_mul_eq whenn */
-/* USE_LONG_DOUBLE is defined. */
-/* It is based on some code posted by Philippe Theveny. */
-
-int _mpc_mul_ld (mpc_ptr rop, mpc_ptr op, long double i, mpc_rnd_t rnd) {
-
-#ifdef USE_LONG_DOUBLE
-
- mpfr_t x;
- int inex;
-
- mpfr_init2 (x, sizeof(long double) * CHAR_BIT);
- mpfr_set_ld (x, i, GMP_RNDN);
-
- inex = mpc_mul_fr (rop, op, x, rnd);
-
- mpfr_clear (x);
- return inex;
-}
-
-#else
-
- croak("_mpc_mul_ld not implememnted on this build of perl");
-}
-
-#endif
-
-
-/* This function is used by overload_mul and overload_mul_eq. */
-/* It is based on some code posted by Philippe Theveny. */
-
-int _mpc_mul_d (mpc_ptr rop, mpc_ptr op, double i, mpc_rnd_t rnd) {
- mpfr_t x;
- int inex;
-
- mpfr_init2 (x, sizeof(double) * CHAR_BIT);
- mpfr_set_d (x, i, GMP_RNDN);
-
- inex = mpc_mul_fr (rop, op, x, rnd);
-
- mpfr_clear (x);
- return inex;
-}
-
-
-/* This function is used by overload_div and overload_div_eq whenn */
-/* USE_64_BIT_INT is defined. */
-/* It is based on some code posted by Philippe Theveny. */
-
-int _mpc_div_sj (mpc_ptr rop, mpc_ptr op, intmax_t i, mpc_rnd_t rnd) {
-
-#ifdef USE_64_BIT_INT
-
- mpfr_t x;
- int inex;
-
- mpfr_init2 (x, sizeof(intmax_t) * CHAR_BIT);
- mpfr_set_sj (x, i, GMP_RNDN);
-
- inex = mpc_div_fr (rop, op, x, rnd);
-
- mpfr_clear (x);
- return inex;
-}
-
-#else
-
- croak("_mpc_div_sj not implememnted on this build of perl");
-}
-
-#endif
-
-
-/* This function is used by overload_div and overload_div_eq whenn */
-/* USE_64_BIT_INT is defined. */
-/* It is based on some code posted by Philippe Theveny. */
-
-int _mpc_sj_div (mpc_ptr rop, intmax_t i, mpc_ptr op, mpc_rnd_t rnd) {
-
-#ifdef USE_64_BIT_INT
-
- mpfr_t x;
- int inex;
-
- mpfr_init2 (x, sizeof(intmax_t) * CHAR_BIT);
- mpfr_set_sj (x, i, GMP_RNDN);
-
- inex = mpc_fr_div (rop, x, op, rnd);
-
- mpfr_clear (x);
- return inex;
-}
-
-#else
-
- croak("_mpc_sj_div not implememnted on this build of perl");
-}
-
-#endif
-
-
-/* This function is used by overload_div and overload_div_eq whenn */
-/* USE_LONG_DOUBLE is defined. */
-/* It is based on some code posted by Philippe Theveny. */
-
-int _mpc_div_ld (mpc_ptr rop, mpc_ptr op, long double i, mpc_rnd_t rnd) {
-
-#ifdef USE_LONG_DOUBLE
-
- mpfr_t x;
- int inex;
-
- mpfr_init2 (x, sizeof(long double) * CHAR_BIT);
- mpfr_set_ld (x, i, GMP_RNDN);
-
- inex = mpc_div_fr (rop, op, x, rnd);
-
- mpfr_clear (x);
- return inex;
-}
-
-#else
-
- croak("_mpc_div_ld not implememnted on this build of perl");
-}
-
-#endif
-
-
-/* This function is used by overload_div and overload_div_eq whenn */
-/* USE_LONG_DOUBLE is defined. */
-/* It is based on some code posted by Philippe Theveny. */
-
-int _mpc_ld_div (mpc_ptr rop, long double i, mpc_ptr op, mpc_rnd_t rnd) {
-
-#ifdef USE_LONG_DOUBLE
-
- mpfr_t x;
- int inex;
-
- mpfr_init2 (x, sizeof(long double) * CHAR_BIT);
- mpfr_set_ld (x, i, GMP_RNDN);
-
- inex = mpc_fr_div (rop, x, op, rnd);
-
- mpfr_clear (x);
- return inex;
-}
-
-#else
-
- croak("_mpc_ld_div not implememnted on this build of perl");
-}
-
-#endif
-
-/* This function is used by overload_div and overload_div_eq. */
-/* It is based on some code posted by Philippe Theveny. */
-int _mpc_div_d (mpc_ptr rop, mpc_ptr op, double i, mpc_rnd_t rnd) {
- mpfr_t x;
- int inex;
-
- mpfr_init2 (x, sizeof(double) * CHAR_BIT);
- mpfr_set_d (x, i, GMP_RNDN);
-
- inex = mpc_div_fr (rop, op, x, rnd);
-
- mpfr_clear (x);
- return inex;
-}
-
-
-/* This function is used by overload_div and overload_div_eq. */
-/* It is based on some code posted by Philippe Theveny. */
-int _mpc_d_div (mpc_ptr rop, double i, mpc_ptr op, mpc_rnd_t rnd) {
- mpfr_t x;
- int inex;
-
- mpfr_init2 (x, sizeof(double) * CHAR_BIT);
- mpfr_set_d (x, i, GMP_RNDN);
-
- inex = mpc_fr_div (rop, x, op, rnd);
-
- mpfr_clear (x);
- return inex;
-}
-
-void Rmpc_set_default_rounding_mode(SV * round) {
- dMY_CXT;
- DEFAULT_ROUNDING_MODE = (mpc_rnd_t)SvUV(round);
-}
-
-SV * Rmpc_get_default_rounding_mode(void) {
- dMY_CXT;
- return newSVuv(DEFAULT_ROUNDING_MODE);
-}
-
-void Rmpc_set_default_prec(SV * prec) {
- dMY_CXT;
- DEFAULT_PREC_RE = (mp_prec_t)SvUV(prec);
- DEFAULT_PREC_IM = (mp_prec_t)SvUV(prec);
-}
-
-void Rmpc_set_default_prec2(SV * prec_re, SV * prec_im) {
- dMY_CXT;
- DEFAULT_PREC_RE = (mp_prec_t)SvUV(prec_re);
- DEFAULT_PREC_IM = (mp_prec_t)SvUV(prec_im);
-}
-
-SV * Rmpc_get_default_prec(void) {
- dMY_CXT;
- if(DEFAULT_PREC_RE == DEFAULT_PREC_IM)
- return newSVuv(DEFAULT_PREC_RE);
- return newSVuv(0);
-}
-
-void Rmpc_get_default_prec2(void) {
- dXSARGS;
- dMY_CXT;
- EXTEND(SP, 2);
- ST(0) = sv_2mortal(newSVuv(DEFAULT_PREC_RE));
- ST(1) = sv_2mortal(newSVuv(DEFAULT_PREC_IM));
- XSRETURN(2);
-}
-
-void Rmpc_set_prec(mpc_t * p, SV * prec) {
- mpc_set_prec(*p, SvUV(prec));
-}
-
-void Rmpc_set_re_prec(mpc_t * p, SV * prec) {
- mpfr_set_prec(MPC_RE(*p), SvUV(prec));
-}
-
-void Rmpc_set_im_prec(mpc_t * p, SV * prec) {
- mpfr_set_prec(MPC_IM(*p), SvUV(prec));
-}
-
-SV * Rmpc_get_prec(mpc_t * x) {
- return newSVuv(mpc_get_prec(*x));
-}
-
-void Rmpc_get_prec2(mpc_t * x) {
- dXSARGS;
- mp_prec_t re, im;
- mpc_get_prec2(&re, &im, *x);
- /* sp = mark; *//* not needed */
- EXTEND(SP, 2);
- ST(0) = sv_2mortal(newSVuv(re));
- ST(1) = sv_2mortal(newSVuv(im));
- /* PUTBACK; *//* not needed */
- XSRETURN(2);
-}
-
-SV * Rmpc_get_im_prec(mpc_t * x) {
- return newSVuv(mpfr_get_prec(MPC_IM(*x)));
-}
-
-SV * Rmpc_get_re_prec(mpc_t * x) {
- return newSVuv(mpfr_get_prec(MPC_RE(*x)));
-}
-
-void RMPC_RE(mpfr_t * fr, mpc_t * x) {
- mp_prec_t precision = mpfr_get_prec(MPC_RE(*x));
- mpfr_set_prec(*fr, precision);
- mpfr_set(*fr, MPC_RE(*x), GMP_RNDN); /* No rounding will be done, anyway */
-}
-
-void RMPC_IM(mpfr_t * fr, mpc_t * x) {
- mp_prec_t precision = mpfr_get_prec(MPC_IM(*x));
- mpfr_set_prec(*fr, precision);
- mpfr_set(*fr, MPC_IM(*x), GMP_RNDN); /* No rounding will be done, anyway */
-}
-
-SV * RMPC_INEX_RE(SV * x) {
- return newSViv(MPC_INEX_RE(SvIV(x)));
-}
-
-SV * RMPC_INEX_IM(SV * x) {
- return newSViv(MPC_INEX_IM(SvIV(x)));
-}
-
-void DESTROY(mpc_t * p) {
- mpc_clear(*p);
- Safefree(p);
-}
-
-void Rmpc_clear(mpc_t * p) {
- mpc_clear(*p);
- Safefree(p);
-}
-
-void Rmpc_clear_mpc(mpc_t * p) {
- mpc_clear(*p);
-}
-
-void Rmpc_clear_ptr(mpc_t * p) {
- Safefree(p);
-}
-
-SV * Rmpc_init2(SV * prec) {
- mpc_t * mpc_t_obj;
- SV * obj_ref, * obj;
-
- New(1, mpc_t_obj, 1, mpc_t);
- if(mpc_t_obj == NULL) croak("Failed to allocate memory in Rmpc_init2 function");
- obj_ref = newSV(0);
- obj = newSVrv(obj_ref, "Math::MPC");
- mpc_init2 (*mpc_t_obj, SvUV(prec));
-
- sv_setiv(obj, INT2PTR(IV,mpc_t_obj));
- SvREADONLY_on(obj);
- return obj_ref;
-}
-
-SV * Rmpc_init3(SV * prec_r, SV * prec_i) {
- mpc_t * mpc_t_obj;
- SV * obj_ref, * obj;
-
- New(1, mpc_t_obj, 1, mpc_t);
- if(mpc_t_obj == NULL) croak("Failed to allocate memory in Rmpc_init3 function");
- obj_ref = newSV(0);
- obj = newSVrv(obj_ref, "Math::MPC");
- mpc_init3 (*mpc_t_obj, SvUV(prec_r), SvUV(prec_i));
-
- sv_setiv(obj, INT2PTR(IV,mpc_t_obj));
- SvREADONLY_on(obj);
- return obj_ref;
-}
-
-SV * Rmpc_init2_nobless(SV * prec) {
- mpc_t * mpc_t_obj;
- SV * obj_ref, * obj;
-
- New(1, mpc_t_obj, 1, mpc_t);
- if(mpc_t_obj == NULL) croak("Failed to allocate memory in Rmpc_init2_nobless function");
- obj_ref = newSV(0);
- obj = newSVrv(obj_ref, NULL);
- mpc_init2 (*mpc_t_obj, SvUV(prec));
-
- sv_setiv(obj, INT2PTR(IV,mpc_t_obj));
- SvREADONLY_on(obj);
- return obj_ref;
-}
-
-SV * Rmpc_init3_nobless(SV * prec_r, SV * prec_i) {
- mpc_t * mpc_t_obj;
- SV * obj_ref, * obj;
-
- New(1, mpc_t_obj, 1, mpc_t);
- if(mpc_t_obj == NULL) croak("Failed to allocate memory in Rmpc_init3_nobless function");
- obj_ref = newSV(0);
- obj = newSVrv(obj_ref, NULL);
- mpc_init3 (*mpc_t_obj, SvUV(prec_r), SvUV(prec_i));
-
- sv_setiv(obj, INT2PTR(IV,mpc_t_obj));
- SvREADONLY_on(obj);
- return obj_ref;
-}
-
-SV * Rmpc_set(mpc_t * p, mpc_t * q, SV * round) {
- return newSViv(mpc_set(*p, *q, (mpc_rnd_t)SvUV(round)));
-}
-
-SV * Rmpc_set_ui(mpc_t * p, SV * q, SV * round) {
- return newSViv(mpc_set_ui(*p, SvUV(q), (mpc_rnd_t)SvUV(round)));
-}
-
-SV * Rmpc_set_si(mpc_t * p, SV * q, SV * round) {
- return newSViv(mpc_set_si(*p, SvIV(q), (mpc_rnd_t)SvUV(round)));
-}
-
-SV * Rmpc_set_ld(mpc_t * p, SV * q, SV * round) {
-#ifdef USE_LONG_DOUBLE
- return newSViv(mpc_set_ld(*p, SvNV(q), (mpc_rnd_t)SvUV(round)));
-#else
- croak("Rmpc_set_ld not implemented for this build of perl");
-#endif
-}
-
-SV * Rmpc_set_uj(mpc_t * p, SV * q, SV * round) {
-#ifdef USE_64_BIT_INT
- return newSViv(mpc_set_uj(*p, SvUV(q), (mpc_rnd_t)SvUV(round)));
-#else
- croak("Rmpc_set_uj not implemented for this build of perl");
-#endif
-}
-
-SV * Rmpc_set_sj(mpc_t * p, SV * q, SV * round) {
-#ifdef USE_64_BIT_INT
- return newSViv(mpc_set_sj(*p, SvIV(q), (mpc_rnd_t)SvUV(round)));
-#else
- croak("Rmpc_set_sj not implemented for this build of perl");
-#endif
-}
-
-SV * Rmpc_set_z(mpc_t * p, mpz_t * q, SV * round) {
- return newSViv(mpc_set_z(*p, *q, (mpc_rnd_t)SvUV(round)));
-}
-
-SV * Rmpc_set_f(mpc_t * p, mpf_t * q, SV * round) {
- return newSViv(mpc_set_f(*p, *q, (mpc_rnd_t)SvUV(round)));
-}
-
-SV * Rmpc_set_q(mpc_t * p, mpq_t * q, SV * round) {
- return newSViv(mpc_set_q(*p, *q, (mpc_rnd_t)SvUV(round)));
-}
-
-SV * Rmpc_set_d(mpc_t * p, SV * q, SV * round) {
- return newSViv(mpc_set_d(*p, SvNV(q), (mpc_rnd_t)SvUV(round)));
-}
-
-SV * Rmpc_set_fr(mpc_t * p, mpfr_t * q, SV * round) {
- return newSViv(mpc_set_fr(*p, *q, (mpc_rnd_t)SvUV(round)));
-}
-
-SV * Rmpc_set_ui_ui(mpc_t * p, SV * q_r, SV * q_i, SV * round) {
- return newSViv(mpc_set_ui_ui(*p, SvUV(q_r), SvUV(q_i), (mpc_rnd_t)SvUV(round)));
-}
-
-SV * Rmpc_set_si_si(mpc_t * p, SV * q_r, SV * q_i, SV * round) {
- return newSViv(mpc_set_si_si(*p, SvIV(q_r), SvIV(q_i), (mpc_rnd_t)SvUV(round)));
-}
-
-SV * Rmpc_set_d_d(mpc_t * p, SV * q_r, SV * q_i, SV * round) {
- return newSViv(mpc_set_d_d(*p, SvNV(q_r), SvNV(q_i), (mpc_rnd_t)SvUV(round)));
-}
-
-SV * Rmpc_set_ld_ld(mpc_t * mpc, SV * ld1, SV * ld2, SV * round) {
-#ifdef USE_LONG_DOUBLE
- return newSViv(mpc_set_ld_ld(*mpc, SvNV(ld1), SvNV(ld2), (mpc_rnd_t) SvUV(round)));
-#else
- croak("Rmpc_set_ld_ld not implemented for this build of perl");
-#endif
-}
-
-SV * Rmpc_set_z_z(mpc_t * p, mpz_t * q_r, mpz_t * q_i, SV * round) {
- return newSViv(mpc_set_z_z(*p, *q_r, *q_i, (mpc_rnd_t)SvUV(round)));
-}
-
-SV * Rmpc_set_q_q(mpc_t * p, mpq_t * q_r, mpq_t * q_i, SV * round) {
- return newSViv(mpc_set_q_q(*p, *q_r, *q_i, (mpc_rnd_t)SvUV(round)));
-}
-
-SV * Rmpc_set_f_f(mpc_t * p, mpf_t * q_r, mpf_t * q_i, SV * round) {
- return newSViv(mpc_set_f_f(*p, *q_r, *q_i, (mpc_rnd_t)SvUV(round)));
-}
-
-SV * Rmpc_set_fr_fr(mpc_t * p, mpfr_t * q_r, mpfr_t * q_i, SV * round) {
- return newSViv(mpc_set_fr_fr(*p, *q_r, *q_i, (mpc_rnd_t)SvUV(round)));
-}
-
-int Rmpc_set_d_ui(mpc_t * mpc, SV * d, SV * ui, SV * round) {
- MPC_SET_X_Y(d, ui, *mpc, (double)SvNV(d), (unsigned long)SvUV(ui), (mpc_rnd_t) SvUV(round));
-}
-
-int Rmpc_set_d_si(mpc_t * mpc, SV * d, SV * si, SV * round) {
- MPC_SET_X_Y(d, si, *mpc, (double)SvNV(d), (signed long int)SvIV(si), (mpc_rnd_t) SvUV(round));
-}
-
-int Rmpc_set_d_fr(mpc_t * mpc, SV * d, mpfr_t * mpfr, SV * round) {
- MPC_SET_X_Y(d, fr, *mpc, (double)SvNV(d), *mpfr, (mpc_rnd_t) SvUV(round));
-}
-
-int Rmpc_set_ui_d(mpc_t * mpc, SV * ui, SV * d, SV * round) {
- MPC_SET_X_Y(ui, d, *mpc, (unsigned long)SvUV(ui), (double)SvNV(d), (mpc_rnd_t) SvUV(round));
-}
-
-int Rmpc_set_ui_si(mpc_t * mpc, SV * ui, SV * si, SV * round) {
- MPC_SET_X_Y(ui, si, *mpc, (unsigned long)SvUV(ui), (signed long int)SvIV(si), (mpc_rnd_t) SvUV(round));
-}
-
-int Rmpc_set_ui_fr(mpc_t * mpc, SV * ui, mpfr_t * mpfr, SV * round) {
- MPC_SET_X_Y(ui, fr, *mpc, (unsigned long)SvUV(ui), *mpfr, (mpc_rnd_t) SvUV(round));
-}
-
-int Rmpc_set_si_d(mpc_t * mpc, SV * si, SV * d, SV * round) {
- MPC_SET_X_Y(si, d, *mpc, (signed long int)SvIV(si), (double)SvNV(d), (mpc_rnd_t) SvUV(round));
-}
-
-int Rmpc_set_si_ui(mpc_t * mpc, SV * si, SV * ui, SV * round) {
- MPC_SET_X_Y(si, ui, *mpc, (signed long int)SvIV(si), (unsigned long)SvUV(ui), (mpc_rnd_t) SvUV(round));
-}
-
-int Rmpc_set_si_fr(mpc_t * mpc, SV * si, mpfr_t * mpfr, SV * round) {
- MPC_SET_X_Y(si, fr, *mpc, (signed long int)SvIV(si), *mpfr, (mpc_rnd_t) SvUV(round));
-}
-
-int Rmpc_set_fr_d(mpc_t * mpc, mpfr_t * mpfr, SV * d, SV * round) {
- MPC_SET_X_Y(fr, d, *mpc, *mpfr, (double)SvNV(d), (mpc_rnd_t) SvUV(round));
-}
-
-int Rmpc_set_fr_ui(mpc_t * mpc, mpfr_t * mpfr, SV * ui, SV * round) {
- MPC_SET_X_Y(fr, ui, *mpc, *mpfr, (unsigned long)SvUV(ui), (mpc_rnd_t) SvUV(round));
-}
-
-int Rmpc_set_fr_si(mpc_t * mpc, mpfr_t * mpfr, SV * si, SV * round) {
- MPC_SET_X_Y(fr, si, *mpc, *mpfr , (signed long int)SvIV(si), (mpc_rnd_t) SvUV(round));
-}
-
-int Rmpc_set_ld_ui(mpc_t * mpc, SV * d, SV * ui, SV * round) {
-#ifdef USE_LONG_DOUBLE
- MPC_SET_X_Y(ld, ui, *mpc, SvNV(d), (unsigned long)SvUV(ui), (mpc_rnd_t) SvUV(round));
-#else
- croak("Rmpc_set_ld_ui not implemented for this build of perl");
-#endif
-}
-
-int Rmpc_set_ld_si(mpc_t * mpc, SV * d, SV * si, SV * round) {
-#ifdef USE_LONG_DOUBLE
- MPC_SET_X_Y(ld, si, *mpc, SvNV(d), (signed long int)SvIV(si), (mpc_rnd_t) SvUV(round));
-#else
- croak("Rmpc_set_ld_si not implemented for this build of perl");
-#endif
-}
-
-int Rmpc_set_ld_fr(mpc_t * mpc, SV * d, mpfr_t * mpfr, SV * round) {
-#ifdef USE_LONG_DOUBLE
- MPC_SET_X_Y(ld, fr, *mpc, SvNV(d), *mpfr, (mpc_rnd_t) SvUV(round));
-#else
- croak("Rmpc_set_ld_fr not implemented for this build of perl");
-#endif
-}
-
-int Rmpc_set_ui_ld(mpc_t * mpc, SV * ui, SV * d, SV * round) {
-#ifdef USE_LONG_DOUBLE
- MPC_SET_X_Y(ui, ld, *mpc, (unsigned long)SvUV(ui), SvNV(d), (mpc_rnd_t) SvUV(round));
-#else
- croak("Rmpc_set_ui_ld not implemented for this build of perl");
-#endif
-}
-
-int Rmpc_set_si_ld(mpc_t * mpc, SV * si, SV * d, SV * round) {
-#ifdef USE_LONG_DOUBLE
- MPC_SET_X_Y(si, ld, *mpc, (signed long int)SvIV(si), SvNV(d), (mpc_rnd_t) SvUV(round));
-#else
- croak("Rmpc_set_si_ld not implemented for this build of perl");
-#endif
-}
-
-int Rmpc_set_fr_ld(mpc_t * mpc, mpfr_t * mpfr, SV * d, SV * round) {
-#ifdef USE_LONG_DOUBLE
- MPC_SET_X_Y(fr, ld, *mpc, *mpfr, SvNV(d), (mpc_rnd_t) SvUV(round));
-#else
- croak("Rmpc_set_fr_ld not implemented for this build of perl");
-#endif
-}
-
-int Rmpc_set_d_uj(mpc_t * mpc, SV * d, SV * ui, SV * round) {
-#ifdef USE_64_BIT_INT
- MPC_SET_X_Y(d, uj, *mpc, (double)SvNV(d), SvUV(ui), (mpc_rnd_t) SvUV(round));
-#else
- croak("Rmpc_set_d_uj not implemented for this build of perl");
-#endif
-}
-
-int Rmpc_set_d_sj(mpc_t * mpc, SV * d, SV * si, SV * round) {
-#ifdef USE_64_BIT_INT
- MPC_SET_X_Y(d, sj, *mpc, (double)SvNV(d), SvIV(si), (mpc_rnd_t) SvUV(round));
-#else
- croak("Rmpc_set_d_sj not implemented for this build of perl");
-#endif
-}
-
-int Rmpc_set_sj_d(mpc_t * mpc, SV * si, SV * d, SV * round) {
-#ifdef USE_64_BIT_INT
- MPC_SET_X_Y(sj, d, *mpc, SvIV(si), (double)SvNV(d), (mpc_rnd_t) SvUV(round));
-#else
- croak("Rmpc_set_sj_d not implemented for this build of perl");
-#endif
-}
-
-int Rmpc_set_uj_d(mpc_t * mpc, SV * ui, SV * d, SV * round) {
-#ifdef USE_64_BIT_INT
- MPC_SET_X_Y(uj, d, *mpc, SvUV(ui), (double)SvNV(d), (mpc_rnd_t) SvUV(round));
-#else
- croak("Rmpc_set_uj_d not implemented for this build of perl");
-#endif
-}
-
-int Rmpc_set_uj_fr(mpc_t * mpc, SV * ui, mpfr_t * mpfr, SV * round) {
-#ifdef USE_64_BIT_INT
- MPC_SET_X_Y(uj, fr, *mpc, SvUV(ui), *mpfr, (mpc_rnd_t) SvUV(round));
-#else
- croak("Rmpc_set_uj_fr not implemented for this build of perl");
-#endif
-}
-
-int Rmpc_set_sj_fr(mpc_t * mpc, SV * si, mpfr_t * mpfr, SV * round) {
-#ifdef USE_64_BIT_INT
- MPC_SET_X_Y(sj, fr, *mpc, SvIV(si), *mpfr, (mpc_rnd_t) SvUV(round));
-#else
- croak("Rmpc_set_sj_fr not implemented for this build of perl");
-#endif
-}
-
-int Rmpc_set_fr_uj(mpc_t * mpc, mpfr_t * mpfr, SV * ui, SV * round) {
-#ifdef USE_64_BIT_INT
- MPC_SET_X_Y(fr, uj, *mpc, *mpfr, SvUV(ui), (mpc_rnd_t) SvUV(round));
-#else
- croak("Rmpc_set_fr_uj not implemented for this build of perl");
-#endif
-}
-
-int Rmpc_set_fr_sj(mpc_t * mpc, mpfr_t * mpfr, SV * si, SV * round) {
-#ifdef USE_64_BIT_INT
- MPC_SET_X_Y(fr, sj, *mpc, *mpfr , SvIV(si), (mpc_rnd_t) SvUV(round));
-#else
- croak("Rmpc_set_fr_sj not implemented for this build of perl");
-#endif
-}
-
-int Rmpc_set_uj_sj(mpc_t * mpc, SV * ui, SV * si, SV * round) {
-#ifdef USE_64_BIT_INT
- MPC_SET_X_Y(uj, sj, *mpc, SvUV(ui), SvIV(si), (mpc_rnd_t) SvUV(round));
-#else
- croak("Rmpc_set_uj_si, Rmpc_set_ui_sj and Rmpc_set_uj_sj not implemented for this build of perl");
-#endif
-}
-
-int Rmpc_set_sj_uj(mpc_t * mpc, SV * si, SV * ui, SV * round) {
-#ifdef USE_64_BIT_INT
- MPC_SET_X_Y(sj, uj, *mpc, SvIV(si), SvUV(ui), (mpc_rnd_t) SvUV(round));
-#else
- croak("Rmpc_set_sj_ui, Rmpc_set_si_uj and Rmpc_set_sj_uj not implemented for this build of perl");
-#endif
-}
-
-
-int Rmpc_set_ld_uj(mpc_t * mpc, SV * d, SV * ui, SV * round) {
-#ifdef USE_64_BIT_INT
-#ifdef USE_LONG_DOUBLE
- MPC_SET_X_Y(ld, uj, *mpc, SvNV(d), SvUV(ui), (mpc_rnd_t) SvUV(round));
-#else
- croak("Rmpc_set_ld_uj not implemented for this build of perl");
-#endif
-#else
- croak("Rmpc_set_ld_uj not implemented for this build of perl");
-#endif
-}
-
-int Rmpc_set_ld_sj(mpc_t * mpc, SV * d, SV * si, SV * round) {
-#ifdef USE_64_BIT_INT
-#ifdef USE_LONG_DOUBLE
- MPC_SET_X_Y(ld, sj, *mpc, SvNV(d), SvIV(si), (mpc_rnd_t) SvUV(round));
-#else
- croak("Rmpc_set_ld_sj not implemented for this build of perl");
-#endif
-#else
- croak("Rmpc_set_ld_sj not implemented for this build of perl");
-#endif
-}
-
-int Rmpc_set_uj_ld(mpc_t * mpc, SV * ui, SV * d, SV * round) {
-#ifdef USE_64_BIT_INT
-#ifdef USE_LONG_DOUBLE
- MPC_SET_X_Y(uj, ld, *mpc, SvUV(ui), SvNV(d), (mpc_rnd_t) SvUV(round));
-#else
- croak("Rmpc_set_uj_ld not implemented for this build of perl");
-#endif
-#else
- croak("Rmpc_set_uj_ld not implemented for this build of perl");
-#endif
-}
-
-int Rmpc_set_sj_ld(mpc_t * mpc, SV * si, SV * d, SV * round) {
-#ifdef USE_64_BIT_INT
-#ifdef USE_LONG_DOUBLE
- MPC_SET_X_Y(sj, ld, *mpc, SvIV(si), SvNV(d), (mpc_rnd_t) SvUV(round));
-#else
- croak("Rmpc_set_sj_ld not implemented for this build of perl");
-#endif
-#else
- croak("Rmpc_set_sj_ld not implemented for this build of perl");
-#endif
-}
-
-int Rmpc_set_f_ui(mpc_t * mpc, mpf_t * mpf, SV * ui, SV * round) {
- MPC_SET_X_Y(f, ui, *mpc, *mpf, (unsigned long int)SvUV(ui), (mpc_rnd_t) SvUV(round));
-}
-
-int Rmpc_set_q_ui(mpc_t * mpc, mpq_t * mpq, SV * ui, SV * round) {
- MPC_SET_X_Y(q, ui, *mpc, *mpq, (unsigned long int)SvUV(ui), (mpc_rnd_t) SvUV(round));
-}
-
-int Rmpc_set_z_ui(mpc_t * mpc, mpz_t * mpz, SV * ui, SV * round) {
- MPC_SET_X_Y(z, ui, *mpc, *mpz, (unsigned long int)SvUV(ui), (mpc_rnd_t) SvUV(round));
-}
-
-int Rmpc_set_f_si(mpc_t * mpc, mpf_t * mpf, SV * si, SV * round) {
- MPC_SET_X_Y(f, si, *mpc, *mpf, (signed long int)SvIV(si), (mpc_rnd_t) SvUV(round));
-}
-
-int Rmpc_set_q_si(mpc_t * mpc, mpq_t * mpq, SV * si, SV * round) {
- MPC_SET_X_Y(q, si, *mpc, *mpq, (signed long int)SvIV(si), (mpc_rnd_t) SvUV(round));
-}
-
-int Rmpc_set_z_si(mpc_t * mpc, mpz_t * mpz, SV * si, SV * round) {
- MPC_SET_X_Y(z, si, *mpc, *mpz, (signed long int)SvIV(si), (mpc_rnd_t) SvUV(round));
-}
-
-int Rmpc_set_f_d(mpc_t * mpc, mpf_t * mpf, SV * d, SV * round) {
- MPC_SET_X_Y(f, d, *mpc, *mpf, (double)SvNV(d), (mpc_rnd_t) SvUV(round));
-}
-
-int Rmpc_set_q_d(mpc_t * mpc, mpq_t * mpq, SV * d, SV * round) {
- MPC_SET_X_Y(q, d, *mpc, *mpq, (double)SvNV(d), (mpc_rnd_t) SvUV(round));
-}
-
-int Rmpc_set_z_d(mpc_t * mpc, mpz_t * mpz, SV * d, SV * round) {
- MPC_SET_X_Y(z, d, *mpc, *mpz, (double)SvNV(d), (mpc_rnd_t) SvUV(round));
-}
-
-int Rmpc_set_f_uj(mpc_t * mpc, mpf_t * mpf, SV * uj, SV * round) {
-#ifdef USE_64_BIT_INT
- MPC_SET_X_Y(f, uj, *mpc, *mpf, (unsigned long long)SvUV(uj), (mpc_rnd_t) SvUV(round));
-#else
- croak("Rmpc_set_f_uj not implemented for this build of perl");
-#endif
-}
-
-int Rmpc_set_q_uj(mpc_t * mpc, mpq_t * mpq, SV * uj, SV * round) {
-#ifdef USE_64_BIT_INT
- MPC_SET_X_Y(q, uj, *mpc, *mpq, (unsigned long long)SvUV(uj), (mpc_rnd_t) SvUV(round));
-#else
- croak("Rmpc_set_q_uj not implemented for this build of perl");
-#endif
-}
-
-int Rmpc_set_z_uj(mpc_t * mpc, mpz_t * mpz, SV * uj, SV * round) {
-#ifdef USE_64_BIT_INT
- MPC_SET_X_Y(z, uj, *mpc, *mpz, (unsigned long long)SvUV(uj), (mpc_rnd_t) SvUV(round));
-#else
- croak("Rmpc_set_z_uj not implemented for this build of perl");
-#endif
-}
-
-int Rmpc_set_f_sj(mpc_t * mpc, mpf_t * mpf, SV * sj, SV * round) {
-#ifdef USE_64_BIT_INT
- MPC_SET_X_Y(f, sj, *mpc, *mpf, (signed long long)SvIV(sj), (mpc_rnd_t) SvUV(round));
-#else
- croak("Rmpc_set_f_sj not implemented for this build of perl");
-#endif
-}
-
-int Rmpc_set_q_sj(mpc_t * mpc, mpq_t * mpq, SV * sj, SV * round) {
-#ifdef USE_64_BIT_INT
- MPC_SET_X_Y(q, sj, *mpc, *mpq, (signed long long)SvIV(sj), (mpc_rnd_t) SvUV(round));
-#else
- croak("Rmpc_set_q_sj not implemented for this build of perl");
-#endif
-}
-
-int Rmpc_set_z_sj(mpc_t * mpc, mpz_t * mpz, SV * sj, SV * round) {
-#ifdef USE_64_BIT_INT
- MPC_SET_X_Y(z, sj, *mpc, *mpz, (signed long long)SvIV(sj), (mpc_rnd_t) SvUV(round));
-#else
- croak("Rmpc_set_z_sj not implemented for this build of perl");
-#endif
-}
-
-int Rmpc_set_f_ld(mpc_t * mpc, mpf_t * mpf, SV * ld, SV * round) {
-#ifdef USE_LONG_DOUBLE
- MPC_SET_X_Y(f, ld, *mpc, *mpf, (long double)SvNV(ld), (mpc_rnd_t) SvUV(round));
-#else
- croak("Rmpc_set_f_ld not implemented for this build of perl");
-#endif
-}
-
-int Rmpc_set_q_ld(mpc_t * mpc, mpq_t * mpq, SV * ld, SV * round) {
-#ifdef USE_LONG_DOUBLE
- MPC_SET_X_Y(q, ld, *mpc, *mpq, (long double)SvNV(ld), (mpc_rnd_t) SvUV(round));
-#else
- croak("Rmpc_set_q_ld not implemented for this build of perl");
-#endif
-}
-
-int Rmpc_set_z_ld(mpc_t * mpc, mpz_t * mpz, SV * ld, SV * round) {
-#ifdef USE_LONG_DOUBLE
- MPC_SET_X_Y(z, ld, *mpc, *mpz, (long double)SvNV(ld), (mpc_rnd_t) SvUV(round));
-#else
- croak("Rmpc_set_z_ld not implemented for this build of perl");
-#endif
-}
-
-/*
-##############################
-##############################
-*/
-
-int Rmpc_set_ui_f(mpc_t * mpc, SV * ui, mpf_t * mpf, SV * round) {
- MPC_SET_X_Y(ui, f, *mpc, (unsigned long int)SvUV(ui), *mpf, (mpc_rnd_t) SvUV(round));
-}
-
-int Rmpc_set_ui_q(mpc_t * mpc, SV * ui, mpq_t * mpq, SV * round) {
- MPC_SET_X_Y(ui, q, *mpc, (unsigned long int)SvUV(ui), *mpq, (mpc_rnd_t) SvUV(round));
-}
-
-int Rmpc_set_ui_z(mpc_t * mpc, SV * ui, mpz_t * mpz, SV * round) {
- MPC_SET_X_Y(ui, z, *mpc, (unsigned long int)SvUV(ui), *mpz, (mpc_rnd_t) SvUV(round));
-}
-
-int Rmpc_set_si_f(mpc_t * mpc, SV * si, mpf_t * mpf, SV * round) {
- MPC_SET_X_Y(si, f, *mpc, (signed long int)SvIV(si), *mpf, (mpc_rnd_t) SvUV(round));
-}
-
-int Rmpc_set_si_q(mpc_t * mpc, SV * si, mpq_t * mpq, SV * round) {
- MPC_SET_X_Y(si, q, *mpc, (signed long int)SvIV(si), *mpq, (mpc_rnd_t) SvUV(round));
-}
-
-int Rmpc_set_si_z(mpc_t * mpc, SV * si, mpz_t * mpz, SV * round) {
- MPC_SET_X_Y(si, z, *mpc, (signed long int)SvIV(si), *mpz, (mpc_rnd_t) SvUV(round));
-}
-
-int Rmpc_set_d_f(mpc_t * mpc, SV * d, mpf_t * mpf, SV * round) {
- MPC_SET_X_Y(d, f, *mpc, (double)SvNV(d), *mpf, (mpc_rnd_t) SvUV(round));
-}
-
-int Rmpc_set_d_q(mpc_t * mpc, SV * d, mpq_t * mpq, SV * round) {
- MPC_SET_X_Y(d, q, *mpc, (double)SvNV(d), *mpq, (mpc_rnd_t) SvUV(round));
-}
-
-int Rmpc_set_d_z(mpc_t * mpc, SV * d, mpz_t * mpz, SV * round) {
- MPC_SET_X_Y(d, z, *mpc, (double)SvNV(d), *mpz, (mpc_rnd_t) SvUV(round));
-}
-
-int Rmpc_set_uj_f(mpc_t * mpc, SV * uj, mpf_t * mpf, SV * round) {
-#ifdef USE_64_BIT_INT
- MPC_SET_X_Y(uj, f, *mpc, (unsigned long long)SvUV(uj), *mpf, (mpc_rnd_t) SvUV(round));
-#else
- croak("Rmpc_set_uj_f not implemented for this build of perl");
-#endif
-}
-
-int Rmpc_set_uj_q(mpc_t * mpc, SV * uj, mpq_t * mpq, SV * round) {
-#ifdef USE_64_BIT_INT
- MPC_SET_X_Y(uj, q, *mpc, (unsigned long long)SvUV(uj), *mpq, (mpc_rnd_t) SvUV(round));
-#else
- croak("Rmpc_set_uj_q not implemented for this build of perl");
-#endif
-}
-
-int Rmpc_set_uj_z(mpc_t * mpc, SV * uj, mpz_t * mpz, SV * round) {
-#ifdef USE_64_BIT_INT
- MPC_SET_X_Y(uj, z, *mpc, (unsigned long long)SvUV(uj), *mpz, (mpc_rnd_t) SvUV(round));
-#else
- croak("Rmpc_set_uj_z not implemented for this build of perl");
-#endif
-}
-
-int Rmpc_set_sj_f(mpc_t * mpc, SV * sj, mpf_t * mpf, SV * round) {
-#ifdef USE_64_BIT_INT
- MPC_SET_X_Y(sj, f, *mpc, (signed long long)SvIV(sj), *mpf, (mpc_rnd_t) SvUV(round));
-#else
- croak("Rmpc_set_sj_f not implemented for this build of perl");
-#endif
-}
-
-int Rmpc_set_sj_q(mpc_t * mpc, SV * sj, mpq_t * mpq, SV * round) {
-#ifdef USE_64_BIT_INT
- MPC_SET_X_Y(sj, q, *mpc, (signed long long)SvIV(sj), *mpq, (mpc_rnd_t) SvUV(round));
-#else
- croak("Rmpc_set_sj_q not implemented for this build of perl");
-#endif
-}
-
-int Rmpc_set_sj_z(mpc_t * mpc, SV * sj, mpz_t * mpz, SV * round) {
-#ifdef USE_64_BIT_INT
- MPC_SET_X_Y(sj, z, *mpc, (signed long long)SvIV(sj), *mpz, (mpc_rnd_t) SvUV(round));
-#else
- croak("Rmpc_set_sj_z not implemented for this build of perl");
-#endif
-}
-
-int Rmpc_set_ld_f(mpc_t * mpc, SV * ld, mpf_t * mpf, SV * round) {
-#ifdef USE_LONG_DOUBLE
- MPC_SET_X_Y(ld, f, *mpc, (long double)SvNV(ld), *mpf, (mpc_rnd_t) SvUV(round));
-#else
- croak("Rmpc_set_ld_f not implemented for this build of perl");
-#endif
-}
-
-int Rmpc_set_ld_q(mpc_t * mpc, SV * ld, mpq_t * mpq, SV * round) {
-#ifdef USE_LONG_DOUBLE
- MPC_SET_X_Y(ld, q, *mpc, (long double)SvNV(ld), *mpq, (mpc_rnd_t) SvUV(round));
-#else
- croak("Rmpc_set_ld_q not implemented for this build of perl");
-#endif
-}
-
-int Rmpc_set_ld_z(mpc_t * mpc, SV * ld, mpz_t * mpz, SV * round) {
-#ifdef USE_LONG_DOUBLE
- MPC_SET_X_Y(ld, z, *mpc, (long double)SvNV(ld), *mpz, (mpc_rnd_t) SvUV(round));
-#else
- croak("Rmpc_set_ld_z not implemented for this build of perl");
-#endif
-}
-
-/*
-##############################
-##############################
-*/
-
-int Rmpc_set_f_q(mpc_t * mpc, mpf_t * mpf, mpq_t * mpq, SV * round) {
- MPC_SET_X_Y(f, q, *mpc, *mpf, *mpq, (mpc_rnd_t) SvUV(round));
-}
-
-int Rmpc_set_q_f(mpc_t * mpc, mpq_t * mpq, mpf_t * mpf, SV * round) {
- MPC_SET_X_Y(q, f, *mpc, *mpq, *mpf, (mpc_rnd_t) SvUV(round));
-}
-
-int Rmpc_set_f_z(mpc_t * mpc, mpf_t * mpf, mpz_t * mpz, SV * round) {
- MPC_SET_X_Y(f, z, *mpc, *mpf, *mpz, (mpc_rnd_t) SvUV(round));
-}
-
-int Rmpc_set_z_f(mpc_t * mpc, mpz_t * mpz, mpf_t * mpf, SV * round) {
- MPC_SET_X_Y(z, f, *mpc, *mpz, *mpf, (mpc_rnd_t) SvUV(round));
-}
-
-int Rmpc_set_q_z(mpc_t * mpc, mpq_t * mpq, mpz_t * mpz, SV * round) {
- MPC_SET_X_Y(q, z, *mpc, *mpq, *mpz, (mpc_rnd_t) SvUV(round));
-}
-
-int Rmpc_set_z_q(mpc_t * mpc, mpz_t * mpz, mpq_t * mpq, SV * round) {
- MPC_SET_X_Y(z, q, *mpc, *mpz, *mpq, (mpc_rnd_t) SvUV(round));
-}
-
-int Rmpc_set_f_fr(mpc_t * mpc, mpf_t * mpf, mpfr_t * mpfr, SV * round) {
- MPC_SET_X_Y(f, fr, *mpc, *mpf, *mpfr, (mpc_rnd_t) SvUV(round));
-}
-
-int Rmpc_set_fr_f(mpc_t * mpc, mpfr_t * mpfr, mpf_t * mpf, SV * round) {
- MPC_SET_X_Y(fr, f, *mpc, *mpfr, *mpf, (mpc_rnd_t) SvUV(round));
-}
-
-int Rmpc_set_q_fr(mpc_t * mpc, mpq_t * mpq, mpfr_t * mpfr, SV * round) {
- MPC_SET_X_Y(q, fr, *mpc, *mpq, *mpfr, (mpc_rnd_t) SvUV(round));
-}
-
-int Rmpc_set_fr_q(mpc_t * mpc, mpfr_t * mpfr, mpq_t * mpq, SV * round) {
- MPC_SET_X_Y(fr, q, *mpc, *mpfr, *mpq, (mpc_rnd_t) SvUV(round));
-}
-
-int Rmpc_set_z_fr(mpc_t * mpc, mpz_t * mpz, mpfr_t * mpfr, SV * round) {
- MPC_SET_X_Y(z, fr, *mpc, *mpz, *mpfr, (mpc_rnd_t) SvUV(round));
-}
-
-int Rmpc_set_fr_z(mpc_t * mpc, mpfr_t * mpfr, mpz_t * mpz, SV * round) {
- MPC_SET_X_Y(fr, z, *mpc, *mpfr, *mpz, (mpc_rnd_t) SvUV(round));
-}
-
-
-/*
-##############################
-##############################
-*/
-
-SV * Rmpc_set_uj_uj(mpc_t * mpc, SV * uj1, SV * uj2, SV * round) {
-#ifdef USE_64_BIT_INT
- return newSViv(mpc_set_uj_uj(*mpc, (unsigned long long)SvUV(uj1),
- (unsigned long long)SvUV(uj2), (mpc_rnd_t)SvUV(round)));
-#else
- croak("Rmpc_set_ui_uj, Rmpc_set_uj_ui and Rmpc_set_uj_uj not implemented for this build of perl");
-#endif
-}
-
-SV * Rmpc_set_sj_sj(mpc_t * mpc, SV * sj1, SV * sj2, SV * round) {
-#ifdef USE_64_BIT_INT
- return newSViv(mpc_set_sj_sj(*mpc, (signed long long)SvIV(sj1),
- (signed long long)SvIV(sj2), (mpc_rnd_t)SvUV(round)));
-#else
- croak("Rmpc_set_si_sj, Rmpc_set_sj_si and Rmpc_set_sj_sj not implemented for this build of perl");
-#endif
-}
-
-SV * Rmpc_add(mpc_t * a, mpc_t * b, mpc_t * c, SV * round) {
- return newSViv(mpc_add(*a, *b, *c, (mpc_rnd_t)SvUV(round)));
-}
-
-SV * Rmpc_add_ui(mpc_t * a, mpc_t * b, SV * c, SV * round){
- return newSViv(mpc_add_ui(*a, *b, SvUV(c), (mpc_rnd_t)SvUV(round)));
-}
-
-SV * Rmpc_add_fr(mpc_t * a, mpc_t * b, mpfr_t * c, SV * round){
- return newSViv(mpc_add_fr(*a, *b, *c, (mpc_rnd_t)SvUV(round)));
-}
-
-SV * Rmpc_sub(mpc_t * a, mpc_t * b, mpc_t * c, SV * round) {
- return newSViv(mpc_sub(*a, *b, *c, (mpc_rnd_t)SvUV(round)));
-}
-
-SV * Rmpc_sub_ui(mpc_t * a, mpc_t * b, SV * c, SV * round) {
- return newSViv(mpc_sub_ui(*a, *b, SvUV(c), (mpc_rnd_t)SvUV(round)));
-}
-
-SV * Rmpc_ui_sub(mpc_t * a, SV * b, mpc_t * c, SV * round) {
- return newSViv(mpc_ui_sub(*a, SvUV(b), *c, (mpc_rnd_t)SvUV(round)));
-}
-
-SV * Rmpc_ui_ui_sub(mpc_t * a, SV * b_r, SV * b_i, mpc_t * c, SV * round) {
- return newSViv(mpc_ui_ui_sub(*a, SvUV(b_r), SvUV(b_i), *c, (mpc_rnd_t)SvUV(round)));
-}
-
-SV * Rmpc_mul(mpc_t * a, mpc_t * b, mpc_t * c, SV * round) {
- return newSViv(mpc_mul(*a, *b, *c, (mpc_rnd_t)SvUV(round)));
-}
-
-SV * Rmpc_mul_ui(mpc_t * a, mpc_t * b, SV * c, SV * round){
- return newSViv(mpc_mul_ui(*a, *b, SvUV(c), (mpc_rnd_t)SvUV(round)));
-}
-
-SV * Rmpc_mul_si(mpc_t * a, mpc_t * b, SV * c, SV * round){
- return newSViv(mpc_mul_si(*a, *b, SvIV(c), (mpc_rnd_t)SvUV(round)));
-}
-
-SV * Rmpc_mul_fr(mpc_t * a, mpc_t * b, mpfr_t * c, SV * round){
- return newSViv(mpc_mul_fr(*a, *b, *c, (mpc_rnd_t)SvUV(round)));
-}
-
-SV * Rmpc_mul_i(mpc_t * a, mpc_t * b, SV * sign, SV * round){
- return newSViv(mpc_mul_i(*a, *b, SvIV(sign), (mpc_rnd_t)SvUV(round)));
-}
-
-SV * Rmpc_sqr(mpc_t * a, mpc_t * b, SV * round) {
- return newSViv(mpc_sqr(*a, *b, (mpc_rnd_t)SvUV(round)));
-}
-
-SV * Rmpc_div(mpc_t * a, mpc_t * b, mpc_t * c, SV * round) {
- return newSViv(mpc_div(*a, *b, *c, (mpc_rnd_t)SvUV(round)));
-}
-
-SV * Rmpc_div_ui(mpc_t * a, mpc_t * b, SV * c, SV * round){
- return newSViv(mpc_div_ui(*a, *b, SvUV(c), (mpc_rnd_t)SvUV(round)));
-}
-
-SV * Rmpc_ui_div(mpc_t * a, SV * b, mpc_t * c, SV * round) {
- return newSViv(mpc_ui_div(*a, SvUV(b), *c, (mpc_rnd_t)SvUV(round)));
-}
-
-SV * Rmpc_div_fr(mpc_t * a, mpc_t * b, mpfr_t * c, SV * round){
- return newSViv(mpc_div_fr(*a, *b, *c, (mpc_rnd_t)SvUV(round)));
-}
-
-SV * Rmpc_sqrt(mpc_t * a, mpc_t * b, SV * round) {
- return newSViv(mpc_sqrt(*a, *b, (mpc_rnd_t)SvUV(round)));
-}
-
-SV * Rmpc_pow(mpc_t * a, mpc_t * b, mpc_t * pow, SV * round) {
- return newSViv(mpc_pow(*a, *b, *pow, (mpc_rnd_t)SvUV(round)));
-}
-
-SV * Rmpc_pow_d(mpc_t * a, mpc_t * b, SV * pow, SV * round) {
- return newSViv(mpc_pow_d(*a, *b, SvNV(pow), (mpc_rnd_t)SvUV(round)));
-}
-
-SV * Rmpc_pow_ld(mpc_t * a, mpc_t * b, SV * pow, SV * round) {
-#ifdef USE_LONG_DOUBLE
- return newSViv(mpc_pow_ld(*a, *b, SvNV(pow), (mpc_rnd_t)SvUV(round)));
-#else
- croak("Rmpc_pow_ld not implemented on this build of perl");
-#endif
-}
-
-SV * Rmpc_pow_si(mpc_t * a, mpc_t * b, SV * pow, SV * round) {
- return newSViv(mpc_pow_si(*a, *b, SvIV(pow), (mpc_rnd_t)SvUV(round)));
-}
-
-SV * Rmpc_pow_ui(mpc_t * a, mpc_t * b, SV * pow, SV * round) {
- return newSViv(mpc_pow_ui(*a, *b, SvUV(pow), (mpc_rnd_t)SvUV(round)));
-}
-
-SV * Rmpc_pow_z(mpc_t * a, mpc_t * b, mpz_t * pow, SV * round) {
- return newSViv(mpc_pow_z(*a, *b, *pow, (mpc_rnd_t)SvUV(round)));
-}
-
-SV * Rmpc_pow_fr(mpc_t * a, mpc_t * b, mpfr_t * pow, SV * round) {
- return newSViv(mpc_pow_fr(*a, *b, *pow, (mpc_rnd_t)SvUV(round)));
-}
-
-SV * Rmpc_neg(mpc_t * a, mpc_t * b, SV * round) {
- return newSViv(mpc_neg(*a, *b, (mpc_rnd_t)SvUV(round)));
-}
-
-SV * Rmpc_abs(mpfr_t * a, mpc_t * b, SV * round) {
- return newSViv(mpc_abs(*a, *b, (mpc_rnd_t)SvUV(round)));
-}
-
-SV * Rmpc_conj(mpc_t * a, mpc_t * b, SV * round) {
- return newSViv(mpc_conj(*a, *b, (mpc_rnd_t)SvUV(round)));
-}
-
-SV * Rmpc_norm(mpfr_t * a, mpc_t * b, SV * round) {
- return newSViv(mpc_norm(*a, *b, (mpc_rnd_t)SvUV(round)));
-}
-
-/* Beginning mpc-1.0, mpc_mul_2exp and mpc_div_2exp were
-* renamed mpc_mul_2ui and mpc_div_2ui
-*/
-
-SV * Rmpc_mul_2ui(mpc_t * a, mpc_t * b, SV * c, SV * round) {
-#if MPC_VERSION < 65536
- return newSViv(mpc_mul_2exp(*a, *b, SvUV(c), (mpc_rnd_t)SvUV(round)));
-#else
- return newSViv(mpc_mul_2ui(*a, *b, SvUV(c), (mpc_rnd_t)SvUV(round)));
-#endif
-}
-
-SV * Rmpc_div_2ui(mpc_t * a, mpc_t * b, SV * c, SV * round) {
-#if MPC_VERSION < 65536
- return newSViv(mpc_div_2exp(*a, *b, SvUV(c), (mpc_rnd_t)SvUV(round)));
-#else
- return newSViv(mpc_div_2ui(*a, *b, SvUV(c), (mpc_rnd_t)SvUV(round)));
-#endif
-}
-
-SV * Rmpc_cmp(mpc_t * a, mpc_t * b) {
- return newSViv(mpc_cmp(*a, *b));
-}
-
-SV * Rmpc_cmp_si(mpc_t * a, SV * b) {
- return newSViv(mpc_cmp_si(*a, SvIV(b)));
-}
-
-SV * Rmpc_cmp_si_si(mpc_t * a, SV * b, SV * c) {
- return newSViv(mpc_cmp_si_si(*a, SvIV(b), SvIV(c)));
-}
-
-SV * Rmpc_exp(mpc_t * a, mpc_t * b, SV * round) {
- return newSViv(mpc_exp(*a, *b, (mpc_rnd_t)SvUV(round)));
-}
-
-SV * Rmpc_log(mpc_t * rop, mpc_t * op, SV * round) {
- return newSViv(mpc_log(*rop, *op, (mpc_rnd_t)SvUV(round)));
-}
-
-SV * _Rmpc_out_str(FILE * stream, SV * base, SV * dig, mpc_t * p, SV * round) {
- size_t ret;
- if(SvIV(base) < 2 || SvIV(base) > 36) croak("2nd argument supplied to Rmpc_out_str is out of allowable range (must be between 2 and 36 inclusive)");
- ret = mpc_out_str(stream, (int)SvIV(base), (size_t)SvUV(dig), *p, (mpc_rnd_t)SvUV(round));
- fflush(stream);
- return newSVuv(ret);
-}
-
-SV * _Rmpc_out_strS(FILE * stream, SV * base, SV * dig, mpc_t * p, SV * round, SV * suff) {
- size_t ret;
- if(SvIV(base) < 2 || SvIV(base) > 36) croak("2nd argument supplied to Rmpc_out_str is out of allowable range (must be between 2 and 36 inclusive)");
- ret = mpc_out_str(stream, (int)SvIV(base), (size_t)SvUV(dig), *p, (mpc_rnd_t)SvUV(round));
- fflush(stream);
- fprintf(stream, "%s", SvPV_nolen(suff));
- fflush(stream);
- return newSVuv(ret);
-}
-
-SV * _Rmpc_out_strP(SV * pre, FILE * stream, SV * base, SV * dig, mpc_t * p, SV * round) {
- size_t ret;
- if(SvIV(base) < 2 || SvIV(base) > 36) croak("3rd argument supplied to Rmpc_out_str is out of allowable range (must be between 2 and 36 inclusive)");
- fprintf(stream, "%s", SvPV_nolen(pre));
- fflush(stream);
- ret = mpc_out_str(stream, (int)SvIV(base), (size_t)SvUV(dig), *p, (mpc_rnd_t)SvUV(round));
- fflush(stream);
- return newSVuv(ret);
-}
-
-SV * _Rmpc_out_strPS(SV * pre, FILE * stream, SV * base, SV * dig, mpc_t * p, SV * round, SV * suff) {
- size_t ret;
- if(SvIV(base) < 2 || SvIV(base) > 36) croak("3rd argument supplied to Rmpc_out_str is out of allowable range (must be between 2 and 36 inclusive)");
- fprintf(stream, "%s", SvPV_nolen(pre));
- fflush(stream);
- ret = mpc_out_str(stream, (int)SvIV(base), (size_t)SvUV(dig), *p, (mpc_rnd_t)SvUV(round));
- fflush(stream);
- fprintf(stream, "%s", SvPV_nolen(suff));
- fflush(stream);
- return newSVuv(ret);
-}
-
-
-SV * Rmpc_inp_str(mpc_t * p, FILE * stream, SV * base, SV * round) {
- if(SvIV(base) < 2 || SvIV(base) > 36) croak("3rd argument supplied to TRmpfr_inp_str is out of allowable range (must be between 2 and 36 inclusive)");
- return newSViv(mpc_inp_str(*p, stream, NULL, (int)SvIV(base), (mpc_rnd_t)SvUV(round)));
-}
-
-/* Removed in mpc-0.7
-void Rmpc_random(mpc_t * p) {
- mpc_random(*p);
-}
-*/
-
-/* Removed in mpc-0.7
-void Rmpc_random2(mpc_t * p, SV * s, SV * exp) {
- mpc_random2(*p, SvIV(s), SvUV(exp));
-}
-*/
-
-SV * Rmpc_sin(mpc_t * rop, mpc_t * op, SV * round) {
- return newSViv(mpc_sin(*rop, *op, (mpc_rnd_t)SvUV(round)));
-}
-
-SV * Rmpc_cos(mpc_t * rop, mpc_t * op, SV * round) {
- return newSViv(mpc_cos(*rop, *op, (mpc_rnd_t)SvUV(round)));
-}
-
-SV * Rmpc_tan(mpc_t * rop, mpc_t * op, SV * round) {
- return newSViv(mpc_tan(*rop, *op, (mpc_rnd_t)SvUV(round)));
-}
-
-SV * Rmpc_sinh(mpc_t * rop, mpc_t * op, SV * round) {
- return newSViv(mpc_sinh(*rop, *op, (mpc_rnd_t)SvUV(round)));
-}
-
-SV * Rmpc_cosh(mpc_t * rop, mpc_t * op, SV * round) {
- return newSViv(mpc_cosh(*rop, *op, (mpc_rnd_t)SvUV(round)));
-}
-
-SV * Rmpc_tanh(mpc_t * rop, mpc_t * op, SV * round) {
- return newSViv(mpc_tanh(*rop, *op, (mpc_rnd_t)SvUV(round)));
-}
-
-SV * Rmpc_asin(mpc_t * rop, mpc_t * op, SV * round) {
- return newSViv(mpc_asin(*rop, *op, (mpc_rnd_t)SvUV(round)));
-}
-
-SV * Rmpc_acos(mpc_t * rop, mpc_t * op, SV * round) {
- return newSViv(mpc_acos(*rop, *op, (mpc_rnd_t)SvUV(round)));
-}
-
-SV * Rmpc_atan(mpc_t * rop, mpc_t * op, SV * round) {
- return newSViv(mpc_atan(*rop, *op, (mpc_rnd_t)SvUV(round)));
-}
-
-SV * Rmpc_asinh(mpc_t * rop, mpc_t * op, SV * round) {
- return newSViv(mpc_asinh(*rop, *op, (mpc_rnd_t)SvUV(round)));
-}
-
-SV * Rmpc_acosh(mpc_t * rop, mpc_t * op, SV * round) {
- return newSViv(mpc_acosh(*rop, *op, (mpc_rnd_t)SvUV(round)));
-}
-
-SV * Rmpc_atanh(mpc_t * rop, mpc_t * op, SV * round) {
- return newSViv(mpc_atanh(*rop, *op, (mpc_rnd_t)SvUV(round)));
-}
-
-SV * overload_true(mpc_t *a, SV *second, SV * third) {
- if(
- ( mpfr_nan_p(MPC_RE(*a)) || !mpfr_cmp_ui(MPC_RE(*a), 0) ) &&
- ( mpfr_nan_p(MPC_IM(*a)) || !mpfr_cmp_ui(MPC_IM(*a), 0) )
- ) return newSVuv(0);
- return newSVuv(1);
-}
-
-/********************************/
-/********************************/
-/********************************/
-/********************************/
-/********************************/
-/********************************/
-/********************************/
-/********************************/
-
-SV * overload_mul(mpc_t * a, SV * b, SV * third) {
- dMY_CXT;
- mpc_t * mpc_t_obj;
- SV * obj_ref, * obj;
-
- New(1, mpc_t_obj, 1, mpc_t);
- if(mpc_t_obj == NULL) croak("Failed to allocate memory in overload_mul function");
- obj_ref = newSV(0);
- obj = newSVrv(obj_ref, "Math::MPC");
- mpc_init3(*mpc_t_obj, DEFAULT_PREC);
- sv_setiv(obj, INT2PTR(IV,mpc_t_obj));
- SvREADONLY_on(obj);
-
-#ifdef USE_64_BIT_INT
-
- if(SvUOK(b)) {
-#ifdef _MSC_VER
- mpc_set_str(*mpc_t_obj, SvPV_nolen(b), 10, DEFAULT_ROUNDING_MODE);
-#else
- mpc_set_uj(*mpc_t_obj, SvUV(b), DEFAULT_ROUNDING_MODE);
-#endif
- mpc_mul(*mpc_t_obj, *a, *mpc_t_obj, DEFAULT_ROUNDING_MODE);
- return obj_ref;
- }
-
- if(SvIOK(b)) {
-#ifdef _MSC_VER
- mpc_set_str(*mpc_t_obj, SvPV_nolen(b), 10, DEFAULT_ROUNDING_MODE);
- mpc_mul(*mpc_t_obj, *a, *mpc_t_obj, DEFAULT_ROUNDING_MODE);
-#else
- /* mpc_set_sj(*mpc_t_obj, SvIV(b), DEFAULT_ROUNDING_MODE); */
- _mpc_mul_sj(*mpc_t_obj, *a, SvIV(b), DEFAULT_ROUNDING_MODE);
-#endif
- /* mpc_mul(*mpc_t_obj, *a, *mpc_t_obj, DEFAULT_ROUNDING_MODE); */
- return obj_ref;
- }
-
-#else
- if(SvUOK(b)) {
- mpc_mul_ui(*mpc_t_obj, *a, SvUV(b), DEFAULT_ROUNDING_MODE);
- return obj_ref;
- }
-
- if(SvIOK(b)) {
- mpc_mul_si(*mpc_t_obj, *a, SvIV(b), DEFAULT_ROUNDING_MODE);
- return obj_ref;
- }
-#endif
-
- if(SvNOK(b)) {
-#ifdef USE_LONG_DOUBLE
- _mpc_mul_ld(*mpc_t_obj, *a, (long double)SvNV(b), DEFAULT_ROUNDING_MODE);
-#else
- _mpc_mul_d(*mpc_t_obj,*a, (double)SvNV(b), DEFAULT_ROUNDING_MODE);
-#endif
-
- return obj_ref;
- }
-
- if(SvPOK(b)) {
- if(mpc_set_str(*mpc_t_obj, SvPV_nolen(b), 0, DEFAULT_ROUNDING_MODE) == -1)
- croak("Invalid string supplied to Math::MPC::overload_mul");
- mpc_mul(*mpc_t_obj, *a, *mpc_t_obj, DEFAULT_ROUNDING_MODE);
- return obj_ref;
- }
-
- if(sv_isobject(b)) {
- const char *h = HvNAME(SvSTASH(SvRV(b)));
- if(strEQ(h, "Math::MPC")) {
- mpc_mul(*mpc_t_obj, *a, *(INT2PTR(mpc_t *, SvIV(SvRV(b)))), DEFAULT_ROUNDING_MODE);
- return obj_ref;
- }
- }
-
- croak("Invalid argument supplied to Math::MPC::overload_mul");
-}
-
-SV * overload_add(mpc_t* a, SV * b, SV * third) {
- dMY_CXT;
- mpc_t * mpc_t_obj;
- SV * obj_ref, * obj;
-
- New(1, mpc_t_obj, 1, mpc_t);
- if(mpc_t_obj == NULL) croak("Failed to allocate memory in overload_add function");
- obj_ref = newSV(0);
- obj = newSVrv(obj_ref, "Math::MPC");
- mpc_init3(*mpc_t_obj, DEFAULT_PREC);
- sv_setiv(obj, INT2PTR(IV,mpc_t_obj));
- SvREADONLY_on(obj);
-
-#ifdef USE_64_BIT_INT
-
- if(SvUOK(b)) {
-#ifdef _MSC_VER
- mpc_set_str(*mpc_t_obj, SvPV_nolen(b), 10, DEFAULT_ROUNDING_MODE);
-#else
- mpc_set_uj(*mpc_t_obj, SvUV(b), DEFAULT_ROUNDING_MODE);
-#endif
- mpc_add(*mpc_t_obj, *a, *mpc_t_obj, DEFAULT_ROUNDING_MODE);
- return obj_ref;
- }
-
- if(SvIOK(b)) {
-#ifdef _MSC_VER
- mpc_set_str(*mpc_t_obj, SvPV_nolen(b), 10, DEFAULT_ROUNDING_MODE);
-#else
- mpc_set_sj(*mpc_t_obj, SvIV(b), DEFAULT_ROUNDING_MODE);
-#endif
- mpc_add(*mpc_t_obj, *a, *mpc_t_obj, DEFAULT_ROUNDING_MODE);
- return obj_ref;
- }
-
-#else
-
- if(SvUOK(b)) {
- mpc_add_ui(*mpc_t_obj, *a, SvUV(b), DEFAULT_ROUNDING_MODE);
- return obj_ref;
- }
-
- if(SvIOK(b)) {
- if(SvIV(b) >= 0) {
- mpc_add_ui(*mpc_t_obj, *a, SvUV(b), DEFAULT_ROUNDING_MODE);
- return obj_ref;
- }
- mpc_sub_ui(*mpc_t_obj, *a, SvIV(b) * -1, DEFAULT_ROUNDING_MODE);
- return obj_ref;
- }
-
-#endif
-
- if(SvNOK(b)) {
-#ifdef USE_LONG_DOUBLE
- mpc_set_ld(*mpc_t_obj, SvNV(b), DEFAULT_ROUNDING_MODE);
- mpc_add(*mpc_t_obj, *a, *mpc_t_obj, DEFAULT_ROUNDING_MODE);
-#else
- mpc_set_d(*mpc_t_obj, SvNV(b), DEFAULT_ROUNDING_MODE);
- mpc_add(*mpc_t_obj, *mpc_t_obj, *a, DEFAULT_ROUNDING_MODE);
-#endif
-
- return obj_ref;
- }
-
- if(SvPOK(b)) {
- if(mpc_set_str(*mpc_t_obj, SvPV_nolen(b), 0, DEFAULT_ROUNDING_MODE) == -1)
- croak("Invalid string supplied to Math::MPC::overload_add");
- mpc_add(*mpc_t_obj, *a, *mpc_t_obj, DEFAULT_ROUNDING_MODE);
- return obj_ref;
- }
-
- if(sv_isobject(b)) {
- const char *h = HvNAME(SvSTASH(SvRV(b)));
- if(strEQ(h, "Math::MPC")) {
- mpc_add(*mpc_t_obj, *a, *(INT2PTR(mpc_t *, SvIV(SvRV(b)))), DEFAULT_ROUNDING_MODE);
- return obj_ref;
- }
- }
-
- croak("Invalid argument supplied to Math::MPC::overload_add");
-}
-
-SV * overload_sub(mpc_t * a, SV * b, SV * third) {
- dMY_CXT;
- mpc_t * mpc_t_obj;
- SV * obj_ref, * obj;
-
- New(1, mpc_t_obj, 1, mpc_t);
- if(mpc_t_obj == NULL) croak("Failed to allocate memory in overload_sub function");
- obj_ref = newSV(0);
- obj = newSVrv(obj_ref, "Math::MPC");
- mpc_init3(*mpc_t_obj, DEFAULT_PREC);
- sv_setiv(obj, INT2PTR(IV,mpc_t_obj));
- SvREADONLY_on(obj);
-
-#ifdef USE_64_BIT_INT
- if(SvUOK(b)) {
-#ifdef _MSC_VER
- mpc_set_str(*mpc_t_obj, SvPV_nolen(b), 10, DEFAULT_ROUNDING_MODE);
-#else
- mpc_set_uj(*mpc_t_obj, SvUV(b), DEFAULT_ROUNDING_MODE);
-#endif
- if(third == &PL_sv_yes) mpc_sub(*mpc_t_obj, *mpc_t_obj, *a, DEFAULT_ROUNDING_MODE);
- else mpc_sub(*mpc_t_obj, *a, *mpc_t_obj, DEFAULT_ROUNDING_MODE);
- return obj_ref;
- }
-
- if(SvIOK(b)) {
-#ifdef _MSC_VER
- mpc_set_str(*mpc_t_obj, SvPV_nolen(b), 10, DEFAULT_ROUNDING_MODE);
-#else
- mpc_set_sj(*mpc_t_obj, SvIV(b), DEFAULT_ROUNDING_MODE);
-#endif
- if(third == &PL_sv_yes) mpc_sub(*mpc_t_obj, *mpc_t_obj, *a, DEFAULT_ROUNDING_MODE);
- else mpc_sub(*mpc_t_obj, *a, *mpc_t_obj, DEFAULT_ROUNDING_MODE);
- return obj_ref;
- }
-#else
- if(SvUOK(b)) {
- if(third == &PL_sv_yes) mpc_ui_sub(*mpc_t_obj, SvUV(b), *a, DEFAULT_ROUNDING_MODE);
- else mpc_sub_ui(*mpc_t_obj, *a, SvUV(b), DEFAULT_ROUNDING_MODE);
- return obj_ref;
- }
-
- if(SvIOK(b)) {
- if(SvIV(b) >= 0) {
- if(third == &PL_sv_yes) mpc_ui_sub(*mpc_t_obj, SvUV(b), *a, DEFAULT_ROUNDING_MODE);
- else mpc_sub_ui(*mpc_t_obj, *a, SvUV(b), DEFAULT_ROUNDING_MODE);
- return obj_ref;
- }
- mpc_add_ui(*mpc_t_obj, *a, SvIV(b) * -1, DEFAULT_ROUNDING_MODE);
- if(third == &PL_sv_yes) mpc_neg(*mpc_t_obj, *mpc_t_obj, DEFAULT_ROUNDING_MODE);
- return obj_ref;
- }
-#endif
-
- if(SvNOK(b)) {
-#ifdef USE_LONG_DOUBLE
- mpc_set_ld(*mpc_t_obj, SvNV(b), DEFAULT_ROUNDING_MODE);
-#else
- mpc_set_d(*mpc_t_obj, SvNV(b), DEFAULT_ROUNDING_MODE);
-#endif
- if(third == &PL_sv_yes) mpc_sub(*mpc_t_obj, *mpc_t_obj, *a, DEFAULT_ROUNDING_MODE);
- else mpc_sub(*mpc_t_obj, *a, *mpc_t_obj, DEFAULT_ROUNDING_MODE);
- return obj_ref;
- }
-
- if(SvPOK(b)) {
- if(mpc_set_str(*mpc_t_obj, SvPV_nolen(b), 0, DEFAULT_ROUNDING_MODE) == -1)
- croak("Invalid string supplied to Math::MPC::overload_sub");
- if(third == &PL_sv_yes) mpc_sub(*mpc_t_obj, *mpc_t_obj, *a, DEFAULT_ROUNDING_MODE);
- else mpc_sub(*mpc_t_obj, *a, *mpc_t_obj, DEFAULT_ROUNDING_MODE);
- return obj_ref;
- }
-
- if(sv_isobject(b)) {
- const char *h = HvNAME(SvSTASH(SvRV(b)));
- if(strEQ(h, "Math::MPC")) {
- mpc_sub(*mpc_t_obj, *a, *(INT2PTR(mpc_t *, SvIV(SvRV(b)))), DEFAULT_ROUNDING_MODE);
- return obj_ref;
- }
- }
-
- croak("Invalid argument supplied to Math::MPC::overload_sub function");
-}
-
-SV * overload_div(mpc_t * a, SV * b, SV * third) {
- dMY_CXT;
- mpc_t * mpc_t_obj;
- SV * obj_ref, * obj;
-
- New(1, mpc_t_obj, 1, mpc_t);
- if(mpc_t_obj == NULL) croak("Failed to allocate memory in overload_div function");
- obj_ref = newSV(0);
- obj = newSVrv(obj_ref, "Math::MPC");
- mpc_init3(*mpc_t_obj, DEFAULT_PREC);
- sv_setiv(obj, INT2PTR(IV,mpc_t_obj));
- SvREADONLY_on(obj);
-
-#ifdef USE_64_BIT_INT
- if(SvUOK(b)) {
-#ifdef _MSC_VER
- mpc_set_str(*mpc_t_obj, SvPV_nolen(b), 10, DEFAULT_ROUNDING_MODE);
-#else
- mpc_set_uj(*mpc_t_obj, SvUV(b), DEFAULT_ROUNDING_MODE);
-#endif
- if(third == &PL_sv_yes) mpc_div(*mpc_t_obj, *mpc_t_obj, *a, DEFAULT_ROUNDING_MODE);
- else mpc_div(*mpc_t_obj, *a, *mpc_t_obj, DEFAULT_ROUNDING_MODE);
- return obj_ref;
- }
-
- if(SvIOK(b)) {
-#ifdef _MSC_VER
- mpc_set_str(*mpc_t_obj, SvPV_nolen(b), 10, DEFAULT_ROUNDING_MODE);
- if(third == &PL_sv_yes) mpc_div(*mpc_t_obj, *mpc_t_obj, *a, DEFAULT_ROUNDING_MODE);
- else mpc_div(*mpc_t_obj, *a, *mpc_t_obj, DEFAULT_ROUNDING_MODE);
-#else
- /* mpc_set_sj(*mpc_t_obj, SvIV(b), DEFAULT_ROUNDING_MODE); */
- if(third == &PL_sv_yes) _mpc_sj_div(*mpc_t_obj, SvIV(b), *a, DEFAULT_ROUNDING_MODE);
- else _mpc_div_sj(*mpc_t_obj, *a, SvIV(b), DEFAULT_ROUNDING_MODE);
-#endif
- /* if(third == &PL_sv_yes) mpc_div(*mpc_t_obj, *mpc_t_obj, *a, DEFAULT_ROUNDING_MODE);
- else mpc_div(*mpc_t_obj, *a, *mpc_t_obj, DEFAULT_ROUNDING_MODE); */
- return obj_ref;
- }
-#else
- if(SvUOK(b)) {
- if(third == &PL_sv_yes) mpc_ui_div(*mpc_t_obj, SvUV(b), *a, DEFAULT_ROUNDING_MODE);
- else mpc_div_ui(*mpc_t_obj, *a, SvUV(b), DEFAULT_ROUNDING_MODE);
- return obj_ref;
- }
-
- if(SvIOK(b)) {
- if(SvIV(b) >= 0) {
- if(third == &PL_sv_yes) mpc_ui_div(*mpc_t_obj, SvUV(b), *a, DEFAULT_ROUNDING_MODE);
- else mpc_div_ui(*mpc_t_obj, *a, SvUV(b), DEFAULT_ROUNDING_MODE);
- return obj_ref;
- }
- if(third == &PL_sv_yes) mpc_ui_div(*mpc_t_obj, SvIV(b) * -1, *a, DEFAULT_ROUNDING_MODE);
- else mpc_div_ui(*mpc_t_obj, *a, SvIV(b) * -1, DEFAULT_ROUNDING_MODE);
- mpc_neg(*mpc_t_obj, *mpc_t_obj, DEFAULT_ROUNDING_MODE);
- return obj_ref;
- }
-#endif
-
- if(SvNOK(b)) {
-#ifdef USE_LONG_DOUBLE
- /* mpc_set_ld(*mpc_t_obj, SvNV(b), DEFAULT_ROUNDING_MODE); */
- if(third == &PL_sv_yes) _mpc_ld_div(*mpc_t_obj, (long double)SvNV(b), *a, DEFAULT_ROUNDING_MODE);
- else _mpc_div_ld(*mpc_t_obj, *a, (long double)SvNV(b), DEFAULT_ROUNDING_MODE);
-#else
- /* mpc_set_d(*mpc_t_obj, SvNV(b), DEFAULT_ROUNDING_MODE); */
- if(third == &PL_sv_yes) _mpc_d_div(*mpc_t_obj, (double)SvNV(b), *a, DEFAULT_ROUNDING_MODE);
- else _mpc_div_d(*mpc_t_obj, *a, (double)SvNV(b), DEFAULT_ROUNDING_MODE);
-#endif
- /* if(third == &PL_sv_yes) mpc_div(*mpc_t_obj, *mpc_t_obj, *a, DEFAULT_ROUNDING_MODE); */
- /* else mpc_div(*mpc_t_obj, *a, *mpc_t_obj, DEFAULT_ROUNDING_MODE); */
- return obj_ref;
- }
-
- if(SvPOK(b)) {
- if(mpc_set_str(*mpc_t_obj, SvPV_nolen(b), 0, DEFAULT_ROUNDING_MODE) == -1)
- croak("Invalid string supplied to Math::MPC::overload_div");
- if(third == &PL_sv_yes) mpc_div(*mpc_t_obj, *mpc_t_obj, *a, DEFAULT_ROUNDING_MODE);
- else mpc_div(*mpc_t_obj, *a, *mpc_t_obj, DEFAULT_ROUNDING_MODE);
- return obj_ref;
- }
-
- if(sv_isobject(b)) {
- const char *h = HvNAME(SvSTASH(SvRV(b)));
- if(strEQ(h, "Math::MPC")) {
- mpc_div(*mpc_t_obj, *a, *(INT2PTR(mpc_t *, SvIV(SvRV(b)))), DEFAULT_ROUNDING_MODE);
- return obj_ref;
- }
- }
-
- croak("Invalid argument supplied to Math::MPC::overload_div function");
-
-}
-
-
-SV * overload_div_eq(SV * a, SV * b, SV * third) {
- dMY_CXT;
- mpc_t temp;
-
- SvREFCNT_inc(a);
-
-#ifdef USE_64_BIT_INT
- if(SvUOK(b)) {
- mpc_init3(temp, DEFAULT_PREC);
-#ifdef _MSC_VER
- mpc_set_str(temp, SvPV_nolen(b), 10, DEFAULT_ROUNDING_MODE);
-#else
- mpc_set_uj(temp, SvUV(b), DEFAULT_ROUNDING_MODE);
-#endif
- mpc_div(*(INT2PTR(mpc_t *, SvIV(SvRV(a)))), *(INT2PTR(mpc_t *, SvIV(SvRV(a)))), temp, DEFAULT_ROUNDING_MODE);
- mpc_clear(temp);
- return a;
- }
-
- if(SvIOK(b)) {
- /* mpc_init3(temp, DEFAULT_PREC); */
-#ifdef _MSC_VER
- mpc_init3(temp, DEFAULT_PREC);
- mpc_set_str(temp, SvPV_nolen(b), 10, DEFAULT_ROUNDING_MODE);
- mpc_div(*(INT2PTR(mpc_t *, SvIV(SvRV(a)))), *(INT2PTR(mpc_t *, SvIV(SvRV(a)))), temp, DEFAULT_ROUNDING_MODE);
- mpc_clear(temp);
-#else
- /* mpc_set_sj(temp, SvIV(b), DEFAULT_ROUNDING_MODE); */
- _mpc_div_sj(*(INT2PTR(mpc_t *, SvIV(SvRV(a)))), *(INT2PTR(mpc_t *, SvIV(SvRV(a)))), SvIV(b), DEFAULT_ROUNDING_MODE);
-#endif
- /* mpc_div(*(INT2PTR(mpc_t *, SvIV(SvRV(a)))), *(INT2PTR(mpc_t *, SvIV(SvRV(a)))), temp, DEFAULT_ROUNDING_MODE);
- mpc_clear(temp); */
- return a;
- }
-#else
- if(SvUOK(b)) {
- mpc_div_ui(*(INT2PTR(mpc_t *, SvIV(SvRV(a)))), *(INT2PTR(mpc_t *, SvIV(SvRV(a)))), SvUV(b), DEFAULT_ROUNDING_MODE);
- return a;
- }
-
- if(SvIOK(b)) {
- if(SvIV(b) >= 0) {
- mpc_div_ui(*(INT2PTR(mpc_t *, SvIV(SvRV(a)))), *(INT2PTR(mpc_t *, SvIV(SvRV(a)))), SvUV(b), DEFAULT_ROUNDING_MODE);
- return a;
- }
- mpc_div_ui(*(INT2PTR(mpc_t *, SvIV(SvRV(a)))), *(INT2PTR(mpc_t *, SvIV(SvRV(a)))), SvIV(b) * -1, DEFAULT_ROUNDING_MODE);
- mpc_neg(*(INT2PTR(mpc_t *, SvIV(SvRV(a)))), *(INT2PTR(mpc_t *, SvIV(SvRV(a)))), DEFAULT_ROUNDING_MODE);
- return a;
- }
-#endif
-
- if(SvNOK(b)) {
- /* mpc_init3(temp, DEFAULT_PREC); */
-#ifdef USE_LONG_DOUBLE
- _mpc_div_ld(*(INT2PTR(mpc_t *, SvIV(SvRV(a)))), *(INT2PTR(mpc_t *, SvIV(SvRV(a)))), (long double)SvNV(b), DEFAULT_ROUNDING_MODE);
- /* mpc_set_ld(temp, SvNV(b), DEFAULT_ROUNDING_MODE); */
-#else
- _mpc_div_d(*(INT2PTR(mpc_t *, SvIV(SvRV(a)))), *(INT2PTR(mpc_t *, SvIV(SvRV(a)))), (double)SvNV(b), DEFAULT_ROUNDING_MODE);
- /* mpc_set_d(temp, SvNV(b), DEFAULT_ROUNDING_MODE); */
-#endif
- /* mpc_div(*(INT2PTR(mpc_t *, SvIV(SvRV(a)))), *(INT2PTR(mpc_t *, SvIV(SvRV(a)))), temp, DEFAULT_ROUNDING_MODE); */
- /* mpc_clear(temp); */
- return a;
- }
-
- if(SvPOK(b)) {
- mpc_init3(temp, DEFAULT_PREC);
- if(mpc_set_str(temp, SvPV_nolen(b), 0, DEFAULT_ROUNDING_MODE) == -1) {
- SvREFCNT_dec(a);
- croak("Invalid string supplied to Math::MPC::overload_div_eq");
- }
- mpc_div(*(INT2PTR(mpc_t *, SvIV(SvRV(a)))), *(INT2PTR(mpc_t *, SvIV(SvRV(a)))), temp, DEFAULT_ROUNDING_MODE);
- mpc_clear(temp);
- return a;
- }
-
- if(sv_isobject(b)) {
- const char *h = HvNAME(SvSTASH(SvRV(b)));
- if(strEQ(h, "Math::MPC")) {
- mpc_div(*(INT2PTR(mpc_t *, SvIV(SvRV(a)))), *(INT2PTR(mpc_t *, SvIV(SvRV(a)))), *(INT2PTR(mpc_t *, SvIV(SvRV(b)))), DEFAULT_ROUNDING_MODE);
- return a;
- }
- }
-
- SvREFCNT_dec(a);
- croak("Invalid argument supplied to Math::MPC::overload_div_eq function");
-
-}
-
-SV * overload_sub_eq(SV * a, SV * b, SV * third) {
- dMY_CXT;
- mpc_t temp;
-
- SvREFCNT_inc(a);
-
-#ifdef USE_64_BIT_INT
- if(SvUOK(b)) {
- mpc_init3(temp, DEFAULT_PREC);
-#ifdef _MSC_VER
- mpc_set_str(temp, SvPV_nolen(b), 10, DEFAULT_ROUNDING_MODE);
-#else
- mpc_set_uj(temp, SvUV(b), DEFAULT_ROUNDING_MODE);
-#endif
- mpc_sub(*(INT2PTR(mpc_t *, SvIV(SvRV(a)))), *(INT2PTR(mpc_t *, SvIV(SvRV(a)))), temp, DEFAULT_ROUNDING_MODE);
- mpc_clear(temp);
- return a;
- }
-
- if(SvIOK(b)) {
- mpc_init3(temp, DEFAULT_PREC);
-#ifdef _MSC_VER
- mpc_set_str(temp, SvPV_nolen(b), 10, DEFAULT_ROUNDING_MODE);
-#else
- mpc_set_sj(temp, SvIV(b), DEFAULT_ROUNDING_MODE);
-#endif
- mpc_sub(*(INT2PTR(mpc_t *, SvIV(SvRV(a)))), *(INT2PTR(mpc_t *, SvIV(SvRV(a)))), temp, DEFAULT_ROUNDING_MODE);
- mpc_clear(temp);
- return a;
- }
-#else
- if(SvUOK(b)) {
- mpc_sub_ui(*(INT2PTR(mpc_t *, SvIV(SvRV(a)))), *(INT2PTR(mpc_t *, SvIV(SvRV(a)))), SvUV(b), DEFAULT_ROUNDING_MODE);
- return a;
- }
-
- if(SvIOK(b)) {
- if(SvIV(b) >= 0) {
- mpc_sub_ui(*(INT2PTR(mpc_t *, SvIV(SvRV(a)))), *(INT2PTR(mpc_t *, SvIV(SvRV(a)))), SvUV(b), DEFAULT_ROUNDING_MODE);
- return a;
- }
- mpc_add_ui(*(INT2PTR(mpc_t *, SvIV(SvRV(a)))), *(INT2PTR(mpc_t *, SvIV(SvRV(a)))), SvIV(b) * -1, DEFAULT_ROUNDING_MODE);
- return a;
- }
-#endif
-
- if(SvNOK(b)) {
- mpc_init3(temp, DEFAULT_PREC);
-
-#ifdef USE_LONG_DOUBLE
- mpc_set_ld(temp, SvNV(b), DEFAULT_ROUNDING_MODE);
-#else
- mpc_set_d(temp, SvNV(b), DEFAULT_ROUNDING_MODE);
-#endif
- mpc_sub(*(INT2PTR(mpc_t *, SvIV(SvRV(a)))), *(INT2PTR(mpc_t *, SvIV(SvRV(a)))), temp, DEFAULT_ROUNDING_MODE);
- mpc_clear(temp);
- return a;
- }
-
- if(SvPOK(b)) {
- mpc_init3(temp, DEFAULT_PREC);
- if(mpc_set_str(temp, SvPV_nolen(b), 0, DEFAULT_ROUNDING_MODE) == -1) {
- SvREFCNT_dec(a);
- croak("Invalid string supplied to Math::MPC::overload_sub_eq");
- }
- mpc_sub(*(INT2PTR(mpc_t *, SvIV(SvRV(a)))), *(INT2PTR(mpc_t *, SvIV(SvRV(a)))), temp, DEFAULT_ROUNDING_MODE);
- mpc_clear(temp);
- return a;
- }
-
- if(sv_isobject(b)) {
- const char *h = HvNAME(SvSTASH(SvRV(b)));
- if(strEQ(h, "Math::MPC")) {
- mpc_sub(*(INT2PTR(mpc_t *, SvIV(SvRV(a)))), *(INT2PTR(mpc_t *, SvIV(SvRV(a)))), *(INT2PTR(mpc_t *, SvIV(SvRV(b)))), DEFAULT_ROUNDING_MODE);
- return a;
- }
- }
-
- SvREFCNT_dec(a);
- croak("Invalid argument supplied to Math::MPC::overload_sub_eq function");
-
-}
-
-SV * overload_add_eq(SV * a, SV * b, SV * third) {
- dMY_CXT;
- mpc_t temp;
- SvREFCNT_inc(a);
-
-#ifdef USE_64_BIT_INT
- if(SvUOK(b)) {
- mpc_init3(temp, DEFAULT_PREC);
-#ifdef _MSC_VER
- mpc_set_str(temp, SvPV_nolen(b), 10, DEFAULT_ROUNDING_MODE);
-#else
- mpc_set_uj(temp, SvUV(b), DEFAULT_ROUNDING_MODE);
-#endif
- mpc_add(*(INT2PTR(mpc_t *, SvIV(SvRV(a)))), *(INT2PTR(mpc_t *, SvIV(SvRV(a)))), temp, DEFAULT_ROUNDING_MODE);
- mpc_clear(temp);
- return a;
- }
-
- if(SvIOK(b)) {
- mpc_init3(temp, DEFAULT_PREC);
- #ifdef _MSC_VER
- mpc_set_str(temp, SvPV_nolen(b), 10, DEFAULT_ROUNDING_MODE);
-#else
- mpc_set_sj(temp, SvIV(b), DEFAULT_ROUNDING_MODE);
-#endif
- mpc_add(*(INT2PTR(mpc_t *, SvIV(SvRV(a)))), *(INT2PTR(mpc_t *, SvIV(SvRV(a)))), temp, DEFAULT_ROUNDING_MODE);
- mpc_clear(temp);
- return a;
- }
-#else
- if(SvUOK(b)) {
- mpc_add_ui(*(INT2PTR(mpc_t *, SvIV(SvRV(a)))), *(INT2PTR(mpc_t *, SvIV(SvRV(a)))), SvUV(b), DEFAULT_ROUNDING_MODE);
- return a;
- }
-
- if(SvIOK(b)) {
- if(SvIV(b) >= 0) {
- mpc_add_ui(*(INT2PTR(mpc_t *, SvIV(SvRV(a)))), *(INT2PTR(mpc_t *, SvIV(SvRV(a)))), SvUV(b), DEFAULT_ROUNDING_MODE);
- return a;
- }
- mpc_sub_ui(*(INT2PTR(mpc_t *, SvIV(SvRV(a)))), *(INT2PTR(mpc_t *, SvIV(SvRV(a)))), SvIV(b) * -1, DEFAULT_ROUNDING_MODE);
- return a;
- }
-#endif
-
- if(SvNOK(b)) {
- mpc_init3(temp, DEFAULT_PREC);
-#ifdef USE_LONG_DOUBLE
- mpc_set_ld(temp, SvNV(b), DEFAULT_ROUNDING_MODE);
-#else
- mpc_set_d(temp, SvNV(b), DEFAULT_ROUNDING_MODE);
-#endif
- mpc_add(*(INT2PTR(mpc_t *, SvIV(SvRV(a)))), *(INT2PTR(mpc_t *, SvIV(SvRV(a)))), temp, DEFAULT_ROUNDING_MODE);
- mpc_clear(temp);
- return a;
- }
-
- if(SvPOK(b)) {
- mpc_init3(temp, DEFAULT_PREC);
- if(mpc_set_str(temp, SvPV_nolen(b), 0, DEFAULT_ROUNDING_MODE) == -1) {
- SvREFCNT_dec(a);
- croak("Invalid string supplied to Math::MPC::overload_add_eq");
- }
- mpc_add(*(INT2PTR(mpc_t *, SvIV(SvRV(a)))), *(INT2PTR(mpc_t *, SvIV(SvRV(a)))), temp, DEFAULT_ROUNDING_MODE);
- mpc_clear(temp);
- return a;
- }
-
- if(sv_isobject(b)) {
- const char *h = HvNAME(SvSTASH(SvRV(b)));
- if(strEQ(h, "Math::MPC")) {
- mpc_add(*(INT2PTR(mpc_t *, SvIV(SvRV(a)))), *(INT2PTR(mpc_t *, SvIV(SvRV(a)))), *(INT2PTR(mpc_t *, SvIV(SvRV(b)))), DEFAULT_ROUNDING_MODE);
- return a;
- }
- }
-
- SvREFCNT_dec(a);
- croak("Invalid argument supplied to Math::MPC::overload_add_eq");
-}
-
-SV * overload_mul_eq(SV * a, SV * b, SV * third) {
- dMY_CXT;
- mpc_t temp;
-
- SvREFCNT_inc(a);
-
-#ifdef USE_64_BIT_INT
- if(SvUOK(b)) {
- mpc_init3(temp, DEFAULT_PREC);
-#ifdef _MSC_VER
- mpc_set_str(temp, SvPV_nolen(b), 10, DEFAULT_ROUNDING_MODE);
-#else
- mpc_set_uj(temp, SvUV(b), DEFAULT_ROUNDING_MODE);
-#endif
- mpc_mul(*(INT2PTR(mpc_t *, SvIV(SvRV(a)))), *(INT2PTR(mpc_t *, SvIV(SvRV(a)))), temp, DEFAULT_ROUNDING_MODE);
- mpc_clear(temp);
- return a;
- }
-
- if(SvIOK(b)) {
- /* mpc_init3(temp, DEFAULT_PREC); */
-#ifdef _MSC_VER
- mpc_init3(temp, DEFAULT_PREC);
- mpc_set_str(temp, SvPV_nolen(b), 10, DEFAULT_ROUNDING_MODE);
- mpc_mul(*(INT2PTR(mpc_t *, SvIV(SvRV(a)))), *(INT2PTR(mpc_t *, SvIV(SvRV(a)))), temp, DEFAULT_ROUNDING_MODE);
- mpc_clear(temp);
-#else
- /* mpc_set_sj(temp, SvIV(b), DEFAULT_ROUNDING_MODE); */
- _mpc_mul_sj(*(INT2PTR(mpc_t *, SvIV(SvRV(a)))), *(INT2PTR(mpc_t *, SvIV(SvRV(a)))), SvUV(b), DEFAULT_ROUNDING_MODE);
-#endif
- /* mpc_mul(*(INT2PTR(mpc_t *, SvIV(SvRV(a)))), *(INT2PTR(mpc_t *, SvIV(SvRV(a)))), temp, DEFAULT_ROUNDING_MODE);
- mpc_clear(temp); */
- return a;
- }
-#else
- if(SvUOK(b)) {
- mpc_mul_ui(*(INT2PTR(mpc_t *, SvIV(SvRV(a)))), *(INT2PTR(mpc_t *, SvIV(SvRV(a)))), SvUV(b), DEFAULT_ROUNDING_MODE);
- return a;
- }
-
- if(SvIOK(b)) {
- mpc_mul_si(*(INT2PTR(mpc_t *, SvIV(SvRV(a)))), *(INT2PTR(mpc_t *, SvIV(SvRV(a)))), SvUV(b), DEFAULT_ROUNDING_MODE);
- return a;
- }
-
-#endif
-
- if(SvNOK(b)) {
- /* mpc_init3(temp, DEFAULT_PREC); */
-#ifdef USE_LONG_DOUBLE
- _mpc_mul_ld(*(INT2PTR(mpc_t *, SvIV(SvRV(a)))), *(INT2PTR(mpc_t *, SvIV(SvRV(a)))), (long double)SvNV(b), DEFAULT_ROUNDING_MODE);
- /* mpc_set_ld(temp, SvNV(b), DEFAULT_ROUNDING_MODE); */
-#else
- _mpc_mul_d(*(INT2PTR(mpc_t *, SvIV(SvRV(a)))), *(INT2PTR(mpc_t *, SvIV(SvRV(a)))), (double)SvNV(b), DEFAULT_ROUNDING_MODE);
- /* mpc_set_d(temp, SvNV(b), DEFAULT_ROUNDING_MODE); */
-#endif
- /* mpc_mul(*(INT2PTR(mpc_t *, SvIV(SvRV(a)))), *(INT2PTR(mpc_t *, SvIV(SvRV(a)))), temp, DEFAULT_ROUNDING_MODE); */
- /* mpc_clear(temp); */
- return a;
- }
-
- if(SvPOK(b)) {
- mpc_init3(temp, DEFAULT_PREC);
- if(mpc_set_str(temp, SvPV_nolen(b), 0, DEFAULT_ROUNDING_MODE) == -1) {
- SvREFCNT_dec(a);
- croak("Invalid string supplied to Math::MPC::overload_mul_eq");
- }
- mpc_mul(*(INT2PTR(mpc_t *, SvIV(SvRV(a)))), *(INT2PTR(mpc_t *, SvIV(SvRV(a)))), temp, DEFAULT_ROUNDING_MODE);
- mpc_clear(temp);
- return a;
- }
-
- if(sv_isobject(b)) {
- const char *h = HvNAME(SvSTASH(SvRV(b)));
- if(strEQ(h, "Math::MPC")) {
- mpc_mul(*(INT2PTR(mpc_t *, SvIV(SvRV(a)))), *(INT2PTR(mpc_t *, SvIV(SvRV(a)))), *(INT2PTR(mpc_t *, SvIV(SvRV(b)))), DEFAULT_ROUNDING_MODE);
- return a;
- }
- }
-
- SvREFCNT_dec(a);
- croak("Invalid argument supplied to Math::MPC::overload_mul_eq");
-}
-
-SV * overload_pow(mpc_t * a, SV * b, SV * third) {
- dMY_CXT;
- mpc_t * mpc_t_obj;
- SV * obj_ref, * obj;
-
- New(1, mpc_t_obj, 1, mpc_t);
- if(mpc_t_obj == NULL) croak("Failed to allocate memory in overload_pow function");
- obj_ref = newSV(0);
- obj = newSVrv(obj_ref, "Math::MPC");
- mpc_init3(*mpc_t_obj, DEFAULT_PREC);
- sv_setiv(obj, INT2PTR(IV,mpc_t_obj));
- SvREADONLY_on(obj);
-
-#ifdef USE_64_BIT_INT
-
- if(SvUOK(b)) {
-#ifdef _MSC_VER
- mpc_set_str(*mpc_t_obj, SvPV_nolen(b), 10, DEFAULT_ROUNDING_MODE);
-#else
- mpc_set_uj(*mpc_t_obj, SvUV(b), DEFAULT_ROUNDING_MODE);
-#endif
- mpc_pow(*mpc_t_obj, *a, *mpc_t_obj, DEFAULT_ROUNDING_MODE);
- return obj_ref;
- }
-
- if(SvIOK(b)) {
-#ifdef _MSC_VER
- mpc_set_str(*mpc_t_obj, SvPV_nolen(b), 10, DEFAULT_ROUNDING_MODE);
-#else
- mpc_set_sj(*mpc_t_obj, SvIV(b), DEFAULT_ROUNDING_MODE);
-#endif
- mpc_pow(*mpc_t_obj, *a, *mpc_t_obj, DEFAULT_ROUNDING_MODE);
- return obj_ref;
- }
-
-#else
- if(SvUOK(b)) {
- mpc_pow_ui(*mpc_t_obj, *a, SvUV(b), DEFAULT_ROUNDING_MODE);
- return obj_ref;
- }
-
- if(SvIOK(b)) {
- mpc_pow_si(*mpc_t_obj, *a, SvIV(b), DEFAULT_ROUNDING_MODE);
- return obj_ref;
- }
-#endif
-
- if(SvNOK(b)) {
-#ifdef USE_LONG_DOUBLE
- mpc_pow_ld(*mpc_t_obj, *a, SvNV(b), DEFAULT_ROUNDING_MODE);
-#else
- mpc_pow_d(*mpc_t_obj, *a, SvNV(b), DEFAULT_ROUNDING_MODE);
-#endif
-
- return obj_ref;
- }
-
- if(SvPOK(b)) {
- if(mpc_set_str(*mpc_t_obj, SvPV_nolen(b), 0, DEFAULT_ROUNDING_MODE) == -1)
- croak("Invalid string supplied to Math::MPC::overload_pow");
- mpc_pow(*mpc_t_obj, *a, *mpc_t_obj, DEFAULT_ROUNDING_MODE);
- return obj_ref;
- }
-
- if(sv_isobject(b)) {
- const char *h = HvNAME(SvSTASH(SvRV(b)));
- if(strEQ(h, "Math::MPC")) {
- mpc_pow(*mpc_t_obj, *a, *(INT2PTR(mpc_t *, SvIV(SvRV(b)))), DEFAULT_ROUNDING_MODE);
- return obj_ref;
- }
- }
-
- croak("Invalid argument supplied to Math::MPC::overload_pow");
-}
-
-SV * overload_pow_eq(SV * a, SV * b, SV * third) {
- dMY_CXT;
- mpc_t temp;
-
- SvREFCNT_inc(a);
-
-#ifdef USE_64_BIT_INT
- if(SvUOK(b)) {
- mpc_init3(temp, DEFAULT_PREC);
-#ifdef _MSC_VER
- mpc_set_str(temp, SvPV_nolen(b), 10, DEFAULT_ROUNDING_MODE);
-#else
- mpc_set_uj(temp, SvUV(b), DEFAULT_ROUNDING_MODE);
-#endif
- mpc_pow(*(INT2PTR(mpc_t *, SvIV(SvRV(a)))), *(INT2PTR(mpc_t *, SvIV(SvRV(a)))), temp, DEFAULT_ROUNDING_MODE);
- mpc_clear(temp);
- return a;
- }
-
- if(SvIOK(b)) {
- mpc_init3(temp, DEFAULT_PREC);
-#ifdef _MSC_VER
- mpc_set_str(temp, SvPV_nolen(b), 10, DEFAULT_ROUNDING_MODE);
-#else
- mpc_set_sj(temp, SvIV(b), DEFAULT_ROUNDING_MODE);
-#endif
- mpc_pow(*(INT2PTR(mpc_t *, SvIV(SvRV(a)))), *(INT2PTR(mpc_t *, SvIV(SvRV(a)))), temp, DEFAULT_ROUNDING_MODE);
- mpc_clear(temp);
- return a;
- }
-#else
- if(SvUOK(b)) {
- mpc_pow_ui(*(INT2PTR(mpc_t *, SvIV(SvRV(a)))), *(INT2PTR(mpc_t *, SvIV(SvRV(a)))), SvUV(b), DEFAULT_ROUNDING_MODE);
- return a;
- }
-
- if(SvIOK(b)) {
- mpc_pow_si(*(INT2PTR(mpc_t *, SvIV(SvRV(a)))), *(INT2PTR(mpc_t *, SvIV(SvRV(a)))), SvIV(b), DEFAULT_ROUNDING_MODE);
- return a;
- }
-
-#endif
-
- if(SvNOK(b)) {
-#ifdef USE_LONG_DOUBLE
- mpc_pow_ld(*(INT2PTR(mpc_t *, SvIV(SvRV(a)))), *(INT2PTR(mpc_t *, SvIV(SvRV(a)))), SvNV(b), DEFAULT_ROUNDING_MODE);
-#else
- mpc_pow_d(*(INT2PTR(mpc_t *, SvIV(SvRV(a)))), *(INT2PTR(mpc_t *, SvIV(SvRV(a)))), SvNV(b), DEFAULT_ROUNDING_MODE);
-#endif
- return a;
- }
-
- if(SvPOK(b)) {
- mpc_init3(temp, DEFAULT_PREC);
- if(mpc_set_str(temp, SvPV_nolen(b), 0, DEFAULT_ROUNDING_MODE) == -1) {
- SvREFCNT_dec(a);
- croak("Invalid string supplied to Math::MPC::overload_pow_eq");
- }
- mpc_pow(*(INT2PTR(mpc_t *, SvIV(SvRV(a)))), *(INT2PTR(mpc_t *, SvIV(SvRV(a)))), temp, DEFAULT_ROUNDING_MODE);
- mpc_clear(temp);
- return a;
- }
-
- if(sv_isobject(b)) {
- const char *h = HvNAME(SvSTASH(SvRV(b)));
- if(strEQ(h, "Math::MPC")) {
- mpc_pow(*(INT2PTR(mpc_t *, SvIV(SvRV(a)))), *(INT2PTR(mpc_t *, SvIV(SvRV(a)))), *(INT2PTR(mpc_t *, SvIV(SvRV(b)))), DEFAULT_ROUNDING_MODE);
- return a;
- }
- }
-
- SvREFCNT_dec(a);
- croak("Invalid argument supplied to Math::MPC::overload_pow_eq");
-}
-
-SV * overload_equiv(mpc_t * a, SV * b, SV * third) {
- dMY_CXT;
- mpfr_t temp;
- mpc_t t;
- int ret;
-
- if(mpfr_nan_p(MPC_RE(*a)) || mpfr_nan_p(MPC_IM(*a))) return newSViv(0);
-
-#ifdef USE_64_BIT_INT
- if(SvUOK(b)) {
- mpfr_init2(temp, DEFAULT_PREC_RE);
-#ifdef _MSC_VER
- mpfr_set_str(temp, SvPV_nolen(b), 10, DEFAULT_ROUNDING_MODE & 3);
-#else
- mpfr_set_uj(temp, SvUV(b), DEFAULT_ROUNDING_MODE & 3);
-#endif
- mpc_init3(t, DEFAULT_PREC);
- mpc_set_ui_ui(t, 0, 0, DEFAULT_ROUNDING_MODE);
- mpc_add_fr(t, t, temp, DEFAULT_ROUNDING_MODE);
- mpfr_clear(temp);
- ret = mpc_cmp(*a, t);
- mpc_clear(t);
- if(ret == 0) return newSViv(1);
- return newSViv(0);
- }
-
- if(SvIOK(b)) {
- mpfr_init2(temp, DEFAULT_PREC_RE);
-#ifdef _MSC_VER
- mpfr_set_str(temp, SvPV_nolen(b), 10, DEFAULT_ROUNDING_MODE & 3);
-#else
- mpfr_set_sj(temp, SvIV(b), DEFAULT_ROUNDING_MODE & 3);
-#endif
- mpc_init3(t, DEFAULT_PREC);
- mpc_set_ui_ui(t, 0, 0, DEFAULT_ROUNDING_MODE);
- mpc_add_fr(t, t, temp, DEFAULT_ROUNDING_MODE);
- mpfr_clear(temp);
- ret = mpc_cmp(*a, t);
- mpc_clear(t);
- if(ret == 0) return newSViv(1);
- return newSViv(0);
- }
-#else
- if(SvUOK(b)) {
- mpc_init3(t, DEFAULT_PREC);
- mpc_set_ui(t, SvUV(b), DEFAULT_ROUNDING_MODE);
- ret = mpc_cmp(*a, t);
- mpc_clear(t);
- if(ret == 0) return newSViv(1);
- return newSViv(0);
- }
-
- if(SvIOK(b)) {
- ret = mpc_cmp_si(*a, SvIV(b));
- if(ret == 0) return newSViv(1);
- return newSViv(0);
- }
-#endif
-
- if(SvNOK(b)) {
-#ifdef USE_LONG_DOUBLE
- mpfr_init2(temp, DEFAULT_PREC_RE);
- mpfr_set_ld(temp, SvNV(b), DEFAULT_ROUNDING_MODE & 3);
- if(mpfr_nan_p(temp)) {
- mpfr_clear(temp);
- return newSViv(0);
- }
- mpc_init3(t, DEFAULT_PREC);
- mpc_set_ui_ui(t, 0, 0, DEFAULT_ROUNDING_MODE);
- mpc_add_fr(t, t, temp, DEFAULT_ROUNDING_MODE);
- mpfr_clear(temp);
- ret = mpc_cmp(*a, t);
- mpc_clear(t);
-#else
- mpc_init3(t, DEFAULT_PREC);
- mpc_set_d(t, SvNV(b), DEFAULT_ROUNDING_MODE);
- if(mpfr_nan_p(MPC_RE(t))) ret = 1;
- else ret = mpc_cmp(*a, t);
- mpc_clear(t);
-#endif
- if(ret == 0) return newSViv(1);
- return newSViv(0);
- }
-
- if(SvPOK(b)) {
- mpfr_init2(temp, DEFAULT_PREC_RE);
- if(mpfr_set_str(temp, (char *)SvPV_nolen(b), 0, DEFAULT_ROUNDING_MODE & 3))
- croak("Invalid string supplied to Math::MPC::overload_equiv");
- mpc_init3(t, DEFAULT_PREC);
- mpc_set_ui_ui(t, 0, 0, DEFAULT_ROUNDING_MODE);
- mpc_add_fr(t, t, temp, DEFAULT_ROUNDING_MODE);
- mpfr_clear(temp);
- ret = mpc_cmp(*a, t);
- mpc_clear(t);
- if(ret == 0) return newSViv(1);
- return newSViv(0);
- }
-
- if(sv_isobject(b)) {
- const char *h = HvNAME(SvSTASH(SvRV(b)));
- if(strEQ(h, "Math::MPC")) {
- if(mpfr_nan_p(MPC_RE(*(INT2PTR(mpc_t *, SvIV(SvRV(b)))))) ||
- mpfr_nan_p(MPC_IM(*(INT2PTR(mpc_t *, SvIV(SvRV(b))))))) return newSViv(0);
- ret = mpc_cmp(*a, *(INT2PTR(mpc_t *, SvIV(SvRV(b)))));
- if(ret == 0) return newSViv(1);
- return newSViv(0);
- }
- }
-
- croak("Invalid argument supplied to Math::MPC::overload_equiv");
-}
-
-SV * overload_not_equiv(mpc_t * a, SV * b, SV * third) {
- dMY_CXT;
- mpfr_t temp;
- mpc_t t;
- int ret;
-
- if(mpfr_nan_p(MPC_RE(*a)) || mpfr_nan_p(MPC_IM(*a))) return newSViv(1);
-
-#ifdef USE_64_BIT_INT
- if(SvUOK(b)) {
- mpfr_init2(temp, DEFAULT_PREC_RE);
-#ifdef _MSC_VER
- mpfr_set_str(temp, SvPV_nolen(b), 10, DEFAULT_ROUNDING_MODE & 3);
-#else
- mpfr_set_uj(temp, SvUV(b), DEFAULT_ROUNDING_MODE & 3);
-#endif
- mpc_init3(t, DEFAULT_PREC);
- mpc_set_ui_ui(t, 0, 0, DEFAULT_ROUNDING_MODE);
- mpc_add_fr(t, t, temp, DEFAULT_ROUNDING_MODE);
- mpfr_clear(temp);
- ret = mpc_cmp(*a, t);
- mpc_clear(t);
- if(ret == 0) return newSViv(0);
- return newSViv(1);
- }
-
- if(SvIOK(b)) {
- mpfr_init2(temp, DEFAULT_PREC_RE);
-#ifdef _MSC_VER
- mpfr_set_str(temp, SvPV_nolen(b), 10, DEFAULT_ROUNDING_MODE & 3);
-#else
- mpfr_set_sj(temp, SvIV(b), DEFAULT_ROUNDING_MODE & 3);
-#endif
- mpc_init3(t, DEFAULT_PREC);
- mpc_set_ui_ui(t, 0, 0, DEFAULT_ROUNDING_MODE);
- mpc_add_fr(t, t, temp, DEFAULT_ROUNDING_MODE);
- mpfr_clear(temp);
- ret = mpc_cmp(*a, t);
- mpc_clear(t);
- if(ret == 0) return newSViv(0);
- return newSViv(1);
- }
-#else
- if(SvUOK(b)) {
- mpc_init3(t, DEFAULT_PREC);
- mpc_set_ui(t, SvUV(b), DEFAULT_ROUNDING_MODE);
- ret = mpc_cmp(*a, t);
- mpc_clear(t);
- if(ret == 0) return newSViv(0);
- return newSViv(1);
- }
-
- if(SvIOK(b)) {
- ret = mpc_cmp_si(*a, SvIV(b));
- if(ret == 0) return newSViv(0);
- return newSViv(1);
- }
-#endif
-
- if(SvNOK(b)) {
-#ifdef USE_LONG_DOUBLE
- mpfr_init2(temp, DEFAULT_PREC_RE);
- mpfr_set_ld(temp, SvNV(b), DEFAULT_ROUNDING_MODE & 3);
- if(mpfr_nan_p(temp)) {
- mpfr_clear(temp);
- return newSViv(1);
- }
- mpc_init3(t, DEFAULT_PREC);
- mpc_set_ui_ui(t, 0, 0, DEFAULT_ROUNDING_MODE);
- mpc_add_fr(t, t, temp, DEFAULT_ROUNDING_MODE);
- mpfr_clear(temp);
- ret = mpc_cmp(*a, t);
- mpc_clear(t);
-#else
- mpc_init3(t, DEFAULT_PREC);
- mpc_set_d(t, SvNV(b), DEFAULT_ROUNDING_MODE);
- if(mpfr_nan_p(MPC_RE(t))) ret = 1;
- else ret = mpc_cmp(*a, t);
- mpc_clear(t);
-#endif
- if(ret == 0) return newSViv(0);
- return newSViv(1);
- }
-
- if(SvPOK(b)) {
- mpfr_init2(temp, DEFAULT_PREC_RE);
- if(mpfr_set_str(temp, (char *)SvPV_nolen(b), 0, DEFAULT_ROUNDING_MODE & 3))
- croak("Invalid string supplied to Math::MPC::overload_not_equiv");
- mpc_init3(t, DEFAULT_PREC);
- mpc_set_ui_ui(t, 0, 0, DEFAULT_ROUNDING_MODE);
- mpc_add_fr(t, t, temp, DEFAULT_ROUNDING_MODE);
- mpfr_clear(temp);
- ret = mpc_cmp(*a, t);
- mpc_clear(t);
- if(ret == 0) return newSViv(0);
- return newSViv(1);
- }
-
- if(sv_isobject(b)) {
- const char *h = HvNAME(SvSTASH(SvRV(b)));
- if(strEQ(h, "Math::MPC")) {
- if(mpfr_nan_p(MPC_RE(*(INT2PTR(mpc_t *, SvIV(SvRV(b)))))) ||
- mpfr_nan_p(MPC_IM(*(INT2PTR(mpc_t *, SvIV(SvRV(b))))))) return newSViv(1);
- if(mpc_cmp(*a, *(INT2PTR(mpc_t *, SvIV(SvRV(b)))))) return newSViv(1);
- return newSViv(0);
- }
- }
-
- croak("Invalid argument supplied to Math::MPC::overload_not_equiv");
-}
-
-SV * overload_not(mpc_t * a, SV * second, SV * third) {
- if(mpfr_nan_p(MPC_RE(*a)) || mpfr_nan_p(MPC_IM(*a))) return newSViv(1); /* Thanks Jean-Louis Morel */
- if(mpc_cmp_si_si(*a, 0, 0)) return newSViv(0);
- return newSViv(1);
-}
-
-SV * overload_sqrt(mpc_t * p, SV * second, SV * third) {
- dMY_CXT;
- mpc_t * mpc_t_obj;
- SV * obj_ref, * obj;
-
- New(1, mpc_t_obj, 1, mpc_t);
- if(mpc_t_obj == NULL) croak("Failed to allocate memory in overload_sqrt function");
- obj_ref = newSV(0);
- obj = newSVrv(obj_ref, "Math::MPC");
- mpc_init3(*mpc_t_obj, DEFAULT_PREC);
-
- mpc_sqrt(*mpc_t_obj, *p, DEFAULT_ROUNDING_MODE);
- sv_setiv(obj, INT2PTR(IV,mpc_t_obj));
- SvREADONLY_on(obj);
- return obj_ref;
-}
-
-void overload_copy(mpc_t * p, SV * second, SV * third) {
- dXSARGS;
- dMY_CXT;
- mpc_t * mpc_t_obj;
- SV * obj_ref, * obj;
- mp_prec_t re, im;
-
- New(1, mpc_t_obj, 1, mpc_t);
- if(mpc_t_obj == NULL) croak("Failed to allocate memory in overload_copy function");
- obj_ref = newSV(0);
- obj = newSVrv(obj_ref, "Math::MPC");
-
- mpc_get_prec2(&re, &im, *p);
- mpc_init3(*mpc_t_obj, re, im);
- mpc_set(*mpc_t_obj, *p, DEFAULT_ROUNDING_MODE);
- sv_setiv(obj, INT2PTR(IV,mpc_t_obj));
- SvREADONLY_on(obj);
- ST(0) = sv_2mortal(obj_ref);
- /* PUTBACK; *//* not needed */
- XSRETURN(1);
-}
-
-SV * overload_abs(mpc_t * p, SV * second, SV * third) {
- dMY_CXT;
- mpfr_t * mpfr_t_obj;
- SV * obj_ref, * obj;
-
- New(1, mpfr_t_obj, 1, mpfr_t);
- if(mpfr_t_obj == NULL) croak("Failed to allocate memory in overload_abs function");
- obj_ref = newSV(0);
- obj = newSVrv(obj_ref, "Math::MPFR");
- mpfr_init(*mpfr_t_obj);
-
- mpc_abs(*mpfr_t_obj, *p, DEFAULT_ROUNDING_MODE);
- sv_setiv(obj, INT2PTR(IV,mpfr_t_obj));
- SvREADONLY_on(obj);
- return obj_ref;
-}
-
-SV * overload_exp(mpc_t * p, SV * second, SV * third) {
- dMY_CXT;
- mpc_t * mpc_t_obj;
- SV * obj_ref, * obj;
-
- New(1, mpc_t_obj, 1, mpc_t);
- if(mpc_t_obj == NULL) croak("Failed to allocate memory in overload_exp function");
- obj_ref = newSV(0);
- obj = newSVrv(obj_ref, "Math::MPC");
- mpc_init3(*mpc_t_obj, DEFAULT_PREC);
-
- mpc_exp(*mpc_t_obj, *p, DEFAULT_ROUNDING_MODE);
- sv_setiv(obj, INT2PTR(IV,mpc_t_obj));
- SvREADONLY_on(obj);
- return obj_ref;
-}
-
-SV * overload_log(mpc_t * p, SV * second, SV * third) {
- dMY_CXT;
- mpc_t * mpc_t_obj;
- SV * obj_ref, * obj;
-
- New(1, mpc_t_obj, 1, mpc_t);
- if(mpc_t_obj == NULL) croak("Failed to allocate memory in overload_exp function");
- obj_ref = newSV(0);
- obj = newSVrv(obj_ref, "Math::MPC");
- mpc_init3(*mpc_t_obj, DEFAULT_PREC);
-
- mpc_log(*mpc_t_obj, *p, DEFAULT_ROUNDING_MODE);
- sv_setiv(obj, INT2PTR(IV,mpc_t_obj));
- SvREADONLY_on(obj);
- return obj_ref;
-}
-
-SV * overload_sin(mpc_t * p, SV * second, SV * third) {
- dMY_CXT;
- mpc_t * mpc_t_obj;
- SV * obj_ref, * obj;
-
- New(1, mpc_t_obj, 1, mpc_t);
- if(mpc_t_obj == NULL) croak("Failed to allocate memory in overload_sin function");
- obj_ref = newSV(0);
- obj = newSVrv(obj_ref, "Math::MPC");
- mpc_init3(*mpc_t_obj, DEFAULT_PREC);
-
- mpc_sin(*mpc_t_obj, *p, DEFAULT_ROUNDING_MODE);
- sv_setiv(obj, INT2PTR(IV,mpc_t_obj));
- SvREADONLY_on(obj);
- return obj_ref;
-}
-
-SV * overload_cos(mpc_t * p, SV * second, SV * third) {
- dMY_CXT;
- mpc_t * mpc_t_obj;
- SV * obj_ref, * obj;
-
- New(1, mpc_t_obj, 1, mpc_t);
- if(mpc_t_obj == NULL) croak("Failed to allocate memory in overload_sin function");
- obj_ref = newSV(0);
- obj = newSVrv(obj_ref, "Math::MPC");
- mpc_init3(*mpc_t_obj, DEFAULT_PREC);
-
- mpc_cos(*mpc_t_obj, *p, DEFAULT_ROUNDING_MODE);
- sv_setiv(obj, INT2PTR(IV,mpc_t_obj));
- SvREADONLY_on(obj);
- return obj_ref;
-}
-
-void _get_r_string(mpc_t * p, SV * base, SV * n_digits, SV * round) {
- dXSARGS;
- char * out;
- mp_exp_t ptr;
- unsigned long b = SvUV(base);
-
- if(b < 2 || b > 36) croak("Second argument supplied to r_string() is not in acceptable range");
-
- out = mpfr_get_str(0, &ptr, b, SvUV(n_digits), MPC_RE(*p), (mpc_rnd_t)SvUV(round) & 3);
-
- if(out == NULL) croak("An error occurred in _get_r_string()");
-
- /* sp = mark; *//* not needed */
- ST(0) = sv_2mortal(newSVpv(out, 0));
- mpfr_free_str(out);
- ST(1) = sv_2mortal(newSViv(ptr));
- /* PUTBACK; *//* not needed */
- XSRETURN(2);
-}
-
-void _get_i_string(mpc_t * p, SV * base, SV * n_digits, SV * round) {
- dXSARGS;
- char * out;
- mp_exp_t ptr;
- unsigned long b = SvUV(base);
-
- if(b < 2 || b > 36) croak("Second argument supplied to i_string() is not in acceptable range");
-
- out = mpfr_get_str(0, &ptr, b, SvUV(n_digits), MPC_IM(*p), (mpc_rnd_t)SvUV(round) & 3);
-
- if(out == NULL) croak("An error occurred in _get_i_string()");
-
- /* sp = mark; *//* not needed */
- ST(0) = sv_2mortal(newSVpv(out, 0));
- mpfr_free_str(out);
- ST(1) = sv_2mortal(newSViv(ptr));
- /* PUTBACK; *//* not needed */
- XSRETURN(2);
-}
-
-
-/* ########################################
- ########################################
- ########################################
- ########################################
- ########################################
- ######################################## */
-
-
-
-SV * _itsa(SV * a) {
- if(SvUOK(a)) return newSVuv(1);
- if(SvIOK(a)) return newSVuv(2);
- if(SvNOK(a)) return newSVuv(3);
- if(SvPOK(a)) return newSVuv(4);
- if(sv_isobject(a)) {
- const char *h = HvNAME(SvSTASH(SvRV(a)));
- if(strEQ(h, "Math::MPFR")) return newSVuv(5);
- if(strEQ(h, "Math::GMPf")) return newSVuv(6);
- if(strEQ(h, "Math::GMPq")) return newSVuv(7);
- if(strEQ(h, "Math::GMPz")) return newSVuv(8);
- if(strEQ(h, "Math::GMP")) return newSVuv(9);
- if(strEQ(h, "Math::MPC")) return newSVuv(10);
- }
- return newSVuv(0);
-}
-
-SV * _new_real(SV * b) {
- dMY_CXT;
- mpc_t * mpc_t_obj;
- mpfr_t temp;
- SV * obj_ref, * obj;
-
- New(1, mpc_t_obj, 1, mpc_t);
- if(mpc_t_obj == NULL) croak("Failed to allocate memory in _new_real function");
- obj_ref = newSV(0);
- obj = newSVrv(obj_ref, "Math::MPC");
- mpc_init3(*mpc_t_obj, DEFAULT_PREC);
-
- sv_setiv(obj, INT2PTR(IV,mpc_t_obj));
- SvREADONLY_on(obj);
-
-#ifdef USE_64_BIT_INT
-
- if(SvUOK(b)) {
- mpfr_init2(temp, DEFAULT_PREC_RE);
-#ifdef _MSC_VER
- mpfr_set_str(temp, SvPV_nolen(b), 10, DEFAULT_ROUNDING_MODE & 3);
-#else
- mpfr_set_uj(temp, SvUV(b), DEFAULT_ROUNDING_MODE & 3);
-#endif
- mpc_set_fr(*mpc_t_obj, temp, DEFAULT_ROUNDING_MODE);
- mpfr_clear(temp);
- return obj_ref;
- }
-
- if(SvIOK(b)) {
- mpfr_init2(temp, DEFAULT_PREC_RE);
-#ifdef _MSC_VER
- mpfr_set_str(temp, SvPV_nolen(b), 10, DEFAULT_ROUNDING_MODE & 3);
-#else
- mpfr_set_sj(temp, SvIV(b), DEFAULT_ROUNDING_MODE & 3);
-#endif
- mpc_set_fr(*mpc_t_obj, temp, DEFAULT_ROUNDING_MODE);
- mpfr_clear(temp);
- return obj_ref;
- }
-
-#else
- if(SvUOK(b)) {
- mpc_set_ui(*mpc_t_obj, SvUV(b), DEFAULT_ROUNDING_MODE);
- return obj_ref;
- }
-
- if(SvIOK(b)) {
- mpc_set_si(*mpc_t_obj, SvIV(b), DEFAULT_ROUNDING_MODE);
- return obj_ref;
- }
-#endif
-
- if(SvNOK(b)) {
-#ifdef USE_LONG_DOUBLE
- mpc_set_ld(*mpc_t_obj, SvNV(b), DEFAULT_ROUNDING_MODE);
-#else
- mpc_set_d(*mpc_t_obj, SvNV(b), DEFAULT_ROUNDING_MODE);
-#endif
-
- return obj_ref;
- }
-
- if(SvPOK(b)) {
- mpfr_init2(temp, DEFAULT_PREC_RE);
- if(mpfr_set_str(temp, SvPV_nolen(b), 0, DEFAULT_ROUNDING_MODE & 3))
- croak("Invalid string supplied to Math::MPC::new");
- mpc_set_fr(*mpc_t_obj, temp, DEFAULT_ROUNDING_MODE);
- mpfr_clear(temp);
- return obj_ref;
- }
-
- if(sv_isobject(b)) {
- const char *h = HvNAME(SvSTASH(SvRV(b)));
- if(strEQ(h, "Math::MPFR")) {
- mpc_set_fr(*mpc_t_obj, *(INT2PTR(mpfr_t *, SvIV(SvRV(b)))), DEFAULT_ROUNDING_MODE);
- return obj_ref;
- }
- if(strEQ(h, "Math::GMPf")) {
- mpc_set_f(*mpc_t_obj, *(INT2PTR(mpf_t *, SvIV(SvRV(b)))), DEFAULT_ROUNDING_MODE);
- return obj_ref;
- }
- if(strEQ(h, "Math::GMPq")) {
- mpc_set_q(*mpc_t_obj, *(INT2PTR(mpq_t *, SvIV(SvRV(b)))), DEFAULT_ROUNDING_MODE);
- return obj_ref;
- }
- if(strEQ(h, "Math::GMP") ||
- strEQ(h, "Math::GMPz")) {
- mpc_set_z(*mpc_t_obj, *(INT2PTR(mpz_t *, SvIV(SvRV(b)))), DEFAULT_ROUNDING_MODE);
- return obj_ref;
- }
- }
-
- croak("Invalid argument supplied to Math::MPC::_new_real");
-}
-
-SV * _new_im(SV * b) {
- dMY_CXT;
- mpc_t * mpc_t_obj;
- mpfr_t temp;
- SV * obj_ref, * obj;
- int ret;
-
- New(1, mpc_t_obj, 1, mpc_t);
- if(mpc_t_obj == NULL) croak("Failed to allocate memory in Rmpc_init function");
- obj_ref = newSV(0);
- obj = newSVrv(obj_ref, "Math::MPC");
- mpc_init3(*mpc_t_obj, DEFAULT_PREC);
-
- sv_setiv(obj, INT2PTR(IV,mpc_t_obj));
- SvREADONLY_on(obj);
-
-#ifdef USE_64_BIT_INT
-
- if(SvUOK(b)) {
- mpfr_init2(temp, DEFAULT_PREC_IM);
-#ifdef _MSC_VER
- mpfr_set_str(temp, SvPV_nolen(b), 10, DEFAULT_ROUNDING_MODE / 16);
-#else
- mpfr_set_uj(temp, SvUV(b), DEFAULT_ROUNDING_MODE / 16);
-#endif
- VOID_MPC_SET_X_Y(ui, fr, *mpc_t_obj, 0, temp, DEFAULT_ROUNDING_MODE);
- mpfr_clear(temp);
- return obj_ref;
- }
-
- if(SvIOK(b)) {
- mpfr_init2(temp, DEFAULT_PREC_IM);
-#ifdef _MSC_VER
- mpfr_set_str(temp, SvPV_nolen(b), 10, DEFAULT_ROUNDING_MODE / 16);
-#else
- mpfr_set_sj(temp, SvIV(b), DEFAULT_ROUNDING_MODE / 16);
-#endif
- VOID_MPC_SET_X_Y(ui, fr, *mpc_t_obj, 0, temp, DEFAULT_ROUNDING_MODE);
- mpfr_clear(temp);
- return obj_ref;
- }
-
-#else
- if(SvUOK(b)) {
- mpc_set_ui_ui(*mpc_t_obj, 0, SvUV(b), DEFAULT_ROUNDING_MODE);
- return obj_ref;
- }
-
- if(SvIOK(b)) {
- mpc_set_si_si(*mpc_t_obj, 0, SvIV(b), DEFAULT_ROUNDING_MODE);
- return obj_ref;
- }
-#endif
-
- if(SvNOK(b)) {
-#ifdef USE_LONG_DOUBLE
- mpc_set_ld_ld(*mpc_t_obj, 0, SvNV(b), DEFAULT_ROUNDING_MODE);
-#else
- mpc_set_d_d(*mpc_t_obj, 0, SvNV(b), DEFAULT_ROUNDING_MODE);
-#endif
-
- return obj_ref;
- }
-
- if(SvPOK(b)) {
- mpfr_init2(temp, DEFAULT_PREC_IM);
- if(mpfr_set_str(temp, SvPV_nolen(b), 0, DEFAULT_ROUNDING_MODE / 16))
- croak("Invalid string supplied to Math::MPC::new");
- VOID_MPC_SET_X_Y(ui, fr, *mpc_t_obj, 0, temp, DEFAULT_ROUNDING_MODE);
- mpfr_clear(temp);
- return obj_ref;
- }
-
- if(sv_isobject(b)) {
- const char *h = HvNAME(SvSTASH(SvRV(b)));
- if(strEQ(h, "Math::MPFR")) {
- VOID_MPC_SET_X_Y(ui, fr, *mpc_t_obj, 0, *(INT2PTR(mpfr_t *, SvIV(SvRV(b)))), DEFAULT_ROUNDING_MODE);
- return obj_ref;
- }
- if(strEQ(h, "Math::GMPf")) {
- mpfr_init2(temp, DEFAULT_PREC_IM);
- mpfr_set_f(temp, *(INT2PTR(mpf_t *, SvIV(SvRV(b)))), DEFAULT_ROUNDING_MODE / 16);
- VOID_MPC_SET_X_Y(ui, fr, *mpc_t_obj, 0, temp, DEFAULT_ROUNDING_MODE);
- mpfr_clear(temp);
- return obj_ref;
- }
- if(strEQ(h, "Math::GMPq")) {
- mpfr_init2(temp, DEFAULT_PREC_IM);
- mpfr_set_q(temp, *(INT2PTR(mpq_t *, SvIV(SvRV(b)))), DEFAULT_ROUNDING_MODE / 16);
- VOID_MPC_SET_X_Y(ui, fr, *mpc_t_obj, 0, temp, DEFAULT_ROUNDING_MODE);
- mpfr_clear(temp);
- return obj_ref;
- }
- if(strEQ(h, "Math::GMP") ||
- strEQ(h, "Math::GMPz")) {
- mpfr_init2(temp, DEFAULT_PREC_IM);
- mpfr_set_z(temp, *(INT2PTR(mpz_t *, SvIV(SvRV(b)))), DEFAULT_ROUNDING_MODE / 16);
- VOID_MPC_SET_X_Y(ui, fr, *mpc_t_obj, 0, temp, DEFAULT_ROUNDING_MODE);
- mpfr_clear(temp);
- return obj_ref;
- }
- }
-
- croak("Invalid argument supplied to Math::MPC::_new_im");
-}
-
-int _has_longlong(void) {
-#ifdef USE_64_BIT_INT
- return 1;
-#else
- return 0;
-#endif
-}
-
-int _has_longdouble(void) {
-#ifdef USE_LONG_DOUBLE
- return 1;
-#else
- return 0;
-#endif
-}
-
-/* Has inttypes.h been included ? */
-int _has_inttypes(void) {
-#ifdef _MSC_VER
-return 0;
-#else
-#if defined USE_64_BIT_INT || defined USE_LONG_DOUBLE
-return 1;
-#else
-return 0;
-#endif
-#endif
-}
-
-SV * gmp_v(void) {
- return newSVpv(gmp_version, 0);
-}
-
-SV * mpfr_v(void) {
- return newSVpv(mpfr_get_version(), 0);
-}
-
-/* Not yet available
-SV * RMPC_MAX_PREC(mpc_t * a) {
- return newSVuv(MPC_MAX_PREC(*a));
-}
-*/
-
-SV * _MPC_VERSION_MAJOR(void) {
- return newSVuv(MPC_VERSION_MAJOR);
-}
-
-SV * _MPC_VERSION_MINOR(void) {
- return newSVuv(MPC_VERSION_MINOR);
-}
-
-SV * _MPC_VERSION_PATCHLEVEL(void) {
- return newSVuv(MPC_VERSION_PATCHLEVEL);
-}
-
-SV * _MPC_VERSION(void) {
- return newSVuv(MPC_VERSION);
-}
-
-SV * _MPC_VERSION_NUM(SV * x, SV * y, SV * z) {
- return newSVuv(MPC_VERSION_NUM((unsigned long)SvUV(x), (unsigned long)SvUV(y), (unsigned long)SvUV(z)));
-}
-
-SV * _MPC_VERSION_STRING(void) {
- return newSVpv(MPC_VERSION_STRING, 0);
-}
-
-SV * Rmpc_get_version(void) {
- return newSVpv(mpc_get_version(), 0);
-}
-
-SV * Rmpc_real(mpfr_t * rop, mpc_t * op, SV * round) {
- return newSViv(mpc_real(*rop, *op, (mpc_rnd_t)SvUV(round)));
-}
-
-SV * Rmpc_imag(mpfr_t * rop, mpc_t * op, SV * round) {
- return newSViv(mpc_imag(*rop, *op, (mpc_rnd_t)SvUV(round)));
-}
-
-SV * Rmpc_arg(mpfr_t * rop, mpc_t * op, SV * round) {
- return newSViv(mpc_arg(*rop, *op, (mpc_rnd_t)SvUV(round)));
-}
-
-SV * Rmpc_proj(mpc_t * rop, mpc_t * op, SV * round) {
- return newSViv(mpc_proj(*rop, *op, (mpc_rnd_t)SvUV(round)));
-}
-
-SV * Rmpc_get_str(SV * base, SV * dig, mpc_t * op, SV * round) {
- char * out;
- SV * outsv;
- out = mpc_get_str((int)SvIV(base), (size_t)SvUV(dig), *op, (mpc_rnd_t)SvUV(round));
- outsv = newSVpv(out, 0);
- mpc_free_str(out);
- return outsv;
-}
-
-SV * Rmpc_set_str(mpc_t * rop, SV * str, SV * base, SV * round) {
- return newSViv(mpc_set_str(*rop, SvPV_nolen(str), (int)SvIV(base), (mpc_rnd_t)SvUV(round)));
-}
-
-SV * Rmpc_strtoc(mpc_t * rop, SV * str, SV * base, SV * round) {
- return newSViv(mpc_strtoc(*rop, SvPV_nolen(str), NULL, (int)SvIV(base), (mpc_rnd_t)SvUV(round)));
-}
-
-void Rmpc_set_nan(mpc_t * a) {
- mpc_set_nan(*a);
-}
-
-void Rmpc_swap(mpc_t * a, mpc_t * b) {
- mpc_swap(*a, *b);
-}
-
-/* atan2(x, y) = atan(x / y) */
-SV * overload_atan2(mpc_t * p, mpc_t * q, SV * third) {
- dMY_CXT;
- mpc_t * mpc_t_obj;
- SV * obj_ref, * obj;
-
- New(1, mpc_t_obj, 1, mpc_t);
- if(mpc_t_obj == NULL) croak("Failed to allocate memory in overload_atan2 function");
- obj_ref = newSV(0);
- obj = newSVrv(obj_ref, "Math::MPC");
- mpc_init3(*mpc_t_obj, DEFAULT_PREC);
-
- mpc_div(*mpc_t_obj, *p, *q, DEFAULT_ROUNDING_MODE);
-
- mpc_atan(*mpc_t_obj, *mpc_t_obj, DEFAULT_ROUNDING_MODE);
- sv_setiv(obj, INT2PTR(IV,mpc_t_obj));
- SvREADONLY_on(obj);
- return obj_ref;
-}
-
-SV * Rmpc_sin_cos(mpc_t * rop_sin, mpc_t * rop_cos, mpc_t * op, SV * rnd_sin, SV * rnd_cos) {
-#ifdef SIN_COS_AVAILABLE
- return newSViv(mpc_sin_cos(*rop_sin, *rop_cos, *op, (mpc_rnd_t)SvUV(rnd_sin), (mpc_rnd_t)SvUV(rnd_cos)));
-#else
- croak("Rmpc_Âsin_cos() not supported by your version (%s) of the mpc library", MPC_VERSION_STRING);
-#endif
-}
-
-void Rmpc_get_dc(SV * crop, mpc_t * op, SV * round) {
-#ifdef _DO_COMPLEX_H
- if(sv_isobject(crop)) {
- const char *h = HvNAME(SvSTASH(SvRV(crop)));
- if(strNE(h, "Math::Complex_C"))
- croak("1st arg to Rmpc_get_dc is a %s object - needs to be a Math::Complex_C object", h);
- }
- else croak("1st arg to Rmpc_get_dc needs to be a Math::Complex_C object");
- *(INT2PTR(double _Complex *, SvIV(SvRV(crop)))) = mpc_get_dc(*op, (mpc_rnd_t)SvUV(round));
-#else
- croak("Rmpc_get_dc() not implemented");
-#endif
-}
-
-void Rmpc_get_ldc(SV * crop, mpc_t * op, SV * round) {
-#ifdef _DO_COMPLEX_H
- if(sv_isobject(crop)) {
- const char *h = HvNAME(SvSTASH(SvRV(crop)));
- if(strNE(h, "Math::Complex_C::Long"))
- croak("1st arg to Rmpc_get_ldc is a %s object - needs to be a Math::Complex_C::Long object", h);
- }
- else croak("1st arg to Rmpc_get_ldc needs to be a Math::Complex_C::Long object");
- *(INT2PTR(long double _Complex *, SvIV(SvRV(crop)))) = mpc_get_ldc(*op, (mpc_rnd_t)SvUV(round));
-#else
- croak("Rmpc_get_ldc() not implemented");
-#endif
-}
-
-SV * Rmpc_set_dc(mpc_t * op, SV * crop, SV * round) {
-#ifdef _DO_COMPLEX_H
- if(sv_isobject(crop)) {
- const char *h = HvNAME(SvSTASH(SvRV(crop)));
- if(strNE(h, "Math::Complex_C"))
- croak("2nd arg to Rmpc_set_dc is a %s object - needs to be a Math::Complex_C object", h);
- }
- else croak("2nd arg to Rmpc_set_dc needs to be a Math::Complex_C object");
- return newSViv(mpc_set_dc(*op, *(INT2PTR(double _Complex *, SvIV(SvRV(crop)))), (mpc_rnd_t)SvUV(round)));
-#else
- croak("Rmpc_set_dc() not implemented");
-#endif
-}
-
-SV * Rmpc_set_ldc(mpc_t * op, SV * crop, SV * round) {
-#ifdef _DO_COMPLEX_H
- if(sv_isobject(crop)) {
- const char *h = HvNAME(SvSTASH(SvRV(crop)));
- if(strNE(h, "Math::Complex_C::Long"))
- croak("2nd arg to Rmpc_set_ldc is a %s object - needs ti be a Math::Complex_C::Long object", h);
- }
- else croak("2nd arg to Rmpc_set_ldc needs to be a Math::Complex_C::Long object");
- return newSViv(mpc_set_ldc(*op, *(INT2PTR(long double _Complex *, SvIV(SvRV(crop)))), (mpc_rnd_t)SvUV(round)));
-#else
- croak("Rmpc_set_ldc() not implemented");
-#endif
-}
-
-SV * _have_Complex_h(void) {
-#ifdef _DO_COMPLEX_H
- return newSVuv(1);
-#else
- return newSVuv(0);
-#endif
-}
-
-SV * _mpfr_buildopt_tls_p(void) {
-#if MPFR_VERSION_MAJOR >= 3
- return newSViv(mpfr_buildopt_tls_p());
-#else
- croak("Math::MPC::_mpfr_buildopt_tls_p not implemented with this version of the mpfr library - we have %s but need at least 3.0.0", MPFR_VERSION_STRING);
-#endif
-}
-
-SV * _get_xs_version(void) {
- return newSVpv(XS_VERSION, 0);
-}
-
-SV * _wrap_count(void) {
- return newSVuv(PL_sv_count);
-}
-
-/* Beginning mpc-1.0, mpc_mul_2si and mpc_div_2si were added */
-
-SV * Rmpc_mul_2si(mpc_t * a, mpc_t * b, SV * c, SV * round) {
-#if MPC_VERSION >= 65536
- return newSViv(mpc_mul_2si(*a, *b, SvUV(c), (mpc_rnd_t)SvUV(round)));
-# else
- croak("mpc_mul_2si not implemented until mpc-1.0. We have version %d", MPC_VERSION);
-#endif
-}
-
-SV * Rmpc_div_2si(mpc_t * a, mpc_t * b, SV * c, SV * round) {
-#if MPC_VERSION >= 65536
- return newSViv(mpc_div_2si(*a, *b, SvUV(c), (mpc_rnd_t)SvUV(round)));
-# else
- croak("mpc_div_2si not implemented until mpc-1.0. We have version %d", MPC_VERSION);
-#endif
-}
-
-SV * Rmpc_log10(mpc_t * rop, mpc_t *op, SV * round) {
-#if MPC_VERSION >= 65536
- return newSViv(mpc_log10(*rop, *op, (mpc_rnd_t)SvUV(round)));
-# else
- croak("mpc_log10 not implemented until mpc-1.0. We have version %d", MPC_VERSION);
-#endif
-}
-
-/* I think the CLONE() function needs to come at the very end ... not sure */
-
-void CLONE(SV * x, ...) {
- MY_CXT_CLONE;
-}
-
-
-
-MODULE = Math::MPC PACKAGE = Math::MPC
-
-PROTOTYPES: DISABLE
-
-
-int
-_mpc_mul_sj (rop, op, i, rnd)
- mpc_ptr rop
- mpc_ptr op
- intmax_t i
- mpc_rnd_t rnd
-
-int
-_mpc_mul_ld (rop, op, i, rnd)
- mpc_ptr rop
- mpc_ptr op
- long double i
- mpc_rnd_t rnd
-
-int
-_mpc_mul_d (rop, op, i, rnd)
- mpc_ptr rop
- mpc_ptr op
- double i
- mpc_rnd_t rnd
-
-int
-_mpc_div_sj (rop, op, i, rnd)
- mpc_ptr rop
- mpc_ptr op
- intmax_t i
- mpc_rnd_t rnd
-
-int
-_mpc_sj_div (rop, i, op, rnd)
- mpc_ptr rop
- intmax_t i
- mpc_ptr op
- mpc_rnd_t rnd
-
-int
-_mpc_div_ld (rop, op, i, rnd)
- mpc_ptr rop
- mpc_ptr op
- long double i
- mpc_rnd_t rnd
-
-int
-_mpc_ld_div (rop, i, op, rnd)
- mpc_ptr rop
- long double i
- mpc_ptr op
- mpc_rnd_t rnd
-
-int
-_mpc_div_d (rop, op, i, rnd)
- mpc_ptr rop
- mpc_ptr op
- double i
- mpc_rnd_t rnd
-
-int
-_mpc_d_div (rop, i, op, rnd)
- mpc_ptr rop
- double i
- mpc_ptr op
- mpc_rnd_t rnd
-
-void
-Rmpc_set_default_rounding_mode (round)
- SV * round
- PREINIT:
- I32* temp;
- PPCODE:
- temp = PL_markstack_ptr++;
- Rmpc_set_default_rounding_mode(round);
- if (PL_markstack_ptr != temp) {
- /* truly void, because dXSARGS not invoked */
- PL_markstack_ptr = temp;
- XSRETURN_EMPTY; /* return empty stack */
- }
- /* must have used dXSARGS; list context implied */
- return; /* assume stack size is correct */
-
-SV *
-Rmpc_get_default_rounding_mode ()
-
-
-void
-Rmpc_set_default_prec (prec)
- SV * prec
- PREINIT:
- I32* temp;
- PPCODE:
- temp = PL_markstack_ptr++;
- Rmpc_set_default_prec(prec);
- if (PL_markstack_ptr != temp) {
- /* truly void, because dXSARGS not invoked */
- PL_markstack_ptr = temp;
- XSRETURN_EMPTY; /* return empty stack */
- }
- /* must have used dXSARGS; list context implied */
- return; /* assume stack size is correct */
-
-void
-Rmpc_set_default_prec2 (prec_re, prec_im)
- SV * prec_re
- SV * prec_im
- PREINIT:
- I32* temp;
- PPCODE:
- temp = PL_markstack_ptr++;
- Rmpc_set_default_prec2(prec_re, prec_im);
- if (PL_markstack_ptr != temp) {
- /* truly void, because dXSARGS not invoked */
- PL_markstack_ptr = temp;
- XSRETURN_EMPTY; /* return empty stack */
- }
- /* must have used dXSARGS; list context implied */
- return; /* assume stack size is correct */
-
-SV *
-Rmpc_get_default_prec ()
-
-
-void
-Rmpc_get_default_prec2 ()
-
- PREINIT:
- I32* temp;
- PPCODE:
- temp = PL_markstack_ptr++;
- Rmpc_get_default_prec2();
- if (PL_markstack_ptr != temp) {
- /* truly void, because dXSARGS not invoked */
- PL_markstack_ptr = temp;
- XSRETURN_EMPTY; /* return empty stack */
- }
- /* must have used dXSARGS; list context implied */
- return; /* assume stack size is correct */
-
-void
-Rmpc_set_prec (p, prec)
- mpc_t * p
- SV * prec
- PREINIT:
- I32* temp;
- PPCODE:
- temp = PL_markstack_ptr++;
- Rmpc_set_prec(p, prec);
- if (PL_markstack_ptr != temp) {
- /* truly void, because dXSARGS not invoked */
- PL_markstack_ptr = temp;
- XSRETURN_EMPTY; /* return empty stack */
- }
- /* must have used dXSARGS; list context implied */
- return; /* assume stack size is correct */
-
-void
-Rmpc_set_re_prec (p, prec)
- mpc_t * p
- SV * prec
- PREINIT:
- I32* temp;
- PPCODE:
- temp = PL_markstack_ptr++;
- Rmpc_set_re_prec(p, prec);
- if (PL_markstack_ptr != temp) {
- /* truly void, because dXSARGS not invoked */
- PL_markstack_ptr = temp;
- XSRETURN_EMPTY; /* return empty stack */
- }
- /* must have used dXSARGS; list context implied */
- return; /* assume stack size is correct */
-
-void
-Rmpc_set_im_prec (p, prec)
- mpc_t * p
- SV * prec
- PREINIT:
- I32* temp;
- PPCODE:
- temp = PL_markstack_ptr++;
- Rmpc_set_im_prec(p, prec);
- if (PL_markstack_ptr != temp) {
- /* truly void, because dXSARGS not invoked */
- PL_markstack_ptr = temp;
- XSRETURN_EMPTY; /* return empty stack */
- }
- /* must have used dXSARGS; list context implied */
- return; /* assume stack size is correct */
-
-SV *
-Rmpc_get_prec (x)
- mpc_t * x
-
-void
-Rmpc_get_prec2 (x)
- mpc_t * x
- PREINIT:
- I32* temp;
- PPCODE:
- temp = PL_markstack_ptr++;
- Rmpc_get_prec2(x);
- if (PL_markstack_ptr != temp) {
- /* truly void, because dXSARGS not invoked */
- PL_markstack_ptr = temp;
- XSRETURN_EMPTY; /* return empty stack */
- }
- /* must have used dXSARGS; list context implied */
- return; /* assume stack size is correct */
-
-SV *
-Rmpc_get_im_prec (x)
- mpc_t * x
-
-SV *
-Rmpc_get_re_prec (x)
- mpc_t * x
-
-void
-RMPC_RE (fr, x)
- mpfr_t * fr
- mpc_t * x
- PREINIT:
- I32* temp;
- PPCODE:
- temp = PL_markstack_ptr++;
- RMPC_RE(fr, x);
- if (PL_markstack_ptr != temp) {
- /* truly void, because dXSARGS not invoked */
- PL_markstack_ptr = temp;
- XSRETURN_EMPTY; /* return empty stack */
- }
- /* must have used dXSARGS; list context implied */
- return; /* assume stack size is correct */
-
-void
-RMPC_IM (fr, x)
- mpfr_t * fr
- mpc_t * x
- PREINIT:
- I32* temp;
- PPCODE:
- temp = PL_markstack_ptr++;
- RMPC_IM(fr, x);
- if (PL_markstack_ptr != temp) {
- /* truly void, because dXSARGS not invoked */
- PL_markstack_ptr = temp;
- XSRETURN_EMPTY; /* return empty stack */
- }
- /* must have used dXSARGS; list context implied */
- return; /* assume stack size is correct */
-
-SV *
-RMPC_INEX_RE (x)
- SV * x
-
-SV *
-RMPC_INEX_IM (x)
- SV * x
-
-void
-DESTROY (p)
- mpc_t * p
- PREINIT:
- I32* temp;
- PPCODE:
- temp = PL_markstack_ptr++;
- DESTROY(p);
- if (PL_markstack_ptr != temp) {
- /* truly void, because dXSARGS not invoked */
- PL_markstack_ptr = temp;
- XSRETURN_EMPTY; /* return empty stack */
- }
- /* must have used dXSARGS; list context implied */
- return; /* assume stack size is correct */
-
-void
-Rmpc_clear (p)
- mpc_t * p
- PREINIT:
- I32* temp;
- PPCODE:
- temp = PL_markstack_ptr++;
- Rmpc_clear(p);
- if (PL_markstack_ptr != temp) {
- /* truly void, because dXSARGS not invoked */
- PL_markstack_ptr = temp;
- XSRETURN_EMPTY; /* return empty stack */
- }
- /* must have used dXSARGS; list context implied */
- return; /* assume stack size is correct */
-
-void
-Rmpc_clear_mpc (p)
- mpc_t * p
- PREINIT:
- I32* temp;
- PPCODE:
- temp = PL_markstack_ptr++;
- Rmpc_clear_mpc(p);
- if (PL_markstack_ptr != temp) {
- /* truly void, because dXSARGS not invoked */
- PL_markstack_ptr = temp;
- XSRETURN_EMPTY; /* return empty stack */
- }
- /* must have used dXSARGS; list context implied */
- return; /* assume stack size is correct */
-
-void
-Rmpc_clear_ptr (p)
- mpc_t * p
- PREINIT:
- I32* temp;
- PPCODE:
- temp = PL_markstack_ptr++;
- Rmpc_clear_ptr(p);
- if (PL_markstack_ptr != temp) {
- /* truly void, because dXSARGS not invoked */
- PL_markstack_ptr = temp;
- XSRETURN_EMPTY; /* return empty stack */
- }
- /* must have used dXSARGS; list context implied */
- return; /* assume stack size is correct */
-
-SV *
-Rmpc_init2 (prec)
- SV * prec
-
-SV *
-Rmpc_init3 (prec_r, prec_i)
- SV * prec_r
- SV * prec_i
-
-SV *
-Rmpc_init2_nobless (prec)
- SV * prec
-
-SV *
-Rmpc_init3_nobless (prec_r, prec_i)
- SV * prec_r
- SV * prec_i
-
-SV *
-Rmpc_set (p, q, round)
- mpc_t * p
- mpc_t * q
- SV * round
-
-SV *
-Rmpc_set_ui (p, q, round)
- mpc_t * p
- SV * q
- SV * round
-
-SV *
-Rmpc_set_si (p, q, round)
- mpc_t * p
- SV * q
- SV * round
-
-SV *
-Rmpc_set_ld (p, q, round)
- mpc_t * p
- SV * q
- SV * round
-
-SV *
-Rmpc_set_uj (p, q, round)
- mpc_t * p
- SV * q
- SV * round
-
-SV *
-Rmpc_set_sj (p, q, round)
- mpc_t * p
- SV * q
- SV * round
-
-SV *
-Rmpc_set_z (p, q, round)
- mpc_t * p
- mpz_t * q
- SV * round
-
-SV *
-Rmpc_set_f (p, q, round)
- mpc_t * p
- mpf_t * q
- SV * round
-
-SV *
-Rmpc_set_q (p, q, round)
- mpc_t * p
- mpq_t * q
- SV * round
-
-SV *
-Rmpc_set_d (p, q, round)
- mpc_t * p
- SV * q
- SV * round
-
-SV *
-Rmpc_set_fr (p, q, round)
- mpc_t * p
- mpfr_t * q
- SV * round
-
-SV *
-Rmpc_set_ui_ui (p, q_r, q_i, round)
- mpc_t * p
- SV * q_r
- SV * q_i
- SV * round
-
-SV *
-Rmpc_set_si_si (p, q_r, q_i, round)
- mpc_t * p
- SV * q_r
- SV * q_i
- SV * round
-
-SV *
-Rmpc_set_d_d (p, q_r, q_i, round)
- mpc_t * p
- SV * q_r
- SV * q_i
- SV * round
-
-SV *
-Rmpc_set_ld_ld (mpc, ld1, ld2, round)
- mpc_t * mpc
- SV * ld1
- SV * ld2
- SV * round
-
-SV *
-Rmpc_set_z_z (p, q_r, q_i, round)
- mpc_t * p
- mpz_t * q_r
- mpz_t * q_i
- SV * round
-
-SV *
-Rmpc_set_q_q (p, q_r, q_i, round)
- mpc_t * p
- mpq_t * q_r
- mpq_t * q_i
- SV * round
-
-SV *
-Rmpc_set_f_f (p, q_r, q_i, round)
- mpc_t * p
- mpf_t * q_r
- mpf_t * q_i
- SV * round
-
-SV *
-Rmpc_set_fr_fr (p, q_r, q_i, round)
- mpc_t * p
- mpfr_t * q_r
- mpfr_t * q_i
- SV * round
-
-int
-Rmpc_set_d_ui (mpc, d, ui, round)
- mpc_t * mpc
- SV * d
- SV * ui
- SV * round
-
-int
-Rmpc_set_d_si (mpc, d, si, round)
- mpc_t * mpc
- SV * d
- SV * si
- SV * round
-
-int
-Rmpc_set_d_fr (mpc, d, mpfr, round)
- mpc_t * mpc
- SV * d
- mpfr_t * mpfr
- SV * round
-
-int
-Rmpc_set_ui_d (mpc, ui, d, round)
- mpc_t * mpc
- SV * ui
- SV * d
- SV * round
-
-int
-Rmpc_set_ui_si (mpc, ui, si, round)
- mpc_t * mpc
- SV * ui
- SV * si
- SV * round
-
-int
-Rmpc_set_ui_fr (mpc, ui, mpfr, round)
- mpc_t * mpc
- SV * ui
- mpfr_t * mpfr
- SV * round
-
-int
-Rmpc_set_si_d (mpc, si, d, round)
- mpc_t * mpc
- SV * si
- SV * d
- SV * round
-
-int
-Rmpc_set_si_ui (mpc, si, ui, round)
- mpc_t * mpc
- SV * si
- SV * ui
- SV * round
-
-int
-Rmpc_set_si_fr (mpc, si, mpfr, round)
- mpc_t * mpc
- SV * si
- mpfr_t * mpfr
- SV * round
-
-int
-Rmpc_set_fr_d (mpc, mpfr, d, round)
- mpc_t * mpc
- mpfr_t * mpfr
- SV * d
- SV * round
-
-int
-Rmpc_set_fr_ui (mpc, mpfr, ui, round)
- mpc_t * mpc
- mpfr_t * mpfr
- SV * ui
- SV * round
-
-int
-Rmpc_set_fr_si (mpc, mpfr, si, round)
- mpc_t * mpc
- mpfr_t * mpfr
- SV * si
- SV * round
-
-int
-Rmpc_set_ld_ui (mpc, d, ui, round)
- mpc_t * mpc
- SV * d
- SV * ui
- SV * round
-
-int
-Rmpc_set_ld_si (mpc, d, si, round)
- mpc_t * mpc
- SV * d
- SV * si
- SV * round
-
-int
-Rmpc_set_ld_fr (mpc, d, mpfr, round)
- mpc_t * mpc
- SV * d
- mpfr_t * mpfr
- SV * round
-
-int
-Rmpc_set_ui_ld (mpc, ui, d, round)
- mpc_t * mpc
- SV * ui
- SV * d
- SV * round
-
-int
-Rmpc_set_si_ld (mpc, si, d, round)
- mpc_t * mpc
- SV * si
- SV * d
- SV * round
-
-int
-Rmpc_set_fr_ld (mpc, mpfr, d, round)
- mpc_t * mpc
- mpfr_t * mpfr
- SV * d
- SV * round
-
-int
-Rmpc_set_d_uj (mpc, d, ui, round)
- mpc_t * mpc
- SV * d
- SV * ui
- SV * round
-
-int
-Rmpc_set_d_sj (mpc, d, si, round)
- mpc_t * mpc
- SV * d
- SV * si
- SV * round
-
-int
-Rmpc_set_sj_d (mpc, si, d, round)
- mpc_t * mpc
- SV * si
- SV * d
- SV * round
-
-int
-Rmpc_set_uj_d (mpc, ui, d, round)
- mpc_t * mpc
- SV * ui
- SV * d
- SV * round
-
-int
-Rmpc_set_uj_fr (mpc, ui, mpfr, round)
- mpc_t * mpc
- SV * ui
- mpfr_t * mpfr
- SV * round
-
-int
-Rmpc_set_sj_fr (mpc, si, mpfr, round)
- mpc_t * mpc
- SV * si
- mpfr_t * mpfr
- SV * round
-
-int
-Rmpc_set_fr_uj (mpc, mpfr, ui, round)
- mpc_t * mpc
- mpfr_t * mpfr
- SV * ui
- SV * round
-
-int
-Rmpc_set_fr_sj (mpc, mpfr, si, round)
- mpc_t * mpc
- mpfr_t * mpfr
- SV * si
- SV * round
-
-int
-Rmpc_set_uj_sj (mpc, ui, si, round)
- mpc_t * mpc
- SV * ui
- SV * si
- SV * round
-
-int
-Rmpc_set_sj_uj (mpc, si, ui, round)
- mpc_t * mpc
- SV * si
- SV * ui
- SV * round
-
-int
-Rmpc_set_ld_uj (mpc, d, ui, round)
- mpc_t * mpc
- SV * d
- SV * ui
- SV * round
-
-int
-Rmpc_set_ld_sj (mpc, d, si, round)
- mpc_t * mpc
- SV * d
- SV * si
- SV * round
-
-int
-Rmpc_set_uj_ld (mpc, ui, d, round)
- mpc_t * mpc
- SV * ui
- SV * d
- SV * round
-
-int
-Rmpc_set_sj_ld (mpc, si, d, round)
- mpc_t * mpc
- SV * si
- SV * d
- SV * round
-
-int
-Rmpc_set_f_ui (mpc, mpf, ui, round)
- mpc_t * mpc
- mpf_t * mpf
- SV * ui
- SV * round
-
-int
-Rmpc_set_q_ui (mpc, mpq, ui, round)
- mpc_t * mpc
- mpq_t * mpq
- SV * ui
- SV * round
-
-int
-Rmpc_set_z_ui (mpc, mpz, ui, round)
- mpc_t * mpc
- mpz_t * mpz
- SV * ui
- SV * round
-
-int
-Rmpc_set_f_si (mpc, mpf, si, round)
- mpc_t * mpc
- mpf_t * mpf
- SV * si
- SV * round
-
-int
-Rmpc_set_q_si (mpc, mpq, si, round)
- mpc_t * mpc
- mpq_t * mpq
- SV * si
- SV * round
-
-int
-Rmpc_set_z_si (mpc, mpz, si, round)
- mpc_t * mpc
- mpz_t * mpz
- SV * si
- SV * round
-
-int
-Rmpc_set_f_d (mpc, mpf, d, round)
- mpc_t * mpc
- mpf_t * mpf
- SV * d
- SV * round
-
-int
-Rmpc_set_q_d (mpc, mpq, d, round)
- mpc_t * mpc
- mpq_t * mpq
- SV * d
- SV * round
-
-int
-Rmpc_set_z_d (mpc, mpz, d, round)
- mpc_t * mpc
- mpz_t * mpz
- SV * d
- SV * round
-
-int
-Rmpc_set_f_uj (mpc, mpf, uj, round)
- mpc_t * mpc
- mpf_t * mpf
- SV * uj
- SV * round
-
-int
-Rmpc_set_q_uj (mpc, mpq, uj, round)
- mpc_t * mpc
- mpq_t * mpq
- SV * uj
- SV * round
-
-int
-Rmpc_set_z_uj (mpc, mpz, uj, round)
- mpc_t * mpc
- mpz_t * mpz
- SV * uj
- SV * round
-
-int
-Rmpc_set_f_sj (mpc, mpf, sj, round)
- mpc_t * mpc
- mpf_t * mpf
- SV * sj
- SV * round
-
-int
-Rmpc_set_q_sj (mpc, mpq, sj, round)
- mpc_t * mpc
- mpq_t * mpq
- SV * sj
- SV * round
-
-int
-Rmpc_set_z_sj (mpc, mpz, sj, round)
- mpc_t * mpc
- mpz_t * mpz
- SV * sj
- SV * round
-
-int
-Rmpc_set_f_ld (mpc, mpf, ld, round)
- mpc_t * mpc
- mpf_t * mpf
- SV * ld
- SV * round
-
-int
-Rmpc_set_q_ld (mpc, mpq, ld, round)
- mpc_t * mpc
- mpq_t * mpq
- SV * ld
- SV * round
-
-int
-Rmpc_set_z_ld (mpc, mpz, ld, round)
- mpc_t * mpc
- mpz_t * mpz
- SV * ld
- SV * round
-
-int
-Rmpc_set_ui_f (mpc, ui, mpf, round)
- mpc_t * mpc
- SV * ui
- mpf_t * mpf
- SV * round
-
-int
-Rmpc_set_ui_q (mpc, ui, mpq, round)
- mpc_t * mpc
- SV * ui
- mpq_t * mpq
- SV * round
-
-int
-Rmpc_set_ui_z (mpc, ui, mpz, round)
- mpc_t * mpc
- SV * ui
- mpz_t * mpz
- SV * round
-
-int
-Rmpc_set_si_f (mpc, si, mpf, round)
- mpc_t * mpc
- SV * si
- mpf_t * mpf
- SV * round
-
-int
-Rmpc_set_si_q (mpc, si, mpq, round)
- mpc_t * mpc
- SV * si
- mpq_t * mpq
- SV * round
-
-int
-Rmpc_set_si_z (mpc, si, mpz, round)
- mpc_t * mpc
- SV * si
- mpz_t * mpz
- SV * round
-
-int
-Rmpc_set_d_f (mpc, d, mpf, round)
- mpc_t * mpc
- SV * d
- mpf_t * mpf
- SV * round
-
-int
-Rmpc_set_d_q (mpc, d, mpq, round)
- mpc_t * mpc
- SV * d
- mpq_t * mpq
- SV * round
-
-int
-Rmpc_set_d_z (mpc, d, mpz, round)
- mpc_t * mpc
- SV * d
- mpz_t * mpz
- SV * round
-
-int
-Rmpc_set_uj_f (mpc, uj, mpf, round)
- mpc_t * mpc
- SV * uj
- mpf_t * mpf
- SV * round
-
-int
-Rmpc_set_uj_q (mpc, uj, mpq, round)
- mpc_t * mpc
- SV * uj
- mpq_t * mpq
- SV * round
-
-int
-Rmpc_set_uj_z (mpc, uj, mpz, round)
- mpc_t * mpc
- SV * uj
- mpz_t * mpz
- SV * round
-
-int
-Rmpc_set_sj_f (mpc, sj, mpf, round)
- mpc_t * mpc
- SV * sj
- mpf_t * mpf
- SV * round
-
-int
-Rmpc_set_sj_q (mpc, sj, mpq, round)
- mpc_t * mpc
- SV * sj
- mpq_t * mpq
- SV * round
-
-int
-Rmpc_set_sj_z (mpc, sj, mpz, round)
- mpc_t * mpc
- SV * sj
- mpz_t * mpz
- SV * round
-
-int
-Rmpc_set_ld_f (mpc, ld, mpf, round)
- mpc_t * mpc
- SV * ld
- mpf_t * mpf
- SV * round
-
-int
-Rmpc_set_ld_q (mpc, ld, mpq, round)
- mpc_t * mpc
- SV * ld
- mpq_t * mpq
- SV * round
-
-int
-Rmpc_set_ld_z (mpc, ld, mpz, round)
- mpc_t * mpc
- SV * ld
- mpz_t * mpz
- SV * round
-
-int
-Rmpc_set_f_q (mpc, mpf, mpq, round)
- mpc_t * mpc
- mpf_t * mpf
- mpq_t * mpq
- SV * round
-
-int
-Rmpc_set_q_f (mpc, mpq, mpf, round)
- mpc_t * mpc
- mpq_t * mpq
- mpf_t * mpf
- SV * round
-
-int
-Rmpc_set_f_z (mpc, mpf, mpz, round)
- mpc_t * mpc
- mpf_t * mpf
- mpz_t * mpz
- SV * round
-
-int
-Rmpc_set_z_f (mpc, mpz, mpf, round)
- mpc_t * mpc
- mpz_t * mpz
- mpf_t * mpf
- SV * round
-
-int
-Rmpc_set_q_z (mpc, mpq, mpz, round)
- mpc_t * mpc
- mpq_t * mpq
- mpz_t * mpz
- SV * round
-
-int
-Rmpc_set_z_q (mpc, mpz, mpq, round)
- mpc_t * mpc
- mpz_t * mpz
- mpq_t * mpq
- SV * round
-
-int
-Rmpc_set_f_fr (mpc, mpf, mpfr, round)
- mpc_t * mpc
- mpf_t * mpf
- mpfr_t * mpfr
- SV * round
-
-int
-Rmpc_set_fr_f (mpc, mpfr, mpf, round)
- mpc_t * mpc
- mpfr_t * mpfr
- mpf_t * mpf
- SV * round
-
-int
-Rmpc_set_q_fr (mpc, mpq, mpfr, round)
- mpc_t * mpc
- mpq_t * mpq
- mpfr_t * mpfr
- SV * round
-
-int
-Rmpc_set_fr_q (mpc, mpfr, mpq, round)
- mpc_t * mpc
- mpfr_t * mpfr
- mpq_t * mpq
- SV * round
-
-int
-Rmpc_set_z_fr (mpc, mpz, mpfr, round)
- mpc_t * mpc
- mpz_t * mpz
- mpfr_t * mpfr
- SV * round
-
-int
-Rmpc_set_fr_z (mpc, mpfr, mpz, round)
- mpc_t * mpc
- mpfr_t * mpfr
- mpz_t * mpz
- SV * round
-
-SV *
-Rmpc_set_uj_uj (mpc, uj1, uj2, round)
- mpc_t * mpc
- SV * uj1
- SV * uj2
- SV * round
-
-SV *
-Rmpc_set_sj_sj (mpc, sj1, sj2, round)
- mpc_t * mpc
- SV * sj1
- SV * sj2
- SV * round
-
-SV *
-Rmpc_add (a, b, c, round)
- mpc_t * a
- mpc_t * b
- mpc_t * c
- SV * round
-
-SV *
-Rmpc_add_ui (a, b, c, round)
- mpc_t * a
- mpc_t * b
- SV * c
- SV * round
-
-SV *
-Rmpc_add_fr (a, b, c, round)
- mpc_t * a
- mpc_t * b
- mpfr_t * c
- SV * round
-
-SV *
-Rmpc_sub (a, b, c, round)
- mpc_t * a
- mpc_t * b
- mpc_t * c
- SV * round
-
-SV *
-Rmpc_sub_ui (a, b, c, round)
- mpc_t * a
- mpc_t * b
- SV * c
- SV * round
-
-SV *
-Rmpc_ui_sub (a, b, c, round)
- mpc_t * a
- SV * b
- mpc_t * c
- SV * round
-
-SV *
-Rmpc_ui_ui_sub (a, b_r, b_i, c, round)
- mpc_t * a
- SV * b_r
- SV * b_i
- mpc_t * c
- SV * round
-
-SV *
-Rmpc_mul (a, b, c, round)
- mpc_t * a
- mpc_t * b
- mpc_t * c
- SV * round
-
-SV *
-Rmpc_mul_ui (a, b, c, round)
- mpc_t * a
- mpc_t * b
- SV * c
- SV * round
-
-SV *
-Rmpc_mul_si (a, b, c, round)
- mpc_t * a
- mpc_t * b
- SV * c
- SV * round
-
-SV *
-Rmpc_mul_fr (a, b, c, round)
- mpc_t * a
- mpc_t * b
- mpfr_t * c
- SV * round
-
-SV *
-Rmpc_mul_i (a, b, sign, round)
- mpc_t * a
- mpc_t * b
- SV * sign
- SV * round
-
-SV *
-Rmpc_sqr (a, b, round)
- mpc_t * a
- mpc_t * b
- SV * round
-
-SV *
-Rmpc_div (a, b, c, round)
- mpc_t * a
- mpc_t * b
- mpc_t * c
- SV * round
-
-SV *
-Rmpc_div_ui (a, b, c, round)
- mpc_t * a
- mpc_t * b
- SV * c
- SV * round
-
-SV *
-Rmpc_ui_div (a, b, c, round)
- mpc_t * a
- SV * b
- mpc_t * c
- SV * round
-
-SV *
-Rmpc_div_fr (a, b, c, round)
- mpc_t * a
- mpc_t * b
- mpfr_t * c
- SV * round
-
-SV *
-Rmpc_sqrt (a, b, round)
- mpc_t * a
- mpc_t * b
- SV * round
-
-SV *
-Rmpc_pow (a, b, pow, round)
- mpc_t * a
- mpc_t * b
- mpc_t * pow
- SV * round
-
-SV *
-Rmpc_pow_d (a, b, pow, round)
- mpc_t * a
- mpc_t * b
- SV * pow
- SV * round
-
-SV *
-Rmpc_pow_ld (a, b, pow, round)
- mpc_t * a
- mpc_t * b
- SV * pow
- SV * round
-
-SV *
-Rmpc_pow_si (a, b, pow, round)
- mpc_t * a
- mpc_t * b
- SV * pow
- SV * round
-
-SV *
-Rmpc_pow_ui (a, b, pow, round)
- mpc_t * a
- mpc_t * b
- SV * pow
- SV * round
-
-SV *
-Rmpc_pow_z (a, b, pow, round)
- mpc_t * a
- mpc_t * b
- mpz_t * pow
- SV * round
-
-SV *
-Rmpc_pow_fr (a, b, pow, round)
- mpc_t * a
- mpc_t * b
- mpfr_t * pow
- SV * round
-
-SV *
-Rmpc_neg (a, b, round)
- mpc_t * a
- mpc_t * b
- SV * round
-
-SV *
-Rmpc_abs (a, b, round)
- mpfr_t * a
- mpc_t * b
- SV * round
-
-SV *
-Rmpc_conj (a, b, round)
- mpc_t * a
- mpc_t * b
- SV * round
-
-SV *
-Rmpc_norm (a, b, round)
- mpfr_t * a
- mpc_t * b
- SV * round
-
-SV *
-Rmpc_mul_2ui (a, b, c, round)
- mpc_t * a
- mpc_t * b
- SV * c
- SV * round
-
-SV *
-Rmpc_div_2ui (a, b, c, round)
- mpc_t * a
- mpc_t * b
- SV * c
- SV * round
-
-SV *
-Rmpc_cmp (a, b)
- mpc_t * a
- mpc_t * b
-
-SV *
-Rmpc_cmp_si (a, b)
- mpc_t * a
- SV * b
-
-SV *
-Rmpc_cmp_si_si (a, b, c)
- mpc_t * a
- SV * b
- SV * c
-
-SV *
-Rmpc_exp (a, b, round)
- mpc_t * a
- mpc_t * b
- SV * round
-
-SV *
-Rmpc_log (rop, op, round)
- mpc_t * rop
- mpc_t * op
- SV * round
-
-SV *
-_Rmpc_out_str (stream, base, dig, p, round)
- FILE * stream
- SV * base
- SV * dig
- mpc_t * p
- SV * round
-
-SV *
-_Rmpc_out_strS (stream, base, dig, p, round, suff)
- FILE * stream
- SV * base
- SV * dig
- mpc_t * p
- SV * round
- SV * suff
-
-SV *
-_Rmpc_out_strP (pre, stream, base, dig, p, round)
- SV * pre
- FILE * stream
- SV * base
- SV * dig
- mpc_t * p
- SV * round
-
-SV *
-_Rmpc_out_strPS (pre, stream, base, dig, p, round, suff)
- SV * pre
- FILE * stream
- SV * base
- SV * dig
- mpc_t * p
- SV * round
- SV * suff
-
-SV *
-Rmpc_inp_str (p, stream, base, round)
- mpc_t * p
- FILE * stream
- SV * base
- SV * round
-
-SV *
-Rmpc_sin (rop, op, round)
- mpc_t * rop
- mpc_t * op
- SV * round
-
-SV *
-Rmpc_cos (rop, op, round)
- mpc_t * rop
- mpc_t * op
- SV * round
-
-SV *
-Rmpc_tan (rop, op, round)
- mpc_t * rop
- mpc_t * op
- SV * round
-
-SV *
-Rmpc_sinh (rop, op, round)
- mpc_t * rop
- mpc_t * op
- SV * round
-
-SV *
-Rmpc_cosh (rop, op, round)
- mpc_t * rop
- mpc_t * op
- SV * round
-
-SV *
-Rmpc_tanh (rop, op, round)
- mpc_t * rop
- mpc_t * op
- SV * round
-
-SV *
-Rmpc_asin (rop, op, round)
- mpc_t * rop
- mpc_t * op
- SV * round
-
-SV *
-Rmpc_acos (rop, op, round)
- mpc_t * rop
- mpc_t * op
- SV * round
-
-SV *
-Rmpc_atan (rop, op, round)
- mpc_t * rop
- mpc_t * op
- SV * round
-
-SV *
-Rmpc_asinh (rop, op, round)
- mpc_t * rop
- mpc_t * op
- SV * round
-
-SV *
-Rmpc_acosh (rop, op, round)
- mpc_t * rop
- mpc_t * op
- SV * round
-
-SV *
-Rmpc_atanh (rop, op, round)
- mpc_t * rop
- mpc_t * op
- SV * round
-
-SV *
-overload_true (a, second, third)
- mpc_t * a
- SV * second
- SV * third
-
-SV *
-overload_mul (a, b, third)
- mpc_t * a
- SV * b
- SV * third
-
-SV *
-overload_add (a, b, third)
- mpc_t * a
- SV * b
- SV * third
-
-SV *
-overload_sub (a, b, third)
- mpc_t * a
- SV * b
- SV * third
-
-SV *
-overload_div (a, b, third)
- mpc_t * a
- SV * b
- SV * third
-
-SV *
-overload_div_eq (a, b, third)
- SV * a
- SV * b
- SV * third
-
-SV *
-overload_sub_eq (a, b, third)
- SV * a
- SV * b
- SV * third
-
-SV *
-overload_add_eq (a, b, third)
- SV * a
- SV * b
- SV * third
-
-SV *
-overload_mul_eq (a, b, third)
- SV * a
- SV * b
- SV * third
-
-SV *
-overload_pow (a, b, third)
- mpc_t * a
- SV * b
- SV * third
-
-SV *
-overload_pow_eq (a, b, third)
- SV * a
- SV * b
- SV * third
-
-SV *
-overload_equiv (a, b, third)
- mpc_t * a
- SV * b
- SV * third
-
-SV *
-overload_not_equiv (a, b, third)
- mpc_t * a
- SV * b
- SV * third
-
-SV *
-overload_not (a, second, third)
- mpc_t * a
- SV * second
- SV * third
-
-SV *
-overload_sqrt (p, second, third)
- mpc_t * p
- SV * second
- SV * third
-
-void
-overload_copy (p, second, third)
- mpc_t * p
- SV * second
- SV * third
- PREINIT:
- I32* temp;
- PPCODE:
- temp = PL_markstack_ptr++;
- overload_copy(p, second, third);
- if (PL_markstack_ptr != temp) {
- /* truly void, because dXSARGS not invoked */
- PL_markstack_ptr = temp;
- XSRETURN_EMPTY; /* return empty stack */
- }
- /* must have used dXSARGS; list context implied */
- return; /* assume stack size is correct */
-
-SV *
-overload_abs (p, second, third)
- mpc_t * p
- SV * second
- SV * third
-
-SV *
-overload_exp (p, second, third)
- mpc_t * p
- SV * second
- SV * third
-
-SV *
-overload_log (p, second, third)
- mpc_t * p
- SV * second
- SV * third
-
-SV *
-overload_sin (p, second, third)
- mpc_t * p
- SV * second
- SV * third
-
-SV *
-overload_cos (p, second, third)
- mpc_t * p
- SV * second
- SV * third
-
-void
-_get_r_string (p, base, n_digits, round)
- mpc_t * p
- SV * base
- SV * n_digits
- SV * round
- PREINIT:
- I32* temp;
- PPCODE:
- temp = PL_markstack_ptr++;
- _get_r_string(p, base, n_digits, round);
- if (PL_markstack_ptr != temp) {
- /* truly void, because dXSARGS not invoked */
- PL_markstack_ptr = temp;
- XSRETURN_EMPTY; /* return empty stack */
- }
- /* must have used dXSARGS; list context implied */
- return; /* assume stack size is correct */
-
-void
-_get_i_string (p, base, n_digits, round)
- mpc_t * p
- SV * base
- SV * n_digits
- SV * round
- PREINIT:
- I32* temp;
- PPCODE:
- temp = PL_markstack_ptr++;
- _get_i_string(p, base, n_digits, round);
- if (PL_markstack_ptr != temp) {
- /* truly void, because dXSARGS not invoked */
- PL_markstack_ptr = temp;
- XSRETURN_EMPTY; /* return empty stack */
- }
- /* must have used dXSARGS; list context implied */
- return; /* assume stack size is correct */
-
-SV *
-_itsa (a)
- SV * a
-
-SV *
-_new_real (b)
- SV * b
-
-SV *
-_new_im (b)
- SV * b
-
-int
-_has_longlong ()
-
-
-int
-_has_longdouble ()
-
-
-int
-_has_inttypes ()
-
-
-SV *
-gmp_v ()
-
-
-SV *
-mpfr_v ()
-
-
-SV *
-_MPC_VERSION_MAJOR ()
-
-
-SV *
-_MPC_VERSION_MINOR ()
-
-
-SV *
-_MPC_VERSION_PATCHLEVEL ()
-
-
-SV *
-_MPC_VERSION ()
-
-
-SV *
-_MPC_VERSION_NUM (x, y, z)
- SV * x
- SV * y
- SV * z
-
-SV *
-_MPC_VERSION_STRING ()
-
-
-SV *
-Rmpc_get_version ()
-
-
-SV *
-Rmpc_real (rop, op, round)
- mpfr_t * rop
- mpc_t * op
- SV * round
-
-SV *
-Rmpc_imag (rop, op, round)
- mpfr_t * rop
- mpc_t * op
- SV * round
-
-SV *
-Rmpc_arg (rop, op, round)
- mpfr_t * rop
- mpc_t * op
- SV * round
-
-SV *
-Rmpc_proj (rop, op, round)
- mpc_t * rop
- mpc_t * op
- SV * round
-
-SV *
-Rmpc_get_str (base, dig, op, round)
- SV * base
- SV * dig
- mpc_t * op
- SV * round
-
-SV *
-Rmpc_set_str (rop, str, base, round)
- mpc_t * rop
- SV * str
- SV * base
- SV * round
-
-SV *
-Rmpc_strtoc (rop, str, base, round)
- mpc_t * rop
- SV * str
- SV * base
- SV * round
-
-void
-Rmpc_set_nan (a)
- mpc_t * a
- PREINIT:
- I32* temp;
- PPCODE:
- temp = PL_markstack_ptr++;
- Rmpc_set_nan(a);
- if (PL_markstack_ptr != temp) {
- /* truly void, because dXSARGS not invoked */
- PL_markstack_ptr = temp;
- XSRETURN_EMPTY; /* return empty stack */
- }
- /* must have used dXSARGS; list context implied */
- return; /* assume stack size is correct */
-
-void
-Rmpc_swap (a, b)
- mpc_t * a
- mpc_t * b
- PREINIT:
- I32* temp;
- PPCODE:
- temp = PL_markstack_ptr++;
- Rmpc_swap(a, b);
- if (PL_markstack_ptr != temp) {
- /* truly void, because dXSARGS not invoked */
- PL_markstack_ptr = temp;
- XSRETURN_EMPTY; /* return empty stack */
- }
- /* must have used dXSARGS; list context implied */
- return; /* assume stack size is correct */
-
-SV *
-overload_atan2 (p, q, third)
- mpc_t * p
- mpc_t * q
- SV * third
-
-SV *
-Rmpc_sin_cos (rop_sin, rop_cos, op, rnd_sin, rnd_cos)
- mpc_t * rop_sin
- mpc_t * rop_cos
- mpc_t * op
- SV * rnd_sin
- SV * rnd_cos
-
-void
-Rmpc_get_dc (crop, op, round)
- SV * crop
- mpc_t * op
- SV * round
- PREINIT:
- I32* temp;
- PPCODE:
- temp = PL_markstack_ptr++;
- Rmpc_get_dc(crop, op, round);
- if (PL_markstack_ptr != temp) {
- /* truly void, because dXSARGS not invoked */
- PL_markstack_ptr = temp;
- XSRETURN_EMPTY; /* return empty stack */
- }
- /* must have used dXSARGS; list context implied */
- return; /* assume stack size is correct */
-
-void
-Rmpc_get_ldc (crop, op, round)
- SV * crop
- mpc_t * op
- SV * round
- PREINIT:
- I32* temp;
- PPCODE:
- temp = PL_markstack_ptr++;
- Rmpc_get_ldc(crop, op, round);
- if (PL_markstack_ptr != temp) {
- /* truly void, because dXSARGS not invoked */
- PL_markstack_ptr = temp;
- XSRETURN_EMPTY; /* return empty stack */
- }
- /* must have used dXSARGS; list context implied */
- return; /* assume stack size is correct */
-
-SV *
-Rmpc_set_dc (op, crop, round)
- mpc_t * op
- SV * crop
- SV * round
-
-SV *
-Rmpc_set_ldc (op, crop, round)
- mpc_t * op
- SV * crop
- SV * round
-
-SV *
-_have_Complex_h ()
-
-
-SV *
-_mpfr_buildopt_tls_p ()
-
-
-SV *
-_get_xs_version ()
-
-
-SV *
-_wrap_count ()
-
-
-SV *
-Rmpc_mul_2si (a, b, c, round)
- mpc_t * a
- mpc_t * b
- SV * c
- SV * round
-
-SV *
-Rmpc_div_2si (a, b, c, round)
- mpc_t * a
- mpc_t * b
- SV * c
- SV * round
-
-SV *
-Rmpc_log10 (rop, op, round)
- mpc_t * rop
- mpc_t * op
- SV * round
-
-void
-CLONE (x, ...)
- SV * x
- PREINIT:
- I32* temp;
- PPCODE:
- temp = PL_markstack_ptr++;
- CLONE(x);
- if (PL_markstack_ptr != temp) {
- /* truly void, because dXSARGS not invoked */
- PL_markstack_ptr = temp;
- XSRETURN_EMPTY; /* return empty stack */
- }
- /* must have used dXSARGS; list context implied */
- return; /* assume stack size is correct */
-
-BOOT:
-
- {
- MY_CXT_INIT;
- MY_CXT._perl_default_prec_re = 53;
- MY_CXT._perl_default_prec_im = 53;
- MY_CXT._perl_default_rounding_mode = 0;
- }
-
+
+#ifdef __MINGW32__
+#ifndef __USE_MINGW_ANSI_STDIO
+#define __USE_MINGW_ANSI_STDIO 1
+#endif
+#endif
+
+#define PERL_NO_GET_CONTEXT 1
+
+#include "EXTERN.h"
+#include "perl.h"
+#include "XSUB.h"
+
+#include <stdio.h>
+
+#ifndef _MSC_VER
+#include <inttypes.h>
+#include <limits.h>
+#ifdef _DO_COMPLEX_H
+#include <complex.h>
+#endif
+#endif
+
+#include <gmp.h>
+#include <mpfr.h>
+#include <mpc.h>
+
+#ifndef _MPC_H_HAVE_COMPLEX
+#ifndef _Complex_I
+#undef _DO_COMPLEX_H
+#endif
+#endif
+
+#ifdef _MSC_VER
+#pragma warning(disable:4700 4715 4716)
+#define intmax_t __int64
+#endif
+
+#ifdef OLDPERL
+#define SvUOK SvIsUV
+#endif
+
+#ifndef Newx
+# define Newx(v,n,t) New(0,v,n,t)
+#endif
+
+#ifndef Newxz
+# define Newxz(v,n,t) Newz(0,v,n,t)
+#endif
+
+#if MPC_VERSION_MAJOR > 0 || MPC_VERSION_MINOR > 8
+#define SIN_COS_AVAILABLE 1
+#endif
+
+#define MPC_RE(x) ((x)->re)
+#define MPC_IM(x) ((x)->im)
+
+#define VOID_MPC_SET_X_Y(real_t, imag_t, z, real_value, imag_value, rnd) \
+ { \
+ int _inex_re, _inex_im; \
+ _inex_re = (mpfr_set_ ## real_t) (MPC_RE (z), (real_value), MPC_RND_RE (rnd)); \
+ _inex_im = (mpfr_set_ ## imag_t) (MPC_IM (z), (imag_value), MPC_RND_IM (rnd)); \
+ }
+
+#define SV_MPC_SET_X_Y(real_t, imag_t, z, real_value, imag_value, rnd) \
+ { \
+ int _inex_re, _inex_im; \
+ _inex_re = (mpfr_set_ ## real_t) (mpc_realref (z), (real_value), MPC_RND_RE (rnd)); \
+ _inex_im = (mpfr_set_ ## imag_t) (mpc_imagref (z), (imag_value), MPC_RND_IM (rnd)); \
+ return newSViv(MPC_INEX (_inex_re, _inex_im)); \
+ }
+
+#define MY_CXT_KEY "Math::MPC::_guts" XS_VERSION
+
+typedef struct {
+ mp_prec_t _perl_default_prec_re;
+ mp_prec_t _perl_default_prec_im;
+ mpc_rnd_t _perl_default_rounding_mode;
+} my_cxt_t;
+
+START_MY_CXT
+
+#define DEFAULT_PREC MY_CXT._perl_default_prec_re,MY_CXT._perl_default_prec_im
+#define DEFAULT_PREC_RE MY_CXT._perl_default_prec_re
+#define DEFAULT_PREC_IM MY_CXT._perl_default_prec_im
+#define DEFAULT_ROUNDING_MODE MY_CXT._perl_default_rounding_mode
+
+/* These (CXT) values set at boot ... MPC_RNDNN == 0 */
+/*
+mpc_rnd_t _perl_default_rounding_mode = MPC_RNDNN;
+mp_prec_t _perl_default_prec_re = 53;
+mp_prec_t _perl_default_prec_im = 53;
+*/
+
+
+
+/* This function is used by overload_mul and overload_mul_eq whenn */
+/* USE_64_BIT_INT is defined. */
+/* It is based on some code posted by Philippe Theveny. */
+
+int _mpc_mul_sj (mpc_ptr rop, mpc_ptr op, intmax_t i, mpc_rnd_t rnd) {
+
+#ifdef USE_64_BIT_INT
+
+ mpfr_t x;
+ int inex;
+
+ mpfr_init2 (x, sizeof(intmax_t) * CHAR_BIT);
+ mpfr_set_sj (x, i, GMP_RNDN);
+
+ inex = mpc_mul_fr (rop, op, x, rnd);
+
+ mpfr_clear (x);
+ return inex;
+}
+
+#else
+
+ croak("_mpc_mul_sj not implememnted on this build of perl");
+}
+
+#endif
+
+
+/* This function is used by overload_mul and overload_mul_eq whenn */
+/* USE_LONG_DOUBLE is defined. */
+/* It is based on some code posted by Philippe Theveny. */
+
+int _mpc_mul_ld (mpc_ptr rop, mpc_ptr op, long double i, mpc_rnd_t rnd) {
+
+#ifdef USE_LONG_DOUBLE
+
+ mpfr_t x;
+ int inex;
+
+ mpfr_init2 (x, sizeof(long double) * CHAR_BIT);
+ mpfr_set_ld (x, i, GMP_RNDN);
+
+ inex = mpc_mul_fr (rop, op, x, rnd);
+
+ mpfr_clear (x);
+ return inex;
+}
+
+#else
+
+ croak("_mpc_mul_ld not implememnted on this build of perl");
+}
+
+#endif
+
+
+/* This function is used by overload_mul and overload_mul_eq. */
+/* It is based on some code posted by Philippe Theveny. */
+
+int _mpc_mul_d (mpc_ptr rop, mpc_ptr op, double i, mpc_rnd_t rnd) {
+ mpfr_t x;
+ int inex;
+
+ mpfr_init2 (x, sizeof(double) * CHAR_BIT);
+ mpfr_set_d (x, i, GMP_RNDN);
+
+ inex = mpc_mul_fr (rop, op, x, rnd);
+
+ mpfr_clear (x);
+ return inex;
+}
+
+
+/* This function is used by overload_div and overload_div_eq whenn */
+/* USE_64_BIT_INT is defined. */
+/* It is based on some code posted by Philippe Theveny. */
+
+int _mpc_div_sj (mpc_ptr rop, mpc_ptr op, intmax_t i, mpc_rnd_t rnd) {
+
+#ifdef USE_64_BIT_INT
+
+ mpfr_t x;
+ int inex;
+
+ mpfr_init2 (x, sizeof(intmax_t) * CHAR_BIT);
+ mpfr_set_sj (x, i, GMP_RNDN);
+
+ inex = mpc_div_fr (rop, op, x, rnd);
+
+ mpfr_clear (x);
+ return inex;
+}
+
+#else
+
+ croak("_mpc_div_sj not implememnted on this build of perl");
+}
+
+#endif
+
+
+/* This function is used by overload_div and overload_div_eq whenn */
+/* USE_64_BIT_INT is defined. */
+/* It is based on some code posted by Philippe Theveny. */
+
+int _mpc_sj_div (mpc_ptr rop, intmax_t i, mpc_ptr op, mpc_rnd_t rnd) {
+
+#ifdef USE_64_BIT_INT
+
+ mpfr_t x;
+ int inex;
+
+ mpfr_init2 (x, sizeof(intmax_t) * CHAR_BIT);
+ mpfr_set_sj (x, i, GMP_RNDN);
+
+ inex = mpc_fr_div (rop, x, op, rnd);
+
+ mpfr_clear (x);
+ return inex;
+}
+
+#else
+
+ croak("_mpc_sj_div not implememnted on this build of perl");
+}
+
+#endif
+
+
+/* This function is used by overload_div and overload_div_eq whenn */
+/* USE_LONG_DOUBLE is defined. */
+/* It is based on some code posted by Philippe Theveny. */
+
+int _mpc_div_ld (mpc_ptr rop, mpc_ptr op, long double i, mpc_rnd_t rnd) {
+
+#ifdef USE_LONG_DOUBLE
+
+ mpfr_t x;
+ int inex;
+
+ mpfr_init2 (x, sizeof(long double) * CHAR_BIT);
+ mpfr_set_ld (x, i, GMP_RNDN);
+
+ inex = mpc_div_fr (rop, op, x, rnd);
+
+ mpfr_clear (x);
+ return inex;
+}
+
+#else
+
+ croak("_mpc_div_ld not implememnted on this build of perl");
+}
+
+#endif
+
+
+/* This function is used by overload_div and overload_div_eq whenn */
+/* USE_LONG_DOUBLE is defined. */
+/* It is based on some code posted by Philippe Theveny. */
+
+int _mpc_ld_div (mpc_ptr rop, long double i, mpc_ptr op, mpc_rnd_t rnd) {
+
+#ifdef USE_LONG_DOUBLE
+
+ mpfr_t x;
+ int inex;
+
+ mpfr_init2 (x, sizeof(long double) * CHAR_BIT);
+ mpfr_set_ld (x, i, GMP_RNDN);
+
+ inex = mpc_fr_div (rop, x, op, rnd);
+
+ mpfr_clear (x);
+ return inex;
+}
+
+#else
+
+ croak("_mpc_ld_div not implememnted on this build of perl");
+}
+
+#endif
+
+/* This function is used by overload_div and overload_div_eq. */
+/* It is based on some code posted by Philippe Theveny. */
+int _mpc_div_d (mpc_ptr rop, mpc_ptr op, double i, mpc_rnd_t rnd) {
+ mpfr_t x;
+ int inex;
+
+ mpfr_init2 (x, sizeof(double) * CHAR_BIT);
+ mpfr_set_d (x, i, GMP_RNDN);
+
+ inex = mpc_div_fr (rop, op, x, rnd);
+
+ mpfr_clear (x);
+ return inex;
+}
+
+
+/* This function is used by overload_div and overload_div_eq. */
+/* It is based on some code posted by Philippe Theveny. */
+int _mpc_d_div (mpc_ptr rop, double i, mpc_ptr op, mpc_rnd_t rnd) {
+ mpfr_t x;
+ int inex;
+
+ mpfr_init2 (x, sizeof(double) * CHAR_BIT);
+ mpfr_set_d (x, i, GMP_RNDN);
+
+ inex = mpc_fr_div (rop, x, op, rnd);
+
+ mpfr_clear (x);
+ return inex;
+}
+
+void Rmpc_set_default_rounding_mode(pTHX_ SV * round) {
+ dMY_CXT;
+ DEFAULT_ROUNDING_MODE = (mpc_rnd_t)SvUV(round);
+}
+
+SV * Rmpc_get_default_rounding_mode(pTHX) {
+ dMY_CXT;
+ return newSVuv(DEFAULT_ROUNDING_MODE);
+}
+
+void Rmpc_set_default_prec(pTHX_ SV * prec) {
+ dMY_CXT;
+ DEFAULT_PREC_RE = (mp_prec_t)SvUV(prec);
+ DEFAULT_PREC_IM = (mp_prec_t)SvUV(prec);
+}
+
+void Rmpc_set_default_prec2(pTHX_ SV * prec_re, SV * prec_im) {
+ dMY_CXT;
+ DEFAULT_PREC_RE = (mp_prec_t)SvUV(prec_re);
+ DEFAULT_PREC_IM = (mp_prec_t)SvUV(prec_im);
+}
+
+SV * Rmpc_get_default_prec(pTHX) {
+ dMY_CXT;
+ if(DEFAULT_PREC_RE == DEFAULT_PREC_IM)
+ return newSVuv(DEFAULT_PREC_RE);
+ return newSVuv(0);
+}
+
+void Rmpc_get_default_prec2(void) {
+ dTHX;
+ dXSARGS;
+ dMY_CXT;
+ EXTEND(SP, 2);
+ ST(0) = sv_2mortal(newSVuv(DEFAULT_PREC_RE));
+ ST(1) = sv_2mortal(newSVuv(DEFAULT_PREC_IM));
+ XSRETURN(2);
+}
+
+void Rmpc_set_prec(pTHX_ mpc_t * p, SV * prec) {
+ mpc_set_prec(*p, SvUV(prec));
+}
+
+void Rmpc_set_re_prec(pTHX_ mpc_t * p, SV * prec) {
+ mpfr_set_prec(MPC_RE(*p), SvUV(prec));
+}
+
+void Rmpc_set_im_prec(pTHX_ mpc_t * p, SV * prec) {
+ mpfr_set_prec(MPC_IM(*p), SvUV(prec));
+}
+
+SV * Rmpc_get_prec(pTHX_ mpc_t * x) {
+ return newSVuv(mpc_get_prec(*x));
+}
+
+void Rmpc_get_prec2(pTHX_ mpc_t * x) {
+ dXSARGS;
+ mp_prec_t re, im;
+ mpc_get_prec2(&re, &im, *x);
+ /* sp = mark; *//* not needed */
+ EXTEND(SP, 2);
+ ST(0) = sv_2mortal(newSVuv(re));
+ ST(1) = sv_2mortal(newSVuv(im));
+ /* PUTBACK; *//* not needed */
+ XSRETURN(2);
+}
+
+SV * Rmpc_get_im_prec(pTHX_ mpc_t * x) {
+ return newSVuv(mpfr_get_prec(MPC_IM(*x)));
+}
+
+SV * Rmpc_get_re_prec(pTHX_ mpc_t * x) {
+ return newSVuv(mpfr_get_prec(MPC_RE(*x)));
+}
+
+void RMPC_RE(mpfr_t * fr, mpc_t * x) {
+ mp_prec_t precision = mpfr_get_prec(MPC_RE(*x));
+ mpfr_set_prec(*fr, precision);
+ mpfr_set(*fr, MPC_RE(*x), GMP_RNDN); /* No rounding will be done, anyway */
+}
+
+void RMPC_IM(mpfr_t * fr, mpc_t * x) {
+ mp_prec_t precision = mpfr_get_prec(MPC_IM(*x));
+ mpfr_set_prec(*fr, precision);
+ mpfr_set(*fr, MPC_IM(*x), GMP_RNDN); /* No rounding will be done, anyway */
+}
+
+SV * RMPC_INEX_RE(pTHX_ SV * x) {
+ return newSViv(MPC_INEX_RE(SvIV(x)));
+}
+
+SV * RMPC_INEX_IM(pTHX_ SV * x) {
+ return newSViv(MPC_INEX_IM(SvIV(x)));
+}
+
+void DESTROY(pTHX_ mpc_t * p) {
+ mpc_clear(*p);
+ Safefree(p);
+}
+
+void Rmpc_clear(pTHX_ mpc_t * p) {
+ mpc_clear(*p);
+ Safefree(p);
+}
+
+void Rmpc_clear_mpc(mpc_t * p) {
+ mpc_clear(*p);
+}
+
+void Rmpc_clear_ptr(pTHX_ mpc_t * p) {
+ Safefree(p);
+}
+
+SV * Rmpc_init2(pTHX_ SV * prec) {
+ mpc_t * mpc_t_obj;
+ SV * obj_ref, * obj;
+
+ New(1, mpc_t_obj, 1, mpc_t);
+ if(mpc_t_obj == NULL) croak("Failed to allocate memory in Rmpc_init2 function");
+ obj_ref = newSV(0);
+ obj = newSVrv(obj_ref, "Math::MPC");
+ mpc_init2 (*mpc_t_obj, SvUV(prec));
+
+ sv_setiv(obj, INT2PTR(IV,mpc_t_obj));
+ SvREADONLY_on(obj);
+ return obj_ref;
+}
+
+SV * Rmpc_init3(pTHX_ SV * prec_r, SV * prec_i) {
+ mpc_t * mpc_t_obj;
+ SV * obj_ref, * obj;
+
+ New(1, mpc_t_obj, 1, mpc_t);
+ if(mpc_t_obj == NULL) croak("Failed to allocate memory in Rmpc_init3 function");
+ obj_ref = newSV(0);
+ obj = newSVrv(obj_ref, "Math::MPC");
+ mpc_init3 (*mpc_t_obj, SvUV(prec_r), SvUV(prec_i));
+
+ sv_setiv(obj, INT2PTR(IV,mpc_t_obj));
+ SvREADONLY_on(obj);
+ return obj_ref;
+}
+
+SV * Rmpc_init2_nobless(pTHX_ SV * prec) {
+ mpc_t * mpc_t_obj;
+ SV * obj_ref, * obj;
+
+ New(1, mpc_t_obj, 1, mpc_t);
+ if(mpc_t_obj == NULL) croak("Failed to allocate memory in Rmpc_init2_nobless function");
+ obj_ref = newSV(0);
+ obj = newSVrv(obj_ref, NULL);
+ mpc_init2 (*mpc_t_obj, SvUV(prec));
+
+ sv_setiv(obj, INT2PTR(IV,mpc_t_obj));
+ SvREADONLY_on(obj);
+ return obj_ref;
+}
+
+SV * Rmpc_init3_nobless(pTHX_ SV * prec_r, SV * prec_i) {
+ mpc_t * mpc_t_obj;
+ SV * obj_ref, * obj;
+
+ New(1, mpc_t_obj, 1, mpc_t);
+ if(mpc_t_obj == NULL) croak("Failed to allocate memory in Rmpc_init3_nobless function");
+ obj_ref = newSV(0);
+ obj = newSVrv(obj_ref, NULL);
+ mpc_init3 (*mpc_t_obj, SvUV(prec_r), SvUV(prec_i));
+
+ sv_setiv(obj, INT2PTR(IV,mpc_t_obj));
+ SvREADONLY_on(obj);
+ return obj_ref;
+}
+
+SV * Rmpc_set(pTHX_ mpc_t * p, mpc_t * q, SV * round) {
+ return newSViv(mpc_set(*p, *q, (mpc_rnd_t)SvUV(round)));
+}
+
+SV * Rmpc_set_ui(pTHX_ mpc_t * p, SV * q, SV * round) {
+ return newSViv(mpc_set_ui(*p, SvUV(q), (mpc_rnd_t)SvUV(round)));
+}
+
+SV * Rmpc_set_si(pTHX_ mpc_t * p, SV * q, SV * round) {
+ return newSViv(mpc_set_si(*p, SvIV(q), (mpc_rnd_t)SvUV(round)));
+}
+
+SV * Rmpc_set_ld(pTHX_ mpc_t * p, SV * q, SV * round) {
+#ifdef USE_LONG_DOUBLE
+ return newSViv(mpc_set_ld(*p, SvNV(q), (mpc_rnd_t)SvUV(round)));
+#else
+ croak("Rmpc_set_ld not implemented for this build of perl");
+#endif
+}
+
+SV * Rmpc_set_uj(pTHX_ mpc_t * p, SV * q, SV * round) {
+#ifdef USE_64_BIT_INT
+ return newSViv(mpc_set_uj(*p, SvUV(q), (mpc_rnd_t)SvUV(round)));
+#else
+ croak("Rmpc_set_uj not implemented for this build of perl");
+#endif
+}
+
+SV * Rmpc_set_sj(pTHX_ mpc_t * p, SV * q, SV * round) {
+#ifdef USE_64_BIT_INT
+ return newSViv(mpc_set_sj(*p, SvIV(q), (mpc_rnd_t)SvUV(round)));
+#else
+ croak("Rmpc_set_sj not implemented for this build of perl");
+#endif
+}
+
+SV * Rmpc_set_z(pTHX_ mpc_t * p, mpz_t * q, SV * round) {
+ return newSViv(mpc_set_z(*p, *q, (mpc_rnd_t)SvUV(round)));
+}
+
+SV * Rmpc_set_f(pTHX_ mpc_t * p, mpf_t * q, SV * round) {
+ return newSViv(mpc_set_f(*p, *q, (mpc_rnd_t)SvUV(round)));
+}
+
+SV * Rmpc_set_q(pTHX_ mpc_t * p, mpq_t * q, SV * round) {
+ return newSViv(mpc_set_q(*p, *q, (mpc_rnd_t)SvUV(round)));
+}
+
+SV * Rmpc_set_d(pTHX_ mpc_t * p, SV * q, SV * round) {
+ return newSViv(mpc_set_d(*p, SvNV(q), (mpc_rnd_t)SvUV(round)));
+}
+
+SV * Rmpc_set_fr(pTHX_ mpc_t * p, mpfr_t * q, SV * round) {
+ return newSViv(mpc_set_fr(*p, *q, (mpc_rnd_t)SvUV(round)));
+}
+
+SV * Rmpc_set_ui_ui(pTHX_ mpc_t * p, SV * q_r, SV * q_i, SV * round) {
+ return newSViv(mpc_set_ui_ui(*p, (unsigned long)SvUV(q_r), (unsigned long)SvUV(q_i), (mpc_rnd_t)SvUV(round)));
+}
+
+SV * Rmpc_set_si_si(pTHX_ mpc_t * p, SV * q_r, SV * q_i, SV * round) {
+ return newSViv(mpc_set_si_si(*p, (long)SvIV(q_r), (long)SvIV(q_i), (mpc_rnd_t)SvUV(round)));
+}
+
+SV * Rmpc_set_d_d(pTHX_ mpc_t * p, SV * q_r, SV * q_i, SV * round) {
+ return newSViv(mpc_set_d_d(*p, (double)SvNV(q_r), (double)SvNV(q_i), (mpc_rnd_t)SvUV(round)));
+}
+
+SV * Rmpc_set_ld_ld(pTHX_ mpc_t * mpc, SV * ld1, SV * ld2, SV * round) {
+#ifdef USE_LONG_DOUBLE
+ return newSViv(mpc_set_ld_ld(*mpc, SvNV(ld1), SvNV(ld2), (mpc_rnd_t) SvUV(round)));
+#else
+ croak("Rmpc_set_ld_ld not implemented for this build of perl");
+#endif
+}
+
+SV * Rmpc_set_z_z(pTHX_ mpc_t * p, mpz_t * q_r, mpz_t * q_i, SV * round) {
+ return newSViv(mpc_set_z_z(*p, *q_r, *q_i, (mpc_rnd_t)SvUV(round)));
+}
+
+SV * Rmpc_set_q_q(pTHX_ mpc_t * p, mpq_t * q_r, mpq_t * q_i, SV * round) {
+ return newSViv(mpc_set_q_q(*p, *q_r, *q_i, (mpc_rnd_t)SvUV(round)));
+}
+
+SV * Rmpc_set_f_f(pTHX_ mpc_t * p, mpf_t * q_r, mpf_t * q_i, SV * round) {
+ return newSViv(mpc_set_f_f(*p, *q_r, *q_i, (mpc_rnd_t)SvUV(round)));
+}
+
+SV * Rmpc_set_fr_fr(pTHX_ mpc_t * p, mpfr_t * q_r, mpfr_t * q_i, SV * round) {
+ return newSViv(mpc_set_fr_fr(*p, *q_r, *q_i, (mpc_rnd_t)SvUV(round)));
+}
+
+SV * Rmpc_set_d_ui(pTHX_ mpc_t * mpc, SV * d, SV * ui, SV * round) {
+ SV_MPC_SET_X_Y(d, ui, *mpc, (double)SvNV(d), (unsigned long int)SvUV(ui), (mpc_rnd_t)SvUV(round));
+}
+
+SV * Rmpc_set_d_si(pTHX_ mpc_t * mpc, SV * d, SV * si, SV * round) {
+ SV_MPC_SET_X_Y(d, si, *mpc, (double)SvNV(d), (signed long int)SvIV(si), (mpc_rnd_t) SvUV(round));
+}
+
+SV * Rmpc_set_d_fr(pTHX_ mpc_t * mpc, SV * d, mpfr_t * mpfr, SV * round) {
+ SV_MPC_SET_X_Y(d, fr, *mpc, (double)SvNV(d), *mpfr, (mpc_rnd_t) SvUV(round));
+}
+
+SV * Rmpc_set_ui_d(pTHX_ mpc_t * mpc, SV * ui, SV * d, SV * round) {
+ SV_MPC_SET_X_Y(ui, d, *mpc, (unsigned long)SvUV(ui), (double)SvNV(d), (mpc_rnd_t) SvUV(round));
+}
+
+SV * Rmpc_set_ui_si(pTHX_ mpc_t * mpc, SV * ui, SV * si, SV * round) {
+ SV_MPC_SET_X_Y(ui, si, *mpc, (unsigned long)SvUV(ui), (signed long int)SvIV(si), (mpc_rnd_t) SvUV(round));
+}
+
+SV * Rmpc_set_ui_fr(pTHX_ mpc_t * mpc, SV * ui, mpfr_t * mpfr, SV * round) {
+ SV_MPC_SET_X_Y(ui, fr, *mpc, (unsigned long)SvUV(ui), *mpfr, (mpc_rnd_t) SvUV(round));
+}
+
+SV * Rmpc_set_si_d(pTHX_ mpc_t * mpc, SV * si, SV * d, SV * round) {
+ SV_MPC_SET_X_Y(si, d, *mpc, (signed long int)SvIV(si), (double)SvNV(d), (mpc_rnd_t) SvUV(round));
+}
+
+SV * Rmpc_set_si_ui(pTHX_ mpc_t * mpc, SV * si, SV * ui, SV * round) {
+ SV_MPC_SET_X_Y(si, ui, *mpc, (signed long int)SvIV(si), (unsigned long)SvUV(ui), (mpc_rnd_t) SvUV(round));
+}
+
+SV * Rmpc_set_si_fr(pTHX_ mpc_t * mpc, SV * si, mpfr_t * mpfr, SV * round) {
+ SV_MPC_SET_X_Y(si, fr, *mpc, (signed long int)SvIV(si), *mpfr, (mpc_rnd_t) SvUV(round));
+}
+
+SV * Rmpc_set_fr_d(pTHX_ mpc_t * mpc, mpfr_t * mpfr, SV * d, SV * round) {
+ SV_MPC_SET_X_Y(fr, d, *mpc, *mpfr, (double)SvNV(d), (mpc_rnd_t) SvUV(round));
+}
+
+SV * Rmpc_set_fr_ui(pTHX_ mpc_t * mpc, mpfr_t * mpfr, SV * ui, SV * round) {
+ SV_MPC_SET_X_Y(fr, ui, *mpc, *mpfr, (unsigned long)SvUV(ui), (mpc_rnd_t) SvUV(round));
+}
+
+SV * Rmpc_set_fr_si(pTHX_ mpc_t * mpc, mpfr_t * mpfr, SV * si, SV * round) {
+ SV_MPC_SET_X_Y(fr, si, *mpc, *mpfr , (signed long int)SvIV(si), (mpc_rnd_t) SvUV(round));
+}
+
+SV * Rmpc_set_ld_ui(pTHX_ mpc_t * mpc, SV * d, SV * ui, SV * round) {
+#ifdef USE_LONG_DOUBLE
+ SV_MPC_SET_X_Y(ld, ui, *mpc, SvNV(d), (unsigned long)SvUV(ui), (mpc_rnd_t) SvUV(round));
+#else
+ croak("Rmpc_set_ld_ui not implemented for this build of perl");
+#endif
+}
+
+SV * Rmpc_set_ld_si(pTHX_ mpc_t * mpc, SV * d, SV * si, SV * round) {
+#ifdef USE_LONG_DOUBLE
+ SV_MPC_SET_X_Y(ld, si, *mpc, SvNV(d), (signed long int)SvIV(si), (mpc_rnd_t) SvUV(round));
+#else
+ croak("Rmpc_set_ld_si not implemented for this build of perl");
+#endif
+}
+
+SV * Rmpc_set_ld_fr(pTHX_ mpc_t * mpc, SV * d, mpfr_t * mpfr, SV * round) {
+#ifdef USE_LONG_DOUBLE
+ SV_MPC_SET_X_Y(ld, fr, *mpc, SvNV(d), *mpfr, (mpc_rnd_t) SvUV(round));
+#else
+ croak("Rmpc_set_ld_fr not implemented for this build of perl");
+#endif
+}
+
+SV * Rmpc_set_ui_ld(pTHX_ mpc_t * mpc, SV * ui, SV * d, SV * round) {
+#ifdef USE_LONG_DOUBLE
+ SV_MPC_SET_X_Y(ui, ld, *mpc, (unsigned long)SvUV(ui), SvNV(d), (mpc_rnd_t) SvUV(round));
+#else
+ croak("Rmpc_set_ui_ld not implemented for this build of perl");
+#endif
+}
+
+SV * Rmpc_set_si_ld(pTHX_ mpc_t * mpc, SV * si, SV * d, SV * round) {
+#ifdef USE_LONG_DOUBLE
+ SV_MPC_SET_X_Y(si, ld, *mpc, (signed long int)SvIV(si), SvNV(d), (mpc_rnd_t) SvUV(round));
+#else
+ croak("Rmpc_set_si_ld not implemented for this build of perl");
+#endif
+}
+
+SV * Rmpc_set_fr_ld(pTHX_ mpc_t * mpc, mpfr_t * mpfr, SV * d, SV * round) {
+#ifdef USE_LONG_DOUBLE
+ SV_MPC_SET_X_Y(fr, ld, *mpc, *mpfr, SvNV(d), (mpc_rnd_t) SvUV(round));
+#else
+ croak("Rmpc_set_fr_ld not implemented for this build of perl");
+#endif
+}
+
+SV * Rmpc_set_d_uj(pTHX_ mpc_t * mpc, SV * d, SV * ui, SV * round) {
+#ifdef USE_64_BIT_INT
+ SV_MPC_SET_X_Y(d, uj, *mpc, (double)SvNV(d), SvUV(ui), (mpc_rnd_t) SvUV(round));
+#else
+ croak("Rmpc_set_d_uj not implemented for this build of perl");
+#endif
+}
+
+SV * Rmpc_set_d_sj(pTHX_ mpc_t * mpc, SV * d, SV * si, SV * round) {
+#ifdef USE_64_BIT_INT
+ SV_MPC_SET_X_Y(d, sj, *mpc, (double)SvNV(d), SvIV(si), (mpc_rnd_t) SvUV(round));
+#else
+ croak("Rmpc_set_d_sj not implemented for this build of perl");
+#endif
+}
+
+SV * Rmpc_set_sj_d(pTHX_ mpc_t * mpc, SV * si, SV * d, SV * round) {
+#ifdef USE_64_BIT_INT
+ SV_MPC_SET_X_Y(sj, d, *mpc, SvIV(si), (double)SvNV(d), (mpc_rnd_t) SvUV(round));
+#else
+ croak("Rmpc_set_sj_d not implemented for this build of perl");
+#endif
+}
+
+SV * Rmpc_set_uj_d(pTHX_ mpc_t * mpc, SV * ui, SV * d, SV * round) {
+#ifdef USE_64_BIT_INT
+ SV_MPC_SET_X_Y(uj, d, *mpc, SvUV(ui), (double)SvNV(d), (mpc_rnd_t) SvUV(round));
+#else
+ croak("Rmpc_set_uj_d not implemented for this build of perl");
+#endif
+}
+
+SV * Rmpc_set_uj_fr(pTHX_ mpc_t * mpc, SV * ui, mpfr_t * mpfr, SV * round) {
+#ifdef USE_64_BIT_INT
+ SV_MPC_SET_X_Y(uj, fr, *mpc, SvUV(ui), *mpfr, (mpc_rnd_t) SvUV(round));
+#else
+ croak("Rmpc_set_uj_fr not implemented for this build of perl");
+#endif
+}
+
+SV * Rmpc_set_sj_fr(pTHX_ mpc_t * mpc, SV * si, mpfr_t * mpfr, SV * round) {
+#ifdef USE_64_BIT_INT
+ SV_MPC_SET_X_Y(sj, fr, *mpc, SvIV(si), *mpfr, (mpc_rnd_t) SvUV(round));
+#else
+ croak("Rmpc_set_sj_fr not implemented for this build of perl");
+#endif
+}
+
+SV * Rmpc_set_fr_uj(pTHX_ mpc_t * mpc, mpfr_t * mpfr, SV * ui, SV * round) {
+#ifdef USE_64_BIT_INT
+ SV_MPC_SET_X_Y(fr, uj, *mpc, *mpfr, SvUV(ui), (mpc_rnd_t) SvUV(round));
+#else
+ croak("Rmpc_set_fr_uj not implemented for this build of perl");
+#endif
+}
+
+SV * Rmpc_set_fr_sj(pTHX_ mpc_t * mpc, mpfr_t * mpfr, SV * si, SV * round) {
+#ifdef USE_64_BIT_INT
+ SV_MPC_SET_X_Y(fr, sj, *mpc, *mpfr , SvIV(si), (mpc_rnd_t) SvUV(round));
+#else
+ croak("Rmpc_set_fr_sj not implemented for this build of perl");
+#endif
+}
+
+SV * Rmpc_set_uj_sj(pTHX_ mpc_t * mpc, SV * ui, SV * si, SV * round) {
+#ifdef USE_64_BIT_INT
+ SV_MPC_SET_X_Y(uj, sj, *mpc, SvUV(ui), SvIV(si), (mpc_rnd_t) SvUV(round));
+#else
+ croak("Rmpc_set_uj_si, Rmpc_set_ui_sj and Rmpc_set_uj_sj not implemented for this build of perl");
+#endif
+}
+
+SV * Rmpc_set_sj_uj(pTHX_ mpc_t * mpc, SV * si, SV * ui, SV * round) {
+#ifdef USE_64_BIT_INT
+ SV_MPC_SET_X_Y(sj, uj, *mpc, SvIV(si), SvUV(ui), (mpc_rnd_t) SvUV(round));
+#else
+ croak("Rmpc_set_sj_ui, Rmpc_set_si_uj and Rmpc_set_sj_uj not implemented for this build of perl");
+#endif
+}
+
+
+SV * Rmpc_set_ld_uj(pTHX_ mpc_t * mpc, SV * d, SV * ui, SV * round) {
+#ifdef USE_64_BIT_INT
+#ifdef USE_LONG_DOUBLE
+ SV_MPC_SET_X_Y(ld, uj, *mpc, SvNV(d), SvUV(ui), (mpc_rnd_t) SvUV(round));
+#else
+ croak("Rmpc_set_ld_uj not implemented for this build of perl");
+#endif
+#else
+ croak("Rmpc_set_ld_uj not implemented for this build of perl");
+#endif
+}
+
+SV * Rmpc_set_ld_sj(pTHX_ mpc_t * mpc, SV * d, SV * si, SV * round) {
+#ifdef USE_64_BIT_INT
+#ifdef USE_LONG_DOUBLE
+ SV_MPC_SET_X_Y(ld, sj, *mpc, SvNV(d), SvIV(si), (mpc_rnd_t) SvUV(round));
+#else
+ croak("Rmpc_set_ld_sj not implemented for this build of perl");
+#endif
+#else
+ croak("Rmpc_set_ld_sj not implemented for this build of perl");
+#endif
+}
+
+SV * Rmpc_set_uj_ld(pTHX_ mpc_t * mpc, SV * ui, SV * d, SV * round) {
+#ifdef USE_64_BIT_INT
+#ifdef USE_LONG_DOUBLE
+ SV_MPC_SET_X_Y(uj, ld, *mpc, SvUV(ui), SvNV(d), (mpc_rnd_t) SvUV(round));
+#else
+ croak("Rmpc_set_uj_ld not implemented for this build of perl");
+#endif
+#else
+ croak("Rmpc_set_uj_ld not implemented for this build of perl");
+#endif
+}
+
+SV * Rmpc_set_sj_ld(pTHX_ mpc_t * mpc, SV * si, SV * d, SV * round) {
+#ifdef USE_64_BIT_INT
+#ifdef USE_LONG_DOUBLE
+ SV_MPC_SET_X_Y(sj, ld, *mpc, SvIV(si), SvNV(d), (mpc_rnd_t) SvUV(round));
+#else
+ croak("Rmpc_set_sj_ld not implemented for this build of perl");
+#endif
+#else
+ croak("Rmpc_set_sj_ld not implemented for this build of perl");
+#endif
+}
+
+SV * Rmpc_set_f_ui(pTHX_ mpc_t * mpc, mpf_t * mpf, SV * ui, SV * round) {
+ SV_MPC_SET_X_Y(f, ui, *mpc, *mpf, (unsigned long int)SvUV(ui), (mpc_rnd_t) SvUV(round));
+}
+
+SV * Rmpc_set_q_ui(pTHX_ mpc_t * mpc, mpq_t * mpq, SV * ui, SV * round) {
+ SV_MPC_SET_X_Y(q, ui, *mpc, *mpq, (unsigned long int)SvUV(ui), (mpc_rnd_t) SvUV(round));
+}
+
+SV * Rmpc_set_z_ui(pTHX_ mpc_t * mpc, mpz_t * mpz, SV * ui, SV * round) {
+ SV_MPC_SET_X_Y(z, ui, *mpc, *mpz, (unsigned long int)SvUV(ui), (mpc_rnd_t) SvUV(round));
+}
+
+SV * Rmpc_set_f_si(pTHX_ mpc_t * mpc, mpf_t * mpf, SV * si, SV * round) {
+ SV_MPC_SET_X_Y(f, si, *mpc, *mpf, (signed long int)SvIV(si), (mpc_rnd_t) SvUV(round));
+}
+
+SV * Rmpc_set_q_si(pTHX_ mpc_t * mpc, mpq_t * mpq, SV * si, SV * round) {
+ SV_MPC_SET_X_Y(q, si, *mpc, *mpq, (signed long int)SvIV(si), (mpc_rnd_t) SvUV(round));
+}
+
+SV * Rmpc_set_z_si(pTHX_ mpc_t * mpc, mpz_t * mpz, SV * si, SV * round) {
+ SV_MPC_SET_X_Y(z, si, *mpc, *mpz, (signed long int)SvIV(si), (mpc_rnd_t) SvUV(round));
+}
+
+SV * Rmpc_set_f_d(pTHX_ mpc_t * mpc, mpf_t * mpf, SV * d, SV * round) {
+ SV_MPC_SET_X_Y(f, d, *mpc, *mpf, (double)SvNV(d), (mpc_rnd_t) SvUV(round));
+}
+
+SV * Rmpc_set_q_d(pTHX_ mpc_t * mpc, mpq_t * mpq, SV * d, SV * round) {
+ SV_MPC_SET_X_Y(q, d, *mpc, *mpq, (double)SvNV(d), (mpc_rnd_t) SvUV(round));
+}
+
+SV * Rmpc_set_z_d(pTHX_ mpc_t * mpc, mpz_t * mpz, SV * d, SV * round) {
+ SV_MPC_SET_X_Y(z, d, *mpc, *mpz, (double)SvNV(d), (mpc_rnd_t) SvUV(round));
+}
+
+SV * Rmpc_set_f_uj(pTHX_ mpc_t * mpc, mpf_t * mpf, SV * uj, SV * round) {
+#ifdef USE_64_BIT_INT
+ SV_MPC_SET_X_Y(f, uj, *mpc, *mpf, (unsigned long long)SvUV(uj), (mpc_rnd_t) SvUV(round));
+#else
+ croak("Rmpc_set_f_uj not implemented for this build of perl");
+#endif
+}
+
+SV * Rmpc_set_q_uj(pTHX_ mpc_t * mpc, mpq_t * mpq, SV * uj, SV * round) {
+#ifdef USE_64_BIT_INT
+ SV_MPC_SET_X_Y(q, uj, *mpc, *mpq, (unsigned long long)SvUV(uj), (mpc_rnd_t) SvUV(round));
+#else
+ croak("Rmpc_set_q_uj not implemented for this build of perl");
+#endif
+}
+
+SV * Rmpc_set_z_uj(pTHX_ mpc_t * mpc, mpz_t * mpz, SV * uj, SV * round) {
+#ifdef USE_64_BIT_INT
+ SV_MPC_SET_X_Y(z, uj, *mpc, *mpz, (unsigned long long)SvUV(uj), (mpc_rnd_t) SvUV(round));
+#else
+ croak("Rmpc_set_z_uj not implemented for this build of perl");
+#endif
+}
+
+SV * Rmpc_set_f_sj(pTHX_ mpc_t * mpc, mpf_t * mpf, SV * sj, SV * round) {
+#ifdef USE_64_BIT_INT
+ SV_MPC_SET_X_Y(f, sj, *mpc, *mpf, (signed long long)SvIV(sj), (mpc_rnd_t) SvUV(round));
+#else
+ croak("Rmpc_set_f_sj not implemented for this build of perl");
+#endif
+}
+
+SV * Rmpc_set_q_sj(pTHX_ mpc_t * mpc, mpq_t * mpq, SV * sj, SV * round) {
+#ifdef USE_64_BIT_INT
+ SV_MPC_SET_X_Y(q, sj, *mpc, *mpq, (signed long long)SvIV(sj), (mpc_rnd_t) SvUV(round));
+#else
+ croak("Rmpc_set_q_sj not implemented for this build of perl");
+#endif
+}
+
+SV * Rmpc_set_z_sj(pTHX_ mpc_t * mpc, mpz_t * mpz, SV * sj, SV * round) {
+#ifdef USE_64_BIT_INT
+ SV_MPC_SET_X_Y(z, sj, *mpc, *mpz, (signed long long)SvIV(sj), (mpc_rnd_t) SvUV(round));
+#else
+ croak("Rmpc_set_z_sj not implemented for this build of perl");
+#endif
+}
+
+SV * Rmpc_set_f_ld(pTHX_ mpc_t * mpc, mpf_t * mpf, SV * ld, SV * round) {
+#ifdef USE_LONG_DOUBLE
+ SV_MPC_SET_X_Y(f, ld, *mpc, *mpf, (long double)SvNV(ld), (mpc_rnd_t) SvUV(round));
+#else
+ croak("Rmpc_set_f_ld not implemented for this build of perl");
+#endif
+}
+
+SV * Rmpc_set_q_ld(pTHX_ mpc_t * mpc, mpq_t * mpq, SV * ld, SV * round) {
+#ifdef USE_LONG_DOUBLE
+ SV_MPC_SET_X_Y(q, ld, *mpc, *mpq, (long double)SvNV(ld), (mpc_rnd_t) SvUV(round));
+#else
+ croak("Rmpc_set_q_ld not implemented for this build of perl");
+#endif
+}
+
+SV * Rmpc_set_z_ld(pTHX_ mpc_t * mpc, mpz_t * mpz, SV * ld, SV * round) {
+#ifdef USE_LONG_DOUBLE
+ SV_MPC_SET_X_Y(z, ld, *mpc, *mpz, (long double)SvNV(ld), (mpc_rnd_t) SvUV(round));
+#else
+ croak("Rmpc_set_z_ld not implemented for this build of perl");
+#endif
+}
+
+/*
+##############################
+##############################
+*/
+
+SV * Rmpc_set_ui_f(pTHX_ mpc_t * mpc, SV * ui, mpf_t * mpf, SV * round) {
+ SV_MPC_SET_X_Y(ui, f, *mpc, (unsigned long int)SvUV(ui), *mpf, (mpc_rnd_t) SvUV(round));
+}
+
+SV * Rmpc_set_ui_q(pTHX_ mpc_t * mpc, SV * ui, mpq_t * mpq, SV * round) {
+ SV_MPC_SET_X_Y(ui, q, *mpc, (unsigned long int)SvUV(ui), *mpq, (mpc_rnd_t) SvUV(round));
+}
+
+SV * Rmpc_set_ui_z(pTHX_ mpc_t * mpc, SV * ui, mpz_t * mpz, SV * round) {
+ SV_MPC_SET_X_Y(ui, z, *mpc, (unsigned long int)SvUV(ui), *mpz, (mpc_rnd_t) SvUV(round));
+}
+
+SV * Rmpc_set_si_f(pTHX_ mpc_t * mpc, SV * si, mpf_t * mpf, SV * round) {
+ SV_MPC_SET_X_Y(si, f, *mpc, (signed long int)SvIV(si), *mpf, (mpc_rnd_t) SvUV(round));
+}
+
+SV * Rmpc_set_si_q(pTHX_ mpc_t * mpc, SV * si, mpq_t * mpq, SV * round) {
+ SV_MPC_SET_X_Y(si, q, *mpc, (signed long int)SvIV(si), *mpq, (mpc_rnd_t) SvUV(round));
+}
+
+SV * Rmpc_set_si_z(pTHX_ mpc_t * mpc, SV * si, mpz_t * mpz, SV * round) {
+ SV_MPC_SET_X_Y(si, z, *mpc, (signed long int)SvIV(si), *mpz, (mpc_rnd_t) SvUV(round));
+}
+
+SV * Rmpc_set_d_f(pTHX_ mpc_t * mpc, SV * d, mpf_t * mpf, SV * round) {
+ SV_MPC_SET_X_Y(d, f, *mpc, (double)SvNV(d), *mpf, (mpc_rnd_t) SvUV(round));
+}
+
+SV * Rmpc_set_d_q(pTHX_ mpc_t * mpc, SV * d, mpq_t * mpq, SV * round) {
+ SV_MPC_SET_X_Y(d, q, *mpc, (double)SvNV(d), *mpq, (mpc_rnd_t) SvUV(round));
+}
+
+SV * Rmpc_set_d_z(pTHX_ mpc_t * mpc, SV * d, mpz_t * mpz, SV * round) {
+ SV_MPC_SET_X_Y(d, z, *mpc, (double)SvNV(d), *mpz, (mpc_rnd_t) SvUV(round));
+}
+
+SV * Rmpc_set_uj_f(pTHX_ mpc_t * mpc, SV * uj, mpf_t * mpf, SV * round) {
+#ifdef USE_64_BIT_INT
+ SV_MPC_SET_X_Y(uj, f, *mpc, (unsigned long long)SvUV(uj), *mpf, (mpc_rnd_t) SvUV(round));
+#else
+ croak("Rmpc_set_uj_f not implemented for this build of perl");
+#endif
+}
+
+SV * Rmpc_set_uj_q(pTHX_ mpc_t * mpc, SV * uj, mpq_t * mpq, SV * round) {
+#ifdef USE_64_BIT_INT
+ SV_MPC_SET_X_Y(uj, q, *mpc, (unsigned long long)SvUV(uj), *mpq, (mpc_rnd_t) SvUV(round));
+#else
+ croak("Rmpc_set_uj_q not implemented for this build of perl");
+#endif
+}
+
+SV * Rmpc_set_uj_z(pTHX_ mpc_t * mpc, SV * uj, mpz_t * mpz, SV * round) {
+#ifdef USE_64_BIT_INT
+ SV_MPC_SET_X_Y(uj, z, *mpc, (unsigned long long)SvUV(uj), *mpz, (mpc_rnd_t) SvUV(round));
+#else
+ croak("Rmpc_set_uj_z not implemented for this build of perl");
+#endif
+}
+
+SV * Rmpc_set_sj_f(pTHX_ mpc_t * mpc, SV * sj, mpf_t * mpf, SV * round) {
+#ifdef USE_64_BIT_INT
+ SV_MPC_SET_X_Y(sj, f, *mpc, (signed long long)SvIV(sj), *mpf, (mpc_rnd_t) SvUV(round));
+#else
+ croak("Rmpc_set_sj_f not implemented for this build of perl");
+#endif
+}
+
+SV * Rmpc_set_sj_q(pTHX_ mpc_t * mpc, SV * sj, mpq_t * mpq, SV * round) {
+#ifdef USE_64_BIT_INT
+ SV_MPC_SET_X_Y(sj, q, *mpc, (signed long long)SvIV(sj), *mpq, (mpc_rnd_t) SvUV(round));
+#else
+ croak("Rmpc_set_sj_q not implemented for this build of perl");
+#endif
+}
+
+SV * Rmpc_set_sj_z(pTHX_ mpc_t * mpc, SV * sj, mpz_t * mpz, SV * round) {
+#ifdef USE_64_BIT_INT
+ SV_MPC_SET_X_Y(sj, z, *mpc, (signed long long)SvIV(sj), *mpz, (mpc_rnd_t) SvUV(round));
+#else
+ croak("Rmpc_set_sj_z not implemented for this build of perl");
+#endif
+}
+
+SV * Rmpc_set_ld_f(pTHX_ mpc_t * mpc, SV * ld, mpf_t * mpf, SV * round) {
+#ifdef USE_LONG_DOUBLE
+ SV_MPC_SET_X_Y(ld, f, *mpc, (long double)SvNV(ld), *mpf, (mpc_rnd_t) SvUV(round));
+#else
+ croak("Rmpc_set_ld_f not implemented for this build of perl");
+#endif
+}
+
+SV * Rmpc_set_ld_q(pTHX_ mpc_t * mpc, SV * ld, mpq_t * mpq, SV * round) {
+#ifdef USE_LONG_DOUBLE
+ SV_MPC_SET_X_Y(ld, q, *mpc, (long double)SvNV(ld), *mpq, (mpc_rnd_t) SvUV(round));
+#else
+ croak("Rmpc_set_ld_q not implemented for this build of perl");
+#endif
+}
+
+SV * Rmpc_set_ld_z(pTHX_ mpc_t * mpc, SV * ld, mpz_t * mpz, SV * round) {
+#ifdef USE_LONG_DOUBLE
+ SV_MPC_SET_X_Y(ld, z, *mpc, (long double)SvNV(ld), *mpz, (mpc_rnd_t) SvUV(round));
+#else
+ croak("Rmpc_set_ld_z not implemented for this build of perl");
+#endif
+}
+
+/*
+##############################
+##############################
+*/
+
+SV * Rmpc_set_f_q(pTHX_ mpc_t * mpc, mpf_t * mpf, mpq_t * mpq, SV * round) {
+ SV_MPC_SET_X_Y(f, q, *mpc, *mpf, *mpq, (mpc_rnd_t) SvUV(round));
+}
+
+SV * Rmpc_set_q_f(pTHX_ mpc_t * mpc, mpq_t * mpq, mpf_t * mpf, SV * round) {
+ SV_MPC_SET_X_Y(q, f, *mpc, *mpq, *mpf, (mpc_rnd_t) SvUV(round));
+}
+
+SV * Rmpc_set_f_z(pTHX_ mpc_t * mpc, mpf_t * mpf, mpz_t * mpz, SV * round) {
+ SV_MPC_SET_X_Y(f, z, *mpc, *mpf, *mpz, (mpc_rnd_t) SvUV(round));
+}
+
+SV * Rmpc_set_z_f(pTHX_ mpc_t * mpc, mpz_t * mpz, mpf_t * mpf, SV * round) {
+ SV_MPC_SET_X_Y(z, f, *mpc, *mpz, *mpf, (mpc_rnd_t) SvUV(round));
+}
+
+SV * Rmpc_set_q_z(pTHX_ mpc_t * mpc, mpq_t * mpq, mpz_t * mpz, SV * round) {
+ SV_MPC_SET_X_Y(q, z, *mpc, *mpq, *mpz, (mpc_rnd_t) SvUV(round));
+}
+
+SV * Rmpc_set_z_q(pTHX_ mpc_t * mpc, mpz_t * mpz, mpq_t * mpq, SV * round) {
+ SV_MPC_SET_X_Y(z, q, *mpc, *mpz, *mpq, (mpc_rnd_t) SvUV(round));
+}
+
+SV * Rmpc_set_f_fr(pTHX_ mpc_t * mpc, mpf_t * mpf, mpfr_t * mpfr, SV * round) {
+ SV_MPC_SET_X_Y(f, fr, *mpc, *mpf, *mpfr, (mpc_rnd_t) SvUV(round));
+}
+
+SV * Rmpc_set_fr_f(pTHX_ mpc_t * mpc, mpfr_t * mpfr, mpf_t * mpf, SV * round) {
+ SV_MPC_SET_X_Y(fr, f, *mpc, *mpfr, *mpf, (mpc_rnd_t) SvUV(round));
+}
+
+SV * Rmpc_set_q_fr(pTHX_ mpc_t * mpc, mpq_t * mpq, mpfr_t * mpfr, SV * round) {
+ SV_MPC_SET_X_Y(q, fr, *mpc, *mpq, *mpfr, (mpc_rnd_t) SvUV(round));
+}
+
+SV * Rmpc_set_fr_q(pTHX_ mpc_t * mpc, mpfr_t * mpfr, mpq_t * mpq, SV * round) {
+ SV_MPC_SET_X_Y(fr, q, *mpc, *mpfr, *mpq, (mpc_rnd_t) SvUV(round));
+}
+
+SV * Rmpc_set_z_fr(pTHX_ mpc_t * mpc, mpz_t * mpz, mpfr_t * mpfr, SV * round) {
+ SV_MPC_SET_X_Y(z, fr, *mpc, *mpz, *mpfr, (mpc_rnd_t) SvUV(round));
+}
+
+SV * Rmpc_set_fr_z(pTHX_ mpc_t * mpc, mpfr_t * mpfr, mpz_t * mpz, SV * round) {
+ SV_MPC_SET_X_Y(fr, z, *mpc, *mpfr, *mpz, (mpc_rnd_t) SvUV(round));
+}
+
+
+/*
+##############################
+##############################
+*/
+
+SV * Rmpc_set_uj_uj(pTHX_ mpc_t * mpc, SV * uj1, SV * uj2, SV * round) {
+#ifdef USE_64_BIT_INT
+ return newSViv(mpc_set_uj_uj(*mpc, (unsigned long long)SvUV(uj1),
+ (unsigned long long)SvUV(uj2), (mpc_rnd_t)SvUV(round)));
+#else
+ croak("Rmpc_set_ui_uj, Rmpc_set_uj_ui and Rmpc_set_uj_uj not implemented for this build of perl");
+#endif
+}
+
+SV * Rmpc_set_sj_sj(pTHX_ mpc_t * mpc, SV * sj1, SV * sj2, SV * round) {
+#ifdef USE_64_BIT_INT
+ return newSViv(mpc_set_sj_sj(*mpc, (signed long long)SvIV(sj1),
+ (signed long long)SvIV(sj2), (mpc_rnd_t)SvUV(round)));
+#else
+ croak("Rmpc_set_si_sj, Rmpc_set_sj_si and Rmpc_set_sj_sj not implemented for this build of perl");
+#endif
+}
+
+SV * Rmpc_add(pTHX_ mpc_t * a, mpc_t * b, mpc_t * c, SV * round) {
+ return newSViv(mpc_add(*a, *b, *c, (mpc_rnd_t)SvUV(round)));
+}
+
+SV * Rmpc_add_ui(pTHX_ mpc_t * a, mpc_t * b, SV * c, SV * round){
+ return newSViv(mpc_add_ui(*a, *b, SvUV(c), (mpc_rnd_t)SvUV(round)));
+}
+
+SV * Rmpc_add_fr(pTHX_ mpc_t * a, mpc_t * b, mpfr_t * c, SV * round){
+ return newSViv(mpc_add_fr(*a, *b, *c, (mpc_rnd_t)SvUV(round)));
+}
+
+SV * Rmpc_sub(pTHX_ mpc_t * a, mpc_t * b, mpc_t * c, SV * round) {
+ return newSViv(mpc_sub(*a, *b, *c, (mpc_rnd_t)SvUV(round)));
+}
+
+SV * Rmpc_sub_ui(pTHX_ mpc_t * a, mpc_t * b, SV * c, SV * round) {
+ return newSViv(mpc_sub_ui(*a, *b, SvUV(c), (mpc_rnd_t)SvUV(round)));
+}
+
+SV * Rmpc_ui_sub(pTHX_ mpc_t * a, SV * b, mpc_t * c, SV * round) {
+ return newSViv(mpc_ui_sub(*a, SvUV(b), *c, (mpc_rnd_t)SvUV(round)));
+}
+
+SV * Rmpc_ui_ui_sub(pTHX_ mpc_t * a, SV * b_r, SV * b_i, mpc_t * c, SV * round) {
+ return newSViv(mpc_ui_ui_sub(*a, SvUV(b_r), SvUV(b_i), *c, (mpc_rnd_t)SvUV(round)));
+}
+
+SV * Rmpc_mul(pTHX_ mpc_t * a, mpc_t * b, mpc_t * c, SV * round) {
+ return newSViv(mpc_mul(*a, *b, *c, (mpc_rnd_t)SvUV(round)));
+}
+
+SV * Rmpc_mul_ui(pTHX_ mpc_t * a, mpc_t * b, SV * c, SV * round){
+ return newSViv(mpc_mul_ui(*a, *b, SvUV(c), (mpc_rnd_t)SvUV(round)));
+}
+
+SV * Rmpc_mul_si(pTHX_ mpc_t * a, mpc_t * b, SV * c, SV * round){
+ return newSViv(mpc_mul_si(*a, *b, SvIV(c), (mpc_rnd_t)SvUV(round)));
+}
+
+SV * Rmpc_mul_fr(pTHX_ mpc_t * a, mpc_t * b, mpfr_t * c, SV * round){
+ return newSViv(mpc_mul_fr(*a, *b, *c, (mpc_rnd_t)SvUV(round)));
+}
+
+SV * Rmpc_mul_i(pTHX_ mpc_t * a, mpc_t * b, SV * sign, SV * round){
+ return newSViv(mpc_mul_i(*a, *b, SvIV(sign), (mpc_rnd_t)SvUV(round)));
+}
+
+SV * Rmpc_sqr(pTHX_ mpc_t * a, mpc_t * b, SV * round) {
+ return newSViv(mpc_sqr(*a, *b, (mpc_rnd_t)SvUV(round)));
+}
+
+SV * Rmpc_div(pTHX_ mpc_t * a, mpc_t * b, mpc_t * c, SV * round) {
+ return newSViv(mpc_div(*a, *b, *c, (mpc_rnd_t)SvUV(round)));
+}
+
+SV * Rmpc_div_ui(pTHX_ mpc_t * a, mpc_t * b, SV * c, SV * round){
+ return newSViv(mpc_div_ui(*a, *b, SvUV(c), (mpc_rnd_t)SvUV(round)));
+}
+
+SV * Rmpc_ui_div(pTHX_ mpc_t * a, SV * b, mpc_t * c, SV * round) {
+ return newSViv(mpc_ui_div(*a, SvUV(b), *c, (mpc_rnd_t)SvUV(round)));
+}
+
+SV * Rmpc_div_fr(pTHX_ mpc_t * a, mpc_t * b, mpfr_t * c, SV * round){
+ return newSViv(mpc_div_fr(*a, *b, *c, (mpc_rnd_t)SvUV(round)));
+}
+
+SV * Rmpc_sqrt(pTHX_ mpc_t * a, mpc_t * b, SV * round) {
+ return newSViv(mpc_sqrt(*a, *b, (mpc_rnd_t)SvUV(round)));
+}
+
+SV * Rmpc_pow(pTHX_ mpc_t * a, mpc_t * b, mpc_t * pow, SV * round) {
+ return newSViv(mpc_pow(*a, *b, *pow, (mpc_rnd_t)SvUV(round)));
+}
+
+SV * Rmpc_pow_d(pTHX_ mpc_t * a, mpc_t * b, SV * pow, SV * round) {
+ return newSViv(mpc_pow_d(*a, *b, SvNV(pow), (mpc_rnd_t)SvUV(round)));
+}
+
+SV * Rmpc_pow_ld(pTHX_ mpc_t * a, mpc_t * b, SV * pow, SV * round) {
+#ifdef USE_LONG_DOUBLE
+ return newSViv(mpc_pow_ld(*a, *b, SvNV(pow), (mpc_rnd_t)SvUV(round)));
+#else
+ croak("Rmpc_pow_ld not implemented on this build of perl");
+#endif
+}
+
+SV * Rmpc_pow_si(pTHX_ mpc_t * a, mpc_t * b, SV * pow, SV * round) {
+ return newSViv(mpc_pow_si(*a, *b, SvIV(pow), (mpc_rnd_t)SvUV(round)));
+}
+
+SV * Rmpc_pow_ui(pTHX_ mpc_t * a, mpc_t * b, SV * pow, SV * round) {
+ return newSViv(mpc_pow_ui(*a, *b, SvUV(pow), (mpc_rnd_t)SvUV(round)));
+}
+
+SV * Rmpc_pow_z(pTHX_ mpc_t * a, mpc_t * b, mpz_t * pow, SV * round) {
+ return newSViv(mpc_pow_z(*a, *b, *pow, (mpc_rnd_t)SvUV(round)));
+}
+
+SV * Rmpc_pow_fr(pTHX_ mpc_t * a, mpc_t * b, mpfr_t * pow, SV * round) {
+ return newSViv(mpc_pow_fr(*a, *b, *pow, (mpc_rnd_t)SvUV(round)));
+}
+
+SV * Rmpc_neg(pTHX_ mpc_t * a, mpc_t * b, SV * round) {
+ return newSViv(mpc_neg(*a, *b, (mpc_rnd_t)SvUV(round)));
+}
+
+SV * Rmpc_abs(pTHX_ mpfr_t * a, mpc_t * b, SV * round) {
+ return newSViv(mpc_abs(*a, *b, (mpc_rnd_t)SvUV(round)));
+}
+
+SV * Rmpc_conj(pTHX_ mpc_t * a, mpc_t * b, SV * round) {
+ return newSViv(mpc_conj(*a, *b, (mpc_rnd_t)SvUV(round)));
+}
+
+SV * Rmpc_norm(pTHX_ mpfr_t * a, mpc_t * b, SV * round) {
+ return newSViv(mpc_norm(*a, *b, (mpc_rnd_t)SvUV(round)));
+}
+
+/* Beginning mpc-1.0, mpc_mul_2exp and mpc_div_2exp were
+* renamed mpc_mul_2ui and mpc_div_2ui
+*/
+
+SV * Rmpc_mul_2ui(pTHX_ mpc_t * a, mpc_t * b, SV * c, SV * round) {
+#if MPC_VERSION < 65536
+ return newSViv(mpc_mul_2exp(*a, *b, SvUV(c), (mpc_rnd_t)SvUV(round)));
+#else
+ return newSViv(mpc_mul_2ui(*a, *b, SvUV(c), (mpc_rnd_t)SvUV(round)));
+#endif
+}
+
+SV * Rmpc_div_2ui(pTHX_ mpc_t * a, mpc_t * b, SV * c, SV * round) {
+#if MPC_VERSION < 65536
+ return newSViv(mpc_div_2exp(*a, *b, SvUV(c), (mpc_rnd_t)SvUV(round)));
+#else
+ return newSViv(mpc_div_2ui(*a, *b, SvUV(c), (mpc_rnd_t)SvUV(round)));
+#endif
+}
+
+SV * Rmpc_cmp(pTHX_ mpc_t * a, mpc_t * b) {
+ return newSViv(mpc_cmp(*a, *b));
+}
+
+SV * Rmpc_cmp_si(pTHX_ mpc_t * a, SV * b) {
+ return newSViv(mpc_cmp_si(*a, SvIV(b)));
+}
+
+SV * Rmpc_cmp_si_si(pTHX_ mpc_t * a, SV * b, SV * c) {
+ return newSViv(mpc_cmp_si_si(*a, SvIV(b), SvIV(c)));
+}
+
+SV * Rmpc_exp(pTHX_ mpc_t * a, mpc_t * b, SV * round) {
+ return newSViv(mpc_exp(*a, *b, (mpc_rnd_t)SvUV(round)));
+}
+
+SV * Rmpc_log(pTHX_ mpc_t * rop, mpc_t * op, SV * round) {
+ return newSViv(mpc_log(*rop, *op, (mpc_rnd_t)SvUV(round)));
+}
+
+SV * _Rmpc_out_str(pTHX_ FILE * stream, SV * base, SV * dig, mpc_t * p, SV * round) {
+ size_t ret;
+ if(SvIV(base) < 2 || SvIV(base) > 36) croak("2nd argument supplied to Rmpc_out_str is out of allowable range (must be between 2 and 36 inclusive)");
+ ret = mpc_out_str(stream, (int)SvIV(base), (size_t)SvUV(dig), *p, (mpc_rnd_t)SvUV(round));
+ fflush(stream);
+ return newSVuv(ret);
+}
+
+SV * _Rmpc_out_strS(pTHX_ FILE * stream, SV * base, SV * dig, mpc_t * p, SV * round, SV * suff) {
+ size_t ret;
+ if(SvIV(base) < 2 || SvIV(base) > 36) croak("2nd argument supplied to Rmpc_out_str is out of allowable range (must be between 2 and 36 inclusive)");
+ ret = mpc_out_str(stream, (int)SvIV(base), (size_t)SvUV(dig), *p, (mpc_rnd_t)SvUV(round));
+ fflush(stream);
+ fprintf(stream, "%s", SvPV_nolen(suff));
+ fflush(stream);
+ return newSVuv(ret);
+}
+
+SV * _Rmpc_out_strP(pTHX_ SV * pre, FILE * stream, SV * base, SV * dig, mpc_t * p, SV * round) {
+ size_t ret;
+ if(SvIV(base) < 2 || SvIV(base) > 36) croak("3rd argument supplied to Rmpc_out_str is out of allowable range (must be between 2 and 36 inclusive)");
+ fprintf(stream, "%s", SvPV_nolen(pre));
+ fflush(stream);
+ ret = mpc_out_str(stream, (int)SvIV(base), (size_t)SvUV(dig), *p, (mpc_rnd_t)SvUV(round));
+ fflush(stream);
+ return newSVuv(ret);
+}
+
+SV * _Rmpc_out_strPS(pTHX_ SV * pre, FILE * stream, SV * base, SV * dig, mpc_t * p, SV * round, SV * suff) {
+ size_t ret;
+ if(SvIV(base) < 2 || SvIV(base) > 36) croak("3rd argument supplied to Rmpc_out_str is out of allowable range (must be between 2 and 36 inclusive)");
+ fprintf(stream, "%s", SvPV_nolen(pre));
+ fflush(stream);
+ ret = mpc_out_str(stream, (int)SvIV(base), (size_t)SvUV(dig), *p, (mpc_rnd_t)SvUV(round));
+ fflush(stream);
+ fprintf(stream, "%s", SvPV_nolen(suff));
+ fflush(stream);
+ return newSVuv(ret);
+}
+
+
+SV * Rmpc_inp_str(pTHX_ mpc_t * p, FILE * stream, SV * base, SV * round) {
+ if(SvIV(base) < 2 || SvIV(base) > 36) croak("3rd argument supplied to TRmpfr_inp_str is out of allowable range (must be between 2 and 36 inclusive)");
+ return newSViv(mpc_inp_str(*p, stream, NULL, (int)SvIV(base), (mpc_rnd_t)SvUV(round)));
+}
+
+/* Removed in mpc-0.7
+void Rmpc_random(mpc_t * p) {
+ mpc_random(*p);
+}
+*/
+
+/* Removed in mpc-0.7
+void Rmpc_random2(mpc_t * p, SV * s, SV * exp) {
+ mpc_random2(*p, SvIV(s), SvUV(exp));
+}
+*/
+
+SV * Rmpc_sin(pTHX_ mpc_t * rop, mpc_t * op, SV * round) {
+ return newSViv(mpc_sin(*rop, *op, (mpc_rnd_t)SvUV(round)));
+}
+
+SV * Rmpc_cos(pTHX_ mpc_t * rop, mpc_t * op, SV * round) {
+ return newSViv(mpc_cos(*rop, *op, (mpc_rnd_t)SvUV(round)));
+}
+
+SV * Rmpc_tan(pTHX_ mpc_t * rop, mpc_t * op, SV * round) {
+ return newSViv(mpc_tan(*rop, *op, (mpc_rnd_t)SvUV(round)));
+}
+
+SV * Rmpc_sinh(pTHX_ mpc_t * rop, mpc_t * op, SV * round) {
+ return newSViv(mpc_sinh(*rop, *op, (mpc_rnd_t)SvUV(round)));
+}
+
+SV * Rmpc_cosh(pTHX_ mpc_t * rop, mpc_t * op, SV * round) {
+ return newSViv(mpc_cosh(*rop, *op, (mpc_rnd_t)SvUV(round)));
+}
+
+SV * Rmpc_tanh(pTHX_ mpc_t * rop, mpc_t * op, SV * round) {
+ return newSViv(mpc_tanh(*rop, *op, (mpc_rnd_t)SvUV(round)));
+}
+
+SV * Rmpc_asin(pTHX_ mpc_t * rop, mpc_t * op, SV * round) {
+ return newSViv(mpc_asin(*rop, *op, (mpc_rnd_t)SvUV(round)));
+}
+
+SV * Rmpc_acos(pTHX_ mpc_t * rop, mpc_t * op, SV * round) {
+ return newSViv(mpc_acos(*rop, *op, (mpc_rnd_t)SvUV(round)));
+}
+
+SV * Rmpc_atan(pTHX_ mpc_t * rop, mpc_t * op, SV * round) {
+ return newSViv(mpc_atan(*rop, *op, (mpc_rnd_t)SvUV(round)));
+}
+
+SV * Rmpc_asinh(pTHX_ mpc_t * rop, mpc_t * op, SV * round) {
+ return newSViv(mpc_asinh(*rop, *op, (mpc_rnd_t)SvUV(round)));
+}
+
+SV * Rmpc_acosh(pTHX_ mpc_t * rop, mpc_t * op, SV * round) {
+ return newSViv(mpc_acosh(*rop, *op, (mpc_rnd_t)SvUV(round)));
+}
+
+SV * Rmpc_atanh(pTHX_ mpc_t * rop, mpc_t * op, SV * round) {
+ return newSViv(mpc_atanh(*rop, *op, (mpc_rnd_t)SvUV(round)));
+}
+
+SV * overload_true(pTHX_ mpc_t *a, SV *second, SV * third) {
+ if(
+ ( mpfr_nan_p(MPC_RE(*a)) || !mpfr_cmp_ui(MPC_RE(*a), 0) ) &&
+ ( mpfr_nan_p(MPC_IM(*a)) || !mpfr_cmp_ui(MPC_IM(*a), 0) )
+ ) return newSVuv(0);
+ return newSVuv(1);
+}
+
+/********************************/
+/********************************/
+/********************************/
+/********************************/
+/********************************/
+/********************************/
+/********************************/
+/********************************/
+
+SV * overload_mul(pTHX_ mpc_t * a, SV * b, SV * third) {
+ dMY_CXT;
+ mpc_t * mpc_t_obj;
+ SV * obj_ref, * obj;
+
+ New(1, mpc_t_obj, 1, mpc_t);
+ if(mpc_t_obj == NULL) croak("Failed to allocate memory in overload_mul function");
+ obj_ref = newSV(0);
+ obj = newSVrv(obj_ref, "Math::MPC");
+ mpc_init3(*mpc_t_obj, DEFAULT_PREC);
+ sv_setiv(obj, INT2PTR(IV,mpc_t_obj));
+ SvREADONLY_on(obj);
+
+#ifdef USE_64_BIT_INT
+
+ if(SvUOK(b)) {
+#ifdef _MSC_VER
+ mpc_set_str(*mpc_t_obj, SvPV_nolen(b), 10, DEFAULT_ROUNDING_MODE);
+#else
+ mpc_set_uj(*mpc_t_obj, SvUV(b), DEFAULT_ROUNDING_MODE);
+#endif
+ mpc_mul(*mpc_t_obj, *a, *mpc_t_obj, DEFAULT_ROUNDING_MODE);
+ return obj_ref;
+ }
+
+ if(SvIOK(b)) {
+#ifdef _MSC_VER
+ mpc_set_str(*mpc_t_obj, SvPV_nolen(b), 10, DEFAULT_ROUNDING_MODE);
+ mpc_mul(*mpc_t_obj, *a, *mpc_t_obj, DEFAULT_ROUNDING_MODE);
+#else
+ /* mpc_set_sj(*mpc_t_obj, SvIV(b), DEFAULT_ROUNDING_MODE); */
+ _mpc_mul_sj(*mpc_t_obj, *a, SvIV(b), DEFAULT_ROUNDING_MODE);
+#endif
+ /* mpc_mul(*mpc_t_obj, *a, *mpc_t_obj, DEFAULT_ROUNDING_MODE); */
+ return obj_ref;
+ }
+
+#else
+ if(SvUOK(b)) {
+ mpc_mul_ui(*mpc_t_obj, *a, SvUV(b), DEFAULT_ROUNDING_MODE);
+ return obj_ref;
+ }
+
+ if(SvIOK(b)) {
+ mpc_mul_si(*mpc_t_obj, *a, SvIV(b), DEFAULT_ROUNDING_MODE);
+ return obj_ref;
+ }
+#endif
+
+ if(SvNOK(b)) {
+#ifdef USE_LONG_DOUBLE
+ _mpc_mul_ld(*mpc_t_obj, *a, (long double)SvNV(b), DEFAULT_ROUNDING_MODE);
+#else
+ _mpc_mul_d(*mpc_t_obj,*a, (double)SvNV(b), DEFAULT_ROUNDING_MODE);
+#endif
+
+ return obj_ref;
+ }
+
+ if(SvPOK(b)) {
+ if(mpc_set_str(*mpc_t_obj, SvPV_nolen(b), 0, DEFAULT_ROUNDING_MODE) == -1)
+ croak("Invalid string supplied to Math::MPC::overload_mul");
+ mpc_mul(*mpc_t_obj, *a, *mpc_t_obj, DEFAULT_ROUNDING_MODE);
+ return obj_ref;
+ }
+
+ if(sv_isobject(b)) {
+ const char *h = HvNAME(SvSTASH(SvRV(b)));
+ if(strEQ(h, "Math::MPC")) {
+ mpc_mul(*mpc_t_obj, *a, *(INT2PTR(mpc_t *, SvIV(SvRV(b)))), DEFAULT_ROUNDING_MODE);
+ return obj_ref;
+ }
+ }
+
+ croak("Invalid argument supplied to Math::MPC::overload_mul");
+}
+
+SV * overload_add(pTHX_ mpc_t* a, SV * b, SV * third) {
+ dMY_CXT;
+ mpc_t * mpc_t_obj;
+ SV * obj_ref, * obj;
+
+ New(1, mpc_t_obj, 1, mpc_t);
+ if(mpc_t_obj == NULL) croak("Failed to allocate memory in overload_add function");
+ obj_ref = newSV(0);
+ obj = newSVrv(obj_ref, "Math::MPC");
+ mpc_init3(*mpc_t_obj, DEFAULT_PREC);
+ sv_setiv(obj, INT2PTR(IV,mpc_t_obj));
+ SvREADONLY_on(obj);
+
+#ifdef USE_64_BIT_INT
+
+ if(SvUOK(b)) {
+#ifdef _MSC_VER
+ mpc_set_str(*mpc_t_obj, SvPV_nolen(b), 10, DEFAULT_ROUNDING_MODE);
+#else
+ mpc_set_uj(*mpc_t_obj, SvUV(b), DEFAULT_ROUNDING_MODE);
+#endif
+ mpc_add(*mpc_t_obj, *a, *mpc_t_obj, DEFAULT_ROUNDING_MODE);
+ return obj_ref;
+ }
+
+ if(SvIOK(b)) {
+#ifdef _MSC_VER
+ mpc_set_str(*mpc_t_obj, SvPV_nolen(b), 10, DEFAULT_ROUNDING_MODE);
+#else
+ mpc_set_sj(*mpc_t_obj, SvIV(b), DEFAULT_ROUNDING_MODE);
+#endif
+ mpc_add(*mpc_t_obj, *a, *mpc_t_obj, DEFAULT_ROUNDING_MODE);
+ return obj_ref;
+ }
+
+#else
+
+ if(SvUOK(b)) {
+ mpc_add_ui(*mpc_t_obj, *a, SvUV(b), DEFAULT_ROUNDING_MODE);
+ return obj_ref;
+ }
+
+ if(SvIOK(b)) {
+ if(SvIV(b) >= 0) {
+ mpc_add_ui(*mpc_t_obj, *a, SvUV(b), DEFAULT_ROUNDING_MODE);
+ return obj_ref;
+ }
+ mpc_sub_ui(*mpc_t_obj, *a, SvIV(b) * -1, DEFAULT_ROUNDING_MODE);
+ return obj_ref;
+ }
+
+#endif
+
+ if(SvNOK(b)) {
+#ifdef USE_LONG_DOUBLE
+ mpc_set_ld(*mpc_t_obj, SvNV(b), DEFAULT_ROUNDING_MODE);
+ mpc_add(*mpc_t_obj, *a, *mpc_t_obj, DEFAULT_ROUNDING_MODE);
+#else
+ mpc_set_d(*mpc_t_obj, SvNV(b), DEFAULT_ROUNDING_MODE);
+ mpc_add(*mpc_t_obj, *mpc_t_obj, *a, DEFAULT_ROUNDING_MODE);
+#endif
+
+ return obj_ref;
+ }
+
+ if(SvPOK(b)) {
+ if(mpc_set_str(*mpc_t_obj, SvPV_nolen(b), 0, DEFAULT_ROUNDING_MODE) == -1)
+ croak("Invalid string supplied to Math::MPC::overload_add");
+ mpc_add(*mpc_t_obj, *a, *mpc_t_obj, DEFAULT_ROUNDING_MODE);
+ return obj_ref;
+ }
+
+ if(sv_isobject(b)) {
+ const char *h = HvNAME(SvSTASH(SvRV(b)));
+ if(strEQ(h, "Math::MPC")) {
+ mpc_add(*mpc_t_obj, *a, *(INT2PTR(mpc_t *, SvIV(SvRV(b)))), DEFAULT_ROUNDING_MODE);
+ return obj_ref;
+ }
+ }
+
+ croak("Invalid argument supplied to Math::MPC::overload_add");
+}
+
+SV * overload_sub(pTHX_ mpc_t * a, SV * b, SV * third) {
+ dMY_CXT;
+ mpc_t * mpc_t_obj;
+ SV * obj_ref, * obj;
+
+ New(1, mpc_t_obj, 1, mpc_t);
+ if(mpc_t_obj == NULL) croak("Failed to allocate memory in overload_sub function");
+ obj_ref = newSV(0);
+ obj = newSVrv(obj_ref, "Math::MPC");
+ mpc_init3(*mpc_t_obj, DEFAULT_PREC);
+ sv_setiv(obj, INT2PTR(IV,mpc_t_obj));
+ SvREADONLY_on(obj);
+
+#ifdef USE_64_BIT_INT
+ if(SvUOK(b)) {
+#ifdef _MSC_VER
+ mpc_set_str(*mpc_t_obj, SvPV_nolen(b), 10, DEFAULT_ROUNDING_MODE);
+#else
+ mpc_set_uj(*mpc_t_obj, SvUV(b), DEFAULT_ROUNDING_MODE);
+#endif
+ if(third == &PL_sv_yes) mpc_sub(*mpc_t_obj, *mpc_t_obj, *a, DEFAULT_ROUNDING_MODE);
+ else mpc_sub(*mpc_t_obj, *a, *mpc_t_obj, DEFAULT_ROUNDING_MODE);
+ return obj_ref;
+ }
+
+ if(SvIOK(b)) {
+#ifdef _MSC_VER
+ mpc_set_str(*mpc_t_obj, SvPV_nolen(b), 10, DEFAULT_ROUNDING_MODE);
+#else
+ mpc_set_sj(*mpc_t_obj, SvIV(b), DEFAULT_ROUNDING_MODE);
+#endif
+ if(third == &PL_sv_yes) mpc_sub(*mpc_t_obj, *mpc_t_obj, *a, DEFAULT_ROUNDING_MODE);
+ else mpc_sub(*mpc_t_obj, *a, *mpc_t_obj, DEFAULT_ROUNDING_MODE);
+ return obj_ref;
+ }
+#else
+ if(SvUOK(b)) {
+ if(third == &PL_sv_yes) mpc_ui_sub(*mpc_t_obj, SvUV(b), *a, DEFAULT_ROUNDING_MODE);
+ else mpc_sub_ui(*mpc_t_obj, *a, SvUV(b), DEFAULT_ROUNDING_MODE);
+ return obj_ref;
+ }
+
+ if(SvIOK(b)) {
+ if(SvIV(b) >= 0) {
+ if(third == &PL_sv_yes) mpc_ui_sub(*mpc_t_obj, SvUV(b), *a, DEFAULT_ROUNDING_MODE);
+ else mpc_sub_ui(*mpc_t_obj, *a, SvUV(b), DEFAULT_ROUNDING_MODE);
+ return obj_ref;
+ }
+ mpc_add_ui(*mpc_t_obj, *a, SvIV(b) * -1, DEFAULT_ROUNDING_MODE);
+ if(third == &PL_sv_yes) mpc_neg(*mpc_t_obj, *mpc_t_obj, DEFAULT_ROUNDING_MODE);
+ return obj_ref;
+ }
+#endif
+
+ if(SvNOK(b)) {
+#ifdef USE_LONG_DOUBLE
+ mpc_set_ld(*mpc_t_obj, SvNV(b), DEFAULT_ROUNDING_MODE);
+#else
+ mpc_set_d(*mpc_t_obj, SvNV(b), DEFAULT_ROUNDING_MODE);
+#endif
+ if(third == &PL_sv_yes) mpc_sub(*mpc_t_obj, *mpc_t_obj, *a, DEFAULT_ROUNDING_MODE);
+ else mpc_sub(*mpc_t_obj, *a, *mpc_t_obj, DEFAULT_ROUNDING_MODE);
+ return obj_ref;
+ }
+
+ if(SvPOK(b)) {
+ if(mpc_set_str(*mpc_t_obj, SvPV_nolen(b), 0, DEFAULT_ROUNDING_MODE) == -1)
+ croak("Invalid string supplied to Math::MPC::overload_sub");
+ if(third == &PL_sv_yes) mpc_sub(*mpc_t_obj, *mpc_t_obj, *a, DEFAULT_ROUNDING_MODE);
+ else mpc_sub(*mpc_t_obj, *a, *mpc_t_obj, DEFAULT_ROUNDING_MODE);
+ return obj_ref;
+ }
+
+ if(sv_isobject(b)) {
+ const char *h = HvNAME(SvSTASH(SvRV(b)));
+ if(strEQ(h, "Math::MPC")) {
+ mpc_sub(*mpc_t_obj, *a, *(INT2PTR(mpc_t *, SvIV(SvRV(b)))), DEFAULT_ROUNDING_MODE);
+ return obj_ref;
+ }
+ }
+
+ croak("Invalid argument supplied to Math::MPC::overload_sub function");
+}
+
+SV * overload_div(pTHX_ mpc_t * a, SV * b, SV * third) {
+ dMY_CXT;
+ mpc_t * mpc_t_obj;
+ SV * obj_ref, * obj;
+
+ New(1, mpc_t_obj, 1, mpc_t);
+ if(mpc_t_obj == NULL) croak("Failed to allocate memory in overload_div function");
+ obj_ref = newSV(0);
+ obj = newSVrv(obj_ref, "Math::MPC");
+ mpc_init3(*mpc_t_obj, DEFAULT_PREC);
+ sv_setiv(obj, INT2PTR(IV,mpc_t_obj));
+ SvREADONLY_on(obj);
+
+#ifdef USE_64_BIT_INT
+ if(SvUOK(b)) {
+#ifdef _MSC_VER
+ mpc_set_str(*mpc_t_obj, SvPV_nolen(b), 10, DEFAULT_ROUNDING_MODE);
+#else
+ mpc_set_uj(*mpc_t_obj, SvUV(b), DEFAULT_ROUNDING_MODE);
+#endif
+ if(third == &PL_sv_yes) mpc_div(*mpc_t_obj, *mpc_t_obj, *a, DEFAULT_ROUNDING_MODE);
+ else mpc_div(*mpc_t_obj, *a, *mpc_t_obj, DEFAULT_ROUNDING_MODE);
+ return obj_ref;
+ }
+
+ if(SvIOK(b)) {
+#ifdef _MSC_VER
+ mpc_set_str(*mpc_t_obj, SvPV_nolen(b), 10, DEFAULT_ROUNDING_MODE);
+ if(third == &PL_sv_yes) mpc_div(*mpc_t_obj, *mpc_t_obj, *a, DEFAULT_ROUNDING_MODE);
+ else mpc_div(*mpc_t_obj, *a, *mpc_t_obj, DEFAULT_ROUNDING_MODE);
+#else
+ /* mpc_set_sj(*mpc_t_obj, SvIV(b), DEFAULT_ROUNDING_MODE); */
+ if(third == &PL_sv_yes) _mpc_sj_div(*mpc_t_obj, SvIV(b), *a, DEFAULT_ROUNDING_MODE);
+ else _mpc_div_sj(*mpc_t_obj, *a, SvIV(b), DEFAULT_ROUNDING_MODE);
+#endif
+ /* if(third == &PL_sv_yes) mpc_div(*mpc_t_obj, *mpc_t_obj, *a, DEFAULT_ROUNDING_MODE);
+ else mpc_div(*mpc_t_obj, *a, *mpc_t_obj, DEFAULT_ROUNDING_MODE); */
+ return obj_ref;
+ }
+#else
+ if(SvUOK(b)) {
+ if(third == &PL_sv_yes) mpc_ui_div(*mpc_t_obj, SvUV(b), *a, DEFAULT_ROUNDING_MODE);
+ else mpc_div_ui(*mpc_t_obj, *a, SvUV(b), DEFAULT_ROUNDING_MODE);
+ return obj_ref;
+ }
+
+ if(SvIOK(b)) {
+ if(SvIV(b) >= 0) {
+ if(third == &PL_sv_yes) mpc_ui_div(*mpc_t_obj, SvUV(b), *a, DEFAULT_ROUNDING_MODE);
+ else mpc_div_ui(*mpc_t_obj, *a, SvUV(b), DEFAULT_ROUNDING_MODE);
+ return obj_ref;
+ }
+ if(third == &PL_sv_yes) mpc_ui_div(*mpc_t_obj, SvIV(b) * -1, *a, DEFAULT_ROUNDING_MODE);
+ else mpc_div_ui(*mpc_t_obj, *a, SvIV(b) * -1, DEFAULT_ROUNDING_MODE);
+ mpc_neg(*mpc_t_obj, *mpc_t_obj, DEFAULT_ROUNDING_MODE);
+ return obj_ref;
+ }
+#endif
+
+ if(SvNOK(b)) {
+#ifdef USE_LONG_DOUBLE
+ /* mpc_set_ld(*mpc_t_obj, SvNV(b), DEFAULT_ROUNDING_MODE); */
+ if(third == &PL_sv_yes) _mpc_ld_div(*mpc_t_obj, (long double)SvNV(b), *a, DEFAULT_ROUNDING_MODE);
+ else _mpc_div_ld(*mpc_t_obj, *a, (long double)SvNV(b), DEFAULT_ROUNDING_MODE);
+#else
+ /* mpc_set_d(*mpc_t_obj, SvNV(b), DEFAULT_ROUNDING_MODE); */
+ if(third == &PL_sv_yes) _mpc_d_div(*mpc_t_obj, (double)SvNV(b), *a, DEFAULT_ROUNDING_MODE);
+ else _mpc_div_d(*mpc_t_obj, *a, (double)SvNV(b), DEFAULT_ROUNDING_MODE);
+#endif
+ /* if(third == &PL_sv_yes) mpc_div(*mpc_t_obj, *mpc_t_obj, *a, DEFAULT_ROUNDING_MODE); */
+ /* else mpc_div(*mpc_t_obj, *a, *mpc_t_obj, DEFAULT_ROUNDING_MODE); */
+ return obj_ref;
+ }
+
+ if(SvPOK(b)) {
+ if(mpc_set_str(*mpc_t_obj, SvPV_nolen(b), 0, DEFAULT_ROUNDING_MODE) == -1)
+ croak("Invalid string supplied to Math::MPC::overload_div");
+ if(third == &PL_sv_yes) mpc_div(*mpc_t_obj, *mpc_t_obj, *a, DEFAULT_ROUNDING_MODE);
+ else mpc_div(*mpc_t_obj, *a, *mpc_t_obj, DEFAULT_ROUNDING_MODE);
+ return obj_ref;
+ }
+
+ if(sv_isobject(b)) {
+ const char *h = HvNAME(SvSTASH(SvRV(b)));
+ if(strEQ(h, "Math::MPC")) {
+ mpc_div(*mpc_t_obj, *a, *(INT2PTR(mpc_t *, SvIV(SvRV(b)))), DEFAULT_ROUNDING_MODE);
+ return obj_ref;
+ }
+ }
+
+ croak("Invalid argument supplied to Math::MPC::overload_div function");
+
+}
+
+
+SV * overload_div_eq(pTHX_ SV * a, SV * b, SV * third) {
+ dMY_CXT;
+ mpc_t temp;
+
+ SvREFCNT_inc(a);
+
+#ifdef USE_64_BIT_INT
+ if(SvUOK(b)) {
+ mpc_init3(temp, DEFAULT_PREC);
+#ifdef _MSC_VER
+ mpc_set_str(temp, SvPV_nolen(b), 10, DEFAULT_ROUNDING_MODE);
+#else
+ mpc_set_uj(temp, SvUV(b), DEFAULT_ROUNDING_MODE);
+#endif
+ mpc_div(*(INT2PTR(mpc_t *, SvIV(SvRV(a)))), *(INT2PTR(mpc_t *, SvIV(SvRV(a)))), temp, DEFAULT_ROUNDING_MODE);
+ mpc_clear(temp);
+ return a;
+ }
+
+ if(SvIOK(b)) {
+ /* mpc_init3(temp, DEFAULT_PREC); */
+#ifdef _MSC_VER
+ mpc_init3(temp, DEFAULT_PREC);
+ mpc_set_str(temp, SvPV_nolen(b), 10, DEFAULT_ROUNDING_MODE);
+ mpc_div(*(INT2PTR(mpc_t *, SvIV(SvRV(a)))), *(INT2PTR(mpc_t *, SvIV(SvRV(a)))), temp, DEFAULT_ROUNDING_MODE);
+ mpc_clear(temp);
+#else
+ /* mpc_set_sj(temp, SvIV(b), DEFAULT_ROUNDING_MODE); */
+ _mpc_div_sj(*(INT2PTR(mpc_t *, SvIV(SvRV(a)))), *(INT2PTR(mpc_t *, SvIV(SvRV(a)))), SvIV(b), DEFAULT_ROUNDING_MODE);
+#endif
+ /* mpc_div(*(INT2PTR(mpc_t *, SvIV(SvRV(a)))), *(INT2PTR(mpc_t *, SvIV(SvRV(a)))), temp, DEFAULT_ROUNDING_MODE);
+ mpc_clear(temp); */
+ return a;
+ }
+#else
+ if(SvUOK(b)) {
+ mpc_div_ui(*(INT2PTR(mpc_t *, SvIV(SvRV(a)))), *(INT2PTR(mpc_t *, SvIV(SvRV(a)))), SvUV(b), DEFAULT_ROUNDING_MODE);
+ return a;
+ }
+
+ if(SvIOK(b)) {
+ if(SvIV(b) >= 0) {
+ mpc_div_ui(*(INT2PTR(mpc_t *, SvIV(SvRV(a)))), *(INT2PTR(mpc_t *, SvIV(SvRV(a)))), SvUV(b), DEFAULT_ROUNDING_MODE);
+ return a;
+ }
+ mpc_div_ui(*(INT2PTR(mpc_t *, SvIV(SvRV(a)))), *(INT2PTR(mpc_t *, SvIV(SvRV(a)))), SvIV(b) * -1, DEFAULT_ROUNDING_MODE);
+ mpc_neg(*(INT2PTR(mpc_t *, SvIV(SvRV(a)))), *(INT2PTR(mpc_t *, SvIV(SvRV(a)))), DEFAULT_ROUNDING_MODE);
+ return a;
+ }
+#endif
+
+ if(SvNOK(b)) {
+ /* mpc_init3(temp, DEFAULT_PREC); */
+#ifdef USE_LONG_DOUBLE
+ _mpc_div_ld(*(INT2PTR(mpc_t *, SvIV(SvRV(a)))), *(INT2PTR(mpc_t *, SvIV(SvRV(a)))), (long double)SvNV(b), DEFAULT_ROUNDING_MODE);
+ /* mpc_set_ld(temp, SvNV(b), DEFAULT_ROUNDING_MODE); */
+#else
+ _mpc_div_d(*(INT2PTR(mpc_t *, SvIV(SvRV(a)))), *(INT2PTR(mpc_t *, SvIV(SvRV(a)))), (double)SvNV(b), DEFAULT_ROUNDING_MODE);
+ /* mpc_set_d(temp, SvNV(b), DEFAULT_ROUNDING_MODE); */
+#endif
+ /* mpc_div(*(INT2PTR(mpc_t *, SvIV(SvRV(a)))), *(INT2PTR(mpc_t *, SvIV(SvRV(a)))), temp, DEFAULT_ROUNDING_MODE); */
+ /* mpc_clear(temp); */
+ return a;
+ }
+
+ if(SvPOK(b)) {
+ mpc_init3(temp, DEFAULT_PREC);
+ if(mpc_set_str(temp, SvPV_nolen(b), 0, DEFAULT_ROUNDING_MODE) == -1) {
+ SvREFCNT_dec(a);
+ croak("Invalid string supplied to Math::MPC::overload_div_eq");
+ }
+ mpc_div(*(INT2PTR(mpc_t *, SvIV(SvRV(a)))), *(INT2PTR(mpc_t *, SvIV(SvRV(a)))), temp, DEFAULT_ROUNDING_MODE);
+ mpc_clear(temp);
+ return a;
+ }
+
+ if(sv_isobject(b)) {
+ const char *h = HvNAME(SvSTASH(SvRV(b)));
+ if(strEQ(h, "Math::MPC")) {
+ mpc_div(*(INT2PTR(mpc_t *, SvIV(SvRV(a)))), *(INT2PTR(mpc_t *, SvIV(SvRV(a)))), *(INT2PTR(mpc_t *, SvIV(SvRV(b)))), DEFAULT_ROUNDING_MODE);
+ return a;
+ }
+ }
+
+ SvREFCNT_dec(a);
+ croak("Invalid argument supplied to Math::MPC::overload_div_eq function");
+
+}
+
+SV * overload_sub_eq(pTHX_ SV * a, SV * b, SV * third) {
+ dMY_CXT;
+ mpc_t temp;
+
+ SvREFCNT_inc(a);
+
+#ifdef USE_64_BIT_INT
+ if(SvUOK(b)) {
+ mpc_init3(temp, DEFAULT_PREC);
+#ifdef _MSC_VER
+ mpc_set_str(temp, SvPV_nolen(b), 10, DEFAULT_ROUNDING_MODE);
+#else
+ mpc_set_uj(temp, SvUV(b), DEFAULT_ROUNDING_MODE);
+#endif
+ mpc_sub(*(INT2PTR(mpc_t *, SvIV(SvRV(a)))), *(INT2PTR(mpc_t *, SvIV(SvRV(a)))), temp, DEFAULT_ROUNDING_MODE);
+ mpc_clear(temp);
+ return a;
+ }
+
+ if(SvIOK(b)) {
+ mpc_init3(temp, DEFAULT_PREC);
+#ifdef _MSC_VER
+ mpc_set_str(temp, SvPV_nolen(b), 10, DEFAULT_ROUNDING_MODE);
+#else
+ mpc_set_sj(temp, SvIV(b), DEFAULT_ROUNDING_MODE);
+#endif
+ mpc_sub(*(INT2PTR(mpc_t *, SvIV(SvRV(a)))), *(INT2PTR(mpc_t *, SvIV(SvRV(a)))), temp, DEFAULT_ROUNDING_MODE);
+ mpc_clear(temp);
+ return a;
+ }
+#else
+ if(SvUOK(b)) {
+ mpc_sub_ui(*(INT2PTR(mpc_t *, SvIV(SvRV(a)))), *(INT2PTR(mpc_t *, SvIV(SvRV(a)))), SvUV(b), DEFAULT_ROUNDING_MODE);
+ return a;
+ }
+
+ if(SvIOK(b)) {
+ if(SvIV(b) >= 0) {
+ mpc_sub_ui(*(INT2PTR(mpc_t *, SvIV(SvRV(a)))), *(INT2PTR(mpc_t *, SvIV(SvRV(a)))), SvUV(b), DEFAULT_ROUNDING_MODE);
+ return a;
+ }
+ mpc_add_ui(*(INT2PTR(mpc_t *, SvIV(SvRV(a)))), *(INT2PTR(mpc_t *, SvIV(SvRV(a)))), SvIV(b) * -1, DEFAULT_ROUNDING_MODE);
+ return a;
+ }
+#endif
+
+ if(SvNOK(b)) {
+ mpc_init3(temp, DEFAULT_PREC);
+
+#ifdef USE_LONG_DOUBLE
+ mpc_set_ld(temp, SvNV(b), DEFAULT_ROUNDING_MODE);
+#else
+ mpc_set_d(temp, SvNV(b), DEFAULT_ROUNDING_MODE);
+#endif
+ mpc_sub(*(INT2PTR(mpc_t *, SvIV(SvRV(a)))), *(INT2PTR(mpc_t *, SvIV(SvRV(a)))), temp, DEFAULT_ROUNDING_MODE);
+ mpc_clear(temp);
+ return a;
+ }
+
+ if(SvPOK(b)) {
+ mpc_init3(temp, DEFAULT_PREC);
+ if(mpc_set_str(temp, SvPV_nolen(b), 0, DEFAULT_ROUNDING_MODE) == -1) {
+ SvREFCNT_dec(a);
+ croak("Invalid string supplied to Math::MPC::overload_sub_eq");
+ }
+ mpc_sub(*(INT2PTR(mpc_t *, SvIV(SvRV(a)))), *(INT2PTR(mpc_t *, SvIV(SvRV(a)))), temp, DEFAULT_ROUNDING_MODE);
+ mpc_clear(temp);
+ return a;
+ }
+
+ if(sv_isobject(b)) {
+ const char *h = HvNAME(SvSTASH(SvRV(b)));
+ if(strEQ(h, "Math::MPC")) {
+ mpc_sub(*(INT2PTR(mpc_t *, SvIV(SvRV(a)))), *(INT2PTR(mpc_t *, SvIV(SvRV(a)))), *(INT2PTR(mpc_t *, SvIV(SvRV(b)))), DEFAULT_ROUNDING_MODE);
+ return a;
+ }
+ }
+
+ SvREFCNT_dec(a);
+ croak("Invalid argument supplied to Math::MPC::overload_sub_eq function");
+
+}
+
+SV * overload_add_eq(pTHX_ SV * a, SV * b, SV * third) {
+ dMY_CXT;
+ mpc_t temp;
+ SvREFCNT_inc(a);
+
+#ifdef USE_64_BIT_INT
+ if(SvUOK(b)) {
+ mpc_init3(temp, DEFAULT_PREC);
+#ifdef _MSC_VER
+ mpc_set_str(temp, SvPV_nolen(b), 10, DEFAULT_ROUNDING_MODE);
+#else
+ mpc_set_uj(temp, SvUV(b), DEFAULT_ROUNDING_MODE);
+#endif
+ mpc_add(*(INT2PTR(mpc_t *, SvIV(SvRV(a)))), *(INT2PTR(mpc_t *, SvIV(SvRV(a)))), temp, DEFAULT_ROUNDING_MODE);
+ mpc_clear(temp);
+ return a;
+ }
+
+ if(SvIOK(b)) {
+ mpc_init3(temp, DEFAULT_PREC);
+ #ifdef _MSC_VER
+ mpc_set_str(temp, SvPV_nolen(b), 10, DEFAULT_ROUNDING_MODE);
+#else
+ mpc_set_sj(temp, SvIV(b), DEFAULT_ROUNDING_MODE);
+#endif
+ mpc_add(*(INT2PTR(mpc_t *, SvIV(SvRV(a)))), *(INT2PTR(mpc_t *, SvIV(SvRV(a)))), temp, DEFAULT_ROUNDING_MODE);
+ mpc_clear(temp);
+ return a;
+ }
+#else
+ if(SvUOK(b)) {
+ mpc_add_ui(*(INT2PTR(mpc_t *, SvIV(SvRV(a)))), *(INT2PTR(mpc_t *, SvIV(SvRV(a)))), SvUV(b), DEFAULT_ROUNDING_MODE);
+ return a;
+ }
+
+ if(SvIOK(b)) {
+ if(SvIV(b) >= 0) {
+ mpc_add_ui(*(INT2PTR(mpc_t *, SvIV(SvRV(a)))), *(INT2PTR(mpc_t *, SvIV(SvRV(a)))), SvUV(b), DEFAULT_ROUNDING_MODE);
+ return a;
+ }
+ mpc_sub_ui(*(INT2PTR(mpc_t *, SvIV(SvRV(a)))), *(INT2PTR(mpc_t *, SvIV(SvRV(a)))), SvIV(b) * -1, DEFAULT_ROUNDING_MODE);
+ return a;
+ }
+#endif
+
+ if(SvNOK(b)) {
+ mpc_init3(temp, DEFAULT_PREC);
+#ifdef USE_LONG_DOUBLE
+ mpc_set_ld(temp, SvNV(b), DEFAULT_ROUNDING_MODE);
+#else
+ mpc_set_d(temp, SvNV(b), DEFAULT_ROUNDING_MODE);
+#endif
+ mpc_add(*(INT2PTR(mpc_t *, SvIV(SvRV(a)))), *(INT2PTR(mpc_t *, SvIV(SvRV(a)))), temp, DEFAULT_ROUNDING_MODE);
+ mpc_clear(temp);
+ return a;
+ }
+
+ if(SvPOK(b)) {
+ mpc_init3(temp, DEFAULT_PREC);
+ if(mpc_set_str(temp, SvPV_nolen(b), 0, DEFAULT_ROUNDING_MODE) == -1) {
+ SvREFCNT_dec(a);
+ croak("Invalid string supplied to Math::MPC::overload_add_eq");
+ }
+ mpc_add(*(INT2PTR(mpc_t *, SvIV(SvRV(a)))), *(INT2PTR(mpc_t *, SvIV(SvRV(a)))), temp, DEFAULT_ROUNDING_MODE);
+ mpc_clear(temp);
+ return a;
+ }
+
+ if(sv_isobject(b)) {
+ const char *h = HvNAME(SvSTASH(SvRV(b)));
+ if(strEQ(h, "Math::MPC")) {
+ mpc_add(*(INT2PTR(mpc_t *, SvIV(SvRV(a)))), *(INT2PTR(mpc_t *, SvIV(SvRV(a)))), *(INT2PTR(mpc_t *, SvIV(SvRV(b)))), DEFAULT_ROUNDING_MODE);
+ return a;
+ }
+ }
+
+ SvREFCNT_dec(a);
+ croak("Invalid argument supplied to Math::MPC::overload_add_eq");
+}
+
+SV * overload_mul_eq(pTHX_ SV * a, SV * b, SV * third) {
+ dMY_CXT;
+ mpc_t temp;
+
+ SvREFCNT_inc(a);
+
+#ifdef USE_64_BIT_INT
+ if(SvUOK(b)) {
+ mpc_init3(temp, DEFAULT_PREC);
+#ifdef _MSC_VER
+ mpc_set_str(temp, SvPV_nolen(b), 10, DEFAULT_ROUNDING_MODE);
+#else
+ mpc_set_uj(temp, SvUV(b), DEFAULT_ROUNDING_MODE);
+#endif
+ mpc_mul(*(INT2PTR(mpc_t *, SvIV(SvRV(a)))), *(INT2PTR(mpc_t *, SvIV(SvRV(a)))), temp, DEFAULT_ROUNDING_MODE);
+ mpc_clear(temp);
+ return a;
+ }
+
+ if(SvIOK(b)) {
+ /* mpc_init3(temp, DEFAULT_PREC); */
+#ifdef _MSC_VER
+ mpc_init3(temp, DEFAULT_PREC);
+ mpc_set_str(temp, SvPV_nolen(b), 10, DEFAULT_ROUNDING_MODE);
+ mpc_mul(*(INT2PTR(mpc_t *, SvIV(SvRV(a)))), *(INT2PTR(mpc_t *, SvIV(SvRV(a)))), temp, DEFAULT_ROUNDING_MODE);
+ mpc_clear(temp);
+#else
+ /* mpc_set_sj(temp, SvIV(b), DEFAULT_ROUNDING_MODE); */
+ _mpc_mul_sj(*(INT2PTR(mpc_t *, SvIV(SvRV(a)))), *(INT2PTR(mpc_t *, SvIV(SvRV(a)))), SvUV(b), DEFAULT_ROUNDING_MODE);
+#endif
+ /* mpc_mul(*(INT2PTR(mpc_t *, SvIV(SvRV(a)))), *(INT2PTR(mpc_t *, SvIV(SvRV(a)))), temp, DEFAULT_ROUNDING_MODE);
+ mpc_clear(temp); */
+ return a;
+ }
+#else
+ if(SvUOK(b)) {
+ mpc_mul_ui(*(INT2PTR(mpc_t *, SvIV(SvRV(a)))), *(INT2PTR(mpc_t *, SvIV(SvRV(a)))), SvUV(b), DEFAULT_ROUNDING_MODE);
+ return a;
+ }
+
+ if(SvIOK(b)) {
+ mpc_mul_si(*(INT2PTR(mpc_t *, SvIV(SvRV(a)))), *(INT2PTR(mpc_t *, SvIV(SvRV(a)))), SvUV(b), DEFAULT_ROUNDING_MODE);
+ return a;
+ }
+
+#endif
+
+ if(SvNOK(b)) {
+ /* mpc_init3(temp, DEFAULT_PREC); */
+#ifdef USE_LONG_DOUBLE
+ _mpc_mul_ld(*(INT2PTR(mpc_t *, SvIV(SvRV(a)))), *(INT2PTR(mpc_t *, SvIV(SvRV(a)))), (long double)SvNV(b), DEFAULT_ROUNDING_MODE);
+ /* mpc_set_ld(temp, SvNV(b), DEFAULT_ROUNDING_MODE); */
+#else
+ _mpc_mul_d(*(INT2PTR(mpc_t *, SvIV(SvRV(a)))), *(INT2PTR(mpc_t *, SvIV(SvRV(a)))), (double)SvNV(b), DEFAULT_ROUNDING_MODE);
+ /* mpc_set_d(temp, SvNV(b), DEFAULT_ROUNDING_MODE); */
+#endif
+ /* mpc_mul(*(INT2PTR(mpc_t *, SvIV(SvRV(a)))), *(INT2PTR(mpc_t *, SvIV(SvRV(a)))), temp, DEFAULT_ROUNDING_MODE); */
+ /* mpc_clear(temp); */
+ return a;
+ }
+
+ if(SvPOK(b)) {
+ mpc_init3(temp, DEFAULT_PREC);
+ if(mpc_set_str(temp, SvPV_nolen(b), 0, DEFAULT_ROUNDING_MODE) == -1) {
+ SvREFCNT_dec(a);
+ croak("Invalid string supplied to Math::MPC::overload_mul_eq");
+ }
+ mpc_mul(*(INT2PTR(mpc_t *, SvIV(SvRV(a)))), *(INT2PTR(mpc_t *, SvIV(SvRV(a)))), temp, DEFAULT_ROUNDING_MODE);
+ mpc_clear(temp);
+ return a;
+ }
+
+ if(sv_isobject(b)) {
+ const char *h = HvNAME(SvSTASH(SvRV(b)));
+ if(strEQ(h, "Math::MPC")) {
+ mpc_mul(*(INT2PTR(mpc_t *, SvIV(SvRV(a)))), *(INT2PTR(mpc_t *, SvIV(SvRV(a)))), *(INT2PTR(mpc_t *, SvIV(SvRV(b)))), DEFAULT_ROUNDING_MODE);
+ return a;
+ }
+ }
+
+ SvREFCNT_dec(a);
+ croak("Invalid argument supplied to Math::MPC::overload_mul_eq");
+}
+
+SV * overload_pow(pTHX_ mpc_t * a, SV * b, SV * third) {
+ dMY_CXT;
+ mpc_t * mpc_t_obj;
+ SV * obj_ref, * obj;
+
+ New(1, mpc_t_obj, 1, mpc_t);
+ if(mpc_t_obj == NULL) croak("Failed to allocate memory in overload_pow function");
+ obj_ref = newSV(0);
+ obj = newSVrv(obj_ref, "Math::MPC");
+ mpc_init3(*mpc_t_obj, DEFAULT_PREC);
+ sv_setiv(obj, INT2PTR(IV,mpc_t_obj));
+ SvREADONLY_on(obj);
+
+#ifdef USE_64_BIT_INT
+
+ if(SvUOK(b)) {
+#ifdef _MSC_VER
+ mpc_set_str(*mpc_t_obj, SvPV_nolen(b), 10, DEFAULT_ROUNDING_MODE);
+#else
+ mpc_set_uj(*mpc_t_obj, SvUV(b), DEFAULT_ROUNDING_MODE);
+#endif
+ mpc_pow(*mpc_t_obj, *a, *mpc_t_obj, DEFAULT_ROUNDING_MODE);
+ return obj_ref;
+ }
+
+ if(SvIOK(b)) {
+#ifdef _MSC_VER
+ mpc_set_str(*mpc_t_obj, SvPV_nolen(b), 10, DEFAULT_ROUNDING_MODE);
+#else
+ mpc_set_sj(*mpc_t_obj, SvIV(b), DEFAULT_ROUNDING_MODE);
+#endif
+ mpc_pow(*mpc_t_obj, *a, *mpc_t_obj, DEFAULT_ROUNDING_MODE);
+ return obj_ref;
+ }
+
+#else
+ if(SvUOK(b)) {
+ mpc_pow_ui(*mpc_t_obj, *a, SvUV(b), DEFAULT_ROUNDING_MODE);
+ return obj_ref;
+ }
+
+ if(SvIOK(b)) {
+ mpc_pow_si(*mpc_t_obj, *a, SvIV(b), DEFAULT_ROUNDING_MODE);
+ return obj_ref;
+ }
+#endif
+
+ if(SvNOK(b)) {
+#ifdef USE_LONG_DOUBLE
+ mpc_pow_ld(*mpc_t_obj, *a, SvNV(b), DEFAULT_ROUNDING_MODE);
+#else
+ mpc_pow_d(*mpc_t_obj, *a, SvNV(b), DEFAULT_ROUNDING_MODE);
+#endif
+
+ return obj_ref;
+ }
+
+ if(SvPOK(b)) {
+ if(mpc_set_str(*mpc_t_obj, SvPV_nolen(b), 0, DEFAULT_ROUNDING_MODE) == -1)
+ croak("Invalid string supplied to Math::MPC::overload_pow");
+ mpc_pow(*mpc_t_obj, *a, *mpc_t_obj, DEFAULT_ROUNDING_MODE);
+ return obj_ref;
+ }
+
+ if(sv_isobject(b)) {
+ const char *h = HvNAME(SvSTASH(SvRV(b)));
+ if(strEQ(h, "Math::MPC")) {
+ mpc_pow(*mpc_t_obj, *a, *(INT2PTR(mpc_t *, SvIV(SvRV(b)))), DEFAULT_ROUNDING_MODE);
+ return obj_ref;
+ }
+ }
+
+ croak("Invalid argument supplied to Math::MPC::overload_pow");
+}
+
+SV * overload_pow_eq(pTHX_ SV * a, SV * b, SV * third) {
+ dMY_CXT;
+ mpc_t temp;
+
+ SvREFCNT_inc(a);
+
+#ifdef USE_64_BIT_INT
+ if(SvUOK(b)) {
+ mpc_init3(temp, DEFAULT_PREC);
+#ifdef _MSC_VER
+ mpc_set_str(temp, SvPV_nolen(b), 10, DEFAULT_ROUNDING_MODE);
+#else
+ mpc_set_uj(temp, SvUV(b), DEFAULT_ROUNDING_MODE);
+#endif
+ mpc_pow(*(INT2PTR(mpc_t *, SvIV(SvRV(a)))), *(INT2PTR(mpc_t *, SvIV(SvRV(a)))), temp, DEFAULT_ROUNDING_MODE);
+ mpc_clear(temp);
+ return a;
+ }
+
+ if(SvIOK(b)) {
+ mpc_init3(temp, DEFAULT_PREC);
+#ifdef _MSC_VER
+ mpc_set_str(temp, SvPV_nolen(b), 10, DEFAULT_ROUNDING_MODE);
+#else
+ mpc_set_sj(temp, SvIV(b), DEFAULT_ROUNDING_MODE);
+#endif
+ mpc_pow(*(INT2PTR(mpc_t *, SvIV(SvRV(a)))), *(INT2PTR(mpc_t *, SvIV(SvRV(a)))), temp, DEFAULT_ROUNDING_MODE);
+ mpc_clear(temp);
+ return a;
+ }
+#else
+ if(SvUOK(b)) {
+ mpc_pow_ui(*(INT2PTR(mpc_t *, SvIV(SvRV(a)))), *(INT2PTR(mpc_t *, SvIV(SvRV(a)))), SvUV(b), DEFAULT_ROUNDING_MODE);
+ return a;
+ }
+
+ if(SvIOK(b)) {
+ mpc_pow_si(*(INT2PTR(mpc_t *, SvIV(SvRV(a)))), *(INT2PTR(mpc_t *, SvIV(SvRV(a)))), SvIV(b), DEFAULT_ROUNDING_MODE);
+ return a;
+ }
+
+#endif
+
+ if(SvNOK(b)) {
+#ifdef USE_LONG_DOUBLE
+ mpc_pow_ld(*(INT2PTR(mpc_t *, SvIV(SvRV(a)))), *(INT2PTR(mpc_t *, SvIV(SvRV(a)))), SvNV(b), DEFAULT_ROUNDING_MODE);
+#else
+ mpc_pow_d(*(INT2PTR(mpc_t *, SvIV(SvRV(a)))), *(INT2PTR(mpc_t *, SvIV(SvRV(a)))), SvNV(b), DEFAULT_ROUNDING_MODE);
+#endif
+ return a;
+ }
+
+ if(SvPOK(b)) {
+ mpc_init3(temp, DEFAULT_PREC);
+ if(mpc_set_str(temp, SvPV_nolen(b), 0, DEFAULT_ROUNDING_MODE) == -1) {
+ SvREFCNT_dec(a);
+ croak("Invalid string supplied to Math::MPC::overload_pow_eq");
+ }
+ mpc_pow(*(INT2PTR(mpc_t *, SvIV(SvRV(a)))), *(INT2PTR(mpc_t *, SvIV(SvRV(a)))), temp, DEFAULT_ROUNDING_MODE);
+ mpc_clear(temp);
+ return a;
+ }
+
+ if(sv_isobject(b)) {
+ const char *h = HvNAME(SvSTASH(SvRV(b)));
+ if(strEQ(h, "Math::MPC")) {
+ mpc_pow(*(INT2PTR(mpc_t *, SvIV(SvRV(a)))), *(INT2PTR(mpc_t *, SvIV(SvRV(a)))), *(INT2PTR(mpc_t *, SvIV(SvRV(b)))), DEFAULT_ROUNDING_MODE);
+ return a;
+ }
+ }
+
+ SvREFCNT_dec(a);
+ croak("Invalid argument supplied to Math::MPC::overload_pow_eq");
+}
+
+SV * overload_equiv(pTHX_ mpc_t * a, SV * b, SV * third) {
+ dMY_CXT;
+ mpfr_t temp;
+ mpc_t t;
+ int ret;
+
+ if(mpfr_nan_p(MPC_RE(*a)) || mpfr_nan_p(MPC_IM(*a))) return newSViv(0);
+
+#ifdef USE_64_BIT_INT
+ if(SvUOK(b)) {
+ mpfr_init2(temp, DEFAULT_PREC_RE);
+#ifdef _MSC_VER
+ mpfr_set_str(temp, SvPV_nolen(b), 10, DEFAULT_ROUNDING_MODE & 3);
+#else
+ mpfr_set_uj(temp, SvUV(b), DEFAULT_ROUNDING_MODE & 3);
+#endif
+ mpc_init3(t, DEFAULT_PREC);
+ mpc_set_ui_ui(t, 0, 0, DEFAULT_ROUNDING_MODE);
+ mpc_add_fr(t, t, temp, DEFAULT_ROUNDING_MODE);
+ mpfr_clear(temp);
+ ret = mpc_cmp(*a, t);
+ mpc_clear(t);
+ if(ret == 0) return newSViv(1);
+ return newSViv(0);
+ }
+
+ if(SvIOK(b)) {
+ mpfr_init2(temp, DEFAULT_PREC_RE);
+#ifdef _MSC_VER
+ mpfr_set_str(temp, SvPV_nolen(b), 10, DEFAULT_ROUNDING_MODE & 3);
+#else
+ mpfr_set_sj(temp, SvIV(b), DEFAULT_ROUNDING_MODE & 3);
+#endif
+ mpc_init3(t, DEFAULT_PREC);
+ mpc_set_ui_ui(t, 0, 0, DEFAULT_ROUNDING_MODE);
+ mpc_add_fr(t, t, temp, DEFAULT_ROUNDING_MODE);
+ mpfr_clear(temp);
+ ret = mpc_cmp(*a, t);
+ mpc_clear(t);
+ if(ret == 0) return newSViv(1);
+ return newSViv(0);
+ }
+#else
+ if(SvUOK(b)) {
+ mpc_init3(t, DEFAULT_PREC);
+ mpc_set_ui(t, SvUV(b), DEFAULT_ROUNDING_MODE);
+ ret = mpc_cmp(*a, t);
+ mpc_clear(t);
+ if(ret == 0) return newSViv(1);
+ return newSViv(0);
+ }
+
+ if(SvIOK(b)) {
+ ret = mpc_cmp_si(*a, SvIV(b));
+ if(ret == 0) return newSViv(1);
+ return newSViv(0);
+ }
+#endif
+
+ if(SvNOK(b)) {
+#ifdef USE_LONG_DOUBLE
+ mpfr_init2(temp, DEFAULT_PREC_RE);
+ mpfr_set_ld(temp, SvNV(b), DEFAULT_ROUNDING_MODE & 3);
+ if(mpfr_nan_p(temp)) {
+ mpfr_clear(temp);
+ return newSViv(0);
+ }
+ mpc_init3(t, DEFAULT_PREC);
+ mpc_set_ui_ui(t, 0, 0, DEFAULT_ROUNDING_MODE);
+ mpc_add_fr(t, t, temp, DEFAULT_ROUNDING_MODE);
+ mpfr_clear(temp);
+ ret = mpc_cmp(*a, t);
+ mpc_clear(t);
+#else
+ mpc_init3(t, DEFAULT_PREC);
+ mpc_set_d(t, SvNV(b), DEFAULT_ROUNDING_MODE);
+ if(mpfr_nan_p(MPC_RE(t))) ret = 1;
+ else ret = mpc_cmp(*a, t);
+ mpc_clear(t);
+#endif
+ if(ret == 0) return newSViv(1);
+ return newSViv(0);
+ }
+
+ if(SvPOK(b)) {
+ mpfr_init2(temp, DEFAULT_PREC_RE);
+ if(mpfr_set_str(temp, (char *)SvPV_nolen(b), 0, DEFAULT_ROUNDING_MODE & 3))
+ croak("Invalid string supplied to Math::MPC::overload_equiv");
+ mpc_init3(t, DEFAULT_PREC);
+ mpc_set_ui_ui(t, 0, 0, DEFAULT_ROUNDING_MODE);
+ mpc_add_fr(t, t, temp, DEFAULT_ROUNDING_MODE);
+ mpfr_clear(temp);
+ ret = mpc_cmp(*a, t);
+ mpc_clear(t);
+ if(ret == 0) return newSViv(1);
+ return newSViv(0);
+ }
+
+ if(sv_isobject(b)) {
+ const char *h = HvNAME(SvSTASH(SvRV(b)));
+ if(strEQ(h, "Math::MPC")) {
+ if(mpfr_nan_p(MPC_RE(*(INT2PTR(mpc_t *, SvIV(SvRV(b)))))) ||
+ mpfr_nan_p(MPC_IM(*(INT2PTR(mpc_t *, SvIV(SvRV(b))))))) return newSViv(0);
+ ret = mpc_cmp(*a, *(INT2PTR(mpc_t *, SvIV(SvRV(b)))));
+ if(ret == 0) return newSViv(1);
+ return newSViv(0);
+ }
+ }
+
+ croak("Invalid argument supplied to Math::MPC::overload_equiv");
+}
+
+SV * overload_not_equiv(pTHX_ mpc_t * a, SV * b, SV * third) {
+ dMY_CXT;
+ mpfr_t temp;
+ mpc_t t;
+ int ret;
+
+ if(mpfr_nan_p(MPC_RE(*a)) || mpfr_nan_p(MPC_IM(*a))) return newSViv(1);
+
+#ifdef USE_64_BIT_INT
+ if(SvUOK(b)) {
+ mpfr_init2(temp, DEFAULT_PREC_RE);
+#ifdef _MSC_VER
+ mpfr_set_str(temp, SvPV_nolen(b), 10, DEFAULT_ROUNDING_MODE & 3);
+#else
+ mpfr_set_uj(temp, SvUV(b), DEFAULT_ROUNDING_MODE & 3);
+#endif
+ mpc_init3(t, DEFAULT_PREC);
+ mpc_set_ui_ui(t, 0, 0, DEFAULT_ROUNDING_MODE);
+ mpc_add_fr(t, t, temp, DEFAULT_ROUNDING_MODE);
+ mpfr_clear(temp);
+ ret = mpc_cmp(*a, t);
+ mpc_clear(t);
+ if(ret == 0) return newSViv(0);
+ return newSViv(1);
+ }
+
+ if(SvIOK(b)) {
+ mpfr_init2(temp, DEFAULT_PREC_RE);
+#ifdef _MSC_VER
+ mpfr_set_str(temp, SvPV_nolen(b), 10, DEFAULT_ROUNDING_MODE & 3);
+#else
+ mpfr_set_sj(temp, SvIV(b), DEFAULT_ROUNDING_MODE & 3);
+#endif
+ mpc_init3(t, DEFAULT_PREC);
+ mpc_set_ui_ui(t, 0, 0, DEFAULT_ROUNDING_MODE);
+ mpc_add_fr(t, t, temp, DEFAULT_ROUNDING_MODE);
+ mpfr_clear(temp);
+ ret = mpc_cmp(*a, t);
+ mpc_clear(t);
+ if(ret == 0) return newSViv(0);
+ return newSViv(1);
+ }
+#else
+ if(SvUOK(b)) {
+ mpc_init3(t, DEFAULT_PREC);
+ mpc_set_ui(t, SvUV(b), DEFAULT_ROUNDING_MODE);
+ ret = mpc_cmp(*a, t);
+ mpc_clear(t);
+ if(ret == 0) return newSViv(0);
+ return newSViv(1);
+ }
+
+ if(SvIOK(b)) {
+ ret = mpc_cmp_si(*a, SvIV(b));
+ if(ret == 0) return newSViv(0);
+ return newSViv(1);
+ }
+#endif
+
+ if(SvNOK(b)) {
+#ifdef USE_LONG_DOUBLE
+ mpfr_init2(temp, DEFAULT_PREC_RE);
+ mpfr_set_ld(temp, SvNV(b), DEFAULT_ROUNDING_MODE & 3);
+ if(mpfr_nan_p(temp)) {
+ mpfr_clear(temp);
+ return newSViv(1);
+ }
+ mpc_init3(t, DEFAULT_PREC);
+ mpc_set_ui_ui(t, 0, 0, DEFAULT_ROUNDING_MODE);
+ mpc_add_fr(t, t, temp, DEFAULT_ROUNDING_MODE);
+ mpfr_clear(temp);
+ ret = mpc_cmp(*a, t);
+ mpc_clear(t);
+#else
+ mpc_init3(t, DEFAULT_PREC);
+ mpc_set_d(t, SvNV(b), DEFAULT_ROUNDING_MODE);
+ if(mpfr_nan_p(MPC_RE(t))) ret = 1;
+ else ret = mpc_cmp(*a, t);
+ mpc_clear(t);
+#endif
+ if(ret == 0) return newSViv(0);
+ return newSViv(1);
+ }
+
+ if(SvPOK(b)) {
+ mpfr_init2(temp, DEFAULT_PREC_RE);
+ if(mpfr_set_str(temp, (char *)SvPV_nolen(b), 0, DEFAULT_ROUNDING_MODE & 3))
+ croak("Invalid string supplied to Math::MPC::overload_not_equiv");
+ mpc_init3(t, DEFAULT_PREC);
+ mpc_set_ui_ui(t, 0, 0, DEFAULT_ROUNDING_MODE);
+ mpc_add_fr(t, t, temp, DEFAULT_ROUNDING_MODE);
+ mpfr_clear(temp);
+ ret = mpc_cmp(*a, t);
+ mpc_clear(t);
+ if(ret == 0) return newSViv(0);
+ return newSViv(1);
+ }
+
+ if(sv_isobject(b)) {
+ const char *h = HvNAME(SvSTASH(SvRV(b)));
+ if(strEQ(h, "Math::MPC")) {
+ if(mpfr_nan_p(MPC_RE(*(INT2PTR(mpc_t *, SvIV(SvRV(b)))))) ||
+ mpfr_nan_p(MPC_IM(*(INT2PTR(mpc_t *, SvIV(SvRV(b))))))) return newSViv(1);
+ if(mpc_cmp(*a, *(INT2PTR(mpc_t *, SvIV(SvRV(b)))))) return newSViv(1);
+ return newSViv(0);
+ }
+ }
+
+ croak("Invalid argument supplied to Math::MPC::overload_not_equiv");
+}
+
+SV * overload_not(pTHX_ mpc_t * a, SV * second, SV * third) {
+ if(mpfr_nan_p(MPC_RE(*a)) || mpfr_nan_p(MPC_IM(*a))) return newSViv(1); /* Thanks Jean-Louis Morel */
+ if(mpc_cmp_si_si(*a, 0, 0)) return newSViv(0);
+ return newSViv(1);
+}
+
+SV * overload_sqrt(pTHX_ mpc_t * p, SV * second, SV * third) {
+ dMY_CXT;
+ mpc_t * mpc_t_obj;
+ SV * obj_ref, * obj;
+
+ New(1, mpc_t_obj, 1, mpc_t);
+ if(mpc_t_obj == NULL) croak("Failed to allocate memory in overload_sqrt function");
+ obj_ref = newSV(0);
+ obj = newSVrv(obj_ref, "Math::MPC");
+ mpc_init3(*mpc_t_obj, DEFAULT_PREC);
+
+ mpc_sqrt(*mpc_t_obj, *p, DEFAULT_ROUNDING_MODE);
+ sv_setiv(obj, INT2PTR(IV,mpc_t_obj));
+ SvREADONLY_on(obj);
+ return obj_ref;
+}
+
+void overload_copy(pTHX_ mpc_t * p, SV * second, SV * third) {
+ dXSARGS;
+ dMY_CXT;
+ mpc_t * mpc_t_obj;
+ SV * obj_ref, * obj;
+ mp_prec_t re, im;
+
+ New(1, mpc_t_obj, 1, mpc_t);
+ if(mpc_t_obj == NULL) croak("Failed to allocate memory in overload_copy function");
+ obj_ref = newSV(0);
+ obj = newSVrv(obj_ref, "Math::MPC");
+
+ mpc_get_prec2(&re, &im, *p);
+ mpc_init3(*mpc_t_obj, re, im);
+ mpc_set(*mpc_t_obj, *p, DEFAULT_ROUNDING_MODE);
+ sv_setiv(obj, INT2PTR(IV,mpc_t_obj));
+ SvREADONLY_on(obj);
+ ST(0) = sv_2mortal(obj_ref);
+ /* PUTBACK; *//* not needed */
+ XSRETURN(1);
+}
+
+SV * overload_abs(pTHX_ mpc_t * p, SV * second, SV * third) {
+ dMY_CXT;
+ mpfr_t * mpfr_t_obj;
+ SV * obj_ref, * obj;
+
+ New(1, mpfr_t_obj, 1, mpfr_t);
+ if(mpfr_t_obj == NULL) croak("Failed to allocate memory in overload_abs function");
+ obj_ref = newSV(0);
+ obj = newSVrv(obj_ref, "Math::MPFR");
+ mpfr_init(*mpfr_t_obj);
+
+ mpc_abs(*mpfr_t_obj, *p, DEFAULT_ROUNDING_MODE);
+ sv_setiv(obj, INT2PTR(IV,mpfr_t_obj));
+ SvREADONLY_on(obj);
+ return obj_ref;
+}
+
+SV * overload_exp(pTHX_ mpc_t * p, SV * second, SV * third) {
+ dMY_CXT;
+ mpc_t * mpc_t_obj;
+ SV * obj_ref, * obj;
+
+ New(1, mpc_t_obj, 1, mpc_t);
+ if(mpc_t_obj == NULL) croak("Failed to allocate memory in overload_exp function");
+ obj_ref = newSV(0);
+ obj = newSVrv(obj_ref, "Math::MPC");
+ mpc_init3(*mpc_t_obj, DEFAULT_PREC);
+
+ mpc_exp(*mpc_t_obj, *p, DEFAULT_ROUNDING_MODE);
+ sv_setiv(obj, INT2PTR(IV,mpc_t_obj));
+ SvREADONLY_on(obj);
+ return obj_ref;
+}
+
+SV * overload_log(pTHX_ mpc_t * p, SV * second, SV * third) {
+ dMY_CXT;
+ mpc_t * mpc_t_obj;
+ SV * obj_ref, * obj;
+
+ New(1, mpc_t_obj, 1, mpc_t);
+ if(mpc_t_obj == NULL) croak("Failed to allocate memory in overload_exp function");
+ obj_ref = newSV(0);
+ obj = newSVrv(obj_ref, "Math::MPC");
+ mpc_init3(*mpc_t_obj, DEFAULT_PREC);
+
+ mpc_log(*mpc_t_obj, *p, DEFAULT_ROUNDING_MODE);
+ sv_setiv(obj, INT2PTR(IV,mpc_t_obj));
+ SvREADONLY_on(obj);
+ return obj_ref;
+}
+
+SV * overload_sin(pTHX_ mpc_t * p, SV * second, SV * third) {
+ dMY_CXT;
+ mpc_t * mpc_t_obj;
+ SV * obj_ref, * obj;
+
+ New(1, mpc_t_obj, 1, mpc_t);
+ if(mpc_t_obj == NULL) croak("Failed to allocate memory in overload_sin function");
+ obj_ref = newSV(0);
+ obj = newSVrv(obj_ref, "Math::MPC");
+ mpc_init3(*mpc_t_obj, DEFAULT_PREC);
+
+ mpc_sin(*mpc_t_obj, *p, DEFAULT_ROUNDING_MODE);
+ sv_setiv(obj, INT2PTR(IV,mpc_t_obj));
+ SvREADONLY_on(obj);
+ return obj_ref;
+}
+
+SV * overload_cos(pTHX_ mpc_t * p, SV * second, SV * third) {
+ dMY_CXT;
+ mpc_t * mpc_t_obj;
+ SV * obj_ref, * obj;
+
+ New(1, mpc_t_obj, 1, mpc_t);
+ if(mpc_t_obj == NULL) croak("Failed to allocate memory in overload_sin function");
+ obj_ref = newSV(0);
+ obj = newSVrv(obj_ref, "Math::MPC");
+ mpc_init3(*mpc_t_obj, DEFAULT_PREC);
+
+ mpc_cos(*mpc_t_obj, *p, DEFAULT_ROUNDING_MODE);
+ sv_setiv(obj, INT2PTR(IV,mpc_t_obj));
+ SvREADONLY_on(obj);
+ return obj_ref;
+}
+
+void _get_r_string(pTHX_ mpc_t * p, SV * base, SV * n_digits, SV * round) {
+ dXSARGS;
+ char * out;
+ mp_exp_t ptr;
+ unsigned long b = SvUV(base);
+
+ if(b < 2 || b > 36) croak("Second argument supplied to r_string() is not in acceptable range");
+
+ out = mpfr_get_str(0, &ptr, b, SvUV(n_digits), MPC_RE(*p), (mpc_rnd_t)SvUV(round) & 3);
+
+ if(out == NULL) croak("An error occurred in _get_r_string(aTHX)");
+
+ /* sp = mark; *//* not needed */
+ ST(0) = sv_2mortal(newSVpv(out, 0));
+ mpfr_free_str(out);
+ ST(1) = sv_2mortal(newSViv(ptr));
+ /* PUTBACK; *//* not needed */
+ XSRETURN(2);
+}
+
+void _get_i_string(pTHX_ mpc_t * p, SV * base, SV * n_digits, SV * round) {
+ dXSARGS;
+ char * out;
+ mp_exp_t ptr;
+ unsigned long b = SvUV(base);
+
+ if(b < 2 || b > 36) croak("Second argument supplied to i_string() is not in acceptable range");
+
+ out = mpfr_get_str(0, &ptr, b, SvUV(n_digits), MPC_IM(*p), (mpc_rnd_t)SvUV(round) & 3);
+
+ if(out == NULL) croak("An error occurred in _get_i_string(aTHX)");
+
+ /* sp = mark; *//* not needed */
+ ST(0) = sv_2mortal(newSVpv(out, 0));
+ mpfr_free_str(out);
+ ST(1) = sv_2mortal(newSViv(ptr));
+ /* PUTBACK; *//* not needed */
+ XSRETURN(2);
+}
+
+
+/* ########################################
+ ########################################
+ ########################################
+ ########################################
+ ########################################
+ ######################################## */
+
+
+
+SV * _itsa(pTHX_ SV * a) {
+ if(SvUOK(a)) return newSVuv(1);
+ if(SvIOK(a)) return newSVuv(2);
+ if(SvNOK(a)) return newSVuv(3);
+ if(SvPOK(a)) return newSVuv(4);
+ if(sv_isobject(a)) {
+ const char *h = HvNAME(SvSTASH(SvRV(a)));
+ if(strEQ(h, "Math::MPFR")) return newSVuv(5);
+ if(strEQ(h, "Math::GMPf")) return newSVuv(6);
+ if(strEQ(h, "Math::GMPq")) return newSVuv(7);
+ if(strEQ(h, "Math::GMPz")) return newSVuv(8);
+ if(strEQ(h, "Math::GMP")) return newSVuv(9);
+ if(strEQ(h, "Math::MPC")) return newSVuv(10);
+ }
+ return newSVuv(0);
+}
+
+SV * _new_real(pTHX_ SV * b) {
+ dMY_CXT;
+ mpc_t * mpc_t_obj;
+ mpfr_t temp;
+ SV * obj_ref, * obj;
+
+ New(1, mpc_t_obj, 1, mpc_t);
+ if(mpc_t_obj == NULL) croak("Failed to allocate memory in _new_real function");
+ obj_ref = newSV(0);
+ obj = newSVrv(obj_ref, "Math::MPC");
+ mpc_init3(*mpc_t_obj, DEFAULT_PREC);
+
+ sv_setiv(obj, INT2PTR(IV,mpc_t_obj));
+ SvREADONLY_on(obj);
+
+#ifdef USE_64_BIT_INT
+
+ if(SvUOK(b)) {
+ mpfr_init2(temp, DEFAULT_PREC_RE);
+#ifdef _MSC_VER
+ mpfr_set_str(temp, SvPV_nolen(b), 10, DEFAULT_ROUNDING_MODE & 3);
+#else
+ mpfr_set_uj(temp, SvUV(b), DEFAULT_ROUNDING_MODE & 3);
+#endif
+ mpc_set_fr(*mpc_t_obj, temp, DEFAULT_ROUNDING_MODE);
+ mpfr_clear(temp);
+ return obj_ref;
+ }
+
+ if(SvIOK(b)) {
+ mpfr_init2(temp, DEFAULT_PREC_RE);
+#ifdef _MSC_VER
+ mpfr_set_str(temp, SvPV_nolen(b), 10, DEFAULT_ROUNDING_MODE & 3);
+#else
+ mpfr_set_sj(temp, SvIV(b), DEFAULT_ROUNDING_MODE & 3);
+#endif
+ mpc_set_fr(*mpc_t_obj, temp, DEFAULT_ROUNDING_MODE);
+ mpfr_clear(temp);
+ return obj_ref;
+ }
+
+#else
+ if(SvUOK(b)) {
+ mpc_set_ui(*mpc_t_obj, SvUV(b), DEFAULT_ROUNDING_MODE);
+ return obj_ref;
+ }
+
+ if(SvIOK(b)) {
+ mpc_set_si(*mpc_t_obj, SvIV(b), DEFAULT_ROUNDING_MODE);
+ return obj_ref;
+ }
+#endif
+
+ if(SvNOK(b)) {
+#ifdef USE_LONG_DOUBLE
+ mpc_set_ld(*mpc_t_obj, SvNV(b), DEFAULT_ROUNDING_MODE);
+#else
+ mpc_set_d(*mpc_t_obj, SvNV(b), DEFAULT_ROUNDING_MODE);
+#endif
+
+ return obj_ref;
+ }
+
+ if(SvPOK(b)) {
+ mpfr_init2(temp, DEFAULT_PREC_RE);
+ if(mpfr_set_str(temp, SvPV_nolen(b), 0, DEFAULT_ROUNDING_MODE & 3))
+ croak("Invalid string supplied to Math::MPC::new");
+ mpc_set_fr(*mpc_t_obj, temp, DEFAULT_ROUNDING_MODE);
+ mpfr_clear(temp);
+ return obj_ref;
+ }
+
+ if(sv_isobject(b)) {
+ const char *h = HvNAME(SvSTASH(SvRV(b)));
+ if(strEQ(h, "Math::MPFR")) {
+ mpc_set_fr(*mpc_t_obj, *(INT2PTR(mpfr_t *, SvIV(SvRV(b)))), DEFAULT_ROUNDING_MODE);
+ return obj_ref;
+ }
+ if(strEQ(h, "Math::GMPf")) {
+ mpc_set_f(*mpc_t_obj, *(INT2PTR(mpf_t *, SvIV(SvRV(b)))), DEFAULT_ROUNDING_MODE);
+ return obj_ref;
+ }
+ if(strEQ(h, "Math::GMPq")) {
+ mpc_set_q(*mpc_t_obj, *(INT2PTR(mpq_t *, SvIV(SvRV(b)))), DEFAULT_ROUNDING_MODE);
+ return obj_ref;
+ }
+ if(strEQ(h, "Math::GMP") ||
+ strEQ(h, "Math::GMPz")) {
+ mpc_set_z(*mpc_t_obj, *(INT2PTR(mpz_t *, SvIV(SvRV(b)))), DEFAULT_ROUNDING_MODE);
+ return obj_ref;
+ }
+ }
+
+ croak("Invalid argument supplied to Math::MPC::_new_real");
+}
+
+SV * _new_im(pTHX_ SV * b) {
+ dMY_CXT;
+ mpc_t * mpc_t_obj;
+ mpfr_t temp;
+ SV * obj_ref, * obj;
+ int ret;
+
+ New(1, mpc_t_obj, 1, mpc_t);
+ if(mpc_t_obj == NULL) croak("Failed to allocate memory in Rmpc_init function");
+ obj_ref = newSV(0);
+ obj = newSVrv(obj_ref, "Math::MPC");
+ mpc_init3(*mpc_t_obj, DEFAULT_PREC);
+
+ sv_setiv(obj, INT2PTR(IV,mpc_t_obj));
+ SvREADONLY_on(obj);
+
+#ifdef USE_64_BIT_INT
+
+ if(SvUOK(b)) {
+ mpfr_init2(temp, DEFAULT_PREC_IM);
+#ifdef _MSC_VER
+ mpfr_set_str(temp, SvPV_nolen(b), 10, DEFAULT_ROUNDING_MODE / 16);
+#else
+ mpfr_set_uj(temp, SvUV(b), DEFAULT_ROUNDING_MODE / 16);
+#endif
+ VOID_MPC_SET_X_Y(ui, fr, *mpc_t_obj, 0, temp, DEFAULT_ROUNDING_MODE);
+ mpfr_clear(temp);
+ return obj_ref;
+ }
+
+ if(SvIOK(b)) {
+ mpfr_init2(temp, DEFAULT_PREC_IM);
+#ifdef _MSC_VER
+ mpfr_set_str(temp, SvPV_nolen(b), 10, DEFAULT_ROUNDING_MODE / 16);
+#else
+ mpfr_set_sj(temp, SvIV(b), DEFAULT_ROUNDING_MODE / 16);
+#endif
+ VOID_MPC_SET_X_Y(ui, fr, *mpc_t_obj, 0, temp, DEFAULT_ROUNDING_MODE);
+ mpfr_clear(temp);
+ return obj_ref;
+ }
+
+#else
+ if(SvUOK(b)) {
+ mpc_set_ui_ui(*mpc_t_obj, 0, SvUV(b), DEFAULT_ROUNDING_MODE);
+ return obj_ref;
+ }
+
+ if(SvIOK(b)) {
+ mpc_set_si_si(*mpc_t_obj, 0, SvIV(b), DEFAULT_ROUNDING_MODE);
+ return obj_ref;
+ }
+#endif
+
+ if(SvNOK(b)) {
+#ifdef USE_LONG_DOUBLE
+ mpc_set_ld_ld(*mpc_t_obj, 0, SvNV(b), DEFAULT_ROUNDING_MODE);
+#else
+ mpc_set_d_d(*mpc_t_obj, 0, SvNV(b), DEFAULT_ROUNDING_MODE);
+#endif
+
+ return obj_ref;
+ }
+
+ if(SvPOK(b)) {
+ mpfr_init2(temp, DEFAULT_PREC_IM);
+ if(mpfr_set_str(temp, SvPV_nolen(b), 0, DEFAULT_ROUNDING_MODE / 16))
+ croak("Invalid string supplied to Math::MPC::new");
+ VOID_MPC_SET_X_Y(ui, fr, *mpc_t_obj, 0, temp, DEFAULT_ROUNDING_MODE);
+ mpfr_clear(temp);
+ return obj_ref;
+ }
+
+ if(sv_isobject(b)) {
+ const char *h = HvNAME(SvSTASH(SvRV(b)));
+ if(strEQ(h, "Math::MPFR")) {
+ VOID_MPC_SET_X_Y(ui, fr, *mpc_t_obj, 0, *(INT2PTR(mpfr_t *, SvIV(SvRV(b)))), DEFAULT_ROUNDING_MODE);
+ return obj_ref;
+ }
+ if(strEQ(h, "Math::GMPf")) {
+ mpfr_init2(temp, DEFAULT_PREC_IM);
+ mpfr_set_f(temp, *(INT2PTR(mpf_t *, SvIV(SvRV(b)))), DEFAULT_ROUNDING_MODE / 16);
+ VOID_MPC_SET_X_Y(ui, fr, *mpc_t_obj, 0, temp, DEFAULT_ROUNDING_MODE);
+ mpfr_clear(temp);
+ return obj_ref;
+ }
+ if(strEQ(h, "Math::GMPq")) {
+ mpfr_init2(temp, DEFAULT_PREC_IM);
+ mpfr_set_q(temp, *(INT2PTR(mpq_t *, SvIV(SvRV(b)))), DEFAULT_ROUNDING_MODE / 16);
+ VOID_MPC_SET_X_Y(ui, fr, *mpc_t_obj, 0, temp, DEFAULT_ROUNDING_MODE);
+ mpfr_clear(temp);
+ return obj_ref;
+ }
+ if(strEQ(h, "Math::GMP") ||
+ strEQ(h, "Math::GMPz")) {
+ mpfr_init2(temp, DEFAULT_PREC_IM);
+ mpfr_set_z(temp, *(INT2PTR(mpz_t *, SvIV(SvRV(b)))), DEFAULT_ROUNDING_MODE / 16);
+ VOID_MPC_SET_X_Y(ui, fr, *mpc_t_obj, 0, temp, DEFAULT_ROUNDING_MODE);
+ mpfr_clear(temp);
+ return obj_ref;
+ }
+ }
+
+ croak("Invalid argument supplied to Math::MPC::_new_im");
+}
+
+int _has_longlong(void) {
+#ifdef USE_64_BIT_INT
+ return 1;
+#else
+ return 0;
+#endif
+}
+
+int _has_longdouble(void) {
+#ifdef USE_LONG_DOUBLE
+ return 1;
+#else
+ return 0;
+#endif
+}
+
+/* Has inttypes.h been included ?
+ &&
+ Do we have USE_64_BIT_INT ? */
+
+int _has_inttypes() {
+#ifdef _MSC_VER
+return 0;
+#else
+#if defined USE_64_BIT_INT
+return 1;
+#else
+return 0;
+#endif
+#endif
+}
+
+SV * gmp_v(pTHX) {
+#if __GNU_MP_VERSION >= 4
+ return newSVpv(gmp_version, 0);
+#else
+ warn("From Math::MPC::gmp_v(aTHX): 'gmp_version' is not implemented - returning '0'");
+ return newSVpv("0", 0);
+#endif
+}
+
+SV * mpfr_v(pTHX) {
+ return newSVpv(mpfr_get_version(), 0);
+}
+
+/* Not yet available
+SV * RMPC_MAX_PREC(mpc_t * a) {
+ return newSVuv(MPC_MAX_PREC(*a));
+}
+*/
+
+SV * _MPC_VERSION_MAJOR(pTHX) {
+ return newSVuv(MPC_VERSION_MAJOR);
+}
+
+SV * _MPC_VERSION_MINOR(pTHX) {
+ return newSVuv(MPC_VERSION_MINOR);
+}
+
+SV * _MPC_VERSION_PATCHLEVEL(pTHX) {
+ return newSVuv(MPC_VERSION_PATCHLEVEL);
+}
+
+SV * _MPC_VERSION(pTHX) {
+ return newSVuv(MPC_VERSION);
+}
+
+SV * _MPC_VERSION_NUM(pTHX_ SV * x, SV * y, SV * z) {
+ return newSVuv(MPC_VERSION_NUM((unsigned long)SvUV(x), (unsigned long)SvUV(y), (unsigned long)SvUV(z)));
+}
+
+SV * _MPC_VERSION_STRING(pTHX) {
+ return newSVpv(MPC_VERSION_STRING, 0);
+}
+
+SV * Rmpc_get_version(pTHX) {
+ return newSVpv(mpc_get_version(), 0);
+}
+
+SV * Rmpc_real(pTHX_ mpfr_t * rop, mpc_t * op, SV * round) {
+ return newSViv(mpc_real(*rop, *op, (mpc_rnd_t)SvUV(round)));
+}
+
+SV * Rmpc_imag(pTHX_ mpfr_t * rop, mpc_t * op, SV * round) {
+ return newSViv(mpc_imag(*rop, *op, (mpc_rnd_t)SvUV(round)));
+}
+
+SV * Rmpc_arg(pTHX_ mpfr_t * rop, mpc_t * op, SV * round) {
+ return newSViv(mpc_arg(*rop, *op, (mpc_rnd_t)SvUV(round)));
+}
+
+SV * Rmpc_proj(pTHX_ mpc_t * rop, mpc_t * op, SV * round) {
+ return newSViv(mpc_proj(*rop, *op, (mpc_rnd_t)SvUV(round)));
+}
+
+SV * Rmpc_get_str(pTHX_ SV * base, SV * dig, mpc_t * op, SV * round) {
+ char * out;
+ SV * outsv;
+ out = mpc_get_str((int)SvIV(base), (size_t)SvUV(dig), *op, (mpc_rnd_t)SvUV(round));
+ outsv = newSVpv(out, 0);
+ mpc_free_str(out);
+ return outsv;
+}
+
+SV * Rmpc_set_str(pTHX_ mpc_t * rop, SV * str, SV * base, SV * round) {
+ return newSViv(mpc_set_str(*rop, SvPV_nolen(str), (int)SvIV(base), (mpc_rnd_t)SvUV(round)));
+}
+
+SV * Rmpc_strtoc(pTHX_ mpc_t * rop, SV * str, SV * base, SV * round) {
+ return newSViv(mpc_strtoc(*rop, SvPV_nolen(str), NULL, (int)SvIV(base), (mpc_rnd_t)SvUV(round)));
+}
+
+void Rmpc_set_nan(mpc_t * a) {
+ mpc_set_nan(*a);
+}
+
+void Rmpc_swap(mpc_t * a, mpc_t * b) {
+ mpc_swap(*a, *b);
+}
+
+/* atan2(x, y) = atan(x / y) */
+SV * overload_atan2(pTHX_ mpc_t * p, mpc_t * q, SV * third) {
+ dMY_CXT;
+ mpc_t * mpc_t_obj;
+ SV * obj_ref, * obj;
+
+ New(1, mpc_t_obj, 1, mpc_t);
+ if(mpc_t_obj == NULL) croak("Failed to allocate memory in overload_atan2 function");
+ obj_ref = newSV(0);
+ obj = newSVrv(obj_ref, "Math::MPC");
+ mpc_init3(*mpc_t_obj, DEFAULT_PREC);
+
+ mpc_div(*mpc_t_obj, *p, *q, DEFAULT_ROUNDING_MODE);
+
+ mpc_atan(*mpc_t_obj, *mpc_t_obj, DEFAULT_ROUNDING_MODE);
+ sv_setiv(obj, INT2PTR(IV,mpc_t_obj));
+ SvREADONLY_on(obj);
+ return obj_ref;
+}
+
+SV * Rmpc_sin_cos(pTHX_ mpc_t * rop_sin, mpc_t * rop_cos, mpc_t * op, SV * rnd_sin, SV * rnd_cos) {
+#ifdef SIN_COS_AVAILABLE
+ return newSViv(mpc_sin_cos(*rop_sin, *rop_cos, *op, (mpc_rnd_t)SvUV(rnd_sin), (mpc_rnd_t)SvUV(rnd_cos)));
+#else
+ croak("Rmpc_Âsin_cos() not supported by your version (%s) of the mpc library", MPC_VERSION_STRING);
+#endif
+}
+
+void Rmpc_get_dc(pTHX_ SV * crop, mpc_t * op, SV * round) {
+#ifdef _DO_COMPLEX_H
+ if(sv_isobject(crop)) {
+ const char *h = HvNAME(SvSTASH(SvRV(crop)));
+ if(strNE(h, "Math::Complex_C"))
+ croak("1st arg to Rmpc_get_dc is a %s object - needs to be a Math::Complex_C object", h);
+ }
+ else croak("1st arg to Rmpc_get_dc needs to be a Math::Complex_C object");
+ *(INT2PTR(double _Complex *, SvIV(SvRV(crop)))) = mpc_get_dc(*op, (mpc_rnd_t)SvUV(round));
+#else
+ croak("Rmpc_get_dc(aTHX) not implemented");
+#endif
+}
+
+void Rmpc_get_ldc(pTHX_ SV * crop, mpc_t * op, SV * round) {
+#ifdef _DO_COMPLEX_H
+ if(sv_isobject(crop)) {
+ const char *h = HvNAME(SvSTASH(SvRV(crop)));
+ if(strNE(h, "Math::Complex_C::Long"))
+ croak("1st arg to Rmpc_get_ldc is a %s object - needs to be a Math::Complex_C::Long object", h);
+ }
+ else croak("1st arg to Rmpc_get_ldc needs to be a Math::Complex_C::Long object");
+ *(INT2PTR(long double _Complex *, SvIV(SvRV(crop)))) = mpc_get_ldc(*op, (mpc_rnd_t)SvUV(round));
+#else
+ croak("Rmpc_get_ldc(aTHX) not implemented");
+#endif
+}
+
+SV * Rmpc_set_dc(pTHX_ mpc_t * op, SV * crop, SV * round) {
+#ifdef _DO_COMPLEX_H
+ if(sv_isobject(crop)) {
+ const char *h = HvNAME(SvSTASH(SvRV(crop)));
+ if(strNE(h, "Math::Complex_C"))
+ croak("2nd arg to Rmpc_set_dc is a %s object - needs to be a Math::Complex_C object", h);
+ }
+ else croak("2nd arg to Rmpc_set_dc needs to be a Math::Complex_C object");
+ return newSViv(mpc_set_dc(*op, *(INT2PTR(double _Complex *, SvIV(SvRV(crop)))), (mpc_rnd_t)SvUV(round)));
+#else
+ croak("Rmpc_set_dc(aTHX) not implemented");
+#endif
+}
+
+SV * Rmpc_set_ldc(pTHX_ mpc_t * op, SV * crop, SV * round) {
+#ifdef _DO_COMPLEX_H
+ if(sv_isobject(crop)) {
+ const char *h = HvNAME(SvSTASH(SvRV(crop)));
+ if(strNE(h, "Math::Complex_C::Long"))
+ croak("2nd arg to Rmpc_set_ldc is a %s object - needs ti be a Math::Complex_C::Long object", h);
+ }
+ else croak("2nd arg to Rmpc_set_ldc needs to be a Math::Complex_C::Long object");
+ return newSViv(mpc_set_ldc(*op, *(INT2PTR(long double _Complex *, SvIV(SvRV(crop)))), (mpc_rnd_t)SvUV(round)));
+#else
+ croak("Rmpc_set_ldc(aTHX) not implemented");
+#endif
+}
+
+int _have_Complex_h(void) {
+#ifdef _DO_COMPLEX_H
+ return 1;
+#else
+ return 0;
+#endif
+}
+
+SV * _mpfr_buildopt_tls_p(pTHX) {
+#if MPFR_VERSION_MAJOR >= 3
+ return newSViv(mpfr_buildopt_tls_p());
+#else
+ croak("Math::MPC::_mpfr_buildopt_tls_p not implemented with this version of the mpfr library - we have %s but need at least 3.0.0", MPFR_VERSION_STRING);
+#endif
+}
+
+SV * _get_xs_version(pTHX) {
+ return newSVpv(XS_VERSION, 0);
+}
+
+SV * _wrap_count(pTHX) {
+ return newSVuv(PL_sv_count);
+}
+
+/* Beginning mpc-1.0, mpc_mul_2si and mpc_div_2si were added */
+
+SV * Rmpc_mul_2si(pTHX_ mpc_t * a, mpc_t * b, SV * c, SV * round) {
+#if MPC_VERSION >= 65536
+ return newSViv(mpc_mul_2si(*a, *b, SvUV(c), (mpc_rnd_t)SvUV(round)));
+# else
+ croak("mpc_mul_2si not implemented until mpc-1.0. We have version %d", MPC_VERSION);
+#endif
+}
+
+SV * Rmpc_div_2si(pTHX_ mpc_t * a, mpc_t * b, SV * c, SV * round) {
+#if MPC_VERSION >= 65536
+ return newSViv(mpc_div_2si(*a, *b, SvUV(c), (mpc_rnd_t)SvUV(round)));
+# else
+ croak("mpc_div_2si not implemented until mpc-1.0. We have version %d", MPC_VERSION);
+#endif
+}
+
+SV * Rmpc_log10(pTHX_ mpc_t * rop, mpc_t *op, SV * round) {
+#if MPC_VERSION >= 65536
+ return newSViv(mpc_log10(*rop, *op, (mpc_rnd_t)SvUV(round)));
+# else
+ croak("mpc_log10 not implemented until mpc-1.0. We have version %d", MPC_VERSION);
+#endif
+}
+
+/* I think the CLONE function needs to come at the very end ... not sure */
+
+void CLONE(pTHX_ SV * x, ...) {
+ MY_CXT_CLONE;
+}
+
+
+
+MODULE = Math::MPC PACKAGE = Math::MPC
+
+PROTOTYPES: DISABLE
+
+
+int
+_mpc_mul_sj (rop, op, i, rnd)
+ mpc_ptr rop
+ mpc_ptr op
+ intmax_t i
+ mpc_rnd_t rnd
+
+int
+_mpc_mul_ld (rop, op, i, rnd)
+ mpc_ptr rop
+ mpc_ptr op
+ long double i
+ mpc_rnd_t rnd
+
+int
+_mpc_mul_d (rop, op, i, rnd)
+ mpc_ptr rop
+ mpc_ptr op
+ double i
+ mpc_rnd_t rnd
+
+int
+_mpc_div_sj (rop, op, i, rnd)
+ mpc_ptr rop
+ mpc_ptr op
+ intmax_t i
+ mpc_rnd_t rnd
+
+int
+_mpc_sj_div (rop, i, op, rnd)
+ mpc_ptr rop
+ intmax_t i
+ mpc_ptr op
+ mpc_rnd_t rnd
+
+int
+_mpc_div_ld (rop, op, i, rnd)
+ mpc_ptr rop
+ mpc_ptr op
+ long double i
+ mpc_rnd_t rnd
+
+int
+_mpc_ld_div (rop, i, op, rnd)
+ mpc_ptr rop
+ long double i
+ mpc_ptr op
+ mpc_rnd_t rnd
+
+int
+_mpc_div_d (rop, op, i, rnd)
+ mpc_ptr rop
+ mpc_ptr op
+ double i
+ mpc_rnd_t rnd
+
+int
+_mpc_d_div (rop, i, op, rnd)
+ mpc_ptr rop
+ double i
+ mpc_ptr op
+ mpc_rnd_t rnd
+
+void
+Rmpc_set_default_rounding_mode (round)
+ SV * round
+ PREINIT:
+ I32* temp;
+ PPCODE:
+ temp = PL_markstack_ptr++;
+ Rmpc_set_default_rounding_mode(aTHX_ round);
+ if (PL_markstack_ptr != temp) {
+ /* truly void, because dXSARGS not invoked */
+ PL_markstack_ptr = temp;
+ XSRETURN_EMPTY; /* return empty stack */
+ }
+ /* must have used dXSARGS; list context implied */
+ return; /* assume stack size is correct */
+
+SV *
+Rmpc_get_default_rounding_mode ()
+CODE:
+ RETVAL = Rmpc_get_default_rounding_mode (aTHX);
+OUTPUT: RETVAL
+
+
+void
+Rmpc_set_default_prec (prec)
+ SV * prec
+ PREINIT:
+ I32* temp;
+ PPCODE:
+ temp = PL_markstack_ptr++;
+ Rmpc_set_default_prec(aTHX_ prec);
+ if (PL_markstack_ptr != temp) {
+ /* truly void, because dXSARGS not invoked */
+ PL_markstack_ptr = temp;
+ XSRETURN_EMPTY; /* return empty stack */
+ }
+ /* must have used dXSARGS; list context implied */
+ return; /* assume stack size is correct */
+
+void
+Rmpc_set_default_prec2 (prec_re, prec_im)
+ SV * prec_re
+ SV * prec_im
+ PREINIT:
+ I32* temp;
+ PPCODE:
+ temp = PL_markstack_ptr++;
+ Rmpc_set_default_prec2(aTHX_ prec_re, prec_im);
+ if (PL_markstack_ptr != temp) {
+ /* truly void, because dXSARGS not invoked */
+ PL_markstack_ptr = temp;
+ XSRETURN_EMPTY; /* return empty stack */
+ }
+ /* must have used dXSARGS; list context implied */
+ return; /* assume stack size is correct */
+
+SV *
+Rmpc_get_default_prec ()
+CODE:
+ RETVAL = Rmpc_get_default_prec (aTHX);
+OUTPUT: RETVAL
+
+
+void
+Rmpc_get_default_prec2 ()
+
+ PREINIT:
+ I32* temp;
+ PPCODE:
+ temp = PL_markstack_ptr++;
+ Rmpc_get_default_prec2();
+ if (PL_markstack_ptr != temp) {
+ /* truly void, because dXSARGS not invoked */
+ PL_markstack_ptr = temp;
+ XSRETURN_EMPTY; /* return empty stack */
+ }
+ /* must have used dXSARGS; list context implied */
+ return; /* assume stack size is correct */
+
+void
+Rmpc_set_prec (p, prec)
+ mpc_t * p
+ SV * prec
+ PREINIT:
+ I32* temp;
+ PPCODE:
+ temp = PL_markstack_ptr++;
+ Rmpc_set_prec(aTHX_ p, prec);
+ if (PL_markstack_ptr != temp) {
+ /* truly void, because dXSARGS not invoked */
+ PL_markstack_ptr = temp;
+ XSRETURN_EMPTY; /* return empty stack */
+ }
+ /* must have used dXSARGS; list context implied */
+ return; /* assume stack size is correct */
+
+void
+Rmpc_set_re_prec (p, prec)
+ mpc_t * p
+ SV * prec
+ PREINIT:
+ I32* temp;
+ PPCODE:
+ temp = PL_markstack_ptr++;
+ Rmpc_set_re_prec(aTHX_ p, prec);
+ if (PL_markstack_ptr != temp) {
+ /* truly void, because dXSARGS not invoked */
+ PL_markstack_ptr = temp;
+ XSRETURN_EMPTY; /* return empty stack */
+ }
+ /* must have used dXSARGS; list context implied */
+ return; /* assume stack size is correct */
+
+void
+Rmpc_set_im_prec (p, prec)
+ mpc_t * p
+ SV * prec
+ PREINIT:
+ I32* temp;
+ PPCODE:
+ temp = PL_markstack_ptr++;
+ Rmpc_set_im_prec(aTHX_ p, prec);
+ if (PL_markstack_ptr != temp) {
+ /* truly void, because dXSARGS not invoked */
+ PL_markstack_ptr = temp;
+ XSRETURN_EMPTY; /* return empty stack */
+ }
+ /* must have used dXSARGS; list context implied */
+ return; /* assume stack size is correct */
+
+SV *
+Rmpc_get_prec (x)
+ mpc_t * x
+CODE:
+ RETVAL = Rmpc_get_prec (aTHX_ x);
+OUTPUT: RETVAL
+
+void
+Rmpc_get_prec2 (x)
+ mpc_t * x
+ PREINIT:
+ I32* temp;
+ PPCODE:
+ temp = PL_markstack_ptr++;
+ Rmpc_get_prec2(aTHX_ x);
+ if (PL_markstack_ptr != temp) {
+ /* truly void, because dXSARGS not invoked */
+ PL_markstack_ptr = temp;
+ XSRETURN_EMPTY; /* return empty stack */
+ }
+ /* must have used dXSARGS; list context implied */
+ return; /* assume stack size is correct */
+
+SV *
+Rmpc_get_im_prec (x)
+ mpc_t * x
+CODE:
+ RETVAL = Rmpc_get_im_prec (aTHX_ x);
+OUTPUT: RETVAL
+
+SV *
+Rmpc_get_re_prec (x)
+ mpc_t * x
+CODE:
+ RETVAL = Rmpc_get_re_prec (aTHX_ x);
+OUTPUT: RETVAL
+
+void
+RMPC_RE (fr, x)
+ mpfr_t * fr
+ mpc_t * x
+ PREINIT:
+ I32* temp;
+ PPCODE:
+ temp = PL_markstack_ptr++;
+ RMPC_RE(fr, x);
+ if (PL_markstack_ptr != temp) {
+ /* truly void, because dXSARGS not invoked */
+ PL_markstack_ptr = temp;
+ XSRETURN_EMPTY; /* return empty stack */
+ }
+ /* must have used dXSARGS; list context implied */
+ return; /* assume stack size is correct */
+
+void
+RMPC_IM (fr, x)
+ mpfr_t * fr
+ mpc_t * x
+ PREINIT:
+ I32* temp;
+ PPCODE:
+ temp = PL_markstack_ptr++;
+ RMPC_IM(fr, x);
+ if (PL_markstack_ptr != temp) {
+ /* truly void, because dXSARGS not invoked */
+ PL_markstack_ptr = temp;
+ XSRETURN_EMPTY; /* return empty stack */
+ }
+ /* must have used dXSARGS; list context implied */
+ return; /* assume stack size is correct */
+
+SV *
+RMPC_INEX_RE (x)
+ SV * x
+CODE:
+ RETVAL = RMPC_INEX_RE (aTHX_ x);
+OUTPUT: RETVAL
+
+SV *
+RMPC_INEX_IM (x)
+ SV * x
+CODE:
+ RETVAL = RMPC_INEX_IM (aTHX_ x);
+OUTPUT: RETVAL
+
+void
+DESTROY (p)
+ mpc_t * p
+ PREINIT:
+ I32* temp;
+ PPCODE:
+ temp = PL_markstack_ptr++;
+ DESTROY(aTHX_ p);
+ if (PL_markstack_ptr != temp) {
+ /* truly void, because dXSARGS not invoked */
+ PL_markstack_ptr = temp;
+ XSRETURN_EMPTY; /* return empty stack */
+ }
+ /* must have used dXSARGS; list context implied */
+ return; /* assume stack size is correct */
+
+void
+Rmpc_clear (p)
+ mpc_t * p
+ PREINIT:
+ I32* temp;
+ PPCODE:
+ temp = PL_markstack_ptr++;
+ Rmpc_clear(aTHX_ p);
+ if (PL_markstack_ptr != temp) {
+ /* truly void, because dXSARGS not invoked */
+ PL_markstack_ptr = temp;
+ XSRETURN_EMPTY; /* return empty stack */
+ }
+ /* must have used dXSARGS; list context implied */
+ return; /* assume stack size is correct */
+
+void
+Rmpc_clear_mpc (p)
+ mpc_t * p
+ PREINIT:
+ I32* temp;
+ PPCODE:
+ temp = PL_markstack_ptr++;
+ Rmpc_clear_mpc(p);
+ if (PL_markstack_ptr != temp) {
+ /* truly void, because dXSARGS not invoked */
+ PL_markstack_ptr = temp;
+ XSRETURN_EMPTY; /* return empty stack */
+ }
+ /* must have used dXSARGS; list context implied */
+ return; /* assume stack size is correct */
+
+void
+Rmpc_clear_ptr (p)
+ mpc_t * p
+ PREINIT:
+ I32* temp;
+ PPCODE:
+ temp = PL_markstack_ptr++;
+ Rmpc_clear_ptr(aTHX_ p);
+ if (PL_markstack_ptr != temp) {
+ /* truly void, because dXSARGS not invoked */
+ PL_markstack_ptr = temp;
+ XSRETURN_EMPTY; /* return empty stack */
+ }
+ /* must have used dXSARGS; list context implied */
+ return; /* assume stack size is correct */
+
+SV *
+Rmpc_init2 (prec)
+ SV * prec
+CODE:
+ RETVAL = Rmpc_init2 (aTHX_ prec);
+OUTPUT: RETVAL
+
+SV *
+Rmpc_init3 (prec_r, prec_i)
+ SV * prec_r
+ SV * prec_i
+CODE:
+ RETVAL = Rmpc_init3 (aTHX_ prec_r, prec_i);
+OUTPUT: RETVAL
+
+SV *
+Rmpc_init2_nobless (prec)
+ SV * prec
+CODE:
+ RETVAL = Rmpc_init2_nobless (aTHX_ prec);
+OUTPUT: RETVAL
+
+SV *
+Rmpc_init3_nobless (prec_r, prec_i)
+ SV * prec_r
+ SV * prec_i
+CODE:
+ RETVAL = Rmpc_init3_nobless (aTHX_ prec_r, prec_i);
+OUTPUT: RETVAL
+
+SV *
+Rmpc_set (p, q, round)
+ mpc_t * p
+ mpc_t * q
+ SV * round
+CODE:
+ RETVAL = Rmpc_set (aTHX_ p, q, round);
+OUTPUT: RETVAL
+
+SV *
+Rmpc_set_ui (p, q, round)
+ mpc_t * p
+ SV * q
+ SV * round
+CODE:
+ RETVAL = Rmpc_set_ui (aTHX_ p, q, round);
+OUTPUT: RETVAL
+
+SV *
+Rmpc_set_si (p, q, round)
+ mpc_t * p
+ SV * q
+ SV * round
+CODE:
+ RETVAL = Rmpc_set_si (aTHX_ p, q, round);
+OUTPUT: RETVAL
+
+SV *
+Rmpc_set_ld (p, q, round)
+ mpc_t * p
+ SV * q
+ SV * round
+CODE:
+ RETVAL = Rmpc_set_ld (aTHX_ p, q, round);
+OUTPUT: RETVAL
+
+SV *
+Rmpc_set_uj (p, q, round)
+ mpc_t * p
+ SV * q
+ SV * round
+CODE:
+ RETVAL = Rmpc_set_uj (aTHX_ p, q, round);
+OUTPUT: RETVAL
+
+SV *
+Rmpc_set_sj (p, q, round)
+ mpc_t * p
+ SV * q
+ SV * round
+CODE:
+ RETVAL = Rmpc_set_sj (aTHX_ p, q, round);
+OUTPUT: RETVAL
+
+SV *
+Rmpc_set_z (p, q, round)
+ mpc_t * p
+ mpz_t * q
+ SV * round
+CODE:
+ RETVAL = Rmpc_set_z (aTHX_ p, q, round);
+OUTPUT: RETVAL
+
+SV *
+Rmpc_set_f (p, q, round)
+ mpc_t * p
+ mpf_t * q
+ SV * round
+CODE:
+ RETVAL = Rmpc_set_f (aTHX_ p, q, round);
+OUTPUT: RETVAL
+
+SV *
+Rmpc_set_q (p, q, round)
+ mpc_t * p
+ mpq_t * q
+ SV * round
+CODE:
+ RETVAL = Rmpc_set_q (aTHX_ p, q, round);
+OUTPUT: RETVAL
+
+SV *
+Rmpc_set_d (p, q, round)
+ mpc_t * p
+ SV * q
+ SV * round
+CODE:
+ RETVAL = Rmpc_set_d (aTHX_ p, q, round);
+OUTPUT: RETVAL
+
+SV *
+Rmpc_set_fr (p, q, round)
+ mpc_t * p
+ mpfr_t * q
+ SV * round
+CODE:
+ RETVAL = Rmpc_set_fr (aTHX_ p, q, round);
+OUTPUT: RETVAL
+
+SV *
+Rmpc_set_ui_ui (p, q_r, q_i, round)
+ mpc_t * p
+ SV * q_r
+ SV * q_i
+ SV * round
+CODE:
+ RETVAL = Rmpc_set_ui_ui (aTHX_ p, q_r, q_i, round);
+OUTPUT: RETVAL
+
+SV *
+Rmpc_set_si_si (p, q_r, q_i, round)
+ mpc_t * p
+ SV * q_r
+ SV * q_i
+ SV * round
+CODE:
+ RETVAL = Rmpc_set_si_si (aTHX_ p, q_r, q_i, round);
+OUTPUT: RETVAL
+
+SV *
+Rmpc_set_d_d (p, q_r, q_i, round)
+ mpc_t * p
+ SV * q_r
+ SV * q_i
+ SV * round
+CODE:
+ RETVAL = Rmpc_set_d_d (aTHX_ p, q_r, q_i, round);
+OUTPUT: RETVAL
+
+SV *
+Rmpc_set_ld_ld (mpc, ld1, ld2, round)
+ mpc_t * mpc
+ SV * ld1
+ SV * ld2
+ SV * round
+CODE:
+ RETVAL = Rmpc_set_ld_ld (aTHX_ mpc, ld1, ld2, round);
+OUTPUT: RETVAL
+
+SV *
+Rmpc_set_z_z (p, q_r, q_i, round)
+ mpc_t * p
+ mpz_t * q_r
+ mpz_t * q_i
+ SV * round
+CODE:
+ RETVAL = Rmpc_set_z_z (aTHX_ p, q_r, q_i, round);
+OUTPUT: RETVAL
+
+SV *
+Rmpc_set_q_q (p, q_r, q_i, round)
+ mpc_t * p
+ mpq_t * q_r
+ mpq_t * q_i
+ SV * round
+CODE:
+ RETVAL = Rmpc_set_q_q (aTHX_ p, q_r, q_i, round);
+OUTPUT: RETVAL
+
+SV *
+Rmpc_set_f_f (p, q_r, q_i, round)
+ mpc_t * p
+ mpf_t * q_r
+ mpf_t * q_i
+ SV * round
+CODE:
+ RETVAL = Rmpc_set_f_f (aTHX_ p, q_r, q_i, round);
+OUTPUT: RETVAL
+
+SV *
+Rmpc_set_fr_fr (p, q_r, q_i, round)
+ mpc_t * p
+ mpfr_t * q_r
+ mpfr_t * q_i
+ SV * round
+CODE:
+ RETVAL = Rmpc_set_fr_fr (aTHX_ p, q_r, q_i, round);
+OUTPUT: RETVAL
+
+SV *
+Rmpc_set_d_ui (mpc, d, ui, round)
+ mpc_t * mpc
+ SV * d
+ SV * ui
+ SV * round
+CODE:
+ RETVAL = Rmpc_set_d_ui (aTHX_ mpc, d, ui, round);
+OUTPUT: RETVAL
+
+SV *
+Rmpc_set_d_si (mpc, d, si, round)
+ mpc_t * mpc
+ SV * d
+ SV * si
+ SV * round
+CODE:
+ RETVAL = Rmpc_set_d_si (aTHX_ mpc, d, si, round);
+OUTPUT: RETVAL
+
+SV *
+Rmpc_set_d_fr (mpc, d, mpfr, round)
+ mpc_t * mpc
+ SV * d
+ mpfr_t * mpfr
+ SV * round
+CODE:
+ RETVAL = Rmpc_set_d_fr (aTHX_ mpc, d, mpfr, round);
+OUTPUT: RETVAL
+
+SV *
+Rmpc_set_ui_d (mpc, ui, d, round)
+ mpc_t * mpc
+ SV * ui
+ SV * d
+ SV * round
+CODE:
+ RETVAL = Rmpc_set_ui_d (aTHX_ mpc, ui, d, round);
+OUTPUT: RETVAL
+
+SV *
+Rmpc_set_ui_si (mpc, ui, si, round)
+ mpc_t * mpc
+ SV * ui
+ SV * si
+ SV * round
+CODE:
+ RETVAL = Rmpc_set_ui_si (aTHX_ mpc, ui, si, round);
+OUTPUT: RETVAL
+
+SV *
+Rmpc_set_ui_fr (mpc, ui, mpfr, round)
+ mpc_t * mpc
+ SV * ui
+ mpfr_t * mpfr
+ SV * round
+CODE:
+ RETVAL = Rmpc_set_ui_fr (aTHX_ mpc, ui, mpfr, round);
+OUTPUT: RETVAL
+
+SV *
+Rmpc_set_si_d (mpc, si, d, round)
+ mpc_t * mpc
+ SV * si
+ SV * d
+ SV * round
+CODE:
+ RETVAL = Rmpc_set_si_d (aTHX_ mpc, si, d, round);
+OUTPUT: RETVAL
+
+SV *
+Rmpc_set_si_ui (mpc, si, ui, round)
+ mpc_t * mpc
+ SV * si
+ SV * ui
+ SV * round
+CODE:
+ RETVAL = Rmpc_set_si_ui (aTHX_ mpc, si, ui, round);
+OUTPUT: RETVAL
+
+SV *
+Rmpc_set_si_fr (mpc, si, mpfr, round)
+ mpc_t * mpc
+ SV * si
+ mpfr_t * mpfr
+ SV * round
+CODE:
+ RETVAL = Rmpc_set_si_fr (aTHX_ mpc, si, mpfr, round);
+OUTPUT: RETVAL
+
+SV *
+Rmpc_set_fr_d (mpc, mpfr, d, round)
+ mpc_t * mpc
+ mpfr_t * mpfr
+ SV * d
+ SV * round
+CODE:
+ RETVAL = Rmpc_set_fr_d (aTHX_ mpc, mpfr, d, round);
+OUTPUT: RETVAL
+
+SV *
+Rmpc_set_fr_ui (mpc, mpfr, ui, round)
+ mpc_t * mpc
+ mpfr_t * mpfr
+ SV * ui
+ SV * round
+CODE:
+ RETVAL = Rmpc_set_fr_ui (aTHX_ mpc, mpfr, ui, round);
+OUTPUT: RETVAL
+
+SV *
+Rmpc_set_fr_si (mpc, mpfr, si, round)
+ mpc_t * mpc
+ mpfr_t * mpfr
+ SV * si
+ SV * round
+CODE:
+ RETVAL = Rmpc_set_fr_si (aTHX_ mpc, mpfr, si, round);
+OUTPUT: RETVAL
+
+SV *
+Rmpc_set_ld_ui (mpc, d, ui, round)
+ mpc_t * mpc
+ SV * d
+ SV * ui
+ SV * round
+CODE:
+ RETVAL = Rmpc_set_ld_ui (aTHX_ mpc, d, ui, round);
+OUTPUT: RETVAL
+
+SV *
+Rmpc_set_ld_si (mpc, d, si, round)
+ mpc_t * mpc
+ SV * d
+ SV * si
+ SV * round
+CODE:
+ RETVAL = Rmpc_set_ld_si (aTHX_ mpc, d, si, round);
+OUTPUT: RETVAL
+
+SV *
+Rmpc_set_ld_fr (mpc, d, mpfr, round)
+ mpc_t * mpc
+ SV * d
+ mpfr_t * mpfr
+ SV * round
+CODE:
+ RETVAL = Rmpc_set_ld_fr (aTHX_ mpc, d, mpfr, round);
+OUTPUT: RETVAL
+
+SV *
+Rmpc_set_ui_ld (mpc, ui, d, round)
+ mpc_t * mpc
+ SV * ui
+ SV * d
+ SV * round
+CODE:
+ RETVAL = Rmpc_set_ui_ld (aTHX_ mpc, ui, d, round);
+OUTPUT: RETVAL
+
+SV *
+Rmpc_set_si_ld (mpc, si, d, round)
+ mpc_t * mpc
+ SV * si
+ SV * d
+ SV * round
+CODE:
+ RETVAL = Rmpc_set_si_ld (aTHX_ mpc, si, d, round);
+OUTPUT: RETVAL
+
+SV *
+Rmpc_set_fr_ld (mpc, mpfr, d, round)
+ mpc_t * mpc
+ mpfr_t * mpfr
+ SV * d
+ SV * round
+CODE:
+ RETVAL = Rmpc_set_fr_ld (aTHX_ mpc, mpfr, d, round);
+OUTPUT: RETVAL
+
+SV *
+Rmpc_set_d_uj (mpc, d, ui, round)
+ mpc_t * mpc
+ SV * d
+ SV * ui
+ SV * round
+CODE:
+ RETVAL = Rmpc_set_d_uj (aTHX_ mpc, d, ui, round);
+OUTPUT: RETVAL
+
+SV *
+Rmpc_set_d_sj (mpc, d, si, round)
+ mpc_t * mpc
+ SV * d
+ SV * si
+ SV * round
+CODE:
+ RETVAL = Rmpc_set_d_sj (aTHX_ mpc, d, si, round);
+OUTPUT: RETVAL
+
+SV *
+Rmpc_set_sj_d (mpc, si, d, round)
+ mpc_t * mpc
+ SV * si
+ SV * d
+ SV * round
+CODE:
+ RETVAL = Rmpc_set_sj_d (aTHX_ mpc, si, d, round);
+OUTPUT: RETVAL
+
+SV *
+Rmpc_set_uj_d (mpc, ui, d, round)
+ mpc_t * mpc
+ SV * ui
+ SV * d
+ SV * round
+CODE:
+ RETVAL = Rmpc_set_uj_d (aTHX_ mpc, ui, d, round);
+OUTPUT: RETVAL
+
+SV *
+Rmpc_set_uj_fr (mpc, ui, mpfr, round)
+ mpc_t * mpc
+ SV * ui
+ mpfr_t * mpfr
+ SV * round
+CODE:
+ RETVAL = Rmpc_set_uj_fr (aTHX_ mpc, ui, mpfr, round);
+OUTPUT: RETVAL
+
+SV *
+Rmpc_set_sj_fr (mpc, si, mpfr, round)
+ mpc_t * mpc
+ SV * si
+ mpfr_t * mpfr
+ SV * round
+CODE:
+ RETVAL = Rmpc_set_sj_fr (aTHX_ mpc, si, mpfr, round);
+OUTPUT: RETVAL
+
+SV *
+Rmpc_set_fr_uj (mpc, mpfr, ui, round)
+ mpc_t * mpc
+ mpfr_t * mpfr
+ SV * ui
+ SV * round
+CODE:
+ RETVAL = Rmpc_set_fr_uj (aTHX_ mpc, mpfr, ui, round);
+OUTPUT: RETVAL
+
+SV *
+Rmpc_set_fr_sj (mpc, mpfr, si, round)
+ mpc_t * mpc
+ mpfr_t * mpfr
+ SV * si
+ SV * round
+CODE:
+ RETVAL = Rmpc_set_fr_sj (aTHX_ mpc, mpfr, si, round);
+OUTPUT: RETVAL
+
+SV *
+Rmpc_set_uj_sj (mpc, ui, si, round)
+ mpc_t * mpc
+ SV * ui
+ SV * si
+ SV * round
+CODE:
+ RETVAL = Rmpc_set_uj_sj (aTHX_ mpc, ui, si, round);
+OUTPUT: RETVAL
+
+SV *
+Rmpc_set_sj_uj (mpc, si, ui, round)
+ mpc_t * mpc
+ SV * si
+ SV * ui
+ SV * round
+CODE:
+ RETVAL = Rmpc_set_sj_uj (aTHX_ mpc, si, ui, round);
+OUTPUT: RETVAL
+
+SV *
+Rmpc_set_ld_uj (mpc, d, ui, round)
+ mpc_t * mpc
+ SV * d
+ SV * ui
+ SV * round
+CODE:
+ RETVAL = Rmpc_set_ld_uj (aTHX_ mpc, d, ui, round);
+OUTPUT: RETVAL
+
+SV *
+Rmpc_set_ld_sj (mpc, d, si, round)
+ mpc_t * mpc
+ SV * d
+ SV * si
+ SV * round
+CODE:
+ RETVAL = Rmpc_set_ld_sj (aTHX_ mpc, d, si, round);
+OUTPUT: RETVAL
+
+SV *
+Rmpc_set_uj_ld (mpc, ui, d, round)
+ mpc_t * mpc
+ SV * ui
+ SV * d
+ SV * round
+CODE:
+ RETVAL = Rmpc_set_uj_ld (aTHX_ mpc, ui, d, round);
+OUTPUT: RETVAL
+
+SV *
+Rmpc_set_sj_ld (mpc, si, d, round)
+ mpc_t * mpc
+ SV * si
+ SV * d
+ SV * round
+CODE:
+ RETVAL = Rmpc_set_sj_ld (aTHX_ mpc, si, d, round);
+OUTPUT: RETVAL
+
+SV *
+Rmpc_set_f_ui (mpc, mpf, ui, round)
+ mpc_t * mpc
+ mpf_t * mpf
+ SV * ui
+ SV * round
+CODE:
+ RETVAL = Rmpc_set_f_ui (aTHX_ mpc, mpf, ui, round);
+OUTPUT: RETVAL
+
+SV *
+Rmpc_set_q_ui (mpc, mpq, ui, round)
+ mpc_t * mpc
+ mpq_t * mpq
+ SV * ui
+ SV * round
+CODE:
+ RETVAL = Rmpc_set_q_ui (aTHX_ mpc, mpq, ui, round);
+OUTPUT: RETVAL
+
+SV *
+Rmpc_set_z_ui (mpc, mpz, ui, round)
+ mpc_t * mpc
+ mpz_t * mpz
+ SV * ui
+ SV * round
+CODE:
+ RETVAL = Rmpc_set_z_ui (aTHX_ mpc, mpz, ui, round);
+OUTPUT: RETVAL
+
+SV *
+Rmpc_set_f_si (mpc, mpf, si, round)
+ mpc_t * mpc
+ mpf_t * mpf
+ SV * si
+ SV * round
+CODE:
+ RETVAL = Rmpc_set_f_si (aTHX_ mpc, mpf, si, round);
+OUTPUT: RETVAL
+
+SV *
+Rmpc_set_q_si (mpc, mpq, si, round)
+ mpc_t * mpc
+ mpq_t * mpq
+ SV * si
+ SV * round
+CODE:
+ RETVAL = Rmpc_set_q_si (aTHX_ mpc, mpq, si, round);
+OUTPUT: RETVAL
+
+SV *
+Rmpc_set_z_si (mpc, mpz, si, round)
+ mpc_t * mpc
+ mpz_t * mpz
+ SV * si
+ SV * round
+CODE:
+ RETVAL = Rmpc_set_z_si (aTHX_ mpc, mpz, si, round);
+OUTPUT: RETVAL
+
+SV *
+Rmpc_set_f_d (mpc, mpf, d, round)
+ mpc_t * mpc
+ mpf_t * mpf
+ SV * d
+ SV * round
+CODE:
+ RETVAL = Rmpc_set_f_d (aTHX_ mpc, mpf, d, round);
+OUTPUT: RETVAL
+
+SV *
+Rmpc_set_q_d (mpc, mpq, d, round)
+ mpc_t * mpc
+ mpq_t * mpq
+ SV * d
+ SV * round
+CODE:
+ RETVAL = Rmpc_set_q_d (aTHX_ mpc, mpq, d, round);
+OUTPUT: RETVAL
+
+SV *
+Rmpc_set_z_d (mpc, mpz, d, round)
+ mpc_t * mpc
+ mpz_t * mpz
+ SV * d
+ SV * round
+CODE:
+ RETVAL = Rmpc_set_z_d (aTHX_ mpc, mpz, d, round);
+OUTPUT: RETVAL
+
+SV *
+Rmpc_set_f_uj (mpc, mpf, uj, round)
+ mpc_t * mpc
+ mpf_t * mpf
+ SV * uj
+ SV * round
+CODE:
+ RETVAL = Rmpc_set_f_uj (aTHX_ mpc, mpf, uj, round);
+OUTPUT: RETVAL
+
+SV *
+Rmpc_set_q_uj (mpc, mpq, uj, round)
+ mpc_t * mpc
+ mpq_t * mpq
+ SV * uj
+ SV * round
+CODE:
+ RETVAL = Rmpc_set_q_uj (aTHX_ mpc, mpq, uj, round);
+OUTPUT: RETVAL
+
+SV *
+Rmpc_set_z_uj (mpc, mpz, uj, round)
+ mpc_t * mpc
+ mpz_t * mpz
+ SV * uj
+ SV * round
+CODE:
+ RETVAL = Rmpc_set_z_uj (aTHX_ mpc, mpz, uj, round);
+OUTPUT: RETVAL
+
+SV *
+Rmpc_set_f_sj (mpc, mpf, sj, round)
+ mpc_t * mpc
+ mpf_t * mpf
+ SV * sj
+ SV * round
+CODE:
+ RETVAL = Rmpc_set_f_sj (aTHX_ mpc, mpf, sj, round);
+OUTPUT: RETVAL
+
+SV *
+Rmpc_set_q_sj (mpc, mpq, sj, round)
+ mpc_t * mpc
+ mpq_t * mpq
+ SV * sj
+ SV * round
+CODE:
+ RETVAL = Rmpc_set_q_sj (aTHX_ mpc, mpq, sj, round);
+OUTPUT: RETVAL
+
+SV *
+Rmpc_set_z_sj (mpc, mpz, sj, round)
+ mpc_t * mpc
+ mpz_t * mpz
+ SV * sj
+ SV * round
+CODE:
+ RETVAL = Rmpc_set_z_sj (aTHX_ mpc, mpz, sj, round);
+OUTPUT: RETVAL
+
+SV *
+Rmpc_set_f_ld (mpc, mpf, ld, round)
+ mpc_t * mpc
+ mpf_t * mpf
+ SV * ld
+ SV * round
+CODE:
+ RETVAL = Rmpc_set_f_ld (aTHX_ mpc, mpf, ld, round);
+OUTPUT: RETVAL
+
+SV *
+Rmpc_set_q_ld (mpc, mpq, ld, round)
+ mpc_t * mpc
+ mpq_t * mpq
+ SV * ld
+ SV * round
+CODE:
+ RETVAL = Rmpc_set_q_ld (aTHX_ mpc, mpq, ld, round);
+OUTPUT: RETVAL
+
+SV *
+Rmpc_set_z_ld (mpc, mpz, ld, round)
+ mpc_t * mpc
+ mpz_t * mpz
+ SV * ld
+ SV * round
+CODE:
+ RETVAL = Rmpc_set_z_ld (aTHX_ mpc, mpz, ld, round);
+OUTPUT: RETVAL
+
+SV *
+Rmpc_set_ui_f (mpc, ui, mpf, round)
+ mpc_t * mpc
+ SV * ui
+ mpf_t * mpf
+ SV * round
+CODE:
+ RETVAL = Rmpc_set_ui_f (aTHX_ mpc, ui, mpf, round);
+OUTPUT: RETVAL
+
+SV *
+Rmpc_set_ui_q (mpc, ui, mpq, round)
+ mpc_t * mpc
+ SV * ui
+ mpq_t * mpq
+ SV * round
+CODE:
+ RETVAL = Rmpc_set_ui_q (aTHX_ mpc, ui, mpq, round);
+OUTPUT: RETVAL
+
+SV *
+Rmpc_set_ui_z (mpc, ui, mpz, round)
+ mpc_t * mpc
+ SV * ui
+ mpz_t * mpz
+ SV * round
+CODE:
+ RETVAL = Rmpc_set_ui_z (aTHX_ mpc, ui, mpz, round);
+OUTPUT: RETVAL
+
+SV *
+Rmpc_set_si_f (mpc, si, mpf, round)
+ mpc_t * mpc
+ SV * si
+ mpf_t * mpf
+ SV * round
+CODE:
+ RETVAL = Rmpc_set_si_f (aTHX_ mpc, si, mpf, round);
+OUTPUT: RETVAL
+
+SV *
+Rmpc_set_si_q (mpc, si, mpq, round)
+ mpc_t * mpc
+ SV * si
+ mpq_t * mpq
+ SV * round
+CODE:
+ RETVAL = Rmpc_set_si_q (aTHX_ mpc, si, mpq, round);
+OUTPUT: RETVAL
+
+SV *
+Rmpc_set_si_z (mpc, si, mpz, round)
+ mpc_t * mpc
+ SV * si
+ mpz_t * mpz
+ SV * round
+CODE:
+ RETVAL = Rmpc_set_si_z (aTHX_ mpc, si, mpz, round);
+OUTPUT: RETVAL
+
+SV *
+Rmpc_set_d_f (mpc, d, mpf, round)
+ mpc_t * mpc
+ SV * d
+ mpf_t * mpf
+ SV * round
+CODE:
+ RETVAL = Rmpc_set_d_f (aTHX_ mpc, d, mpf, round);
+OUTPUT: RETVAL
+
+SV *
+Rmpc_set_d_q (mpc, d, mpq, round)
+ mpc_t * mpc
+ SV * d
+ mpq_t * mpq
+ SV * round
+CODE:
+ RETVAL = Rmpc_set_d_q (aTHX_ mpc, d, mpq, round);
+OUTPUT: RETVAL
+
+SV *
+Rmpc_set_d_z (mpc, d, mpz, round)
+ mpc_t * mpc
+ SV * d
+ mpz_t * mpz
+ SV * round
+CODE:
+ RETVAL = Rmpc_set_d_z (aTHX_ mpc, d, mpz, round);
+OUTPUT: RETVAL
+
+SV *
+Rmpc_set_uj_f (mpc, uj, mpf, round)
+ mpc_t * mpc
+ SV * uj
+ mpf_t * mpf
+ SV * round
+CODE:
+ RETVAL = Rmpc_set_uj_f (aTHX_ mpc, uj, mpf, round);
+OUTPUT: RETVAL
+
+SV *
+Rmpc_set_uj_q (mpc, uj, mpq, round)
+ mpc_t * mpc
+ SV * uj
+ mpq_t * mpq
+ SV * round
+CODE:
+ RETVAL = Rmpc_set_uj_q (aTHX_ mpc, uj, mpq, round);
+OUTPUT: RETVAL
+
+SV *
+Rmpc_set_uj_z (mpc, uj, mpz, round)
+ mpc_t * mpc
+ SV * uj
+ mpz_t * mpz
+ SV * round
+CODE:
+ RETVAL = Rmpc_set_uj_z (aTHX_ mpc, uj, mpz, round);
+OUTPUT: RETVAL
+
+SV *
+Rmpc_set_sj_f (mpc, sj, mpf, round)
+ mpc_t * mpc
+ SV * sj
+ mpf_t * mpf
+ SV * round
+CODE:
+ RETVAL = Rmpc_set_sj_f (aTHX_ mpc, sj, mpf, round);
+OUTPUT: RETVAL
+
+SV *
+Rmpc_set_sj_q (mpc, sj, mpq, round)
+ mpc_t * mpc
+ SV * sj
+ mpq_t * mpq
+ SV * round
+CODE:
+ RETVAL = Rmpc_set_sj_q (aTHX_ mpc, sj, mpq, round);
+OUTPUT: RETVAL
+
+SV *
+Rmpc_set_sj_z (mpc, sj, mpz, round)
+ mpc_t * mpc
+ SV * sj
+ mpz_t * mpz
+ SV * round
+CODE:
+ RETVAL = Rmpc_set_sj_z (aTHX_ mpc, sj, mpz, round);
+OUTPUT: RETVAL
+
+SV *
+Rmpc_set_ld_f (mpc, ld, mpf, round)
+ mpc_t * mpc
+ SV * ld
+ mpf_t * mpf
+ SV * round
+CODE:
+ RETVAL = Rmpc_set_ld_f (aTHX_ mpc, ld, mpf, round);
+OUTPUT: RETVAL
+
+SV *
+Rmpc_set_ld_q (mpc, ld, mpq, round)
+ mpc_t * mpc
+ SV * ld
+ mpq_t * mpq
+ SV * round
+CODE:
+ RETVAL = Rmpc_set_ld_q (aTHX_ mpc, ld, mpq, round);
+OUTPUT: RETVAL
+
+SV *
+Rmpc_set_ld_z (mpc, ld, mpz, round)
+ mpc_t * mpc
+ SV * ld
+ mpz_t * mpz
+ SV * round
+CODE:
+ RETVAL = Rmpc_set_ld_z (aTHX_ mpc, ld, mpz, round);
+OUTPUT: RETVAL
+
+SV *
+Rmpc_set_f_q (mpc, mpf, mpq, round)
+ mpc_t * mpc
+ mpf_t * mpf
+ mpq_t * mpq
+ SV * round
+CODE:
+ RETVAL = Rmpc_set_f_q (aTHX_ mpc, mpf, mpq, round);
+OUTPUT: RETVAL
+
+SV *
+Rmpc_set_q_f (mpc, mpq, mpf, round)
+ mpc_t * mpc
+ mpq_t * mpq
+ mpf_t * mpf
+ SV * round
+CODE:
+ RETVAL = Rmpc_set_q_f (aTHX_ mpc, mpq, mpf, round);
+OUTPUT: RETVAL
+
+SV *
+Rmpc_set_f_z (mpc, mpf, mpz, round)
+ mpc_t * mpc
+ mpf_t * mpf
+ mpz_t * mpz
+ SV * round
+CODE:
+ RETVAL = Rmpc_set_f_z (aTHX_ mpc, mpf, mpz, round);
+OUTPUT: RETVAL
+
+SV *
+Rmpc_set_z_f (mpc, mpz, mpf, round)
+ mpc_t * mpc
+ mpz_t * mpz
+ mpf_t * mpf
+ SV * round
+CODE:
+ RETVAL = Rmpc_set_z_f (aTHX_ mpc, mpz, mpf, round);
+OUTPUT: RETVAL
+
+SV *
+Rmpc_set_q_z (mpc, mpq, mpz, round)
+ mpc_t * mpc
+ mpq_t * mpq
+ mpz_t * mpz
+ SV * round
+CODE:
+ RETVAL = Rmpc_set_q_z (aTHX_ mpc, mpq, mpz, round);
+OUTPUT: RETVAL
+
+SV *
+Rmpc_set_z_q (mpc, mpz, mpq, round)
+ mpc_t * mpc
+ mpz_t * mpz
+ mpq_t * mpq
+ SV * round
+CODE:
+ RETVAL = Rmpc_set_z_q (aTHX_ mpc, mpz, mpq, round);
+OUTPUT: RETVAL
+
+SV *
+Rmpc_set_f_fr (mpc, mpf, mpfr, round)
+ mpc_t * mpc
+ mpf_t * mpf
+ mpfr_t * mpfr
+ SV * round
+CODE:
+ RETVAL = Rmpc_set_f_fr (aTHX_ mpc, mpf, mpfr, round);
+OUTPUT: RETVAL
+
+SV *
+Rmpc_set_fr_f (mpc, mpfr, mpf, round)
+ mpc_t * mpc
+ mpfr_t * mpfr
+ mpf_t * mpf
+ SV * round
+CODE:
+ RETVAL = Rmpc_set_fr_f (aTHX_ mpc, mpfr, mpf, round);
+OUTPUT: RETVAL
+
+SV *
+Rmpc_set_q_fr (mpc, mpq, mpfr, round)
+ mpc_t * mpc
+ mpq_t * mpq
+ mpfr_t * mpfr
+ SV * round
+CODE:
+ RETVAL = Rmpc_set_q_fr (aTHX_ mpc, mpq, mpfr, round);
+OUTPUT: RETVAL
+
+SV *
+Rmpc_set_fr_q (mpc, mpfr, mpq, round)
+ mpc_t * mpc
+ mpfr_t * mpfr
+ mpq_t * mpq
+ SV * round
+CODE:
+ RETVAL = Rmpc_set_fr_q (aTHX_ mpc, mpfr, mpq, round);
+OUTPUT: RETVAL
+
+SV *
+Rmpc_set_z_fr (mpc, mpz, mpfr, round)
+ mpc_t * mpc
+ mpz_t * mpz
+ mpfr_t * mpfr
+ SV * round
+CODE:
+ RETVAL = Rmpc_set_z_fr (aTHX_ mpc, mpz, mpfr, round);
+OUTPUT: RETVAL
+
+SV *
+Rmpc_set_fr_z (mpc, mpfr, mpz, round)
+ mpc_t * mpc
+ mpfr_t * mpfr
+ mpz_t * mpz
+ SV * round
+CODE:
+ RETVAL = Rmpc_set_fr_z (aTHX_ mpc, mpfr, mpz, round);
+OUTPUT: RETVAL
+
+SV *
+Rmpc_set_uj_uj (mpc, uj1, uj2, round)
+ mpc_t * mpc
+ SV * uj1
+ SV * uj2
+ SV * round
+CODE:
+ RETVAL = Rmpc_set_uj_uj (aTHX_ mpc, uj1, uj2, round);
+OUTPUT: RETVAL
+
+SV *
+Rmpc_set_sj_sj (mpc, sj1, sj2, round)
+ mpc_t * mpc
+ SV * sj1
+ SV * sj2
+ SV * round
+CODE:
+ RETVAL = Rmpc_set_sj_sj (aTHX_ mpc, sj1, sj2, round);
+OUTPUT: RETVAL
+
+SV *
+Rmpc_add (a, b, c, round)
+ mpc_t * a
+ mpc_t * b
+ mpc_t * c
+ SV * round
+CODE:
+ RETVAL = Rmpc_add (aTHX_ a, b, c, round);
+OUTPUT: RETVAL
+
+SV *
+Rmpc_add_ui (a, b, c, round)
+ mpc_t * a
+ mpc_t * b
+ SV * c
+ SV * round
+CODE:
+ RETVAL = Rmpc_add_ui (aTHX_ a, b, c, round);
+OUTPUT: RETVAL
+
+SV *
+Rmpc_add_fr (a, b, c, round)
+ mpc_t * a
+ mpc_t * b
+ mpfr_t * c
+ SV * round
+CODE:
+ RETVAL = Rmpc_add_fr (aTHX_ a, b, c, round);
+OUTPUT: RETVAL
+
+SV *
+Rmpc_sub (a, b, c, round)
+ mpc_t * a
+ mpc_t * b
+ mpc_t * c
+ SV * round
+CODE:
+ RETVAL = Rmpc_sub (aTHX_ a, b, c, round);
+OUTPUT: RETVAL
+
+SV *
+Rmpc_sub_ui (a, b, c, round)
+ mpc_t * a
+ mpc_t * b
+ SV * c
+ SV * round
+CODE:
+ RETVAL = Rmpc_sub_ui (aTHX_ a, b, c, round);
+OUTPUT: RETVAL
+
+SV *
+Rmpc_ui_sub (a, b, c, round)
+ mpc_t * a
+ SV * b
+ mpc_t * c
+ SV * round
+CODE:
+ RETVAL = Rmpc_ui_sub (aTHX_ a, b, c, round);
+OUTPUT: RETVAL
+
+SV *
+Rmpc_ui_ui_sub (a, b_r, b_i, c, round)
+ mpc_t * a
+ SV * b_r
+ SV * b_i
+ mpc_t * c
+ SV * round
+CODE:
+ RETVAL = Rmpc_ui_ui_sub (aTHX_ a, b_r, b_i, c, round);
+OUTPUT: RETVAL
+
+SV *
+Rmpc_mul (a, b, c, round)
+ mpc_t * a
+ mpc_t * b
+ mpc_t * c
+ SV * round
+CODE:
+ RETVAL = Rmpc_mul (aTHX_ a, b, c, round);
+OUTPUT: RETVAL
+
+SV *
+Rmpc_mul_ui (a, b, c, round)
+ mpc_t * a
+ mpc_t * b
+ SV * c
+ SV * round
+CODE:
+ RETVAL = Rmpc_mul_ui (aTHX_ a, b, c, round);
+OUTPUT: RETVAL
+
+SV *
+Rmpc_mul_si (a, b, c, round)
+ mpc_t * a
+ mpc_t * b
+ SV * c
+ SV * round
+CODE:
+ RETVAL = Rmpc_mul_si (aTHX_ a, b, c, round);
+OUTPUT: RETVAL
+
+SV *
+Rmpc_mul_fr (a, b, c, round)
+ mpc_t * a
+ mpc_t * b
+ mpfr_t * c
+ SV * round
+CODE:
+ RETVAL = Rmpc_mul_fr (aTHX_ a, b, c, round);
+OUTPUT: RETVAL
+
+SV *
+Rmpc_mul_i (a, b, sign, round)
+ mpc_t * a
+ mpc_t * b
+ SV * sign
+ SV * round
+CODE:
+ RETVAL = Rmpc_mul_i (aTHX_ a, b, sign, round);
+OUTPUT: RETVAL
+
+SV *
+Rmpc_sqr (a, b, round)
+ mpc_t * a
+ mpc_t * b
+ SV * round
+CODE:
+ RETVAL = Rmpc_sqr (aTHX_ a, b, round);
+OUTPUT: RETVAL
+
+SV *
+Rmpc_div (a, b, c, round)
+ mpc_t * a
+ mpc_t * b
+ mpc_t * c
+ SV * round
+CODE:
+ RETVAL = Rmpc_div (aTHX_ a, b, c, round);
+OUTPUT: RETVAL
+
+SV *
+Rmpc_div_ui (a, b, c, round)
+ mpc_t * a
+ mpc_t * b
+ SV * c
+ SV * round
+CODE:
+ RETVAL = Rmpc_div_ui (aTHX_ a, b, c, round);
+OUTPUT: RETVAL
+
+SV *
+Rmpc_ui_div (a, b, c, round)
+ mpc_t * a
+ SV * b
+ mpc_t * c
+ SV * round
+CODE:
+ RETVAL = Rmpc_ui_div (aTHX_ a, b, c, round);
+OUTPUT: RETVAL
+
+SV *
+Rmpc_div_fr (a, b, c, round)
+ mpc_t * a
+ mpc_t * b
+ mpfr_t * c
+ SV * round
+CODE:
+ RETVAL = Rmpc_div_fr (aTHX_ a, b, c, round);
+OUTPUT: RETVAL
+
+SV *
+Rmpc_sqrt (a, b, round)
+ mpc_t * a
+ mpc_t * b
+ SV * round
+CODE:
+ RETVAL = Rmpc_sqrt (aTHX_ a, b, round);
+OUTPUT: RETVAL
+
+SV *
+Rmpc_pow (a, b, pow, round)
+ mpc_t * a
+ mpc_t * b
+ mpc_t * pow
+ SV * round
+CODE:
+ RETVAL = Rmpc_pow (aTHX_ a, b, pow, round);
+OUTPUT: RETVAL
+
+SV *
+Rmpc_pow_d (a, b, pow, round)
+ mpc_t * a
+ mpc_t * b
+ SV * pow
+ SV * round
+CODE:
+ RETVAL = Rmpc_pow_d (aTHX_ a, b, pow, round);
+OUTPUT: RETVAL
+
+SV *
+Rmpc_pow_ld (a, b, pow, round)
+ mpc_t * a
+ mpc_t * b
+ SV * pow
+ SV * round
+CODE:
+ RETVAL = Rmpc_pow_ld (aTHX_ a, b, pow, round);
+OUTPUT: RETVAL
+
+SV *
+Rmpc_pow_si (a, b, pow, round)
+ mpc_t * a
+ mpc_t * b
+ SV * pow
+ SV * round
+CODE:
+ RETVAL = Rmpc_pow_si (aTHX_ a, b, pow, round);
+OUTPUT: RETVAL
+
+SV *
+Rmpc_pow_ui (a, b, pow, round)
+ mpc_t * a
+ mpc_t * b
+ SV * pow
+ SV * round
+CODE:
+ RETVAL = Rmpc_pow_ui (aTHX_ a, b, pow, round);
+OUTPUT: RETVAL
+
+SV *
+Rmpc_pow_z (a, b, pow, round)
+ mpc_t * a
+ mpc_t * b
+ mpz_t * pow
+ SV * round
+CODE:
+ RETVAL = Rmpc_pow_z (aTHX_ a, b, pow, round);
+OUTPUT: RETVAL
+
+SV *
+Rmpc_pow_fr (a, b, pow, round)
+ mpc_t * a
+ mpc_t * b
+ mpfr_t * pow
+ SV * round
+CODE:
+ RETVAL = Rmpc_pow_fr (aTHX_ a, b, pow, round);
+OUTPUT: RETVAL
+
+SV *
+Rmpc_neg (a, b, round)
+ mpc_t * a
+ mpc_t * b
+ SV * round
+CODE:
+ RETVAL = Rmpc_neg (aTHX_ a, b, round);
+OUTPUT: RETVAL
+
+SV *
+Rmpc_abs (a, b, round)
+ mpfr_t * a
+ mpc_t * b
+ SV * round
+CODE:
+ RETVAL = Rmpc_abs (aTHX_ a, b, round);
+OUTPUT: RETVAL
+
+SV *
+Rmpc_conj (a, b, round)
+ mpc_t * a
+ mpc_t * b
+ SV * round
+CODE:
+ RETVAL = Rmpc_conj (aTHX_ a, b, round);
+OUTPUT: RETVAL
+
+SV *
+Rmpc_norm (a, b, round)
+ mpfr_t * a
+ mpc_t * b
+ SV * round
+CODE:
+ RETVAL = Rmpc_norm (aTHX_ a, b, round);
+OUTPUT: RETVAL
+
+SV *
+Rmpc_mul_2ui (a, b, c, round)
+ mpc_t * a
+ mpc_t * b
+ SV * c
+ SV * round
+CODE:
+ RETVAL = Rmpc_mul_2ui (aTHX_ a, b, c, round);
+OUTPUT: RETVAL
+
+SV *
+Rmpc_div_2ui (a, b, c, round)
+ mpc_t * a
+ mpc_t * b
+ SV * c
+ SV * round
+CODE:
+ RETVAL = Rmpc_div_2ui (aTHX_ a, b, c, round);
+OUTPUT: RETVAL
+
+SV *
+Rmpc_cmp (a, b)
+ mpc_t * a
+ mpc_t * b
+CODE:
+ RETVAL = Rmpc_cmp (aTHX_ a, b);
+OUTPUT: RETVAL
+
+SV *
+Rmpc_cmp_si (a, b)
+ mpc_t * a
+ SV * b
+CODE:
+ RETVAL = Rmpc_cmp_si (aTHX_ a, b);
+OUTPUT: RETVAL
+
+SV *
+Rmpc_cmp_si_si (a, b, c)
+ mpc_t * a
+ SV * b
+ SV * c
+CODE:
+ RETVAL = Rmpc_cmp_si_si (aTHX_ a, b, c);
+OUTPUT: RETVAL
+
+SV *
+Rmpc_exp (a, b, round)
+ mpc_t * a
+ mpc_t * b
+ SV * round
+CODE:
+ RETVAL = Rmpc_exp (aTHX_ a, b, round);
+OUTPUT: RETVAL
+
+SV *
+Rmpc_log (rop, op, round)
+ mpc_t * rop
+ mpc_t * op
+ SV * round
+CODE:
+ RETVAL = Rmpc_log (aTHX_ rop, op, round);
+OUTPUT: RETVAL
+
+SV *
+_Rmpc_out_str (stream, base, dig, p, round)
+ FILE * stream
+ SV * base
+ SV * dig
+ mpc_t * p
+ SV * round
+CODE:
+ RETVAL = _Rmpc_out_str (aTHX_ stream, base, dig, p, round);
+OUTPUT: RETVAL
+
+SV *
+_Rmpc_out_strS (stream, base, dig, p, round, suff)
+ FILE * stream
+ SV * base
+ SV * dig
+ mpc_t * p
+ SV * round
+ SV * suff
+CODE:
+ RETVAL = _Rmpc_out_strS (aTHX_ stream, base, dig, p, round, suff);
+OUTPUT: RETVAL
+
+SV *
+_Rmpc_out_strP (pre, stream, base, dig, p, round)
+ SV * pre
+ FILE * stream
+ SV * base
+ SV * dig
+ mpc_t * p
+ SV * round
+CODE:
+ RETVAL = _Rmpc_out_strP (aTHX_ pre, stream, base, dig, p, round);
+OUTPUT: RETVAL
+
+SV *
+_Rmpc_out_strPS (pre, stream, base, dig, p, round, suff)
+ SV * pre
+ FILE * stream
+ SV * base
+ SV * dig
+ mpc_t * p
+ SV * round
+ SV * suff
+CODE:
+ RETVAL = _Rmpc_out_strPS (aTHX_ pre, stream, base, dig, p, round, suff);
+OUTPUT: RETVAL
+
+SV *
+Rmpc_inp_str (p, stream, base, round)
+ mpc_t * p
+ FILE * stream
+ SV * base
+ SV * round
+CODE:
+ RETVAL = Rmpc_inp_str (aTHX_ p, stream, base, round);
+OUTPUT: RETVAL
+
+SV *
+Rmpc_sin (rop, op, round)
+ mpc_t * rop
+ mpc_t * op
+ SV * round
+CODE:
+ RETVAL = Rmpc_sin (aTHX_ rop, op, round);
+OUTPUT: RETVAL
+
+SV *
+Rmpc_cos (rop, op, round)
+ mpc_t * rop
+ mpc_t * op
+ SV * round
+CODE:
+ RETVAL = Rmpc_cos (aTHX_ rop, op, round);
+OUTPUT: RETVAL
+
+SV *
+Rmpc_tan (rop, op, round)
+ mpc_t * rop
+ mpc_t * op
+ SV * round
+CODE:
+ RETVAL = Rmpc_tan (aTHX_ rop, op, round);
+OUTPUT: RETVAL
+
+SV *
+Rmpc_sinh (rop, op, round)
+ mpc_t * rop
+ mpc_t * op
+ SV * round
+CODE:
+ RETVAL = Rmpc_sinh (aTHX_ rop, op, round);
+OUTPUT: RETVAL
+
+SV *
+Rmpc_cosh (rop, op, round)
+ mpc_t * rop
+ mpc_t * op
+ SV * round
+CODE:
+ RETVAL = Rmpc_cosh (aTHX_ rop, op, round);
+OUTPUT: RETVAL
+
+SV *
+Rmpc_tanh (rop, op, round)
+ mpc_t * rop
+ mpc_t * op
+ SV * round
+CODE:
+ RETVAL = Rmpc_tanh (aTHX_ rop, op, round);
+OUTPUT: RETVAL
+
+SV *
+Rmpc_asin (rop, op, round)
+ mpc_t * rop
+ mpc_t * op
+ SV * round
+CODE:
+ RETVAL = Rmpc_asin (aTHX_ rop, op, round);
+OUTPUT: RETVAL
+
+SV *
+Rmpc_acos (rop, op, round)
+ mpc_t * rop
+ mpc_t * op
+ SV * round
+CODE:
+ RETVAL = Rmpc_acos (aTHX_ rop, op, round);
+OUTPUT: RETVAL
+
+SV *
+Rmpc_atan (rop, op, round)
+ mpc_t * rop
+ mpc_t * op
+ SV * round
+CODE:
+ RETVAL = Rmpc_atan (aTHX_ rop, op, round);
+OUTPUT: RETVAL
+
+SV *
+Rmpc_asinh (rop, op, round)
+ mpc_t * rop
+ mpc_t * op
+ SV * round
+CODE:
+ RETVAL = Rmpc_asinh (aTHX_ rop, op, round);
+OUTPUT: RETVAL
+
+SV *
+Rmpc_acosh (rop, op, round)
+ mpc_t * rop
+ mpc_t * op
+ SV * round
+CODE:
+ RETVAL = Rmpc_acosh (aTHX_ rop, op, round);
+OUTPUT: RETVAL
+
+SV *
+Rmpc_atanh (rop, op, round)
+ mpc_t * rop
+ mpc_t * op
+ SV * round
+CODE:
+ RETVAL = Rmpc_atanh (aTHX_ rop, op, round);
+OUTPUT: RETVAL
+
+SV *
+overload_true (a, second, third)
+ mpc_t * a
+ SV * second
+ SV * third
+CODE:
+ RETVAL = overload_true (aTHX_ a, second, third);
+OUTPUT: RETVAL
+
+SV *
+overload_mul (a, b, third)
+ mpc_t * a
+ SV * b
+ SV * third
+CODE:
+ RETVAL = overload_mul (aTHX_ a, b, third);
+OUTPUT: RETVAL
+
+SV *
+overload_add (a, b, third)
+ mpc_t * a
+ SV * b
+ SV * third
+CODE:
+ RETVAL = overload_add (aTHX_ a, b, third);
+OUTPUT: RETVAL
+
+SV *
+overload_sub (a, b, third)
+ mpc_t * a
+ SV * b
+ SV * third
+CODE:
+ RETVAL = overload_sub (aTHX_ a, b, third);
+OUTPUT: RETVAL
+
+SV *
+overload_div (a, b, third)
+ mpc_t * a
+ SV * b
+ SV * third
+CODE:
+ RETVAL = overload_div (aTHX_ a, b, third);
+OUTPUT: RETVAL
+
+SV *
+overload_div_eq (a, b, third)
+ SV * a
+ SV * b
+ SV * third
+CODE:
+ RETVAL = overload_div_eq (aTHX_ a, b, third);
+OUTPUT: RETVAL
+
+SV *
+overload_sub_eq (a, b, third)
+ SV * a
+ SV * b
+ SV * third
+CODE:
+ RETVAL = overload_sub_eq (aTHX_ a, b, third);
+OUTPUT: RETVAL
+
+SV *
+overload_add_eq (a, b, third)
+ SV * a
+ SV * b
+ SV * third
+CODE:
+ RETVAL = overload_add_eq (aTHX_ a, b, third);
+OUTPUT: RETVAL
+
+SV *
+overload_mul_eq (a, b, third)
+ SV * a
+ SV * b
+ SV * third
+CODE:
+ RETVAL = overload_mul_eq (aTHX_ a, b, third);
+OUTPUT: RETVAL
+
+SV *
+overload_pow (a, b, third)
+ mpc_t * a
+ SV * b
+ SV * third
+CODE:
+ RETVAL = overload_pow (aTHX_ a, b, third);
+OUTPUT: RETVAL
+
+SV *
+overload_pow_eq (a, b, third)
+ SV * a
+ SV * b
+ SV * third
+CODE:
+ RETVAL = overload_pow_eq (aTHX_ a, b, third);
+OUTPUT: RETVAL
+
+SV *
+overload_equiv (a, b, third)
+ mpc_t * a
+ SV * b
+ SV * third
+CODE:
+ RETVAL = overload_equiv (aTHX_ a, b, third);
+OUTPUT: RETVAL
+
+SV *
+overload_not_equiv (a, b, third)
+ mpc_t * a
+ SV * b
+ SV * third
+CODE:
+ RETVAL = overload_not_equiv (aTHX_ a, b, third);
+OUTPUT: RETVAL
+
+SV *
+overload_not (a, second, third)
+ mpc_t * a
+ SV * second
+ SV * third
+CODE:
+ RETVAL = overload_not (aTHX_ a, second, third);
+OUTPUT: RETVAL
+
+SV *
+overload_sqrt (p, second, third)
+ mpc_t * p
+ SV * second
+ SV * third
+CODE:
+ RETVAL = overload_sqrt (aTHX_ p, second, third);
+OUTPUT: RETVAL
+
+void
+overload_copy (p, second, third)
+ mpc_t * p
+ SV * second
+ SV * third
+ PREINIT:
+ I32* temp;
+ PPCODE:
+ temp = PL_markstack_ptr++;
+ overload_copy(aTHX_ p, second, third);
+ if (PL_markstack_ptr != temp) {
+ /* truly void, because dXSARGS not invoked */
+ PL_markstack_ptr = temp;
+ XSRETURN_EMPTY; /* return empty stack */
+ }
+ /* must have used dXSARGS; list context implied */
+ return; /* assume stack size is correct */
+
+SV *
+overload_abs (p, second, third)
+ mpc_t * p
+ SV * second
+ SV * third
+CODE:
+ RETVAL = overload_abs (aTHX_ p, second, third);
+OUTPUT: RETVAL
+
+SV *
+overload_exp (p, second, third)
+ mpc_t * p
+ SV * second
+ SV * third
+CODE:
+ RETVAL = overload_exp (aTHX_ p, second, third);
+OUTPUT: RETVAL
+
+SV *
+overload_log (p, second, third)
+ mpc_t * p
+ SV * second
+ SV * third
+CODE:
+ RETVAL = overload_log (aTHX_ p, second, third);
+OUTPUT: RETVAL
+
+SV *
+overload_sin (p, second, third)
+ mpc_t * p
+ SV * second
+ SV * third
+CODE:
+ RETVAL = overload_sin (aTHX_ p, second, third);
+OUTPUT: RETVAL
+
+SV *
+overload_cos (p, second, third)
+ mpc_t * p
+ SV * second
+ SV * third
+CODE:
+ RETVAL = overload_cos (aTHX_ p, second, third);
+OUTPUT: RETVAL
+
+void
+_get_r_string (p, base, n_digits, round)
+ mpc_t * p
+ SV * base
+ SV * n_digits
+ SV * round
+ PREINIT:
+ I32* temp;
+ PPCODE:
+ temp = PL_markstack_ptr++;
+ _get_r_string(aTHX_ p, base, n_digits, round);
+ if (PL_markstack_ptr != temp) {
+ /* truly void, because dXSARGS not invoked */
+ PL_markstack_ptr = temp;
+ XSRETURN_EMPTY; /* return empty stack */
+ }
+ /* must have used dXSARGS; list context implied */
+ return; /* assume stack size is correct */
+
+void
+_get_i_string (p, base, n_digits, round)
+ mpc_t * p
+ SV * base
+ SV * n_digits
+ SV * round
+ PREINIT:
+ I32* temp;
+ PPCODE:
+ temp = PL_markstack_ptr++;
+ _get_i_string(aTHX_ p, base, n_digits, round);
+ if (PL_markstack_ptr != temp) {
+ /* truly void, because dXSARGS not invoked */
+ PL_markstack_ptr = temp;
+ XSRETURN_EMPTY; /* return empty stack */
+ }
+ /* must have used dXSARGS; list context implied */
+ return; /* assume stack size is correct */
+
+SV *
+_itsa (a)
+ SV * a
+CODE:
+ RETVAL = _itsa (aTHX_ a);
+OUTPUT: RETVAL
+
+SV *
+_new_real (b)
+ SV * b
+CODE:
+ RETVAL = _new_real (aTHX_ b);
+OUTPUT: RETVAL
+
+SV *
+_new_im (b)
+ SV * b
+CODE:
+ RETVAL = _new_im (aTHX_ b);
+OUTPUT: RETVAL
+
+int
+_has_longlong ()
+
+
+int
+_has_longdouble ()
+
+
+int
+_has_inttypes ()
+
+SV *
+gmp_v ()
+CODE:
+ RETVAL = gmp_v (aTHX);
+OUTPUT: RETVAL
+
+
+SV *
+mpfr_v ()
+CODE:
+ RETVAL = mpfr_v (aTHX);
+OUTPUT: RETVAL
+
+
+SV *
+_MPC_VERSION_MAJOR ()
+CODE:
+ RETVAL = _MPC_VERSION_MAJOR (aTHX);
+OUTPUT: RETVAL
+
+
+SV *
+_MPC_VERSION_MINOR ()
+CODE:
+ RETVAL = _MPC_VERSION_MINOR (aTHX);
+OUTPUT: RETVAL
+
+
+SV *
+_MPC_VERSION_PATCHLEVEL ()
+CODE:
+ RETVAL = _MPC_VERSION_PATCHLEVEL (aTHX);
+OUTPUT: RETVAL
+
+
+SV *
+_MPC_VERSION ()
+CODE:
+ RETVAL = _MPC_VERSION (aTHX);
+OUTPUT: RETVAL
+
+
+SV *
+_MPC_VERSION_NUM (x, y, z)
+ SV * x
+ SV * y
+ SV * z
+CODE:
+ RETVAL = _MPC_VERSION_NUM (aTHX_ x, y, z);
+OUTPUT: RETVAL
+
+SV *
+_MPC_VERSION_STRING ()
+CODE:
+ RETVAL = _MPC_VERSION_STRING (aTHX);
+OUTPUT: RETVAL
+
+
+SV *
+Rmpc_get_version ()
+CODE:
+ RETVAL = Rmpc_get_version (aTHX);
+OUTPUT: RETVAL
+
+
+SV *
+Rmpc_real (rop, op, round)
+ mpfr_t * rop
+ mpc_t * op
+ SV * round
+CODE:
+ RETVAL = Rmpc_real (aTHX_ rop, op, round);
+OUTPUT: RETVAL
+
+SV *
+Rmpc_imag (rop, op, round)
+ mpfr_t * rop
+ mpc_t * op
+ SV * round
+CODE:
+ RETVAL = Rmpc_imag (aTHX_ rop, op, round);
+OUTPUT: RETVAL
+
+SV *
+Rmpc_arg (rop, op, round)
+ mpfr_t * rop
+ mpc_t * op
+ SV * round
+CODE:
+ RETVAL = Rmpc_arg (aTHX_ rop, op, round);
+OUTPUT: RETVAL
+
+SV *
+Rmpc_proj (rop, op, round)
+ mpc_t * rop
+ mpc_t * op
+ SV * round
+CODE:
+ RETVAL = Rmpc_proj (aTHX_ rop, op, round);
+OUTPUT: RETVAL
+
+SV *
+Rmpc_get_str (base, dig, op, round)
+ SV * base
+ SV * dig
+ mpc_t * op
+ SV * round
+CODE:
+ RETVAL = Rmpc_get_str (aTHX_ base, dig, op, round);
+OUTPUT: RETVAL
+
+SV *
+Rmpc_set_str (rop, str, base, round)
+ mpc_t * rop
+ SV * str
+ SV * base
+ SV * round
+CODE:
+ RETVAL = Rmpc_set_str (aTHX_ rop, str, base, round);
+OUTPUT: RETVAL
+
+SV *
+Rmpc_strtoc (rop, str, base, round)
+ mpc_t * rop
+ SV * str
+ SV * base
+ SV * round
+CODE:
+ RETVAL = Rmpc_strtoc (aTHX_ rop, str, base, round);
+OUTPUT: RETVAL
+
+void
+Rmpc_set_nan (a)
+ mpc_t * a
+ PREINIT:
+ I32* temp;
+ PPCODE:
+ temp = PL_markstack_ptr++;
+ Rmpc_set_nan(a);
+ if (PL_markstack_ptr != temp) {
+ /* truly void, because dXSARGS not invoked */
+ PL_markstack_ptr = temp;
+ XSRETURN_EMPTY; /* return empty stack */
+ }
+ /* must have used dXSARGS; list context implied */
+ return; /* assume stack size is correct */
+
+void
+Rmpc_swap (a, b)
+ mpc_t * a
+ mpc_t * b
+ PREINIT:
+ I32* temp;
+ PPCODE:
+ temp = PL_markstack_ptr++;
+ Rmpc_swap(a, b);
+ if (PL_markstack_ptr != temp) {
+ /* truly void, because dXSARGS not invoked */
+ PL_markstack_ptr = temp;
+ XSRETURN_EMPTY; /* return empty stack */
+ }
+ /* must have used dXSARGS; list context implied */
+ return; /* assume stack size is correct */
+
+SV *
+overload_atan2 (p, q, third)
+ mpc_t * p
+ mpc_t * q
+ SV * third
+CODE:
+ RETVAL = overload_atan2 (aTHX_ p, q, third);
+OUTPUT: RETVAL
+
+SV *
+Rmpc_sin_cos (rop_sin, rop_cos, op, rnd_sin, rnd_cos)
+ mpc_t * rop_sin
+ mpc_t * rop_cos
+ mpc_t * op
+ SV * rnd_sin
+ SV * rnd_cos
+CODE:
+ RETVAL = Rmpc_sin_cos (aTHX_ rop_sin, rop_cos, op, rnd_sin, rnd_cos);
+OUTPUT: RETVAL
+
+void
+Rmpc_get_dc (crop, op, round)
+ SV * crop
+ mpc_t * op
+ SV * round
+ PREINIT:
+ I32* temp;
+ PPCODE:
+ temp = PL_markstack_ptr++;
+ Rmpc_get_dc(aTHX_ crop, op, round);
+ if (PL_markstack_ptr != temp) {
+ /* truly void, because dXSARGS not invoked */
+ PL_markstack_ptr = temp;
+ XSRETURN_EMPTY; /* return empty stack */
+ }
+ /* must have used dXSARGS; list context implied */
+ return; /* assume stack size is correct */
+
+void
+Rmpc_get_ldc (crop, op, round)
+ SV * crop
+ mpc_t * op
+ SV * round
+ PREINIT:
+ I32* temp;
+ PPCODE:
+ temp = PL_markstack_ptr++;
+ Rmpc_get_ldc(aTHX_ crop, op, round);
+ if (PL_markstack_ptr != temp) {
+ /* truly void, because dXSARGS not invoked */
+ PL_markstack_ptr = temp;
+ XSRETURN_EMPTY; /* return empty stack */
+ }
+ /* must have used dXSARGS; list context implied */
+ return; /* assume stack size is correct */
+
+SV *
+Rmpc_set_dc (op, crop, round)
+ mpc_t * op
+ SV * crop
+ SV * round
+CODE:
+ RETVAL = Rmpc_set_dc (aTHX_ op, crop, round);
+OUTPUT: RETVAL
+
+SV *
+Rmpc_set_ldc (op, crop, round)
+ mpc_t * op
+ SV * crop
+ SV * round
+CODE:
+ RETVAL = Rmpc_set_ldc (aTHX_ op, crop, round);
+OUTPUT: RETVAL
+
+int
+_have_Complex_h ()
+
+
+SV *
+_mpfr_buildopt_tls_p ()
+CODE:
+ RETVAL = _mpfr_buildopt_tls_p (aTHX);
+OUTPUT: RETVAL
+
+
+SV *
+_get_xs_version ()
+CODE:
+ RETVAL = _get_xs_version (aTHX);
+OUTPUT: RETVAL
+
+
+SV *
+_wrap_count ()
+CODE:
+ RETVAL = _wrap_count (aTHX);
+OUTPUT: RETVAL
+
+
+SV *
+Rmpc_mul_2si (a, b, c, round)
+ mpc_t * a
+ mpc_t * b
+ SV * c
+ SV * round
+CODE:
+ RETVAL = Rmpc_mul_2si (aTHX_ a, b, c, round);
+OUTPUT: RETVAL
+
+SV *
+Rmpc_div_2si (a, b, c, round)
+ mpc_t * a
+ mpc_t * b
+ SV * c
+ SV * round
+CODE:
+ RETVAL = Rmpc_div_2si (aTHX_ a, b, c, round);
+OUTPUT: RETVAL
+
+SV *
+Rmpc_log10 (rop, op, round)
+ mpc_t * rop
+ mpc_t * op
+ SV * round
+CODE:
+ RETVAL = Rmpc_log10 (aTHX_ rop, op, round);
+OUTPUT: RETVAL
+
+void
+CLONE (x, ...)
+ SV * x
+ PREINIT:
+ I32* temp;
+ PPCODE:
+ temp = PL_markstack_ptr++;
+ CLONE(aTHX_ x);
+ if (PL_markstack_ptr != temp) {
+ /* truly void, because dXSARGS not invoked */
+ PL_markstack_ptr = temp;
+ XSRETURN_EMPTY; /* return empty stack */
+ }
+ /* must have used dXSARGS; list context implied */
+ return; /* assume stack size is correct */
+
+BOOT:
+
+ {
+ MY_CXT_INIT;
+ MY_CXT._perl_default_prec_re = 53;
+ MY_CXT._perl_default_prec_im = 53;
+ MY_CXT._perl_default_rounding_mode = 0;
+ }
+
@@ -1,79 +1,90 @@
-use ExtUtils::MakeMaker;
-use Config;
-require 5.008008;
-
-$do_complex_h = 0; # Let the Makefile.PL decide whether to support the double _Complex and
- # long double _Complex data types.
-#$do_complex_h = 1; # Force inclusion of the double _Complex and long double _Complex data types
-#$do_complex_h = -1;# Force exclusion of the double _Complex and long double _Complex data types
-
-unless ($do_complex_h) {
- eval {require Math::Complex_C;};
- $do_complex_h = $@ ? -1 : 1;
-}
-
-$use_64_bit_int = 0; # Let perl decide whether to include 64-bit 'long long' support
-$use_long_double = 0;# Let perl decide whether to include 'long double' support
-
-#$use_64_bit_int = -1; # Force exclusion of 64-bit 'long long' support
-#$use_long_double = -1;# Force exclusion of 'long double' support
-
-#$use_64_bit_int = 1; # Force inclusion of 64-bit 'long long' support
-#$use_long_double = 1;# Force inclusion of 'long double' support
-
-print "\nThis module requires the following C libraries:\n";
-print " gmp-4.3.2 (or later)\n mpfr-2.4.2 (or later)\n mpc-0.8 (or later)\n\n";
-
-my $defines = $] < 5.008 ? "-DOLDPERL" : "-DNEWPERL";
-
-if($use_64_bit_int == -1) {}
-elsif($use_64_bit_int == 1) {$defines .= " -DUSE_64_BIT_INT"}
-else {
- unless($Config::Config{ivsize} < 8) {
- $defines .= " -DUSE_64_BIT_INT";
- }
-}
-
-if($use_long_double == -1) {}
-elsif($use_long_double == 1) {$defines .= " -DUSE_LONG_DOUBLE"}
-else {
- if($Config::Config{nvsize} > 8 ) {
- $defines .= " -DUSE_LONG_DOUBLE";
- }
-}
-
-if($do_complex_h == 1) { $defines .= " -D_DO_COMPLEX_H"}
-
-$defines =~ /-DUSE_64_BIT_INT/ ? print "Building with 64-bit'long long' support\n" :
- print "Building without 64-bit 'long long' support\n";
-
-print "If this is wrong, see the \"64-bit support\" section in the README\n\n";
-
-$defines =~ /-DUSE_LONG_DOUBLE/ ? print "Building with 'long double' support\n" :
- print "Building without 'long double' support\n";
-
-print "If this is wrong, see the \"64-bit support\" section in the README\n\n";
-
-$defines =~ /-D_DO_COMPLEX_H/ ? print "Trying to build with 'double _Complex' & 'long double _Complex' support\n" :
- print "Building without 'double _Complex' & 'long double _Complex' support\n";
-
-print "If this is wrong, see the \"_Complex C types support\" section in the README\n\n";
-
-my %options = (
- NAME => 'Math::MPC',
- AUTHOR => 'Sisyphus (sisyphus at (@) cpan dot (.) org)',
- ABSTRACT => 'Perl interface to the MPC (multi precision complex) library',
- PREREQ_PM => {'Math::MPFR' => '2.01'},
- DEFINE => $defines,
- LIBS => [
- '-lmpc -lmpfr -lgmp'
- ],
- VERSION_FROM => 'MPC.pm',
- clean => { FILES => 'out1.txt out2.txt out3.txt out4.txt out5.txt out6.txt out7.txt save_child_setting.txt' },
-);
-
-WriteMakefile(%options);
-
-# Remove the Makefile dependency. Causes problems on a few systems.
-sub MY::makefile { '' }
-
+use ExtUtils::MakeMaker;
+use Config;
+require 5.008008;
+
+$do_complex_h = 0; # Let the Makefile.PL decide whether to support the double _Complex and
+ # long double _Complex data types.
+#$do_complex_h = 1; # Force inclusion of the double _Complex and long double _Complex data types
+#$do_complex_h = -1;# Force exclusion of the double _Complex and long double _Complex data types
+
+unless ($do_complex_h) {
+ eval {require Math::Complex_C;};
+ $do_complex_h = $@ ? -1 : 1;
+}
+
+$use_64_bit_int = 0; # Let perl decide whether to include 64-bit 'long long' support
+$use_long_double = 0;# Let perl decide whether to include 'long double' support
+
+#$use_64_bit_int = -1; # Force exclusion of 64-bit 'long long' support
+#$use_long_double = -1;# Force exclusion of 'long double' support
+
+#$use_64_bit_int = 1; # Force inclusion of 64-bit 'long long' support
+#$use_long_double = 1;# Force inclusion of 'long double' support
+
+print "\nThis module requires the following C libraries:\n";
+print " gmp-4.3.2 (or later)\n mpfr-2.4.2 (or later)\n mpc-0.8 (or later)\n\n";
+
+my $defines = $] < 5.008 ? "-DOLDPERL" : "-DNEWPERL";
+
+if($use_64_bit_int == -1) {}
+elsif($use_64_bit_int == 1) {$defines .= " -DUSE_64_BIT_INT"}
+else {
+ unless($Config::Config{ivsize} < 8) {
+ $defines .= " -DUSE_64_BIT_INT";
+ }
+}
+
+if($use_long_double == -1) {}
+elsif($use_long_double == 1) {$defines .= " -DUSE_LONG_DOUBLE"}
+else {
+ if($Config::Config{nvsize} > 8 ) {
+ $defines .= " -DUSE_LONG_DOUBLE";
+ }
+}
+
+if($do_complex_h == 1) { $defines .= " -D_DO_COMPLEX_H"}
+
+$defines =~ /-DUSE_64_BIT_INT/ ? print "Building with 64-bit'long long' support\n" :
+ print "Building without 64-bit 'long long' support\n";
+
+print "If this is wrong, see the \"64-bit support\" section in the README\n\n";
+
+$defines =~ /-DUSE_LONG_DOUBLE/ ? print "Building with 'long double' support\n" :
+ print "Building without 'long double' support\n";
+
+print "If this is wrong, see the \"64-bit support\" section in the README\n\n";
+
+$defines =~ /-D_DO_COMPLEX_H/ ? print "Trying to build with 'double _Complex' & 'long double _Complex' support\n" :
+ print "Building without 'double _Complex' & 'long double _Complex' support\n";
+
+print "If this is wrong, see the \"_Complex C types support\" section in the README\n\n";
+
+my %options = (
+ NAME => 'Math::MPC',
+ AUTHOR => 'Sisyphus (sisyphus at (@) cpan dot (.) org)',
+ ABSTRACT => 'Perl interface to the MPC (multi precision complex) library',
+ PREREQ_PM => {'Math::MPFR' => '2.01'},
+ DEFINE => $defines,
+ LIBS => [
+ '-lmpc -lmpfr -lgmp'
+ ],
+ LICENSE => 'perl',
+ VERSION_FROM => 'MPC.pm',
+ clean => { FILES => 'out1.txt out2.txt out3.txt out4.txt out5.txt out6.txt out7.txt save_child_setting.txt' },
+ META_MERGE => {
+ 'meta-spec' => { version => 2 },
+ resources => {
+ repository => {
+ type => 'git',
+ url => 'https://github.com/sisyphus/math-mpc.git',
+ web => 'https://github.com/sisyphus/math-mpc',
+ },
+ },
+ },
+);
+
+WriteMakefile(%options);
+
+# Remove the Makefile dependency. Causes problems on a few systems.
+sub MY::makefile { '' }
+
@@ -1,99 +1,99 @@
-This module wraps the MPC library functions.
-
-This version of Math::MPC needs mpc-0.8 or later.
-
-The MPC library is a C library for multiple-precision complex number
-computations with exact rounding. It is based on the MPFR C library
-which, in turn, is based on the GMP C library.
-
-MPC, like MPFR and GMP, is free. It is distributed under the
-GNU Lesser General Public License (GNU Lesser GPL).
-
-Because this module wraps the MPC functions, it requires that the
-MPC library (version 0.8.0 or later), the GMP library (version 4.3.2
-or later) and the MPFR library (version 2.4.2 or later) have been
-installed.
-
-For the GMP library see:
-http://gmplib.org
-
-For the MPFR library see:
-http://www.mpfr.org
-Do not use the (outdated) MPFR library source that ships with the
-GMP source.
-
-For the MPC library see:
-http://www.multiprecision.org/mpc/
-
-You'll also need to have Math::MPFR (version 2.01 or later) installed.
-
-To build this module you need perl 5.6.0 or later. I'm not sure of all
-the requirements to get it to build with earlier versions of perl, but
-it's definite that the XS code relating to operator overloading will
-not compile with perl versions prior to 5.6.
-
-Build in the usual way:
-
- perl Makefile.PL
- make
- make test
- make install
-
-When building this module, the MPC, GMP and MPFR libraries will need to be
-accessible. If those files are in a location where your compiler does
-not find them by default, then instead of running 'perl Makefile.PL',
-you'll need to run:
-
-perl Makefile.pl INC="-I/path/to/gmp_includes -I/path/to/mpfr_includes -I/path/to/mpc/include"
- LIBS="-L/path/to/mpc_lib -lmpc -L/path/to/mpfr_lib -lmpfr -L/path/to/gmp_lib -lgmp"
-
-==============
-64-bit support
-==============
-
-If your perl's Config reports that 'ivsize' is greater than
-or equal to 8,then Math::MPC will, by default, be built with access
-to the mpfr_*_uj and mpfr_*_sj functions. Else, access to those
-functions is, by default, denied. You can override the default by
-opening up the Makefile.PL and uncommenting the appropriate line (just
-a few lines down from the top of the file ... the comments in that
-file should make it clear).
-
-Similarly, if your perl's Config reports that 'nvsize' is greater than
-8 then Math::MPC will, by default, be built with access
-to the mpfr_*_ld functions. Else, access to those functions is,
-by default, denied. You can override the default by opening up the
-Makefile.PL and uncommenting the appropriate line (just a few lines down
-from the top of the file ... the comments in that file should make it
-clear).
-
-I believe it to be both unnecessary and inadvisable to override the
-default - but if you do find that you need to override the default,
-please let me know. That you have found it necessary to override the
-default is something I probably ought to know about.
-
-=========================
-_Complex C types support
-=========================
-
-The mpc library (beginning with version 0.9) provides support for assigning
-and returning the 'double _Complex' and 'long double _Complex' C data types.
-Therefore Math::MPC (beginning with version 0.90) provides optional support for
-assigning/returning Math::Complex_C (double _Complex) objects and Math::Complex_C::Long
-(long double _Complex) objects, using the Rmpc_set_dc, Rmpc_set_ldc, Rmpc_get_dc and
-Rmpc_get_ldc functions.
-
-If Math::Complex_C can be loaded then complex.h will be included in the compilation
-and, iff _MPC_H_HAVE_COMPLEX is thereby defined (in mpc.h), then Math::MPC will be built
-with support for the above mentioned set/get functions.
-
-If there's a need to override this default behaviour, just open the Makefile.PL and
-comment in the line of code that forces '$do_complex_h' to be assigned the value you
-want ... either -1 (to force exclusion of support), or 1 (to force support). Then
-run 'make realclean' and start over again.
-
-Any problems, let me know.
-
-I am contactable by email at sisyphus at(@) cpan dot (.) org.
-
-
+This module wraps the MPC library functions.
+
+This version of Math::MPC needs mpc-0.8 or later.
+
+The MPC library is a C library for multiple-precision complex number
+computations with exact rounding. It is based on the MPFR C library
+which, in turn, is based on the GMP C library.
+
+MPC, like MPFR and GMP, is free. It is distributed under the
+GNU Lesser General Public License (GNU Lesser GPL).
+
+Because this module wraps the MPC functions, it requires that the
+MPC library (version 0.8.0 or later), the GMP library (version 4.3.2
+or later) and the MPFR library (version 2.4.2 or later) have been
+installed.
+
+For the GMP library see:
+http://gmplib.org
+
+For the MPFR library see:
+http://www.mpfr.org
+Do not use the (outdated) MPFR library source that ships with the
+GMP source.
+
+For the MPC library see:
+http://www.multiprecision.org/mpc/
+
+You'll also need to have Math::MPFR (version 2.01 or later) installed.
+
+To build this module you need perl 5.6.0 or later. I'm not sure of all
+the requirements to get it to build with earlier versions of perl, but
+it's definite that the XS code relating to operator overloading will
+not compile with perl versions prior to 5.6.
+
+Build in the usual way:
+
+ perl Makefile.PL
+ make
+ make test
+ make install
+
+When building this module, the MPC, GMP and MPFR libraries will need to be
+accessible. If those files are in a location where your compiler does
+not find them by default, then instead of running 'perl Makefile.PL',
+you'll need to run:
+
+perl Makefile.pl INC="-I/path/to/gmp_includes -I/path/to/mpfr_includes -I/path/to/mpc/include"
+ LIBS="-L/path/to/mpc_lib -lmpc -L/path/to/mpfr_lib -lmpfr -L/path/to/gmp_lib -lgmp"
+
+==============
+64-bit support
+==============
+
+If your perl's Config reports that 'ivsize' is greater than
+or equal to 8,then Math::MPC will, by default, be built with access
+to the mpfr_*_uj and mpfr_*_sj functions. Else, access to those
+functions is, by default, denied. You can override the default by
+opening up the Makefile.PL and uncommenting the appropriate line (just
+a few lines down from the top of the file ... the comments in that
+file should make it clear).
+
+Similarly, if your perl's Config reports that 'nvsize' is greater than
+8 then Math::MPC will, by default, be built with access
+to the mpfr_*_ld functions. Else, access to those functions is,
+by default, denied. You can override the default by opening up the
+Makefile.PL and uncommenting the appropriate line (just a few lines down
+from the top of the file ... the comments in that file should make it
+clear).
+
+I believe it to be both unnecessary and inadvisable to override the
+default - but if you do find that you need to override the default,
+please let me know. That you have found it necessary to override the
+default is something I probably ought to know about.
+
+=========================
+_Complex C types support
+=========================
+
+The mpc library (beginning with version 0.9) provides support for assigning
+and returning the 'double _Complex' and 'long double _Complex' C data types.
+Therefore Math::MPC (beginning with version 0.90) provides optional support for
+assigning/returning Math::Complex_C (double _Complex) objects and Math::Complex_C::Long
+(long double _Complex) objects, using the Rmpc_set_dc, Rmpc_set_ldc, Rmpc_get_dc and
+Rmpc_get_ldc functions.
+
+If Math::Complex_C can be loaded then complex.h will be included in the compilation
+and, iff _MPC_H_HAVE_COMPLEX is thereby defined (in mpc.h), then Math::MPC will be built
+with support for the above mentioned set/get functions.
+
+If there's a need to override this default behaviour, just open the Makefile.PL and
+comment in the line of code that forces '$do_complex_h' to be assigned the value you
+want ... either -1 (to force exclusion of support), or 1 (to force support). Then
+run 'make realclean' and start over again.
+
+Any problems, let me know.
+
+I am contactable by email at sisyphus at(@) cpan dot (.) org.
+
+
@@ -1,27 +1,27 @@
-use Math::MPC qw(:mpc);
-use Math::MPFR qw(:mpfr);
-use warnings;
-use strict;
-
-print "1..2\n";
-
-if(Math::MPC::_has_longdouble() == Math::MPFR::_has_longdouble()) {print "ok 1\n"}
-else {
- warn "\n Math::MPC and Math::MPFR treat NV's (doubles) differently.\n",
- " This breaks assumptions that have been made - and could result\n",
- " in failing tests and/or strange behaviour. It is recommended that\n",
- " both modules be built in the same way as regards support of long\n",
- " doubles - see the Makefile.PL for information on how to control this\n";
- print "not ok 1\n";
-}
-
-if(Math::MPC::_has_longlong() == Math::MPFR::_has_longlong()) {print "ok 2\n"}
-else {
- warn "\n Math::MPC and Math::MPFR treat IV's (integers) differently.\n",
- " This breaks assumptions that have been made - and could result\n",
- " in failing tests and/or strange behaviour. It is recommended that\n",
- " both modules be built in the same way as regards support of long\n",
- " longs - see the Makefile.PL for information on how to control this\n";
- print "not ok 2\n";
-}
-
+use Math::MPC qw(:mpc);
+use Math::MPFR qw(:mpfr);
+use warnings;
+use strict;
+
+print "1..2\n";
+
+if(Math::MPC::_has_longdouble() == Math::MPFR::_has_longdouble()) {print "ok 1\n"}
+else {
+ warn "\n Math::MPC and Math::MPFR treat NV's (doubles) differently.\n",
+ " This breaks assumptions that have been made - and could result\n",
+ " in failing tests and/or strange behaviour. It is recommended that\n",
+ " both modules be built in the same way as regards support of long\n",
+ " doubles - see the Makefile.PL for information on how to control this\n";
+ print "not ok 1\n";
+}
+
+if(Math::MPC::_has_longlong() == Math::MPFR::_has_longlong()) {print "ok 2\n"}
+else {
+ warn "\n Math::MPC and Math::MPFR treat IV's (integers) differently.\n",
+ " This breaks assumptions that have been made - and could result\n",
+ " in failing tests and/or strange behaviour. It is recommended that\n",
+ " both modules be built in the same way as regards support of long\n",
+ " longs - see the Makefile.PL for information on how to control this\n";
+ print "not ok 2\n";
+}
+
@@ -1,41 +1,41 @@
-use warnings;
-use strict;
-use Math::MPC qw(:mpc);
-use Math::MPFR qw(:mpfr);
-
-print "1..5\n";
-
-my $string = Rmpc_get_version();
-
-print STDERR "\n# Using Math::MPFR version ", $Math::MPFR::VERSION, "\n";
-print STDERR "# Using Math::MPC version ", $Math::MPC::VERSION, "\n";
-print STDERR "# Math::MPC uses mpc library version ", Rmpc_get_version(), "\n";
-print STDERR "# Math::MPFR uses mpfr library version ", Rmpfr_get_version(), "\n";
-print STDERR "# Math::MPC uses mpfr library version ", Math::MPC::mpfr_v(), "\n";
-print STDERR "# Math::MPFR uses gmp library version ", Math::MPFR::gmp_v(), "\n";
-print STDERR "# Math::MPC uses gmp library version ", Math::MPC::gmp_v(), "\n";
-
-Math::MPC::_have_Complex_h() ?
- warn "\n# Built with support for 'double _Complex' and 'long double _Complex' types\n"
- :
- warn "\n# Built without support for 'double _Complex' and 'long double _Complex types'\n";
-
-if($Math::MPC::VERSION eq '1.01') {print "ok 1\n"}
-else {print "not ok 1 $Math::MPC::VERSION\n"}
-
-if(MPC_VERSION_MAJOR > 0 || MPC_VERSION_MINOR > 7) {print "ok 2\n"}
-else {print "not ok 2 MPC Library version ", MPC_VERSION_STRING, " is too old\n"}
-
-if($string eq MPC_VERSION_STRING) {print "ok 3\n"}
-else {print "not ok 3 \"", Rmpc_get_version, "\" (library version) does not match \"", MPC_VERSION_STRING, "\" (header file version)\n"}
-
-if(MPC_VERSION == MPC_VERSION_NUM(MPC_VERSION_MAJOR, MPC_VERSION_MINOR, MPC_VERSION_PATCHLEVEL)) {print "ok 4\n"}
-else {print "not ok 4 ", MPC_VERSION, " does not match ",
- MPC_VERSION_NUM(MPC_VERSION_MAJOR, MPC_VERSION_MINOR, MPC_VERSION_PATCHLEVEL), "\n"}
-
-if($Math::MPC::VERSION eq Math::MPC::_get_xs_version()) {print "ok 5\n"}
-else {
- warn "\$Math::MPC::VERSION: $Math::MPC::VERSION\nXS_VERSION: ", Math::MPC::_get_xs_version(), "\n";
- print "not ok 5\n";
-}
-
+use warnings;
+use strict;
+use Math::MPC qw(:mpc);
+use Math::MPFR qw(:mpfr);
+
+print "1..5\n";
+
+my $string = Rmpc_get_version();
+
+print STDERR "\n# Using Math::MPFR version ", $Math::MPFR::VERSION, "\n";
+print STDERR "# Using Math::MPC version ", $Math::MPC::VERSION, "\n";
+print STDERR "# Math::MPC uses mpc library version ", Rmpc_get_version(), "\n";
+print STDERR "# Math::MPFR uses mpfr library version ", Rmpfr_get_version(), "\n";
+print STDERR "# Math::MPC uses mpfr library version ", Math::MPC::mpfr_v(), "\n";
+print STDERR "# Math::MPFR uses gmp library version ", Math::MPFR::gmp_v(), "\n";
+print STDERR "# Math::MPC uses gmp library version ", Math::MPC::gmp_v(), "\n";
+
+Math::MPC::_have_Complex_h() ?
+ warn "\n# Built with support for 'double _Complex' and 'long double _Complex' types\n"
+ :
+ warn "\n# Built without support for 'double _Complex' and 'long double _Complex types'\n";
+
+if($Math::MPC::VERSION eq '1.02') {print "ok 1\n"}
+else {print "not ok 1 $Math::MPC::VERSION\n"}
+
+if(MPC_VERSION_MAJOR > 0 || MPC_VERSION_MINOR > 7) {print "ok 2\n"}
+else {print "not ok 2 MPC Library version ", MPC_VERSION_STRING, " is too old\n"}
+
+if($string eq MPC_VERSION_STRING) {print "ok 3\n"}
+else {print "not ok 3 \"", Rmpc_get_version, "\" (library version) does not match \"", MPC_VERSION_STRING, "\" (header file version)\n"}
+
+if(MPC_VERSION == MPC_VERSION_NUM(MPC_VERSION_MAJOR, MPC_VERSION_MINOR, MPC_VERSION_PATCHLEVEL)) {print "ok 4\n"}
+else {print "not ok 4 ", MPC_VERSION, " does not match ",
+ MPC_VERSION_NUM(MPC_VERSION_MAJOR, MPC_VERSION_MINOR, MPC_VERSION_PATCHLEVEL), "\n"}
+
+if($Math::MPC::VERSION eq Math::MPC::_get_xs_version()) {print "ok 5\n"}
+else {
+ warn "\$Math::MPC::VERSION: $Math::MPC::VERSION\nXS_VERSION: ", Math::MPC::_get_xs_version(), "\n";
+ print "not ok 5\n";
+}
+
@@ -1,103 +1,103 @@
-use strict;
-use warnings;
-use Math::MPC qw(:mpc);
-use Math::MPFR qw(:mpfr);
-
-print "1..2\n";
-
-print "# Using mpfr version ", MPFR_VERSION_STRING, "\n";
-print "# Using mpc library version ", MPC_VERSION_STRING, "\n";
-
-my $nan = Math::MPC->new();
-my $t1 = Math::MPFR->new();
-my $t2 = Math::MPFR->new();
-my $untrue1 = Math::MPC->new(Math::MPFR->new(), 0);
-my $untrue2 = Math::MPC->new(0, Math::MPFR->new());
-my $ok = '';
-my $flag_clear = 1;
-
-if(Rmpfr_erangeflag_p()) {Rmpfr_clear_erangeflag()}
-
-if(Rmpfr_erangeflag_p()) {
- warn "erange flag did not clear\n";
- $flag_clear = 0;
-}
-
-RMPC_RE($t1, $nan);
-RMPC_IM($t2, $nan);
-
-if(Rmpfr_nan_p($t1) && Rmpfr_nan_p($t2))
- {$ok .= 'a'}
-
-if(Rmpfr_erangeflag_p() && $flag_clear) {
- warn "Test 1a set the erange flag\n";
- $flag_clear = 0;
-}
-
-RMPC_RE($t1, $untrue1);
-RMPC_IM($t2, $untrue1);
-
-if(Rmpfr_nan_p($t1) && !Rmpfr_nan_p($t2))
- {$ok .= 'b'}
-
-if(Rmpfr_erangeflag_p() && $flag_clear) {
- warn "Test 1b set the erange flag\n";
- $flag_clear = 0;
-}
-
-RMPC_RE($t1, $untrue2);
-RMPC_IM($t2, $untrue2);
-
-if(!Rmpfr_nan_p($t1) && Rmpfr_nan_p($t2))
- {$ok .= 'c'}
-
-if(Rmpfr_erangeflag_p() && $flag_clear) {
- warn "Test 1c set the erange flag\n";
- $flag_clear = 0;
-}
-
-if(!$nan) {$ok .= 'd'}
-if(Rmpfr_erangeflag_p() && $flag_clear) {
- warn "Test 1d set the erange flag\n";
- $flag_clear = 0;
-}
-
-if(!$untrue1) {$ok .= 'e'}
-if(Rmpfr_erangeflag_p() && $flag_clear) {
- warn "Test 1e set the erange flag\n";
- $flag_clear = 0;
-}
-
-if(!$untrue2) {$ok .= 'f'}
-if(Rmpfr_erangeflag_p() && $flag_clear) {
- warn "Test 1f set the erange flag\n";
- $flag_clear = 0;
-}
-
-if($nan) {$ok .= 'A'}
-if(Rmpfr_erangeflag_p() && $flag_clear) {
- warn "Test 1A set the erange flag\n";
- $flag_clear = 0;
-}
-
-if($untrue1) {$ok .= 'B'}
-if(Rmpfr_erangeflag_p() && $flag_clear) {
- warn "Test 1B set the erange flag\n";
- $flag_clear = 0;
-}
-
-if($untrue2) {$ok .= 'C'}
-if(Rmpfr_erangeflag_p() && $flag_clear) {
- warn "Test 1C set the erange flag\n";
- $flag_clear = 0;
-}
-
-if($ok eq 'abcdef') {print "ok 1\n"}
-else {print "not ok 1 $ok\n"}
-
-if(!Rmpfr_erangeflag_p()) {print "ok 2\n"}
-else {
- warn "The erangeflag has been set and we don't want that\n";
- print "not ok 2\n";
-}
-
+use strict;
+use warnings;
+use Math::MPC qw(:mpc);
+use Math::MPFR qw(:mpfr);
+
+print "1..2\n";
+
+print "# Using mpfr version ", MPFR_VERSION_STRING, "\n";
+print "# Using mpc library version ", MPC_VERSION_STRING, "\n";
+
+my $nan = Math::MPC->new();
+my $t1 = Math::MPFR->new();
+my $t2 = Math::MPFR->new();
+my $untrue1 = Math::MPC->new(Math::MPFR->new(), 0);
+my $untrue2 = Math::MPC->new(0, Math::MPFR->new());
+my $ok = '';
+my $flag_clear = 1;
+
+if(Rmpfr_erangeflag_p()) {Rmpfr_clear_erangeflag()}
+
+if(Rmpfr_erangeflag_p()) {
+ warn "erange flag did not clear\n";
+ $flag_clear = 0;
+}
+
+RMPC_RE($t1, $nan);
+RMPC_IM($t2, $nan);
+
+if(Rmpfr_nan_p($t1) && Rmpfr_nan_p($t2))
+ {$ok .= 'a'}
+
+if(Rmpfr_erangeflag_p() && $flag_clear) {
+ warn "Test 1a set the erange flag\n";
+ $flag_clear = 0;
+}
+
+RMPC_RE($t1, $untrue1);
+RMPC_IM($t2, $untrue1);
+
+if(Rmpfr_nan_p($t1) && !Rmpfr_nan_p($t2))
+ {$ok .= 'b'}
+
+if(Rmpfr_erangeflag_p() && $flag_clear) {
+ warn "Test 1b set the erange flag\n";
+ $flag_clear = 0;
+}
+
+RMPC_RE($t1, $untrue2);
+RMPC_IM($t2, $untrue2);
+
+if(!Rmpfr_nan_p($t1) && Rmpfr_nan_p($t2))
+ {$ok .= 'c'}
+
+if(Rmpfr_erangeflag_p() && $flag_clear) {
+ warn "Test 1c set the erange flag\n";
+ $flag_clear = 0;
+}
+
+if(!$nan) {$ok .= 'd'}
+if(Rmpfr_erangeflag_p() && $flag_clear) {
+ warn "Test 1d set the erange flag\n";
+ $flag_clear = 0;
+}
+
+if(!$untrue1) {$ok .= 'e'}
+if(Rmpfr_erangeflag_p() && $flag_clear) {
+ warn "Test 1e set the erange flag\n";
+ $flag_clear = 0;
+}
+
+if(!$untrue2) {$ok .= 'f'}
+if(Rmpfr_erangeflag_p() && $flag_clear) {
+ warn "Test 1f set the erange flag\n";
+ $flag_clear = 0;
+}
+
+if($nan) {$ok .= 'A'}
+if(Rmpfr_erangeflag_p() && $flag_clear) {
+ warn "Test 1A set the erange flag\n";
+ $flag_clear = 0;
+}
+
+if($untrue1) {$ok .= 'B'}
+if(Rmpfr_erangeflag_p() && $flag_clear) {
+ warn "Test 1B set the erange flag\n";
+ $flag_clear = 0;
+}
+
+if($untrue2) {$ok .= 'C'}
+if(Rmpfr_erangeflag_p() && $flag_clear) {
+ warn "Test 1C set the erange flag\n";
+ $flag_clear = 0;
+}
+
+if($ok eq 'abcdef') {print "ok 1\n"}
+else {print "not ok 1 $ok\n"}
+
+if(!Rmpfr_erangeflag_p()) {print "ok 2\n"}
+else {
+ warn "The erangeflag has been set and we don't want that\n";
+ print "not ok 2\n";
+}
+
@@ -1,232 +1,232 @@
-use warnings;
-use strict;
-use Math::MPFR qw(:mpfr);
-use Math::MPC qw(:mpc);
-
-my $count = 16;
-
-print "1..$count\n";
-
-Rmpc_set_default_prec2(200, 200);
-
-eval {require Math::Complex_C;};
-
-if($@) {
- warn "Skipping all tests - couldn't load Math::Complex_C";
- for(1 .. $count) {print "ok $_\n"}
- exit 0;
-}
-
-unless(Math::MPC::_have_Complex_h()) {
- warn "Skipping all tests - Math::MPC not built with support for 'double _Complex' & 'long double _Complex' types";
- for(1 .. $count) {print "ok $_\n"}
- exit 0;
-}
-
-my $cc = Math::Complex_C->new(4.5, -231.125);
-my $ccl = Math::Complex_C::Long->new(4.5, -231.125);
-my $mpcc = Math::MPC->new();
-my $mpfr = Math::MPFR->new();
-
-Rmpc_set_dc($mpcc, $cc, MPC_RNDNN);
-
-RMPC_RE($mpfr, $mpcc);
-if($mpfr == 4.5) {print "ok 1\n"}
-else {
- warn "\$mpfr: $mpfr\n";
- print "not ok 1\n";
-}
-
-RMPC_IM($mpfr, $mpcc);
-if($mpfr == -231.125) {print "ok 2\n"}
-else {
- warn "\$mpfr: $mpfr\n";
- print "not ok 2\n";
-}
-
-Rmpc_set_ldc($mpcc, $ccl, MPC_RNDNN);
-
-RMPC_RE($mpfr, $mpcc);
-if($mpfr == 4.5) {print "ok 3\n"}
-else {
- warn "\$mpfr: $mpfr\n";
- print "not ok 3\n";
-}
-
-RMPC_IM($mpfr, $mpcc);
-if($mpfr == -231.125) {print "ok 4\n"}
-else {
- warn "\$mpfr: $mpfr\n";
- print "not ok 4\n";
-}
-
-Math::Complex_C::assign_c($cc, 3.19, -12.621);
-Math::Complex_C::Long::assign_cl($ccl, 3.19, -12.621);
-
-my $mpccl = Math::MPC->new();
-
-Rmpc_set_dc($mpcc, $cc, MPC_RNDNN);
-Rmpc_set_ldc($mpccl, $ccl, MPC_RNDNN);
-
-# Math::Complex_C::assign_cl changed with the release of version 0.07
-
-if(Math::Complex_C::_nvsize() == Math::Complex_C::_doublesize()) {
- if($Math::Complex_C::VERSION < 0.065) {
- warn "\nBetter to upgrade to the latest version of Math::Complex_C\n";
- if($mpcc == $mpccl) {print "ok 5\n"}
- else {print "not ok 5\n"}
- }
- else {
- if($mpcc == $mpccl) {print "not ok 5\n"}
- else {print "ok 5\n"}
- }
-}
-elsif((Math::Complex_C::_nvsize() == Math::Complex_C::_longdoublesize()) &&
- (Math::Complex_C::_longdoublesize() > Math::Complex_C::_doublesize())) {
- unless($mpcc == $mpccl) {print "ok 5\n"}
- else {print "not ok 5\n"}
-}
-else {
- warn "Skipping test 5 for this configuration of perl\n";
- print "ok 5\n";
-}
-
-my $cc_check = Math::Complex_C->new();
-my $ccl_check = Math::Complex_C::Long->new();
-
-Rmpc_get_dc($cc_check, $mpcc, MPC_RNDNN);
-Rmpc_get_ldc($ccl_check, $mpccl, MPC_RNDNN);
-
-if($cc_check == $cc) {print "ok 6\n"}
-else {
- warn "\$cc_check: $cc_check\n\$cc: $cc\n";
- print "not ok 6\n";
-}
-
-if($ccl_check == $ccl) {print "ok 7\n"}
-else {
- warn "\$ccl_check: $ccl_check\n\$ccl: $ccl\n";
- print "not ok 7\n";
-}
-
-eval {Rmpc_get_dc($ccl_check, $mpcc, MPC_RNDNN);};
-
-if($@) {
- if($@ =~ /1st arg/) {print "ok 8\n"}
- else {
- warn "\$\@: $@\n";
- print "not ok 8\n";
- }
-}
-else {print "not ok 8\n"}
-
-eval {Rmpc_get_ldc($cc_check, $mpccl, MPC_RNDNN);};
-
-if($@) {
- if($@ =~ /1st arg/) {print "ok 9\n"}
- else {
- warn "\$\@: $@\n";
- print "not ok 9\n";
- }
-}
-else {print "not ok 9\n"}
-
-eval {Rmpc_set_dc($mpcc, $ccl, MPC_RNDNN);};
-
-if($@) {
- if($@ =~ /2nd arg/) {print "ok 10\n"}
- else {
- warn "\$\@: $@\n";
- print "not ok 10\n";
- }
-}
-else {print "not ok 10\n"}
-
-eval {Rmpc_set_ldc($mpccl, $cc, MPC_RNDNN);};
-
-if($@) {
- if($@ =~ /2nd arg/) {print "ok 11\n"}
- else {
- warn "\$\@: $@\n";
- print "not ok 11\n";
- }
-}
-else {print "not ok 11\n"}
-
-unless(Math::Complex_C::_double_Complexsize() == Math::Complex_C::_longdouble_Complexsize()) {
-
- eval {require ActivePerl::DocTools;};
- unless($@) {
- warn "\nExpect tests 12-14, 16 to fail on ActivePerl for Windows.\n";
- warn "Can someone explain ? ... and why test 15 does not also fail ?\n";
- }
-
- my $cc_rop = sqrt($cc);
- my $ccl_rop = sqrt($ccl);
-
- Rmpc_set_dc($mpcc, $cc_rop, MPC_RNDNN);
- Rmpc_set_ldc($mpccl, $ccl_rop, MPC_RNDNN);
-
- if($mpcc != $mpccl) {print "ok 12\n"}
- else {
- warn "\$mpccl: $mpccl\n";
- print "not ok 12\n";
- }
-
- Math::Complex_C::pow_c($cc_rop, $cc, Math::Complex_C->new(1.1, 1.1));
- Math::Complex_C::pow_cl($ccl_rop, $ccl, Math::Complex_C::Long->new(1.1, 1.1));
-
- Rmpc_set_dc($mpcc, $cc_rop, MPC_RNDNN);
- Rmpc_set_ldc($mpccl, $ccl_rop, MPC_RNDNN);
-
- if($mpcc != $mpccl) {print "ok 13\n"}
- else {
- warn "\$mpccl: $mpccl\n";
- print "not ok 13\n";
- }
-
- Math::Complex_C::exp_c($cc_rop, $cc);
- Math::Complex_C::exp_cl($ccl_rop, $ccl);
-
- Rmpc_set_dc($mpcc, $cc_rop, MPC_RNDNN);
- Rmpc_set_ldc($mpccl, $ccl_rop, MPC_RNDNN);
-
- if($mpcc != $mpccl) {print "ok 14\n"}
- else {
- warn "\$mpccl: $mpccl\n";
- print "not ok 14\n";
- }
-
- Math::Complex_C::log_c($cc_rop, $cc);
- Math::Complex_C::log_cl($ccl_rop, $ccl);
-
- Rmpc_set_dc($mpcc, $cc_rop, MPC_RNDNN);
- Rmpc_set_ldc($mpccl, $ccl_rop, MPC_RNDNN);
-
- if($mpcc != $mpccl) {print "ok 15\n"}
- else {
- warn "\$mpccl: $mpccl\n";
- print "not ok 15\n";
- }
-
- #print "\n\n$mpcc\n$mpccl\n\n";
-
- Math::Complex_C::cos_c($cc_rop, $cc);
- Math::Complex_C::cos_cl($ccl_rop, $ccl);
-
- Rmpc_set_dc($mpcc, $cc_rop, MPC_RNDNN);
- Rmpc_set_ldc($mpccl, $ccl_rop, MPC_RNDNN);
-
- if($mpcc != $mpccl) {print "ok 16\n"}
- else {
- warn "\$mpccl: $mpccl\n";
- print "not ok 16\n";
- }
-}
-else {
- warn "Skipping tests 12 to 16 - tests are inapplicable\n";
- print "ok $_\n" for 12 .. 16;
-}
-
-
-
+use warnings;
+use strict;
+use Math::MPFR qw(:mpfr);
+use Math::MPC qw(:mpc);
+
+my $count = 16;
+
+print "1..$count\n";
+
+Rmpc_set_default_prec2(200, 200);
+
+eval {require Math::Complex_C;};
+
+if($@) {
+ warn "Skipping all tests - couldn't load Math::Complex_C";
+ for(1 .. $count) {print "ok $_\n"}
+ exit 0;
+}
+
+unless(Math::MPC::_have_Complex_h()) {
+ warn "Skipping all tests - Math::MPC not built with support for 'double _Complex' & 'long double _Complex' types";
+ for(1 .. $count) {print "ok $_\n"}
+ exit 0;
+}
+
+my $cc = Math::Complex_C->new(4.5, -231.125);
+my $ccl = Math::Complex_C::Long->new(4.5, -231.125);
+my $mpcc = Math::MPC->new();
+my $mpfr = Math::MPFR->new();
+
+Rmpc_set_dc($mpcc, $cc, MPC_RNDNN);
+
+RMPC_RE($mpfr, $mpcc);
+if($mpfr == 4.5) {print "ok 1\n"}
+else {
+ warn "\$mpfr: $mpfr\n";
+ print "not ok 1\n";
+}
+
+RMPC_IM($mpfr, $mpcc);
+if($mpfr == -231.125) {print "ok 2\n"}
+else {
+ warn "\$mpfr: $mpfr\n";
+ print "not ok 2\n";
+}
+
+Rmpc_set_ldc($mpcc, $ccl, MPC_RNDNN);
+
+RMPC_RE($mpfr, $mpcc);
+if($mpfr == 4.5) {print "ok 3\n"}
+else {
+ warn "\$mpfr: $mpfr\n";
+ print "not ok 3\n";
+}
+
+RMPC_IM($mpfr, $mpcc);
+if($mpfr == -231.125) {print "ok 4\n"}
+else {
+ warn "\$mpfr: $mpfr\n";
+ print "not ok 4\n";
+}
+
+Math::Complex_C::assign_c($cc, 3.19, -12.621);
+Math::Complex_C::Long::assign_cl($ccl, 3.19, -12.621);
+
+my $mpccl = Math::MPC->new();
+
+Rmpc_set_dc($mpcc, $cc, MPC_RNDNN);
+Rmpc_set_ldc($mpccl, $ccl, MPC_RNDNN);
+
+# Math::Complex_C::assign_cl changed with the release of version 0.07
+
+if(Math::Complex_C::_nvsize() == Math::Complex_C::_doublesize()) {
+ if($Math::Complex_C::VERSION < 0.065) {
+ warn "\nBetter to upgrade to the latest version of Math::Complex_C\n";
+ if($mpcc == $mpccl) {print "ok 5\n"}
+ else {print "not ok 5\n"}
+ }
+ else {
+ if($mpcc == $mpccl) {print "not ok 5\n"}
+ else {print "ok 5\n"}
+ }
+}
+elsif((Math::Complex_C::_nvsize() == Math::Complex_C::_longdoublesize()) &&
+ (Math::Complex_C::_longdoublesize() > Math::Complex_C::_doublesize())) {
+ unless($mpcc == $mpccl) {print "ok 5\n"}
+ else {print "not ok 5\n"}
+}
+else {
+ warn "Skipping test 5 for this configuration of perl\n";
+ print "ok 5\n";
+}
+
+my $cc_check = Math::Complex_C->new();
+my $ccl_check = Math::Complex_C::Long->new();
+
+Rmpc_get_dc($cc_check, $mpcc, MPC_RNDNN);
+Rmpc_get_ldc($ccl_check, $mpccl, MPC_RNDNN);
+
+if($cc_check == $cc) {print "ok 6\n"}
+else {
+ warn "\$cc_check: $cc_check\n\$cc: $cc\n";
+ print "not ok 6\n";
+}
+
+if($ccl_check == $ccl) {print "ok 7\n"}
+else {
+ warn "\$ccl_check: $ccl_check\n\$ccl: $ccl\n";
+ print "not ok 7\n";
+}
+
+eval {Rmpc_get_dc($ccl_check, $mpcc, MPC_RNDNN);};
+
+if($@) {
+ if($@ =~ /1st arg/) {print "ok 8\n"}
+ else {
+ warn "\$\@: $@\n";
+ print "not ok 8\n";
+ }
+}
+else {print "not ok 8\n"}
+
+eval {Rmpc_get_ldc($cc_check, $mpccl, MPC_RNDNN);};
+
+if($@) {
+ if($@ =~ /1st arg/) {print "ok 9\n"}
+ else {
+ warn "\$\@: $@\n";
+ print "not ok 9\n";
+ }
+}
+else {print "not ok 9\n"}
+
+eval {Rmpc_set_dc($mpcc, $ccl, MPC_RNDNN);};
+
+if($@) {
+ if($@ =~ /2nd arg/) {print "ok 10\n"}
+ else {
+ warn "\$\@: $@\n";
+ print "not ok 10\n";
+ }
+}
+else {print "not ok 10\n"}
+
+eval {Rmpc_set_ldc($mpccl, $cc, MPC_RNDNN);};
+
+if($@) {
+ if($@ =~ /2nd arg/) {print "ok 11\n"}
+ else {
+ warn "\$\@: $@\n";
+ print "not ok 11\n";
+ }
+}
+else {print "not ok 11\n"}
+
+unless(Math::Complex_C::_double_Complexsize() == Math::Complex_C::_longdouble_Complexsize()) {
+
+ eval {require ActivePerl::DocTools;};
+ unless($@) {
+ warn "\nExpect tests 12-14, 16 to fail on ActivePerl for Windows.\n";
+ warn "Can someone explain ? ... and why test 15 does not also fail ?\n";
+ }
+
+ my $cc_rop = sqrt($cc);
+ my $ccl_rop = sqrt($ccl);
+
+ Rmpc_set_dc($mpcc, $cc_rop, MPC_RNDNN);
+ Rmpc_set_ldc($mpccl, $ccl_rop, MPC_RNDNN);
+
+ if($mpcc != $mpccl) {print "ok 12\n"}
+ else {
+ warn "\$mpccl: $mpccl\n";
+ print "not ok 12\n";
+ }
+
+ Math::Complex_C::pow_c($cc_rop, $cc, Math::Complex_C->new(1.1, 1.1));
+ Math::Complex_C::pow_cl($ccl_rop, $ccl, Math::Complex_C::Long->new(1.1, 1.1));
+
+ Rmpc_set_dc($mpcc, $cc_rop, MPC_RNDNN);
+ Rmpc_set_ldc($mpccl, $ccl_rop, MPC_RNDNN);
+
+ if($mpcc != $mpccl) {print "ok 13\n"}
+ else {
+ warn "\$mpccl: $mpccl\n";
+ print "not ok 13\n";
+ }
+
+ Math::Complex_C::exp_c($cc_rop, $cc);
+ Math::Complex_C::exp_cl($ccl_rop, $ccl);
+
+ Rmpc_set_dc($mpcc, $cc_rop, MPC_RNDNN);
+ Rmpc_set_ldc($mpccl, $ccl_rop, MPC_RNDNN);
+
+ if($mpcc != $mpccl) {print "ok 14\n"}
+ else {
+ warn "\$mpccl: $mpccl\n";
+ print "not ok 14\n";
+ }
+
+ Math::Complex_C::log_c($cc_rop, $cc);
+ Math::Complex_C::log_cl($ccl_rop, $ccl);
+
+ Rmpc_set_dc($mpcc, $cc_rop, MPC_RNDNN);
+ Rmpc_set_ldc($mpccl, $ccl_rop, MPC_RNDNN);
+
+ if($mpcc != $mpccl) {print "ok 15\n"}
+ else {
+ warn "\$mpccl: $mpccl\n";
+ print "not ok 15\n";
+ }
+
+ #print "\n\n$mpcc\n$mpccl\n\n";
+
+ Math::Complex_C::cos_c($cc_rop, $cc);
+ Math::Complex_C::cos_cl($ccl_rop, $ccl);
+
+ Rmpc_set_dc($mpcc, $cc_rop, MPC_RNDNN);
+ Rmpc_set_ldc($mpccl, $ccl_rop, MPC_RNDNN);
+
+ if($mpcc != $mpccl) {print "ok 16\n"}
+ else {
+ warn "\$mpccl: $mpccl\n";
+ print "not ok 16\n";
+ }
+}
+else {
+ warn "Skipping tests 12 to 16 - tests are inapplicable\n";
+ print "ok $_\n" for 12 .. 16;
+}
+
+
+
@@ -1,80 +1,80 @@
-use warnings;
-use strict;
-use Math::MPC qw(:mpc);
-use Math::MPFR qw(:mpfr);
-
-print "1..3\n";
-
-Rmpc_set_default_prec2(100, 100);
-
-my $mpc = Math::MPC->new('246' x 7, '3579' x 6);
-my $ok = '';
-my($real, $im) = c_string($mpc, 16, 0, MPC_RNDNN);
-my $r = r_string($mpc, 16, 0, MPC_RNDNN);
-my $i = i_string($mpc, 16, 0, MPC_RNDNN);
-
-if($r eq $real) {$ok .= 'a'}
-else {print "$r ne $real\n"}
-
-if($i eq $im) {$ok .= 'b'}
-else {print "$i ne $im\n"}
-
-if($real eq 'd.595a684adcdfe766@16') {$ok .= 'c'}
-else {print "$real ne d.595a684adcdfe766\@16\n"}
-
-if($im eq '4.bcbbcfdfb50863475ab@19') {$ok .= 'd'}
-else {print "$im ne 4.bcbbcfdfb50863475ab\@19\n"}
-
-($real, $im) = c_string($mpc, 10, 0, MPC_RNDNN);
-
-if($real eq '2.46246246246246246246e20') {$ok .= 'e'}
-else {print "$real ne 2.46246246246246246246e20\n"}
-
-if($im eq '3.57935793579357935793579e23') {$ok .= 'f'}
-else {print "$im ne 3.57935793579357935793579e23\n"}
-
-my $mpc_simple = Math::MPC->new(16.03125, 15.25);
-my $complex_string = Rmpc_get_str(16, 0, $mpc_simple, MPC_RNDNN);
-if($complex_string eq '(1.0080000000000000000000000p+4 f.4000000000000000000000000)') {$ok .= 'g'}
-
-$complex_string = Rmpc_get_str(16, 5, $mpc_simple, MPC_RNDNN);
-if($complex_string eq '(1.0080p+4 f.4000)') {$ok .= 'h'}
-
-$complex_string = Rmpc_get_str(10, 0, $mpc_simple, MPC_RNDNN);
-if($complex_string eq '(1.6031250000000000000000000000000e+1 1.5250000000000000000000000000000e+1)') {$ok .= 'i'}
-
-$complex_string = Rmpc_get_str(10, 9, $mpc_simple, MPC_RNDNN);
-if($complex_string eq '(1.60312500e+1 1.52500000e+1)') {$ok .= 'j'}
-
-if($ok eq 'abcdefghij') {print "ok 1\n"}
-else {print "not ok 1 $ok\n"}
-
-$ok = '';
-
-my $mpc2 = Math::MPC->new(0, 0);
-$mpc2 *= -1;
-if(Math::MPC::overload_string($mpc2) eq '(-0 -0)') {$ok .= 'a'}
-else {warn "\n2a: got '",Math::MPC::overload_string($mpc2), "'\nexpected '(-0 -0)'\n"}
-my $mpfr1 = Math::MPFR->new(-0.0);
-my $inf = 1 / $mpfr1;
-my $nan = Math::MPFR->new();
-my $mpc3 = Math::MPC->new($nan, $inf);
-
-if(lc(Math::MPC::overload_string($mpc3)) eq '(@nan@ -@inf@)') {$ok .= 'b'}
-else {warn "\n2b: got '", lc(Math::MPC::overload_string($mpc3)), "'\n" }
-
-if($ok eq 'ab') {print "ok 2\n"}
-else {print "not ok 2 $ok\n"}
-
-$ok = '';
-
-my $mpc4 = Math::MPC->new(-10, 12.5);
-my @vals = Rmpc_deref4($mpc4, 10, 5, MPC_RNDNN);
-
-$ok .= 'a' if $vals[0] eq '-10000';
-$ok .= 'b' if $vals[1] == 2;
-$ok .= 'c' if $vals[2] eq '12500';
-$ok .= 'd' if $vals[3] == 2;
-
-if($ok eq 'abcd') {print "ok 3\n"}
-else {print "not ok 3 $ok\n"}
+use warnings;
+use strict;
+use Math::MPC qw(:mpc);
+use Math::MPFR qw(:mpfr);
+
+print "1..3\n";
+
+Rmpc_set_default_prec2(100, 100);
+
+my $mpc = Math::MPC->new('246' x 7, '3579' x 6);
+my $ok = '';
+my($real, $im) = c_string($mpc, 16, 0, MPC_RNDNN);
+my $r = r_string($mpc, 16, 0, MPC_RNDNN);
+my $i = i_string($mpc, 16, 0, MPC_RNDNN);
+
+if($r eq $real) {$ok .= 'a'}
+else {print "$r ne $real\n"}
+
+if($i eq $im) {$ok .= 'b'}
+else {print "$i ne $im\n"}
+
+if($real eq 'd.595a684adcdfe766@16') {$ok .= 'c'}
+else {print "$real ne d.595a684adcdfe766\@16\n"}
+
+if($im eq '4.bcbbcfdfb50863475ab@19') {$ok .= 'd'}
+else {print "$im ne 4.bcbbcfdfb50863475ab\@19\n"}
+
+($real, $im) = c_string($mpc, 10, 0, MPC_RNDNN);
+
+if($real eq '2.46246246246246246246e20') {$ok .= 'e'}
+else {print "$real ne 2.46246246246246246246e20\n"}
+
+if($im eq '3.57935793579357935793579e23') {$ok .= 'f'}
+else {print "$im ne 3.57935793579357935793579e23\n"}
+
+my $mpc_simple = Math::MPC->new(16.03125, 15.25);
+my $complex_string = Rmpc_get_str(16, 0, $mpc_simple, MPC_RNDNN);
+if($complex_string eq '(1.0080000000000000000000000p+4 f.4000000000000000000000000)') {$ok .= 'g'}
+
+$complex_string = Rmpc_get_str(16, 5, $mpc_simple, MPC_RNDNN);
+if($complex_string eq '(1.0080p+4 f.4000)') {$ok .= 'h'}
+
+$complex_string = Rmpc_get_str(10, 0, $mpc_simple, MPC_RNDNN);
+if($complex_string eq '(1.6031250000000000000000000000000e+1 1.5250000000000000000000000000000e+1)') {$ok .= 'i'}
+
+$complex_string = Rmpc_get_str(10, 9, $mpc_simple, MPC_RNDNN);
+if($complex_string eq '(1.60312500e+1 1.52500000e+1)') {$ok .= 'j'}
+
+if($ok eq 'abcdefghij') {print "ok 1\n"}
+else {print "not ok 1 $ok\n"}
+
+$ok = '';
+
+my $mpc2 = Math::MPC->new(0, 0);
+$mpc2 *= -1;
+if(Math::MPC::overload_string($mpc2) eq '(-0 -0)') {$ok .= 'a'}
+else {warn "\n2a: got '",Math::MPC::overload_string($mpc2), "'\nexpected '(-0 -0)'\n"}
+my $mpfr1 = Math::MPFR->new(-0.0);
+my $inf = 1 / $mpfr1;
+my $nan = Math::MPFR->new();
+my $mpc3 = Math::MPC->new($nan, $inf);
+
+if(lc(Math::MPC::overload_string($mpc3)) eq '(@nan@ -@inf@)') {$ok .= 'b'}
+else {warn "\n2b: got '", lc(Math::MPC::overload_string($mpc3)), "'\n" }
+
+if($ok eq 'ab') {print "ok 2\n"}
+else {print "not ok 2 $ok\n"}
+
+$ok = '';
+
+my $mpc4 = Math::MPC->new(-10, 12.5);
+my @vals = Rmpc_deref4($mpc4, 10, 5, MPC_RNDNN);
+
+$ok .= 'a' if $vals[0] eq '-10000';
+$ok .= 'b' if $vals[1] == 2;
+$ok .= 'c' if $vals[2] eq '12500';
+$ok .= 'd' if $vals[3] == 2;
+
+if($ok eq 'abcd') {print "ok 3\n"}
+else {print "not ok 3 $ok\n"}
@@ -1,82 +1,82 @@
-use warnings;
-use strict;
-use Math::MPFR qw(:mpfr);
-use Math::MPC qw(:mpc);
-
-Rmpc_set_default_prec2(100, 100);
-Rmpfr_set_default_prec(100);
-
-print "1..2\n";
-
-my $_64i = Math::MPC::_has_longlong();
-my $_64d = Math::MPC::_has_longdouble();
-
-if($_64i) {print "Using 64-bit integer\n"}
-else {print "Using 32-bit integer\n"}
-
-if($_64d) {print "Using long double\n"}
-else {print "Not using long double\n"};
-
-my $uimax = ~0;
-my $simax = ($uimax - 1) / -2;
-my $mpc1 = Rmpc_init3(100, 100);
-my $mpfr1 = Rmpfr_init();
-my $uimpfr = Math::MPFR->new(~0);
-my $simpfr = Math::MPFR->new((~0 - 1) / -2);
-
-my $ok = '';
-
-$ok .= 'a' if Math::MPC::_itsa($uimax == 1);
-$ok .= 'b' if Math::MPC::_itsa($simax == 2);
-$ok .= 'c' if $simax < 0;
-$ok .= 'd' if $uimpfr == $uimax;
-$ok .= 'e' if $simpfr == $simax;
-
-if($ok eq 'abcde') {print "ok 1\n"}
-else {print "not ok 1 $ok mpc_64.t test script bug\n"}
-
-$ok = '';
-
-if($_64i) {Rmpc_set_uj_uj($mpc1, ~0, ~0, MPC_RNDNN)}
-else {Rmpc_set_ui_ui($mpc1, ~0, ~0, MPC_RNDNN)}
-
-RMPC_RE($mpfr1, $mpc1);
-$ok .= 'a' if $mpfr1 == ~0;
-RMPC_IM($mpfr1, $mpc1);
-$ok .= 'b' if $mpfr1 == ~0;
-
-if($_64i) {Rmpc_set_sj_sj($mpc1, $simax, $simax, MPC_RNDNN)}
-else {Rmpc_set_si_si($mpc1, $simax, $simax, MPC_RNDNN)}
-
-RMPC_RE($mpfr1, $mpc1);
-$ok .= 'c' if $mpfr1 == $simax;
-RMPC_IM($mpfr1, $mpc1);
-$ok .= 'd' if $mpfr1 == $simax;
-
-if($_64d) {Rmpc_set_ld_ld($mpc1, $uimax + 2, $uimax + 2, MPC_RNDNN)}
-else {Rmpc_set_d_d($mpc1, $uimax + 2, $uimax + 2, MPC_RNDNN)}
-
-RMPC_RE($mpfr1, $mpc1);
-$ok .= 'e' if $mpfr1 == $uimax + 2;
-RMPC_IM($mpfr1, $mpc1);
-$ok .= 'f' if $mpfr1 == $uimax + 2;
-
-Rmpc_set_fr_fr($mpc1, $uimpfr, $uimpfr, MPC_RNDNN);
-
-RMPC_RE($mpfr1, $mpc1);
-$ok .= 'g' if $mpfr1 == ~0;
-RMPC_IM($mpfr1, $mpc1);
-$ok .= 'h' if $mpfr1 == ~0;
-
-Rmpc_set_fr_fr($mpc1, $simpfr, $simpfr, MPC_RNDNN);
-
-RMPC_RE($mpfr1, $mpc1);
-$ok .= 'i' if $mpfr1 == $simpfr;
-RMPC_IM($mpfr1, $mpc1);
-$ok .= 'j' if $mpfr1 == $simpfr;
-
-if($ok eq 'abcdefghij') {print "ok 2\n"}
-else {print "not ok 2 $ok\n"}
-
-$ok = '';
-
+use warnings;
+use strict;
+use Math::MPFR qw(:mpfr);
+use Math::MPC qw(:mpc);
+
+Rmpc_set_default_prec2(100, 100);
+Rmpfr_set_default_prec(100);
+
+print "1..2\n";
+
+my $_64i = Math::MPC::_has_longlong();
+my $_64d = Math::MPC::_has_longdouble();
+
+if($_64i) {print "Using 64-bit integer\n"}
+else {print "Using 32-bit integer\n"}
+
+if($_64d) {print "Using long double\n"}
+else {print "Not using long double\n"};
+
+my $uimax = ~0;
+my $simax = ($uimax - 1) / -2;
+my $mpc1 = Rmpc_init3(100, 100);
+my $mpfr1 = Rmpfr_init();
+my $uimpfr = Math::MPFR->new(~0);
+my $simpfr = Math::MPFR->new((~0 - 1) / -2);
+
+my $ok = '';
+
+$ok .= 'a' if Math::MPC::_itsa($uimax == 1);
+$ok .= 'b' if Math::MPC::_itsa($simax == 2);
+$ok .= 'c' if $simax < 0;
+$ok .= 'd' if $uimpfr == $uimax;
+$ok .= 'e' if $simpfr == $simax;
+
+if($ok eq 'abcde') {print "ok 1\n"}
+else {print "not ok 1 $ok mpc_64.t test script bug\n"}
+
+$ok = '';
+
+if($_64i) {Rmpc_set_uj_uj($mpc1, ~0, ~0, MPC_RNDNN)}
+else {Rmpc_set_ui_ui($mpc1, ~0, ~0, MPC_RNDNN)}
+
+RMPC_RE($mpfr1, $mpc1);
+$ok .= 'a' if $mpfr1 == ~0;
+RMPC_IM($mpfr1, $mpc1);
+$ok .= 'b' if $mpfr1 == ~0;
+
+if($_64i) {Rmpc_set_sj_sj($mpc1, $simax, $simax, MPC_RNDNN)}
+else {Rmpc_set_si_si($mpc1, $simax, $simax, MPC_RNDNN)}
+
+RMPC_RE($mpfr1, $mpc1);
+$ok .= 'c' if $mpfr1 == $simax;
+RMPC_IM($mpfr1, $mpc1);
+$ok .= 'd' if $mpfr1 == $simax;
+
+if($_64d) {Rmpc_set_ld_ld($mpc1, $uimax + 2, $uimax + 2, MPC_RNDNN)}
+else {Rmpc_set_d_d($mpc1, $uimax + 2, $uimax + 2, MPC_RNDNN)}
+
+RMPC_RE($mpfr1, $mpc1);
+$ok .= 'e' if $mpfr1 == $uimax + 2;
+RMPC_IM($mpfr1, $mpc1);
+$ok .= 'f' if $mpfr1 == $uimax + 2;
+
+Rmpc_set_fr_fr($mpc1, $uimpfr, $uimpfr, MPC_RNDNN);
+
+RMPC_RE($mpfr1, $mpc1);
+$ok .= 'g' if $mpfr1 == ~0;
+RMPC_IM($mpfr1, $mpc1);
+$ok .= 'h' if $mpfr1 == ~0;
+
+Rmpc_set_fr_fr($mpc1, $simpfr, $simpfr, MPC_RNDNN);
+
+RMPC_RE($mpfr1, $mpc1);
+$ok .= 'i' if $mpfr1 == $simpfr;
+RMPC_IM($mpfr1, $mpc1);
+$ok .= 'j' if $mpfr1 == $simpfr;
+
+if($ok eq 'abcdefghij') {print "ok 2\n"}
+else {print "not ok 2 $ok\n"}
+
+$ok = '';
+
@@ -1,321 +1,321 @@
-use warnings;
-use strict;
-use Math::MPFR qw(:mpfr);
-use Math::MPC qw(:mpc);
-
-print "1..6\n";
-
-Rmpc_set_default_prec2(200, 200);
-Rmpfr_set_default_prec(200);
-my $_64 = Math::MPC::_has_longlong();
-
-my $mpc1 = Rmpc_init2(200);
-Rmpc_set_ui_ui($mpc1, 10, 10, MPC_RNDNN);
-my $mpfr1 = Math::MPFR->new(50.5);
-my $ok = '';
-
-Rmpc_add_ui($mpc1, $mpc1, 30, MPC_RNDNN);
-Rmpc_add_fr($mpc1, $mpc1, $mpfr1, MPC_RNDNN);
-Rmpc_add($mpc1, $mpc1, $mpc1, MPC_RNDNN);
-
-RMPC_RE($mpfr1, $mpc1);
-$ok .= 'a' if $mpfr1 == 181;
-RMPC_IM($mpfr1, $mpc1);
-$ok .= 'b' if $mpfr1 == 20;
-
-if($ok eq 'ab') {print "ok 1\n"}
-else {print "not ok 1 $ok\n"}
-
-$ok = '';
-
-#$mpc1 is 181, 20
-Rmpc_sub_ui($mpc1, $mpc1, 31, MPC_RNDNN);
-
-#$mpc1 is 150, 20
-Rmpc_ui_sub($mpc1, 50, $mpc1, MPC_RNDNN);
-
-#$mpc1 is -100, -20
-Rmpc_ui_ui_sub($mpc1, 30, 40, $mpc1, MPC_RNDNN);
-
-#$mpc1 is 130, 60
-RMPC_RE($mpfr1, $mpc1);
-$ok .= 'a' if $mpfr1 == 130;
-RMPC_IM($mpfr1, $mpc1);
-$ok .= 'b' if $mpfr1 == 60;
-
-my $mpc2 = Math::MPC->new($mpc1);
-
-Rmpc_sub($mpc1, $mpc1, $mpc2, MPC_RNDNN);
-
-RMPC_RE($mpfr1, $mpc1);
-$ok .= 'c' if $mpfr1 == 0;
-RMPC_IM($mpfr1, $mpc1);
-$ok .= 'd' if $mpfr1 == 0;
-
-if($ok eq 'abcd') {print "ok 2\n"}
-else {print "not ok 2 $ok\n"}
-
-$ok = '';
-
-Rmpc_set_ui_ui($mpc1, 10, 10, MPC_RNDNN);
-my $mpfr = Math::MPFR->new(~0);
-$mpfr += 10;
-
-$mpc1 += ~0;
-
-RMPC_RE($mpfr1, $mpc1);
-$ok .= 'a' if $mpfr1 == $mpfr;
-RMPC_IM($mpfr1, $mpc1);
-$ok .= 'b' if $mpfr1 == 10;
-
-$mpc1 -= ~0;
-
-RMPC_RE($mpfr1, $mpc1);
-$ok .= 'c' if $mpfr1 == 10;
-RMPC_IM($mpfr1, $mpc1);
-$ok .= 'd' if $mpfr1 == 10;
-
-$mpc1 += -100;
-
-RMPC_RE($mpfr1, $mpc1);
-$ok .= 'e' if $mpfr1 == -90;
-RMPC_IM($mpfr1, $mpc1);
-$ok .= 'f' if $mpfr1 == 10;
-
-$mpc1 -= -50;
-
-RMPC_RE($mpfr1, $mpc1);
-$ok .= 'g' if $mpfr1 == -40;
-RMPC_IM($mpfr1, $mpc1);
-$ok .= 'h' if $mpfr1 == 10;
-
-$mpc1 += 20.25;
-
-RMPC_RE($mpfr1, $mpc1);
-$ok .= 'i' if $mpfr1 == -19.75;
-RMPC_IM($mpfr1, $mpc1);
-$ok .= 'j' if $mpfr1 == 10;
-
-$mpc1 -= -20.5;
-
-RMPC_RE($mpfr1, $mpc1);
-$ok .= 'k' if $mpfr1 == 0.75;
-RMPC_IM($mpfr1, $mpc1);
-$ok .= 'l' if $mpfr1 == 10;
-
-my $string = '12345678' x 7;
-
-Rmpfr_set_str($mpfr, $string, 0, MPC_RNDNN);
-$mpfr += 0.75;
-
-$mpc1 += $string;
-
-RMPC_RE($mpfr1, $mpc1);
-$ok .= 'm' if $mpfr1 == $mpfr;
-RMPC_IM($mpfr1, $mpc1);
-$ok .= 'n' if $mpfr1 == 10;
-
-$mpc1 -= $string;
-
-RMPC_RE($mpfr1, $mpc1);
-$ok .= 'o' if $mpfr1 == 0.75;
-RMPC_IM($mpfr1, $mpc1);
-$ok .= 'p' if $mpfr1 == 10;
-
-Rmpc_set_d_d($mpc2, 1099511627770.5, 1099511627770.5, MPC_RNDNN);
-
-$mpc1 += $mpc2;
-
-RMPC_RE($mpfr1, $mpc1);
-$ok .= 'q' if $mpfr1 == 1099511627771.25;
-RMPC_IM($mpfr1, $mpc1);
-$ok .= 'r' if $mpfr1 == 1099511627780.5;
-
-$mpc1 -= $mpc2;
-
-RMPC_RE($mpfr1, $mpc1);
-$ok .= 's' if $mpfr1 == 0.75;
-RMPC_IM($mpfr1, $mpc1);
-$ok .= 't' if $mpfr1 == 10;
-
-if($ok eq 'abcdefghijklmnopqrst') {print "ok 3\n"}
-else {print "not ok 3 $ok\n"}
-
-$ok = '';
-
-Rmpc_set_ui_ui($mpc1, 10, 10, MPC_RNDNN);
-if($_64){
- if(Math::MPC::_has_inttypes()) {Math::MPFR::Rmpfr_set_uj($mpfr, ~0, GMP_RNDN)}
- else {Math::MPFR::Rmpfr_set_str($mpfr, ~0, 10, GMP_RNDN)}
-}
-else {Rmpfr_set_ui($mpfr, ~0, GMP_RNDN)}
-$mpfr += 10;
-
-$mpc1 = $mpc1 + ~0;
-
-RMPC_RE($mpfr1, $mpc1);
-$ok .= 'a' if $mpfr1 == $mpfr;
-RMPC_IM($mpfr1, $mpc1);
-$ok .= 'b' if $mpfr1 == 10;
-
-$mpc1 = $mpc1 - ~0;
-
-RMPC_RE($mpfr1, $mpc1);
-$ok .= 'c' if $mpfr1 == 10;
-RMPC_IM($mpfr1, $mpc1);
-$ok .= 'd' if $mpfr1 == 10;
-
-$mpc1 = $mpc1 + -100;
-
-RMPC_RE($mpfr1, $mpc1);
-$ok .= 'e' if $mpfr1 == -90;
-RMPC_IM($mpfr1, $mpc1);
-$ok .= 'f' if $mpfr1 == 10;
-
-$mpc1 = $mpc1 - -50;
-
-RMPC_RE($mpfr1, $mpc1);
-$ok .= 'g' if $mpfr1 == -40;
-RMPC_IM($mpfr1, $mpc1);
-$ok .= 'h' if $mpfr1 == 10;
-
-$mpc1 = $mpc1 + 20.25;
-
-RMPC_RE($mpfr1, $mpc1);
-$ok .= 'i' if $mpfr1 == -19.75;
-RMPC_IM($mpfr1, $mpc1);
-$ok .= 'j' if $mpfr1 == 10;
-
-$mpc1 = $mpc1 - -20.5;
-
-RMPC_RE($mpfr1, $mpc1);
-$ok .= 'k' if $mpfr1 == 0.75;
-RMPC_IM($mpfr1, $mpc1);
-$ok .= 'l' if $mpfr1 == 10;
-
-# LINE 189
-
-Rmpfr_set_str($mpfr, $string, 0, MPC_RNDNN);
-$mpfr += 0.75;
-
-$mpc1 = $mpc1 + $string;
-
-RMPC_RE($mpfr1, $mpc1);
-$ok .= 'm' if $mpfr1 == $mpfr;
-RMPC_IM($mpfr1, $mpc1);
-$ok .= 'n' if $mpfr1 == 10;
-
-$mpc1 = $mpc1 - $string;
-
-RMPC_RE($mpfr1, $mpc1);
-$ok .= 'o' if $mpfr1 == 0.75;
-RMPC_IM($mpfr1, $mpc1);
-$ok .= 'p' if $mpfr1 == 10;
-
-Rmpc_set_d_d($mpc2, 1099511627770.5, 1099511627770.5, MPC_RNDNN);
-
-$mpc1 = $mpc1 + $mpc2;
-
-RMPC_RE($mpfr1, $mpc1);
-$ok .= 'q' if $mpfr1 == 1099511627771.25;
-RMPC_IM($mpfr1, $mpc1);
-$ok .= 'r' if $mpfr1 == 1099511627780.5;
-
-$mpc1 = $mpc1 - $mpc2;
-
-RMPC_RE($mpfr1, $mpc1);
-$ok .= 's' if $mpfr1 == 0.75;
-RMPC_IM($mpfr1, $mpc1);
-$ok .= 't' if $mpfr1 == 10;
-
-if($ok eq 'abcdefghijklmnopqrst') {print "ok 4\n"}
-else {print "not ok 4 $ok\n"}
-
-$ok = '';
-
-Rmpc_set_ui_ui($mpc1, 10, 10, MPC_RNDNN);
-if($_64){
- if(Math::MPC::_has_inttypes()) {Math::MPFR::Rmpfr_set_uj($mpfr, ~0, GMP_RNDN)}
- else {Math::MPFR::Rmpfr_set_str($mpfr, ~0, 10, GMP_RNDN)}
-}
-else {Rmpfr_set_ui($mpfr, ~0, GMP_RNDN)}
-$mpfr += 10;
-
-$mpc1 = ~0 + $mpc1;
-
-RMPC_RE($mpfr1, $mpc1);
-$ok .= 'a' if $mpfr1 == $mpfr;
-RMPC_IM($mpfr1, $mpc1);
-$ok .= 'b' if $mpfr1 == 10;
-
-$mpc1 = ~0 - $mpc1;
-$mpfr = ~0 - $mpfr;
-
-RMPC_RE($mpfr1, $mpc1);
-$ok .= 'c' if $mpfr1 == $mpfr;
-RMPC_IM($mpfr1, $mpc1);
-$ok .= 'd' if $mpfr1 == -10;
-
-$mpc1 = -100 + $mpc1;
-$mpfr -= 100;
-
-RMPC_RE($mpfr1, $mpc1);
-$ok .= 'e' if $mpfr1 == $mpfr;
-RMPC_IM($mpfr1, $mpc1);
-$ok .= 'f' if $mpfr1 == -10;
-
-$mpc1 = -50 - $mpc1;
-$mpfr = -50 - $mpfr;
-
-RMPC_RE($mpfr1, $mpc1);
-$ok .= 'g' if $mpfr1 == $mpfr;
-RMPC_IM($mpfr1, $mpc1);
-$ok .= 'h' if $mpfr1 == 10;
-
-$mpc1 = 20.25 + $mpc1;
-$mpfr += 20.25;
-
-RMPC_RE($mpfr1, $mpc1);
-$ok .= 'i' if $mpfr1 == $mpfr;
-RMPC_IM($mpfr1, $mpc1);
-$ok .= 'j' if $mpfr1 == 10;
-
-$mpc1 = -20.5 - $mpc1;
-$mpfr = -20.5 - $mpfr;
-
-RMPC_RE($mpfr1, $mpc1);
-$ok .= 'k' if $mpfr1 == $mpfr;
-RMPC_IM($mpfr1, $mpc1);
-$ok .= 'l' if $mpfr1 == -10;
-
-$mpc1 = $string + $mpc1;
-$mpfr += $string;
-
-RMPC_RE($mpfr1, $mpc1);
-$ok .= 'm' if $mpfr1 == $mpfr;
-RMPC_IM($mpfr1, $mpc1);
-$ok .= 'n' if $mpfr1 == -10;
-
-$mpc1 = $string - $mpc1;
-$mpfr = $string - $mpfr;
-
-RMPC_RE($mpfr1, $mpc1);
-$ok .= 'o' if $mpfr1 == $mpfr;
-RMPC_IM($mpfr1, $mpc1);
-$ok .= 'p' if $mpfr1 == 10;
-
-if($ok eq 'abcdefghijklmnop') {print "ok 5\n"}
-else {print "not ok 5 $ok\n"}
-
-$ok = '';
-
-Rmpc_neg($mpc2, $mpc1, MPC_RNDNN);
-
-if($mpc2 == -$mpc1 && $mpc1 == -$mpc2) {print "ok 6\n"}
-else {print "not ok 6\n"}
-
-
-
-
-
-
+use warnings;
+use strict;
+use Math::MPFR qw(:mpfr);
+use Math::MPC qw(:mpc);
+
+print "1..6\n";
+
+Rmpc_set_default_prec2(200, 200);
+Rmpfr_set_default_prec(200);
+my $_64 = Math::MPC::_has_longlong();
+
+my $mpc1 = Rmpc_init2(200);
+Rmpc_set_ui_ui($mpc1, 10, 10, MPC_RNDNN);
+my $mpfr1 = Math::MPFR->new(50.5);
+my $ok = '';
+
+Rmpc_add_ui($mpc1, $mpc1, 30, MPC_RNDNN);
+Rmpc_add_fr($mpc1, $mpc1, $mpfr1, MPC_RNDNN);
+Rmpc_add($mpc1, $mpc1, $mpc1, MPC_RNDNN);
+
+RMPC_RE($mpfr1, $mpc1);
+$ok .= 'a' if $mpfr1 == 181;
+RMPC_IM($mpfr1, $mpc1);
+$ok .= 'b' if $mpfr1 == 20;
+
+if($ok eq 'ab') {print "ok 1\n"}
+else {print "not ok 1 $ok\n"}
+
+$ok = '';
+
+#$mpc1 is 181, 20
+Rmpc_sub_ui($mpc1, $mpc1, 31, MPC_RNDNN);
+
+#$mpc1 is 150, 20
+Rmpc_ui_sub($mpc1, 50, $mpc1, MPC_RNDNN);
+
+#$mpc1 is -100, -20
+Rmpc_ui_ui_sub($mpc1, 30, 40, $mpc1, MPC_RNDNN);
+
+#$mpc1 is 130, 60
+RMPC_RE($mpfr1, $mpc1);
+$ok .= 'a' if $mpfr1 == 130;
+RMPC_IM($mpfr1, $mpc1);
+$ok .= 'b' if $mpfr1 == 60;
+
+my $mpc2 = Math::MPC->new($mpc1);
+
+Rmpc_sub($mpc1, $mpc1, $mpc2, MPC_RNDNN);
+
+RMPC_RE($mpfr1, $mpc1);
+$ok .= 'c' if $mpfr1 == 0;
+RMPC_IM($mpfr1, $mpc1);
+$ok .= 'd' if $mpfr1 == 0;
+
+if($ok eq 'abcd') {print "ok 2\n"}
+else {print "not ok 2 $ok\n"}
+
+$ok = '';
+
+Rmpc_set_ui_ui($mpc1, 10, 10, MPC_RNDNN);
+my $mpfr = Math::MPFR->new(~0);
+$mpfr += 10;
+
+$mpc1 += ~0;
+
+RMPC_RE($mpfr1, $mpc1);
+$ok .= 'a' if $mpfr1 == $mpfr;
+RMPC_IM($mpfr1, $mpc1);
+$ok .= 'b' if $mpfr1 == 10;
+
+$mpc1 -= ~0;
+
+RMPC_RE($mpfr1, $mpc1);
+$ok .= 'c' if $mpfr1 == 10;
+RMPC_IM($mpfr1, $mpc1);
+$ok .= 'd' if $mpfr1 == 10;
+
+$mpc1 += -100;
+
+RMPC_RE($mpfr1, $mpc1);
+$ok .= 'e' if $mpfr1 == -90;
+RMPC_IM($mpfr1, $mpc1);
+$ok .= 'f' if $mpfr1 == 10;
+
+$mpc1 -= -50;
+
+RMPC_RE($mpfr1, $mpc1);
+$ok .= 'g' if $mpfr1 == -40;
+RMPC_IM($mpfr1, $mpc1);
+$ok .= 'h' if $mpfr1 == 10;
+
+$mpc1 += 20.25;
+
+RMPC_RE($mpfr1, $mpc1);
+$ok .= 'i' if $mpfr1 == -19.75;
+RMPC_IM($mpfr1, $mpc1);
+$ok .= 'j' if $mpfr1 == 10;
+
+$mpc1 -= -20.5;
+
+RMPC_RE($mpfr1, $mpc1);
+$ok .= 'k' if $mpfr1 == 0.75;
+RMPC_IM($mpfr1, $mpc1);
+$ok .= 'l' if $mpfr1 == 10;
+
+my $string = '12345678' x 7;
+
+Rmpfr_set_str($mpfr, $string, 0, MPC_RNDNN);
+$mpfr += 0.75;
+
+$mpc1 += $string;
+
+RMPC_RE($mpfr1, $mpc1);
+$ok .= 'm' if $mpfr1 == $mpfr;
+RMPC_IM($mpfr1, $mpc1);
+$ok .= 'n' if $mpfr1 == 10;
+
+$mpc1 -= $string;
+
+RMPC_RE($mpfr1, $mpc1);
+$ok .= 'o' if $mpfr1 == 0.75;
+RMPC_IM($mpfr1, $mpc1);
+$ok .= 'p' if $mpfr1 == 10;
+
+Rmpc_set_d_d($mpc2, 1099511627770.5, 1099511627770.5, MPC_RNDNN);
+
+$mpc1 += $mpc2;
+
+RMPC_RE($mpfr1, $mpc1);
+$ok .= 'q' if $mpfr1 == 1099511627771.25;
+RMPC_IM($mpfr1, $mpc1);
+$ok .= 'r' if $mpfr1 == 1099511627780.5;
+
+$mpc1 -= $mpc2;
+
+RMPC_RE($mpfr1, $mpc1);
+$ok .= 's' if $mpfr1 == 0.75;
+RMPC_IM($mpfr1, $mpc1);
+$ok .= 't' if $mpfr1 == 10;
+
+if($ok eq 'abcdefghijklmnopqrst') {print "ok 3\n"}
+else {print "not ok 3 $ok\n"}
+
+$ok = '';
+
+Rmpc_set_ui_ui($mpc1, 10, 10, MPC_RNDNN);
+if($_64){
+ if(Math::MPC::_has_inttypes()) {Math::MPFR::Rmpfr_set_uj($mpfr, ~0, GMP_RNDN)}
+ else {Math::MPFR::Rmpfr_set_str($mpfr, ~0, 10, GMP_RNDN)}
+}
+else {Rmpfr_set_ui($mpfr, ~0, GMP_RNDN)}
+$mpfr += 10;
+
+$mpc1 = $mpc1 + ~0;
+
+RMPC_RE($mpfr1, $mpc1);
+$ok .= 'a' if $mpfr1 == $mpfr;
+RMPC_IM($mpfr1, $mpc1);
+$ok .= 'b' if $mpfr1 == 10;
+
+$mpc1 = $mpc1 - ~0;
+
+RMPC_RE($mpfr1, $mpc1);
+$ok .= 'c' if $mpfr1 == 10;
+RMPC_IM($mpfr1, $mpc1);
+$ok .= 'd' if $mpfr1 == 10;
+
+$mpc1 = $mpc1 + -100;
+
+RMPC_RE($mpfr1, $mpc1);
+$ok .= 'e' if $mpfr1 == -90;
+RMPC_IM($mpfr1, $mpc1);
+$ok .= 'f' if $mpfr1 == 10;
+
+$mpc1 = $mpc1 - -50;
+
+RMPC_RE($mpfr1, $mpc1);
+$ok .= 'g' if $mpfr1 == -40;
+RMPC_IM($mpfr1, $mpc1);
+$ok .= 'h' if $mpfr1 == 10;
+
+$mpc1 = $mpc1 + 20.25;
+
+RMPC_RE($mpfr1, $mpc1);
+$ok .= 'i' if $mpfr1 == -19.75;
+RMPC_IM($mpfr1, $mpc1);
+$ok .= 'j' if $mpfr1 == 10;
+
+$mpc1 = $mpc1 - -20.5;
+
+RMPC_RE($mpfr1, $mpc1);
+$ok .= 'k' if $mpfr1 == 0.75;
+RMPC_IM($mpfr1, $mpc1);
+$ok .= 'l' if $mpfr1 == 10;
+
+# LINE 189
+
+Rmpfr_set_str($mpfr, $string, 0, MPC_RNDNN);
+$mpfr += 0.75;
+
+$mpc1 = $mpc1 + $string;
+
+RMPC_RE($mpfr1, $mpc1);
+$ok .= 'm' if $mpfr1 == $mpfr;
+RMPC_IM($mpfr1, $mpc1);
+$ok .= 'n' if $mpfr1 == 10;
+
+$mpc1 = $mpc1 - $string;
+
+RMPC_RE($mpfr1, $mpc1);
+$ok .= 'o' if $mpfr1 == 0.75;
+RMPC_IM($mpfr1, $mpc1);
+$ok .= 'p' if $mpfr1 == 10;
+
+Rmpc_set_d_d($mpc2, 1099511627770.5, 1099511627770.5, MPC_RNDNN);
+
+$mpc1 = $mpc1 + $mpc2;
+
+RMPC_RE($mpfr1, $mpc1);
+$ok .= 'q' if $mpfr1 == 1099511627771.25;
+RMPC_IM($mpfr1, $mpc1);
+$ok .= 'r' if $mpfr1 == 1099511627780.5;
+
+$mpc1 = $mpc1 - $mpc2;
+
+RMPC_RE($mpfr1, $mpc1);
+$ok .= 's' if $mpfr1 == 0.75;
+RMPC_IM($mpfr1, $mpc1);
+$ok .= 't' if $mpfr1 == 10;
+
+if($ok eq 'abcdefghijklmnopqrst') {print "ok 4\n"}
+else {print "not ok 4 $ok\n"}
+
+$ok = '';
+
+Rmpc_set_ui_ui($mpc1, 10, 10, MPC_RNDNN);
+if($_64){
+ if(Math::MPC::_has_inttypes()) {Math::MPFR::Rmpfr_set_uj($mpfr, ~0, GMP_RNDN)}
+ else {Math::MPFR::Rmpfr_set_str($mpfr, ~0, 10, GMP_RNDN)}
+}
+else {Rmpfr_set_ui($mpfr, ~0, GMP_RNDN)}
+$mpfr += 10;
+
+$mpc1 = ~0 + $mpc1;
+
+RMPC_RE($mpfr1, $mpc1);
+$ok .= 'a' if $mpfr1 == $mpfr;
+RMPC_IM($mpfr1, $mpc1);
+$ok .= 'b' if $mpfr1 == 10;
+
+$mpc1 = ~0 - $mpc1;
+$mpfr = ~0 - $mpfr;
+
+RMPC_RE($mpfr1, $mpc1);
+$ok .= 'c' if $mpfr1 == $mpfr;
+RMPC_IM($mpfr1, $mpc1);
+$ok .= 'd' if $mpfr1 == -10;
+
+$mpc1 = -100 + $mpc1;
+$mpfr -= 100;
+
+RMPC_RE($mpfr1, $mpc1);
+$ok .= 'e' if $mpfr1 == $mpfr;
+RMPC_IM($mpfr1, $mpc1);
+$ok .= 'f' if $mpfr1 == -10;
+
+$mpc1 = -50 - $mpc1;
+$mpfr = -50 - $mpfr;
+
+RMPC_RE($mpfr1, $mpc1);
+$ok .= 'g' if $mpfr1 == $mpfr;
+RMPC_IM($mpfr1, $mpc1);
+$ok .= 'h' if $mpfr1 == 10;
+
+$mpc1 = 20.25 + $mpc1;
+$mpfr += 20.25;
+
+RMPC_RE($mpfr1, $mpc1);
+$ok .= 'i' if $mpfr1 == $mpfr;
+RMPC_IM($mpfr1, $mpc1);
+$ok .= 'j' if $mpfr1 == 10;
+
+$mpc1 = -20.5 - $mpc1;
+$mpfr = -20.5 - $mpfr;
+
+RMPC_RE($mpfr1, $mpc1);
+$ok .= 'k' if $mpfr1 == $mpfr;
+RMPC_IM($mpfr1, $mpc1);
+$ok .= 'l' if $mpfr1 == -10;
+
+$mpc1 = $string + $mpc1;
+$mpfr += $string;
+
+RMPC_RE($mpfr1, $mpc1);
+$ok .= 'm' if $mpfr1 == $mpfr;
+RMPC_IM($mpfr1, $mpc1);
+$ok .= 'n' if $mpfr1 == -10;
+
+$mpc1 = $string - $mpc1;
+$mpfr = $string - $mpfr;
+
+RMPC_RE($mpfr1, $mpc1);
+$ok .= 'o' if $mpfr1 == $mpfr;
+RMPC_IM($mpfr1, $mpc1);
+$ok .= 'p' if $mpfr1 == 10;
+
+if($ok eq 'abcdefghijklmnop') {print "ok 5\n"}
+else {print "not ok 5 $ok\n"}
+
+$ok = '';
+
+Rmpc_neg($mpc2, $mpc1, MPC_RNDNN);
+
+if($mpc2 == -$mpc1 && $mpc1 == -$mpc2) {print "ok 6\n"}
+else {print "not ok 6\n"}
+
+
+
+
+
+
@@ -1,34 +1,34 @@
-use warnings;
-use strict;
-use Math::MPFR qw(:mpfr);
-use Math::MPC qw(:mpc);
-
-print "1..2\n";
-
-my $m1 = Math::MPC->new(0, 0);
-my $m2 = Math::MPC->new(0, 0);
-my $m3 = Math::MPC->new(0, 1);
-my $m4 = Math::MPC->new(-230, 0);
-my $m5 = Math::MPC->new(-3, -7);
-my $ok = '';
-
-$ok .= 'a' if !Rmpc_cmp($m1, $m2);
-$ok .= 'b' if $m1 == $m2;
-$ok .= 'c' if Rmpc_cmp($m3, $m1);
-$ok .= 'd' if $m3 != $m2;
-$ok .= 'e' if Rmpc_cmp($m3, $m4);
-$ok .= 'f' if $m3 != $m4;
-
-if($ok eq 'abcdef') {print "ok 1\n"}
-else {print "not ok 1 $ok \n"}
-
-$ok = '';
-
-$ok .= 'a' if !$m1;
-$ok .= 'b' unless !$m3;
-$ok .= 'c' unless !$m4;
-$ok .= 'd' unless Rmpc_cmp_si($m4, -230);
-$ok .= 'e' unless Rmpc_cmp_si_si($m5, -3, -7);
-
-if($ok eq 'abcde') {print "ok 2\n"}
-else {print "not ok 2 $ok \n"}
\ No newline at end of file
+use warnings;
+use strict;
+use Math::MPFR qw(:mpfr);
+use Math::MPC qw(:mpc);
+
+print "1..2\n";
+
+my $m1 = Math::MPC->new(0, 0);
+my $m2 = Math::MPC->new(0, 0);
+my $m3 = Math::MPC->new(0, 1);
+my $m4 = Math::MPC->new(-230, 0);
+my $m5 = Math::MPC->new(-3, -7);
+my $ok = '';
+
+$ok .= 'a' if !Rmpc_cmp($m1, $m2);
+$ok .= 'b' if $m1 == $m2;
+$ok .= 'c' if Rmpc_cmp($m3, $m1);
+$ok .= 'd' if $m3 != $m2;
+$ok .= 'e' if Rmpc_cmp($m3, $m4);
+$ok .= 'f' if $m3 != $m4;
+
+if($ok eq 'abcdef') {print "ok 1\n"}
+else {print "not ok 1 $ok \n"}
+
+$ok = '';
+
+$ok .= 'a' if !$m1;
+$ok .= 'b' unless !$m3;
+$ok .= 'c' unless !$m4;
+$ok .= 'd' unless Rmpc_cmp_si($m4, -230);
+$ok .= 'e' unless Rmpc_cmp_si_si($m5, -3, -7);
+
+if($ok eq 'abcde') {print "ok 2\n"}
+else {print "not ok 2 $ok \n"}
@@ -1,12 +1,12 @@
-use warnings;
-use Math::MPFR qw(:mpfr);
-use Math::MPC qw(:mpc);
-
-print "1..2\n";
-
-if(Math::MPFR::_has_longlong() == Math::MPC::_has_longlong()) {print "ok 1\n"}
-else {print "not ok 1 - Math::MPFR and Math::MPC have been built with different characteristics re the handling of 64 bit long longs. This is likely to cause problems\n"}
-
-if(Math::MPFR::_has_longdouble() == Math::MPC::_has_longdouble()) {print "ok 2\n"}
-else {print "not ok 2 - Math::MPFR and Math::MPC have been built with different characteristics re the handling of long doubles. This is likely to cause problems\n"}
-
+use warnings;
+use Math::MPFR qw(:mpfr);
+use Math::MPC qw(:mpc);
+
+print "1..2\n";
+
+if(Math::MPFR::_has_longlong() == Math::MPC::_has_longlong()) {print "ok 1\n"}
+else {print "not ok 1 - Math::MPFR and Math::MPC have been built with different characteristics re the handling of 64 bit long longs. This is likely to cause problems\n"}
+
+if(Math::MPFR::_has_longdouble() == Math::MPC::_has_longdouble()) {print "ok 2\n"}
+else {print "not ok 2 - Math::MPFR and Math::MPC have been built with different characteristics re the handling of long doubles. This is likely to cause problems\n"}
+
@@ -1,520 +1,520 @@
-use warnings;
-use strict;
-use Math::MPFR qw(:mpfr);
-use Math::MPC qw(:mpc);
-
-print "1..8\n";
-
-Rmpc_set_default_prec2(500, 500);
-Rmpfr_set_default_prec(500);
-my $mpfr1 = Math::MPFR->new();
-my $mpc1 = Math::MPC->new(10, 20);
-my $mpfrr = Math::MPFR->new(10);
-my $mpfri = Math::MPFR->new(20);
-my $mpfrtemp = Math::MPFR->new();
-my $mpfrti = Math::MPFR->new();
-my $mpfrtr = Math::MPFR->new();
-my $mpfr_tilde0;
-my$ok = '';
-
-my $_64 = Math::MPC::_has_longlong() ? 1 : 0;
-
-if($_64) {
- $mpfr_tilde0 = Math::MPFR->new(~0);
-}
-
-if($_64) {Rmpc_mul_fr($mpc1, $mpc1, $mpfr_tilde0, MPC_RNDNN)}
-else {Rmpc_mul_ui($mpc1, $mpc1, ~0, MPC_RNDNN)}
-Rmpc_mul_si($mpc1, $mpc1, -15, MPC_RNDNN);
-Rmpc_mul($mpc1, $mpc1, $mpc1, MPC_RNDNN);
-
-$mpfrr *= ~0;
-$mpfri *= ~0;
-$mpfrr *= -15;
-$mpfri *= -15;
-$mpfrtemp = ($mpfrr * $mpfri) * 2;
-$mpfrr = ($mpfrr * $mpfrr) - ($mpfri * $mpfri);
-Rmpfr_set($mpfri, $mpfrtemp, MPC_RNDNN);
-
-RMPC_RE($mpfr1, $mpc1);
-$ok .= 'a' if abs($mpfr1 - $mpfrr) < 0.0000001;
-RMPC_IM($mpfr1, $mpc1);
-$ok .= 'b' if abs($mpfr1 - $mpfri) < 0.0000001;
-
-if($ok eq 'ab') {print "ok 1\n"}
-else {print "not ok 1 $ok\n"}
-
-$ok = '';
-
-if($_64) {Rmpc_div_fr($mpc1, $mpc1, $mpfr_tilde0, MPC_RNDNN)}
-else {Rmpc_div_ui($mpc1, $mpc1, ~0, MPC_RNDNN)}
-$mpfrr /= ~0;
-$mpfri /= ~0;
-
-RMPC_RE($mpfr1, $mpc1);
-$ok .= 'a' if abs($mpfr1 - $mpfrr) < 0.0000001;
-RMPC_IM($mpfr1, $mpc1);
-$ok .= 'b' if abs($mpfr1 - $mpfri) < 0.0000001;
-
-Rmpc_ui_div($mpc1, 50, $mpc1, MPC_RNDNN);
-$mpfrtr = ($mpfrr * 50) / (($mpfrr * $mpfrr) + ($mpfri * $mpfri)) ;
-$mpfrti = (-50 * $mpfri) / (($mpfrr * $mpfrr) + ($mpfri * $mpfri));
-Rmpfr_set($mpfrr, $mpfrtr, MPC_RNDNN);
-Rmpfr_set($mpfri, $mpfrti, MPC_RNDNN);
-
-RMPC_RE($mpfr1, $mpc1);
-$ok .= 'c' if abs($mpfr1 - $mpfrr) < 0.0000001;
-RMPC_IM($mpfr1, $mpc1);
-$ok .= 'd' if abs($mpfr1 - $mpfri) < 0.0000001;
-
-my $mpc2 = Math::MPC->new($mpc1);
-
-Rmpc_div($mpc1, $mpc1, $mpc2, MPC_RNDNN);
-
-RMPC_RE($mpfr1, $mpc1);
-$ok .= 'e' if $mpfr1 == 1;
-RMPC_IM($mpfr1, $mpc1);
-$ok .= 'f' if $mpfr1 == 0;
-
-if($ok eq 'abcdef') {print "ok 2\n"}
-else {print "not ok 2 $ok\n"}
-
-$ok = '';
-
-Rmpc_set_ui_ui($mpc1, 10, 20, MPC_RNDNN);
-Rmpfr_set_ui($mpfrr, 10, MPC_RNDNN);
-Rmpfr_set_ui($mpfri, 20, MPC_RNDNN);
-
-$mpc1 *= ~0;
-$mpfrr *= ~0;
-$mpfri *= ~0;
-
-RMPC_RE($mpfr1, $mpc1);
-$ok .= 'a' if abs($mpfr1 - $mpfrr) < 0.0000001;
-RMPC_IM($mpfr1, $mpc1);
-$ok .= 'b' if abs($mpfr1 - $mpfri) < 0.0000001;
-
-$mpc1 /= ~0;
-$mpfrr /= ~0;
-$mpfri /= ~0;
-
-RMPC_RE($mpfr1, $mpc1);
-$ok .= 'c' if abs($mpfr1 - $mpfrr) < 0.0000001;
-RMPC_IM($mpfr1, $mpc1);
-$ok .= 'd' if abs($mpfr1 - $mpfri) < 0.0000001;
-
-$mpc1 *= -100;
-$mpfrr *= -100;
-$mpfri *= -100;
-
-RMPC_RE($mpfr1, $mpc1);
-$ok .= 'e' if abs($mpfr1 - $mpfrr) < 0.0000001;
-RMPC_IM($mpfr1, $mpc1);
-$ok .= 'f' if abs($mpfr1 - $mpfri) < 0.0000001;
-
-$mpc1 /= -50;
-$mpfrr /= -50;
-$mpfri /= -50;
-
-RMPC_RE($mpfr1, $mpc1);
-$ok .= 'g' if abs($mpfr1 - $mpfrr) < 0.0000001;
-RMPC_IM($mpfr1, $mpc1);
-$ok .= 'h' if abs($mpfr1 - $mpfri) < 0.0000001;
-
-$mpc1 *= 20.25;
-$mpfrr *= 20.25;
-$mpfri *= 20.25;
-
-RMPC_RE($mpfr1, $mpc1);
-$ok .= 'i' if abs($mpfr1 - $mpfrr) < 0.0000001;
-RMPC_IM($mpfr1, $mpc1);
-$ok .= 'j' if abs($mpfr1 - $mpfri) < 0.0000001;
-
-$mpc1 /= -20.5;
-$mpfrr /= -20.5;
-$mpfri /= -20.5;
-
-RMPC_RE($mpfr1, $mpc1);
-$ok .= 'k' if abs($mpfr1 - $mpfrr) < 0.0000001;
-RMPC_IM($mpfr1, $mpc1);
-$ok .= 'l' if abs($mpfr1 - $mpfri) < 0.0000001;
-
-my $string = '12345678' x 7;
-
-$mpc1 *= $string;
-$mpfrr *= $string;
-$mpfri *= $string;
-
-RMPC_RE($mpfr1, $mpc1);
-$ok .= 'm' if abs($mpfr1 - $mpfrr) < 0.0000001;
-RMPC_IM($mpfr1, $mpc1);
-$ok .= 'n' if abs($mpfr1 - $mpfri) < 0.0000001;
-
-$mpc1 /= $string;
-$mpfrr /= $string;
-$mpfri /= $string;
-
-RMPC_RE($mpfr1, $mpc1);
-$ok .= 'o' if abs($mpfr1 - $mpfrr) < 0.0000001;
-RMPC_IM($mpfr1, $mpc1);
-$ok .= 'p' if abs($mpfr1 - $mpfri) < 0.0000001;
-
-Rmpc_set_d_d($mpc2, 1099511627770.5, 1099511627770.5, MPC_RNDNN);
-
-$mpc1 *= $mpc2;
-$mpfrtr = ($mpfrr * 1099511627770.5) - ($mpfri * 1099511627770.5);
-$mpfrti = ($mpfrr * 1099511627770.5) + ($mpfri * 1099511627770.5);
-Rmpfr_set($mpfrr, $mpfrtr, MPC_RNDNN);
-Rmpfr_set($mpfri, $mpfrti, MPC_RNDNN);
-
-RMPC_RE($mpfr1, $mpc1);
-$ok .= 'q' if abs($mpfr1 - $mpfrr) < 0.0000001;
-RMPC_IM($mpfr1, $mpc1);
-$ok .= 'r' if abs($mpfr1 - $mpfri) < 0.0000001;
-
-$mpc1 /= $mpc2;
-my $mpfr_sq = Math::MPFR->new(1099511627770.5);
-$mpfr_sq *= $mpfr_sq;
-$mpfrtr = (($mpfrr * 1099511627770.5) + ($mpfri * 1099511627770.5)) / ($mpfr_sq * 2) ;
-$mpfrti = ((1099511627770.5 * $mpfri) - ($mpfrr * 1099511627770.5))/ ($mpfr_sq * 2);
-Rmpfr_set($mpfrr, $mpfrtr, MPC_RNDNN);
-Rmpfr_set($mpfri, $mpfrti, MPC_RNDNN);
-
-RMPC_RE($mpfr1, $mpc1);
-$ok .= 's' if abs($mpfr1 - $mpfrr) < 0.0000001;
-RMPC_IM($mpfr1, $mpc1);
-$ok .= 't' if abs($mpfr1 - $mpfri) < 0.0000001;
-
-if($ok eq 'abcdefghijklmnopqrst') {print "ok 3\n"}
-else {print "not ok 3 $ok\n"}
-
-$ok = '';
-
-Rmpc_set_ui_ui($mpc1, 10, 20, MPC_RNDNN);
-Rmpfr_set_ui($mpfrr, 10, MPC_RNDNN);
-Rmpfr_set_ui($mpfri, 20, MPC_RNDNN);
-
-$mpc1 = $mpc1 * ~0;
-$mpfrr *= ~0;
-$mpfri *= ~0;
-
-
-RMPC_RE($mpfr1, $mpc1);
-$ok .= 'a' if abs($mpfr1 - $mpfrr) < 0.0000001;
-RMPC_IM($mpfr1, $mpc1);
-$ok .= 'b' if abs($mpfr1 - $mpfri) < 0.0000001;
-
-$mpc1 = $mpc1 / ~0;
-$mpfrr /= ~0;
-$mpfri /= ~0;
-
-RMPC_RE($mpfr1, $mpc1);
-$ok .= 'c' if abs($mpfr1 - $mpfrr) < 0.0000001;
-RMPC_IM($mpfr1, $mpc1);
-$ok .= 'd' if abs($mpfr1 - $mpfri) < 0.0000001;
-
-$mpc1 = $mpc1 * -100;
-$mpfrr *= -100;
-$mpfri *= -100;
-
-RMPC_RE($mpfr1, $mpc1);
-$ok .= 'e' if abs($mpfr1 - $mpfrr) < 0.0000001;
-RMPC_IM($mpfr1, $mpc1);
-$ok .= 'f' if abs($mpfr1 - $mpfri) < 0.0000001;
-
-$mpc1 = $mpc1 / -50;
-$mpfrr /= -50;
-$mpfri /= -50;
-
-RMPC_RE($mpfr1, $mpc1);
-$ok .= 'g' if abs($mpfr1 - $mpfrr) < 0.0000001;
-RMPC_IM($mpfr1, $mpc1);
-$ok .= 'h' if abs($mpfr1 - $mpfri) < 0.0000001;
-
-$mpc1 = $mpc1 * 20.25;
-$mpfrr *= 20.25;
-$mpfri *= 20.25;
-
-RMPC_RE($mpfr1, $mpc1);
-$ok .= 'i' if abs($mpfr1 - $mpfrr) < 0.0000001;
-RMPC_IM($mpfr1, $mpc1);
-$ok .= 'j' if abs($mpfr1 - $mpfri) < 0.0000001;
-
-$mpc1 = $mpc1 / -20.5;
-$mpfrr /= -20.5;
-$mpfri /= -20.5;
-
-RMPC_RE($mpfr1, $mpc1);
-$ok .= 'k' if abs($mpfr1 - $mpfrr) < 0.0000001;
-RMPC_IM($mpfr1, $mpc1);
-$ok .= 'l' if abs($mpfr1 - $mpfri) < 0.0000001;
-
-$mpc1 = $mpc1 * $string;
-$mpfrr *= $string;
-$mpfri *= $string;
-
-RMPC_RE($mpfr1, $mpc1);
-$ok .= 'm' if abs($mpfr1 - $mpfrr) < 0.0000001;
-RMPC_IM($mpfr1, $mpc1);
-$ok .= 'n' if abs($mpfr1 - $mpfri) < 0.0000001;
-
-$mpc1 = $mpc1 / $string;
-$mpfrr /= $string;
-$mpfri /= $string;
-#####################
-#####################
-RMPC_RE($mpfr1, $mpc1);
-$ok .= 'o' if abs($mpfr1 - $mpfrr) < 0.0000001;
-RMPC_IM($mpfr1, $mpc1);
-$ok .= 'p' if abs($mpfr1 - $mpfri) < 0.0000001;
-
-#Rmpc_set_d_d($mpc2, 1099511627770.5, 1099511627770.5, MPC_RNDNN);
-
-$mpc1 = $mpc1 * $mpc2;
-$mpfrtr = ($mpfrr * 1099511627770.5) - ($mpfri * 1099511627770.5);
-$mpfrti = ($mpfrr * 1099511627770.5) + ($mpfri * 1099511627770.5);
-Rmpfr_set($mpfrr, $mpfrtr, MPC_RNDNN);
-Rmpfr_set($mpfri, $mpfrti, MPC_RNDNN);
-
-RMPC_RE($mpfr1, $mpc1);
-$ok .= 'q' if abs($mpfr1 - $mpfrr) < 0.0000001;
-RMPC_IM($mpfr1, $mpc1);
-$ok .= 'r' if abs($mpfr1 - $mpfri) < 0.0000001;
-######################
-######################
-$mpc1 = $mpc1 / $mpc2;
-$mpfrtr = (($mpfrr * 1099511627770.5) + ($mpfri * 1099511627770.5)) / ($mpfr_sq * 2) ;
-$mpfrti = ((1099511627770.5 * $mpfri) - ($mpfrr * 1099511627770.5))/ ($mpfr_sq * 2);
-Rmpfr_set($mpfrr, $mpfrtr, MPC_RNDNN);
-Rmpfr_set($mpfri, $mpfrti, MPC_RNDNN);
-
-RMPC_RE($mpfr1, $mpc1);
-$ok .= 's' if abs($mpfr1 - $mpfrr) < 0.0000001;
-RMPC_IM($mpfr1, $mpc1);
-$ok .= 't' if abs($mpfr1 - $mpfri) < 0.0000001;
-
-if($ok eq 'abcdefghijklmnopqrst') {print "ok 4\n"}
-else {print "not ok 4 $ok\n"}
-
-$ok = '';
-
-Rmpc_set_ui_ui($mpc1, 10, 20, MPC_RNDNN);
-Rmpfr_set_ui($mpfrr, 10, MPC_RNDNN);
-Rmpfr_set_ui($mpfri, 20, MPC_RNDNN);
-
-$mpc1 = ~0 * $mpc1;
-$mpfrr *= ~0;
-$mpfri *= ~0;
-
-RMPC_RE($mpfr1, $mpc1);
-$ok .= 'a' if abs($mpfr1 - $mpfrr) < 0.0000001;
-RMPC_IM($mpfr1, $mpc1);
-$ok .= 'b' if abs($mpfr1 - $mpfri) < 0.0000001;
-
-$mpc1 = ((~0 - 1) / 2) / $mpc1;
-$mpfrtr = ($mpfrr * ((~0 - 1) / 2)) / (($mpfrr * $mpfrr) + ($mpfri * $mpfri)) ;
-$mpfrti = (-((~0 - 1) / 2) * $mpfri) / (($mpfrr * $mpfrr) + ($mpfri * $mpfri));
-Rmpfr_set($mpfrr, $mpfrtr, GMP_RNDN);
-Rmpfr_set($mpfri, $mpfrti, GMP_RNDN);
-
-RMPC_RE($mpfr1, $mpc1);
-$ok .= 'c' if abs($mpfr1 - $mpfrr) < 0.0000001;
-RMPC_IM($mpfr1, $mpc1);
-$ok .= 'd' if abs($mpfr1 - $mpfri) < 0.0000001;
-
-$mpc1 = -100 * $mpc1;
-$mpfrr *= -100;
-$mpfri *= -100;
-
-
-RMPC_RE($mpfr1, $mpc1);
-$ok .= 'e' if abs($mpfr1 - $mpfrr) < 0.0000001;
-RMPC_IM($mpfr1, $mpc1);
-$ok .= 'f' if abs($mpfr1 - $mpfri) < 0.0000001;
-
-$mpc1 = -50 / $mpc1;
-$mpfrtr = ($mpfrr * -50) / (($mpfrr * $mpfrr) + ($mpfri * $mpfri)) ;
-$mpfrti = (50 * $mpfri) / (($mpfrr * $mpfrr) + ($mpfri * $mpfri));
-Rmpfr_set($mpfrr, $mpfrtr, MPC_RNDNN);
-Rmpfr_set($mpfri, $mpfrti, MPC_RNDNN);
-
-
-RMPC_RE($mpfr1, $mpc1);
-$ok .= 'g' if abs($mpfr1 - $mpfrr) < 0.0000001;
-RMPC_IM($mpfr1, $mpc1);
-$ok .= 'h' if abs($mpfr1 - $mpfri) < 0.0000001;
-
-$mpc1 = 20.25 * $mpc1;
-$mpfrr *= 20.25;
-$mpfri *= 20.25;
-
-
-RMPC_RE($mpfr1, $mpc1);
-$ok .= 'i' if abs($mpfr1 - $mpfrr) < 0.0000001;
-RMPC_IM($mpfr1, $mpc1);
-$ok .= 'j' if abs($mpfr1 - $mpfri) < 0.0000001;
-
-$mpc1 = -20.5 / $mpc1;
-$mpfrtr = ($mpfrr * -20.5) / (($mpfrr * $mpfrr) + ($mpfri * $mpfri)) ;
-$mpfrti = (20.5 * $mpfri) / (($mpfrr * $mpfrr) + ($mpfri * $mpfri));
-Rmpfr_set($mpfrr, $mpfrtr, MPC_RNDNN);
-Rmpfr_set($mpfri, $mpfrti, MPC_RNDNN);
-
-RMPC_RE($mpfr1, $mpc1);
-$ok .= 'k' if abs($mpfr1 - $mpfrr) < 0.0000001;
-RMPC_IM($mpfr1, $mpc1);
-$ok .= 'l' if abs($mpfr1 - $mpfri) < 0.0000001;
-
-$mpc1 = $string * $mpc1;
-$mpfrr *= $string;
-$mpfri *= $string;
-
-
-RMPC_RE($mpfr1, $mpc1);
-$ok .= 'm' if abs($mpfr1 - $mpfrr) < 0.0000001;
-RMPC_IM($mpfr1, $mpc1);
-$ok .= 'n' if abs($mpfr1 - $mpfri) < 0.0000001;
-
-$mpc1 = $string / $mpc1;
-$mpfrtr = ($mpfrr * $string) / (($mpfrr * $mpfrr) + ($mpfri * $mpfri)) ;
-$mpfrti = (($string * -$mpfri)) / (($mpfrr * $mpfrr) + ($mpfri * $mpfri));
-Rmpfr_set($mpfrr, $mpfrtr, MPC_RNDNN);
-Rmpfr_set($mpfri, $mpfrti, MPC_RNDNN);
-
-RMPC_RE($mpfr1, $mpc1);
-$ok .= 'o' if abs($mpfr1 - $mpfrr) < 0.0000001;
-RMPC_IM($mpfr1, $mpc1);
-$ok .= 'p' if abs($mpfr1 - $mpfri) < 0.0000001;
-
-if($ok eq 'abcdefghijklmnop') {print "ok 5\n"}
-else {print "not ok 5 $ok\n"}
-
-$ok = '';
-
-Rmpc_set_ui_ui($mpc2, 5, 12, MPC_RNDNN);
-Rmpc_sqr($mpc1, $mpc2, MPC_RNDNN);
-Rmpc_sqrt($mpc1, $mpc1, MPC_RNDNN);
-
-$ok .= 'a' unless Rmpc_cmp($mpc1, $mpc2);
-
-Rmpc_sqr($mpc1, $mpc2, MPC_RNDNN);
-$mpc1 = sqrt($mpc1);
-
-$ok .= 'b' if $mpc1 == $mpc2;
-
-Rmpc_abs($mpfr1, $mpc2, MPC_RNDNN);
-
-$ok .= 'c' if $mpfr1 == 13;
-
-$mpfrtemp = abs($mpc2);
-
-$ok .= 'd' if $mpfrtemp == 13;
-
-Rmpc_norm($mpfr1, $mpc2, MPC_RNDNN);
-
-$ok .= 'e' if $mpfr1 == 169;
-
-Rmpc_conj($mpc1, $mpc2, MPC_RNDNN);
-$mpc1 += $mpc2;
-
-RMPC_IM($mpfr1, $mpc1);
-
-$ok .= 'f' if $mpfr1 == 0;
-
-Rmpc_neg($mpc1, $mpc2, MPC_RNDNN);
-
-$ok .= 'g' if $mpc1 == -$mpc2;
-$ok .= 'h' if $mpc1 == $mpc2 * -1;
-
-Rmpfr_const_pi($mpfrtemp, MPC_RNDNN);
-my $double = Rmpfr_get_d($mpfrtemp, MPC_RNDNN);
-
-Rmpc_set_d_d($mpc2, 0, $double, MPC_RNDNN);
-Rmpc_exp($mpc1, $mpc2, MPC_RNDNN);
-
-RMPC_RE($mpfr1, $mpc1);
-$ok .= 'i' if $mpfr1 > -1 && $mpfr1 < -0.9999999;
-RMPC_IM($mpfr1, $mpc1);
-$ok .= 'j' if $mpfr1 > 0 && $mpfr1 < 0.0000001;
-
-my $mpc3 = exp($mpc2);
-
-RMPC_RE($mpfr1, $mpc3);
-$ok .= 'k' if $mpfr1 > -1 && $mpfr1 < -0.9999999;
-RMPC_IM($mpfr1, $mpc3);
-$ok .= 'l' if $mpfr1 > 0 && $mpfr1 < 0.0000001;
-
-if($ok eq 'abcdefghijkl') {print "ok 6\n"}
-else {print "not ok 6\n"}
-
-$ok = '';
-
-my $log = log(exp(Math::MPC->new(8.5, 0)));
-
-RMPC_RE($mpfr1, $log);
-$ok .= 'a' if $mpfr1 > 8.499999 && $mpfr1 < 8.500001;
-RMPC_IM($mpfr1, $log);
-$ok .= 'b' if $mpfr1 == 0;
-
-Rmpc_log($log, Math::MPC->new(1, 0), MPC_RNDNN);
-
-RMPC_RE($mpfr1, $log);
-$ok .= 'c' if $mpfr1 == 0;
-RMPC_IM($mpfr1, $log);
-$ok .= 'd' if $mpfr1 == 0;
-
-if($ok eq 'abcd') {print "ok 7\n"}
-else {print "not ok 7\n"}
-
-$ok = '';
-my $pow = Math::MPC->new(3);
-my $op1 = Math::MPC->new(0, 3);
-my $op2 = Math::MPC->new(3, 0);
-my $rop = Math::MPC->new();
-
-Rmpc_pow($rop, $op1, $pow, MPC_RNDNN);
-RMPC_RE($mpfr1, $rop);
-if($mpfr1 == 0) {$ok .= 'a'}
-else {warn "8a: $mpfr1\n"}
-RMPC_IM($mpfr1, $rop);
-if($mpfr1 == -27) {$ok .= 'b'}
-else {warn "8b: $mpfr1\n"}
-
-Rmpc_pow($rop, $op2, $pow, MPC_RNDNN);
-RMPC_IM($mpfr1, $rop);
-if($mpfr1 == 0) {$ok .= 'c'}
-else {warn "8c: $mpfr1\n"}
-RMPC_RE($mpfr1, $rop);
-if($mpfr1 == 27) {$ok .= 'd'}
-else {warn "8d: $mpfr1\n"}
-
-my $root_re = Math::MPFR->new();
-my $root_im = Math::MPFR->new();
-my $pow_re = Math::MPFR->new();
-my $pow_im = Math::MPFR->new();
-
-Rmpc_set_d_ui($pow, 0.5, 0, MPC_RNDNN);
-Rmpc_set_ui_ui($op1, 17, 16, MPC_RNDNN);
-Rmpc_sqrt($rop, $op1, MPC_RNDNN);
-RMPC_RE($root_re, $rop);
-RMPC_IM($root_im, $rop);
-Rmpc_pow($rop, $op1, $pow, MPC_RNDNN);
-RMPC_RE($pow_re, $rop);
-RMPC_IM($pow_im, $rop);
-
-if($root_re == $pow_re){$ok .= 'e'}
-else {warn "8e: $root_re $pow_re\n"}
-
-if($root_im == $pow_im){$ok .= 'f'}
-else {warn "8f: $root_im $pow_im\n"}
-
-if($ok eq 'abcdef') {print "ok 8\n"}
-else {print "not ok 8 $ok\n"}
-
-
-
-
-
-
-
-
+use warnings;
+use strict;
+use Math::MPFR qw(:mpfr);
+use Math::MPC qw(:mpc);
+
+print "1..8\n";
+
+Rmpc_set_default_prec2(500, 500);
+Rmpfr_set_default_prec(500);
+my $mpfr1 = Math::MPFR->new();
+my $mpc1 = Math::MPC->new(10, 20);
+my $mpfrr = Math::MPFR->new(10);
+my $mpfri = Math::MPFR->new(20);
+my $mpfrtemp = Math::MPFR->new();
+my $mpfrti = Math::MPFR->new();
+my $mpfrtr = Math::MPFR->new();
+my $mpfr_tilde0;
+my$ok = '';
+
+my $_64 = Math::MPC::_has_longlong() ? 1 : 0;
+
+if($_64) {
+ $mpfr_tilde0 = Math::MPFR->new(~0);
+}
+
+if($_64) {Rmpc_mul_fr($mpc1, $mpc1, $mpfr_tilde0, MPC_RNDNN)}
+else {Rmpc_mul_ui($mpc1, $mpc1, ~0, MPC_RNDNN)}
+Rmpc_mul_si($mpc1, $mpc1, -15, MPC_RNDNN);
+Rmpc_mul($mpc1, $mpc1, $mpc1, MPC_RNDNN);
+
+$mpfrr *= ~0;
+$mpfri *= ~0;
+$mpfrr *= -15;
+$mpfri *= -15;
+$mpfrtemp = ($mpfrr * $mpfri) * 2;
+$mpfrr = ($mpfrr * $mpfrr) - ($mpfri * $mpfri);
+Rmpfr_set($mpfri, $mpfrtemp, MPC_RNDNN);
+
+RMPC_RE($mpfr1, $mpc1);
+$ok .= 'a' if abs($mpfr1 - $mpfrr) < 0.0000001;
+RMPC_IM($mpfr1, $mpc1);
+$ok .= 'b' if abs($mpfr1 - $mpfri) < 0.0000001;
+
+if($ok eq 'ab') {print "ok 1\n"}
+else {print "not ok 1 $ok\n"}
+
+$ok = '';
+
+if($_64) {Rmpc_div_fr($mpc1, $mpc1, $mpfr_tilde0, MPC_RNDNN)}
+else {Rmpc_div_ui($mpc1, $mpc1, ~0, MPC_RNDNN)}
+$mpfrr /= ~0;
+$mpfri /= ~0;
+
+RMPC_RE($mpfr1, $mpc1);
+$ok .= 'a' if abs($mpfr1 - $mpfrr) < 0.0000001;
+RMPC_IM($mpfr1, $mpc1);
+$ok .= 'b' if abs($mpfr1 - $mpfri) < 0.0000001;
+
+Rmpc_ui_div($mpc1, 50, $mpc1, MPC_RNDNN);
+$mpfrtr = ($mpfrr * 50) / (($mpfrr * $mpfrr) + ($mpfri * $mpfri)) ;
+$mpfrti = (-50 * $mpfri) / (($mpfrr * $mpfrr) + ($mpfri * $mpfri));
+Rmpfr_set($mpfrr, $mpfrtr, MPC_RNDNN);
+Rmpfr_set($mpfri, $mpfrti, MPC_RNDNN);
+
+RMPC_RE($mpfr1, $mpc1);
+$ok .= 'c' if abs($mpfr1 - $mpfrr) < 0.0000001;
+RMPC_IM($mpfr1, $mpc1);
+$ok .= 'd' if abs($mpfr1 - $mpfri) < 0.0000001;
+
+my $mpc2 = Math::MPC->new($mpc1);
+
+Rmpc_div($mpc1, $mpc1, $mpc2, MPC_RNDNN);
+
+RMPC_RE($mpfr1, $mpc1);
+$ok .= 'e' if $mpfr1 == 1;
+RMPC_IM($mpfr1, $mpc1);
+$ok .= 'f' if $mpfr1 == 0;
+
+if($ok eq 'abcdef') {print "ok 2\n"}
+else {print "not ok 2 $ok\n"}
+
+$ok = '';
+
+Rmpc_set_ui_ui($mpc1, 10, 20, MPC_RNDNN);
+Rmpfr_set_ui($mpfrr, 10, MPC_RNDNN);
+Rmpfr_set_ui($mpfri, 20, MPC_RNDNN);
+
+$mpc1 *= ~0;
+$mpfrr *= ~0;
+$mpfri *= ~0;
+
+RMPC_RE($mpfr1, $mpc1);
+$ok .= 'a' if abs($mpfr1 - $mpfrr) < 0.0000001;
+RMPC_IM($mpfr1, $mpc1);
+$ok .= 'b' if abs($mpfr1 - $mpfri) < 0.0000001;
+
+$mpc1 /= ~0;
+$mpfrr /= ~0;
+$mpfri /= ~0;
+
+RMPC_RE($mpfr1, $mpc1);
+$ok .= 'c' if abs($mpfr1 - $mpfrr) < 0.0000001;
+RMPC_IM($mpfr1, $mpc1);
+$ok .= 'd' if abs($mpfr1 - $mpfri) < 0.0000001;
+
+$mpc1 *= -100;
+$mpfrr *= -100;
+$mpfri *= -100;
+
+RMPC_RE($mpfr1, $mpc1);
+$ok .= 'e' if abs($mpfr1 - $mpfrr) < 0.0000001;
+RMPC_IM($mpfr1, $mpc1);
+$ok .= 'f' if abs($mpfr1 - $mpfri) < 0.0000001;
+
+$mpc1 /= -50;
+$mpfrr /= -50;
+$mpfri /= -50;
+
+RMPC_RE($mpfr1, $mpc1);
+$ok .= 'g' if abs($mpfr1 - $mpfrr) < 0.0000001;
+RMPC_IM($mpfr1, $mpc1);
+$ok .= 'h' if abs($mpfr1 - $mpfri) < 0.0000001;
+
+$mpc1 *= 20.25;
+$mpfrr *= 20.25;
+$mpfri *= 20.25;
+
+RMPC_RE($mpfr1, $mpc1);
+$ok .= 'i' if abs($mpfr1 - $mpfrr) < 0.0000001;
+RMPC_IM($mpfr1, $mpc1);
+$ok .= 'j' if abs($mpfr1 - $mpfri) < 0.0000001;
+
+$mpc1 /= -20.5;
+$mpfrr /= -20.5;
+$mpfri /= -20.5;
+
+RMPC_RE($mpfr1, $mpc1);
+$ok .= 'k' if abs($mpfr1 - $mpfrr) < 0.0000001;
+RMPC_IM($mpfr1, $mpc1);
+$ok .= 'l' if abs($mpfr1 - $mpfri) < 0.0000001;
+
+my $string = '12345678' x 7;
+
+$mpc1 *= $string;
+$mpfrr *= $string;
+$mpfri *= $string;
+
+RMPC_RE($mpfr1, $mpc1);
+$ok .= 'm' if abs($mpfr1 - $mpfrr) < 0.0000001;
+RMPC_IM($mpfr1, $mpc1);
+$ok .= 'n' if abs($mpfr1 - $mpfri) < 0.0000001;
+
+$mpc1 /= $string;
+$mpfrr /= $string;
+$mpfri /= $string;
+
+RMPC_RE($mpfr1, $mpc1);
+$ok .= 'o' if abs($mpfr1 - $mpfrr) < 0.0000001;
+RMPC_IM($mpfr1, $mpc1);
+$ok .= 'p' if abs($mpfr1 - $mpfri) < 0.0000001;
+
+Rmpc_set_d_d($mpc2, 1099511627770.5, 1099511627770.5, MPC_RNDNN);
+
+$mpc1 *= $mpc2;
+$mpfrtr = ($mpfrr * 1099511627770.5) - ($mpfri * 1099511627770.5);
+$mpfrti = ($mpfrr * 1099511627770.5) + ($mpfri * 1099511627770.5);
+Rmpfr_set($mpfrr, $mpfrtr, MPC_RNDNN);
+Rmpfr_set($mpfri, $mpfrti, MPC_RNDNN);
+
+RMPC_RE($mpfr1, $mpc1);
+$ok .= 'q' if abs($mpfr1 - $mpfrr) < 0.0000001;
+RMPC_IM($mpfr1, $mpc1);
+$ok .= 'r' if abs($mpfr1 - $mpfri) < 0.0000001;
+
+$mpc1 /= $mpc2;
+my $mpfr_sq = Math::MPFR->new(1099511627770.5);
+$mpfr_sq *= $mpfr_sq;
+$mpfrtr = (($mpfrr * 1099511627770.5) + ($mpfri * 1099511627770.5)) / ($mpfr_sq * 2) ;
+$mpfrti = ((1099511627770.5 * $mpfri) - ($mpfrr * 1099511627770.5))/ ($mpfr_sq * 2);
+Rmpfr_set($mpfrr, $mpfrtr, MPC_RNDNN);
+Rmpfr_set($mpfri, $mpfrti, MPC_RNDNN);
+
+RMPC_RE($mpfr1, $mpc1);
+$ok .= 's' if abs($mpfr1 - $mpfrr) < 0.0000001;
+RMPC_IM($mpfr1, $mpc1);
+$ok .= 't' if abs($mpfr1 - $mpfri) < 0.0000001;
+
+if($ok eq 'abcdefghijklmnopqrst') {print "ok 3\n"}
+else {print "not ok 3 $ok\n"}
+
+$ok = '';
+
+Rmpc_set_ui_ui($mpc1, 10, 20, MPC_RNDNN);
+Rmpfr_set_ui($mpfrr, 10, MPC_RNDNN);
+Rmpfr_set_ui($mpfri, 20, MPC_RNDNN);
+
+$mpc1 = $mpc1 * ~0;
+$mpfrr *= ~0;
+$mpfri *= ~0;
+
+
+RMPC_RE($mpfr1, $mpc1);
+$ok .= 'a' if abs($mpfr1 - $mpfrr) < 0.0000001;
+RMPC_IM($mpfr1, $mpc1);
+$ok .= 'b' if abs($mpfr1 - $mpfri) < 0.0000001;
+
+$mpc1 = $mpc1 / ~0;
+$mpfrr /= ~0;
+$mpfri /= ~0;
+
+RMPC_RE($mpfr1, $mpc1);
+$ok .= 'c' if abs($mpfr1 - $mpfrr) < 0.0000001;
+RMPC_IM($mpfr1, $mpc1);
+$ok .= 'd' if abs($mpfr1 - $mpfri) < 0.0000001;
+
+$mpc1 = $mpc1 * -100;
+$mpfrr *= -100;
+$mpfri *= -100;
+
+RMPC_RE($mpfr1, $mpc1);
+$ok .= 'e' if abs($mpfr1 - $mpfrr) < 0.0000001;
+RMPC_IM($mpfr1, $mpc1);
+$ok .= 'f' if abs($mpfr1 - $mpfri) < 0.0000001;
+
+$mpc1 = $mpc1 / -50;
+$mpfrr /= -50;
+$mpfri /= -50;
+
+RMPC_RE($mpfr1, $mpc1);
+$ok .= 'g' if abs($mpfr1 - $mpfrr) < 0.0000001;
+RMPC_IM($mpfr1, $mpc1);
+$ok .= 'h' if abs($mpfr1 - $mpfri) < 0.0000001;
+
+$mpc1 = $mpc1 * 20.25;
+$mpfrr *= 20.25;
+$mpfri *= 20.25;
+
+RMPC_RE($mpfr1, $mpc1);
+$ok .= 'i' if abs($mpfr1 - $mpfrr) < 0.0000001;
+RMPC_IM($mpfr1, $mpc1);
+$ok .= 'j' if abs($mpfr1 - $mpfri) < 0.0000001;
+
+$mpc1 = $mpc1 / -20.5;
+$mpfrr /= -20.5;
+$mpfri /= -20.5;
+
+RMPC_RE($mpfr1, $mpc1);
+$ok .= 'k' if abs($mpfr1 - $mpfrr) < 0.0000001;
+RMPC_IM($mpfr1, $mpc1);
+$ok .= 'l' if abs($mpfr1 - $mpfri) < 0.0000001;
+
+$mpc1 = $mpc1 * $string;
+$mpfrr *= $string;
+$mpfri *= $string;
+
+RMPC_RE($mpfr1, $mpc1);
+$ok .= 'm' if abs($mpfr1 - $mpfrr) < 0.0000001;
+RMPC_IM($mpfr1, $mpc1);
+$ok .= 'n' if abs($mpfr1 - $mpfri) < 0.0000001;
+
+$mpc1 = $mpc1 / $string;
+$mpfrr /= $string;
+$mpfri /= $string;
+#####################
+#####################
+RMPC_RE($mpfr1, $mpc1);
+$ok .= 'o' if abs($mpfr1 - $mpfrr) < 0.0000001;
+RMPC_IM($mpfr1, $mpc1);
+$ok .= 'p' if abs($mpfr1 - $mpfri) < 0.0000001;
+
+#Rmpc_set_d_d($mpc2, 1099511627770.5, 1099511627770.5, MPC_RNDNN);
+
+$mpc1 = $mpc1 * $mpc2;
+$mpfrtr = ($mpfrr * 1099511627770.5) - ($mpfri * 1099511627770.5);
+$mpfrti = ($mpfrr * 1099511627770.5) + ($mpfri * 1099511627770.5);
+Rmpfr_set($mpfrr, $mpfrtr, MPC_RNDNN);
+Rmpfr_set($mpfri, $mpfrti, MPC_RNDNN);
+
+RMPC_RE($mpfr1, $mpc1);
+$ok .= 'q' if abs($mpfr1 - $mpfrr) < 0.0000001;
+RMPC_IM($mpfr1, $mpc1);
+$ok .= 'r' if abs($mpfr1 - $mpfri) < 0.0000001;
+######################
+######################
+$mpc1 = $mpc1 / $mpc2;
+$mpfrtr = (($mpfrr * 1099511627770.5) + ($mpfri * 1099511627770.5)) / ($mpfr_sq * 2) ;
+$mpfrti = ((1099511627770.5 * $mpfri) - ($mpfrr * 1099511627770.5))/ ($mpfr_sq * 2);
+Rmpfr_set($mpfrr, $mpfrtr, MPC_RNDNN);
+Rmpfr_set($mpfri, $mpfrti, MPC_RNDNN);
+
+RMPC_RE($mpfr1, $mpc1);
+$ok .= 's' if abs($mpfr1 - $mpfrr) < 0.0000001;
+RMPC_IM($mpfr1, $mpc1);
+$ok .= 't' if abs($mpfr1 - $mpfri) < 0.0000001;
+
+if($ok eq 'abcdefghijklmnopqrst') {print "ok 4\n"}
+else {print "not ok 4 $ok\n"}
+
+$ok = '';
+
+Rmpc_set_ui_ui($mpc1, 10, 20, MPC_RNDNN);
+Rmpfr_set_ui($mpfrr, 10, MPC_RNDNN);
+Rmpfr_set_ui($mpfri, 20, MPC_RNDNN);
+
+$mpc1 = ~0 * $mpc1;
+$mpfrr *= ~0;
+$mpfri *= ~0;
+
+RMPC_RE($mpfr1, $mpc1);
+$ok .= 'a' if abs($mpfr1 - $mpfrr) < 0.0000001;
+RMPC_IM($mpfr1, $mpc1);
+$ok .= 'b' if abs($mpfr1 - $mpfri) < 0.0000001;
+
+$mpc1 = ((~0 - 1) / 2) / $mpc1;
+$mpfrtr = ($mpfrr * ((~0 - 1) / 2)) / (($mpfrr * $mpfrr) + ($mpfri * $mpfri)) ;
+$mpfrti = (-((~0 - 1) / 2) * $mpfri) / (($mpfrr * $mpfrr) + ($mpfri * $mpfri));
+Rmpfr_set($mpfrr, $mpfrtr, GMP_RNDN);
+Rmpfr_set($mpfri, $mpfrti, GMP_RNDN);
+
+RMPC_RE($mpfr1, $mpc1);
+$ok .= 'c' if abs($mpfr1 - $mpfrr) < 0.0000001;
+RMPC_IM($mpfr1, $mpc1);
+$ok .= 'd' if abs($mpfr1 - $mpfri) < 0.0000001;
+
+$mpc1 = -100 * $mpc1;
+$mpfrr *= -100;
+$mpfri *= -100;
+
+
+RMPC_RE($mpfr1, $mpc1);
+$ok .= 'e' if abs($mpfr1 - $mpfrr) < 0.0000001;
+RMPC_IM($mpfr1, $mpc1);
+$ok .= 'f' if abs($mpfr1 - $mpfri) < 0.0000001;
+
+$mpc1 = -50 / $mpc1;
+$mpfrtr = ($mpfrr * -50) / (($mpfrr * $mpfrr) + ($mpfri * $mpfri)) ;
+$mpfrti = (50 * $mpfri) / (($mpfrr * $mpfrr) + ($mpfri * $mpfri));
+Rmpfr_set($mpfrr, $mpfrtr, MPC_RNDNN);
+Rmpfr_set($mpfri, $mpfrti, MPC_RNDNN);
+
+
+RMPC_RE($mpfr1, $mpc1);
+$ok .= 'g' if abs($mpfr1 - $mpfrr) < 0.0000001;
+RMPC_IM($mpfr1, $mpc1);
+$ok .= 'h' if abs($mpfr1 - $mpfri) < 0.0000001;
+
+$mpc1 = 20.25 * $mpc1;
+$mpfrr *= 20.25;
+$mpfri *= 20.25;
+
+
+RMPC_RE($mpfr1, $mpc1);
+$ok .= 'i' if abs($mpfr1 - $mpfrr) < 0.0000001;
+RMPC_IM($mpfr1, $mpc1);
+$ok .= 'j' if abs($mpfr1 - $mpfri) < 0.0000001;
+
+$mpc1 = -20.5 / $mpc1;
+$mpfrtr = ($mpfrr * -20.5) / (($mpfrr * $mpfrr) + ($mpfri * $mpfri)) ;
+$mpfrti = (20.5 * $mpfri) / (($mpfrr * $mpfrr) + ($mpfri * $mpfri));
+Rmpfr_set($mpfrr, $mpfrtr, MPC_RNDNN);
+Rmpfr_set($mpfri, $mpfrti, MPC_RNDNN);
+
+RMPC_RE($mpfr1, $mpc1);
+$ok .= 'k' if abs($mpfr1 - $mpfrr) < 0.0000001;
+RMPC_IM($mpfr1, $mpc1);
+$ok .= 'l' if abs($mpfr1 - $mpfri) < 0.0000001;
+
+$mpc1 = $string * $mpc1;
+$mpfrr *= $string;
+$mpfri *= $string;
+
+
+RMPC_RE($mpfr1, $mpc1);
+$ok .= 'm' if abs($mpfr1 - $mpfrr) < 0.0000001;
+RMPC_IM($mpfr1, $mpc1);
+$ok .= 'n' if abs($mpfr1 - $mpfri) < 0.0000001;
+
+$mpc1 = $string / $mpc1;
+$mpfrtr = ($mpfrr * $string) / (($mpfrr * $mpfrr) + ($mpfri * $mpfri)) ;
+$mpfrti = (($string * -$mpfri)) / (($mpfrr * $mpfrr) + ($mpfri * $mpfri));
+Rmpfr_set($mpfrr, $mpfrtr, MPC_RNDNN);
+Rmpfr_set($mpfri, $mpfrti, MPC_RNDNN);
+
+RMPC_RE($mpfr1, $mpc1);
+$ok .= 'o' if abs($mpfr1 - $mpfrr) < 0.0000001;
+RMPC_IM($mpfr1, $mpc1);
+$ok .= 'p' if abs($mpfr1 - $mpfri) < 0.0000001;
+
+if($ok eq 'abcdefghijklmnop') {print "ok 5\n"}
+else {print "not ok 5 $ok\n"}
+
+$ok = '';
+
+Rmpc_set_ui_ui($mpc2, 5, 12, MPC_RNDNN);
+Rmpc_sqr($mpc1, $mpc2, MPC_RNDNN);
+Rmpc_sqrt($mpc1, $mpc1, MPC_RNDNN);
+
+$ok .= 'a' unless Rmpc_cmp($mpc1, $mpc2);
+
+Rmpc_sqr($mpc1, $mpc2, MPC_RNDNN);
+$mpc1 = sqrt($mpc1);
+
+$ok .= 'b' if $mpc1 == $mpc2;
+
+Rmpc_abs($mpfr1, $mpc2, MPC_RNDNN);
+
+$ok .= 'c' if $mpfr1 == 13;
+
+$mpfrtemp = abs($mpc2);
+
+$ok .= 'd' if $mpfrtemp == 13;
+
+Rmpc_norm($mpfr1, $mpc2, MPC_RNDNN);
+
+$ok .= 'e' if $mpfr1 == 169;
+
+Rmpc_conj($mpc1, $mpc2, MPC_RNDNN);
+$mpc1 += $mpc2;
+
+RMPC_IM($mpfr1, $mpc1);
+
+$ok .= 'f' if $mpfr1 == 0;
+
+Rmpc_neg($mpc1, $mpc2, MPC_RNDNN);
+
+$ok .= 'g' if $mpc1 == -$mpc2;
+$ok .= 'h' if $mpc1 == $mpc2 * -1;
+
+Rmpfr_const_pi($mpfrtemp, MPC_RNDNN);
+my $double = Rmpfr_get_d($mpfrtemp, MPC_RNDNN);
+
+Rmpc_set_d_d($mpc2, 0, $double, MPC_RNDNN);
+Rmpc_exp($mpc1, $mpc2, MPC_RNDNN);
+
+RMPC_RE($mpfr1, $mpc1);
+$ok .= 'i' if $mpfr1 > -1 && $mpfr1 < -0.9999999;
+RMPC_IM($mpfr1, $mpc1);
+$ok .= 'j' if $mpfr1 > 0 && $mpfr1 < 0.0000001;
+
+my $mpc3 = exp($mpc2);
+
+RMPC_RE($mpfr1, $mpc3);
+$ok .= 'k' if $mpfr1 > -1 && $mpfr1 < -0.9999999;
+RMPC_IM($mpfr1, $mpc3);
+$ok .= 'l' if $mpfr1 > 0 && $mpfr1 < 0.0000001;
+
+if($ok eq 'abcdefghijkl') {print "ok 6\n"}
+else {print "not ok 6\n"}
+
+$ok = '';
+
+my $log = log(exp(Math::MPC->new(8.5, 0)));
+
+RMPC_RE($mpfr1, $log);
+$ok .= 'a' if $mpfr1 > 8.499999 && $mpfr1 < 8.500001;
+RMPC_IM($mpfr1, $log);
+$ok .= 'b' if $mpfr1 == 0;
+
+Rmpc_log($log, Math::MPC->new(1, 0), MPC_RNDNN);
+
+RMPC_RE($mpfr1, $log);
+$ok .= 'c' if $mpfr1 == 0;
+RMPC_IM($mpfr1, $log);
+$ok .= 'd' if $mpfr1 == 0;
+
+if($ok eq 'abcd') {print "ok 7\n"}
+else {print "not ok 7\n"}
+
+$ok = '';
+my $pow = Math::MPC->new(3);
+my $op1 = Math::MPC->new(0, 3);
+my $op2 = Math::MPC->new(3, 0);
+my $rop = Math::MPC->new();
+
+Rmpc_pow($rop, $op1, $pow, MPC_RNDNN);
+RMPC_RE($mpfr1, $rop);
+if($mpfr1 == 0) {$ok .= 'a'}
+else {warn "8a: $mpfr1\n"}
+RMPC_IM($mpfr1, $rop);
+if($mpfr1 == -27) {$ok .= 'b'}
+else {warn "8b: $mpfr1\n"}
+
+Rmpc_pow($rop, $op2, $pow, MPC_RNDNN);
+RMPC_IM($mpfr1, $rop);
+if($mpfr1 == 0) {$ok .= 'c'}
+else {warn "8c: $mpfr1\n"}
+RMPC_RE($mpfr1, $rop);
+if($mpfr1 == 27) {$ok .= 'd'}
+else {warn "8d: $mpfr1\n"}
+
+my $root_re = Math::MPFR->new();
+my $root_im = Math::MPFR->new();
+my $pow_re = Math::MPFR->new();
+my $pow_im = Math::MPFR->new();
+
+Rmpc_set_d_ui($pow, 0.5, 0, MPC_RNDNN);
+Rmpc_set_ui_ui($op1, 17, 16, MPC_RNDNN);
+Rmpc_sqrt($rop, $op1, MPC_RNDNN);
+RMPC_RE($root_re, $rop);
+RMPC_IM($root_im, $rop);
+Rmpc_pow($rop, $op1, $pow, MPC_RNDNN);
+RMPC_RE($pow_re, $rop);
+RMPC_IM($pow_im, $rop);
+
+if($root_re == $pow_re){$ok .= 'e'}
+else {warn "8e: $root_re $pow_re\n"}
+
+if($root_im == $pow_im){$ok .= 'f'}
+else {warn "8f: $root_im $pow_im\n"}
+
+if($ok eq 'abcdef') {print "ok 8\n"}
+else {print "not ok 8 $ok\n"}
+
+
+
+
+
+
+
+
@@ -1,51 +1,51 @@
-use strict;
-use warnings;
-use Math::MPC qw(:mpc);
-use Math::MPFR qw(:mpfr);
-
-print "1..1\n";
-
-my $ok = '';
-my $nan1 = Math::MPC->new(1,1);
-my $rop = Math::MPC->new();
-my $zero = Math::MPC->new(0,0);
-my $pnan = Rmpfr_get_d(Math::MPFR->new(), GMP_RNDN);
-my $nan2 = Math::MPC->new($pnan, $pnan);
-my $re = Math::MPFR->new(1);
-my $im = Math::MPFR->new(2);
-Rmpc_set_nan($nan1);
-
-RMPC_RE($re, $nan1);
-RMPC_IM($im, $nan1);
-
-if(Rmpfr_nan_p($re)) {$ok .= 'a'}
-else {warn "1a: $re\n"}
-if(Rmpfr_nan_p($im)) {$ok .= 'b'}
-else {warn "1b: $im\n"}
-
-Rmpc_pow($rop, $nan1, $zero, MPC_RNDNN);
-
-RMPC_RE($re, $rop);
-RMPC_IM($im, $rop);
-
-if($re == 1) {$ok .= 'c'}
-else {warn "1c: $re\n"}
-if($im == 0) {$ok .= 'd'}
-else {warn "1d: $im\n"}
-
-Rmpc_mul($rop, $nan2, $zero, MPC_RNDNN);
-
-RMPC_RE($re, $rop);
-RMPC_IM($im, $rop);
-
-if(Rmpfr_nan_p($re)) {$ok .= 'e'}
-else {warn "1e: $re\n"}
-if(Rmpfr_nan_p($im)) {$ok .= 'f'}
-else {warn "1f: $im\n"}
-
-if($ok eq 'abcdef') {print "ok 1\n"}
-else {
- warn "1: $ok\n";
- print "not ok 1\n";
-}
-
+use strict;
+use warnings;
+use Math::MPC qw(:mpc);
+use Math::MPFR qw(:mpfr);
+
+print "1..1\n";
+
+my $ok = '';
+my $nan1 = Math::MPC->new(1,1);
+my $rop = Math::MPC->new();
+my $zero = Math::MPC->new(0,0);
+my $pnan = Rmpfr_get_d(Math::MPFR->new(), GMP_RNDN);
+my $nan2 = Math::MPC->new($pnan, $pnan);
+my $re = Math::MPFR->new(1);
+my $im = Math::MPFR->new(2);
+Rmpc_set_nan($nan1);
+
+RMPC_RE($re, $nan1);
+RMPC_IM($im, $nan1);
+
+if(Rmpfr_nan_p($re)) {$ok .= 'a'}
+else {warn "1a: $re\n"}
+if(Rmpfr_nan_p($im)) {$ok .= 'b'}
+else {warn "1b: $im\n"}
+
+Rmpc_pow($rop, $nan1, $zero, MPC_RNDNN);
+
+RMPC_RE($re, $rop);
+RMPC_IM($im, $rop);
+
+if($re == 1) {$ok .= 'c'}
+else {warn "1c: $re\n"}
+if($im == 0) {$ok .= 'd'}
+else {warn "1d: $im\n"}
+
+Rmpc_mul($rop, $nan2, $zero, MPC_RNDNN);
+
+RMPC_RE($re, $rop);
+RMPC_IM($im, $rop);
+
+if(Rmpfr_nan_p($re)) {$ok .= 'e'}
+else {warn "1e: $re\n"}
+if(Rmpfr_nan_p($im)) {$ok .= 'f'}
+else {warn "1f: $im\n"}
+
+if($ok eq 'abcdef') {print "ok 1\n"}
+else {
+ warn "1: $ok\n";
+ print "not ok 1\n";
+}
+
@@ -1,372 +1,372 @@
-use warnings;
-use strict;
-use Math::MPC qw(:mpc);
-use Math::MPFR qw(:mpfr);
-use Math::BigInt;
-
-print "1..15\n";
-
-Rmpc_set_default_prec2(5000, 5000);
-Rmpfr_set_default_prec(5000);
-
-my ($mpc, $mpc3, $mpc4, $mpfr, $mpfr1, $mpfr2, $mpfr3, $mpfr4, $mpfr5);
-my $ok = '';
-my $string = 'hello world';
-my $mbi = Math::BigInt->new(123456);
-my $mpfr_re = Math::MPFR->new();
-my $mpfr_im = Math::MPFR->new();
-
-eval {$mpc = Math::MPC->new($string);};
-if($@ =~ /Math::MPC::new/) {$ok = 'a'}
-eval {$mpc = new Math::MPC($string);};
-if($@ =~ /Math::MPC::new/) {$ok .= 'b'}
-eval {$mpc = Math::MPC::new($string);};
-if($@ =~ /Math::MPC::new/) {$ok .= 'c'}
-eval {$mpc = Math::MPC->new($string, 0);};
-if($@ =~ /Math::MPC::new/) {$ok .= 'd'}
-eval {$mpc = new Math::MPC($string, 0);};
-if($@ =~ /Math::MPC::new/) {$ok .= 'e'}
-eval {$mpc = Math::MPC::new($string, 0);};
-if($@ =~ /Math::MPC::new/) {$ok .= 'f'}
-eval {$mpc = Math::MPC->new(0, $string);};
-if($@ =~ /Math::MPC::new/) {$ok .= 'g'}
-eval {$mpc = new Math::MPC(0, $string);};
-if($@ =~ /Math::MPC::new/) {$ok .= 'h'}
-eval {$mpc = Math::MPC::new(0, $string);};
-if($@ =~ /Math::MPC::new/) {$ok .= 'i'}
-
-eval {$mpc = Math::MPC->new($mbi);};
-if($@ =~ /First /) {$ok .= 'j'}
-eval {$mpc = new Math::MPC($mbi);};
-if($@ =~ /First /) {$ok .= 'k'}
-eval {$mpc = Math::MPC::new($mbi);};
-if($@ =~ /First/) {$ok .= 'l'}
-eval {$mpc = Math::MPC->new($mbi, 0);};
-if($@ =~ /First /) {$ok .= 'm'}
-eval {$mpc = new Math::MPC($mbi, 0);};
-if($@ =~ /First /) {$ok .= 'n'}
-eval {$mpc = Math::MPC::new($mbi, 0);};
-if($@ =~ /First /) {$ok .= 'o'}
-eval {$mpc = Math::MPC->new(0, $mbi);};
-if($@ =~ /Second /) {$ok .= 'p'}
-eval {$mpc = new Math::MPC(0, $mbi);};
-if($@ =~ /Second /) {$ok .= 'q'}
-eval {$mpc = Math::MPC::new(0, $mbi);};
-if($@ =~ /Second /) {$ok .= 'r'}
-
-eval{$mpc = Math::MPC->new(0, '0b115');};
-if($@ =~ /Invalid string/) {$ok .= 's'}
-eval{$mpc = Math::MPC::new(0, '0B115');};
-if($@ =~ /Invalid string/) {$ok .= 't'}
-
-eval{$mpc = Math::MPC->new(0, '0xz115');};
-if($@ =~ /Invalid string/) {$ok .= 'u'}
-eval{$mpc = Math::MPC::new(0, '0Xz115');};
-if($@ =~ /Invalid string/) {$ok .= 'v'}
-
-eval{$mpc = Math::MPC->new('0b115');};
-if($@ =~ /Invalid string/) {$ok .= 'w'}
-eval{$mpc = Math::MPC::new('0B115');};
-if($@ =~ /Invalid string/) {$ok .= 'x'}
-
-eval{$mpc = Math::MPC->new('0xz115');};
-if($@ =~ /Invalid string/) {$ok .= 'y'}
-eval{$mpc = Math::MPC::new('0Xz115');};
-if($@ =~ /Invalid string/) {$ok .= 'z'}
-
-if($ok eq 'abcdefghijklmnopqrstuvwxyz') {print "ok 1\n"}
-else {print "not ok 1 $ok\n"}
-
-$ok = '';
-
-($mpfr1, $mpfr2, $mpfr3, $mpfr4, $mpfr5) = (Rmpfr_init(), Rmpfr_init(), Rmpfr_init(), Rmpfr_init(), Rmpfr_init());
-
-{
-my $mpc1 = Math::MPC->new();
-my $mpc2 = Math::MPC::new();
-RMPC_RE($mpfr1, $mpc1);
-RMPC_IM($mpfr2, $mpc1);
-RMPC_RE($mpfr3, $mpc2);
-RMPC_IM($mpfr4, $mpc2);
-}
-$ok .= 'a' if Rmpfr_nan_p($mpfr1);
-$ok .= 'b' if Rmpfr_nan_p($mpfr2);
-$ok .= 'c' if Rmpfr_nan_p($mpfr3);
-$ok .= 'd' if Rmpfr_nan_p($mpfr4);
-
-if($ok eq 'abcd') {print "ok 2\n"}
-else {print "not ok 2 $ok\n"}
-
-$ok = '';
-
-{
-my $mpc1 = Math::MPC->new(~0);
-my $mpc2 = Math::MPC::new(~0);
-RMPC_RE($mpfr1, $mpc1);
-RMPC_IM($mpfr2, $mpc1);
-RMPC_RE($mpfr3, $mpc2);
-RMPC_IM($mpfr4, $mpc2);
-}
-
-$ok .= 'a' if $mpfr1 == ~0;
-$ok .= 'b' if $mpfr2 == 0;
-$ok .= 'c' if $mpfr3 == ~0;
-$ok .= 'd' if $mpfr4 == 0;
-
-if($ok eq 'abcd') {print "ok 3\n"}
-else {print "not ok 3 $ok\n"}
-
-$ok = '';
-
-{
-my $mpc1 = Math::MPC->new(-7, ~0);
-my $mpc2 = Math::MPC::new(-7, ~0);
-RMPC_RE($mpfr1, $mpc1);
-RMPC_IM($mpfr2, $mpc1);
-RMPC_RE($mpfr3, $mpc2);
-RMPC_IM($mpfr4, $mpc2);
-}
-
-$ok .= 'a' if $mpfr1 == -7;
-$ok .= 'b' if $mpfr2 == ~0;
-$ok .= 'c' if $mpfr3 == -7;
-$ok .= 'd' if $mpfr4 == ~0;
-
-if($ok eq 'abcd') {print "ok 4\n"}
-else {print "not ok 4 $ok\n"}
-
-$ok = '';
-
-{
-my $mpc1 = Math::MPC->new(2199023255552.5, -7);
-my $mpc2 = Math::MPC::new(2199023255552.5, -7);
-RMPC_RE($mpfr1, $mpc1);
-RMPC_IM($mpfr2, $mpc1);
-RMPC_RE($mpfr3, $mpc2);
-RMPC_IM($mpfr4, $mpc2);
-}
-
-$ok .= 'a' if $mpfr1 == 2199023255552.5;
-$ok .= 'b' if $mpfr2 == -7;
-$ok .= 'c' if $mpfr3 == 2199023255552.5;
-$ok .= 'd' if $mpfr4 == -7;
-
-if($ok eq 'abcd') {print "ok 5\n"}
-else {print "not ok 5 $ok\n"}
-
-$ok = '';
-
-{
-my $mpc1 = Math::MPC->new('2199023255552' x 7, -2199023255552.5);
-my $mpc2 = Math::MPC::new('2199023255552' x 7, -2199023255552.5);
-RMPC_RE($mpfr1, $mpc1);
-RMPC_IM($mpfr2, $mpc1);
-RMPC_RE($mpfr3, $mpc2);
-RMPC_IM($mpfr4, $mpc2);
-$mpfr = Math::MPFR->new($mpfr1);
-}
-
-$ok .= 'a' if $mpfr1 == '2199023255552' x 7;
-$ok .= 'b' if $mpfr2 == -2199023255552.5;
-$ok .= 'c' if $mpfr3 == '2199023255552' x 7;
-$ok .= 'd' if $mpfr4 == -2199023255552.5;
-
-if($ok eq 'abcd') {print "ok 6\n"}
-else {print "not ok 6 $ok\n"}
-
-$ok = '';
-
-$string = '2199023255552' x 7;
-$string = '-' . $string;
-
-{
-my $mpc1 = Math::MPC->new($mpfr, $string);
-my $mpc2 = Math::MPC::new($mpfr, $string);
-RMPC_RE($mpfr1, $mpc1);
-RMPC_IM($mpfr2, $mpc1);
-RMPC_RE($mpfr3, $mpc2);
-RMPC_IM($mpfr4, $mpc2);
-}
-
-$ok .= 'a' if $mpfr1 == $mpfr;
-$ok .= 'b' if $mpfr2 == $string;
-$ok .= 'c' if $mpfr3 == $mpfr;
-$ok .= 'd' if $mpfr4 == $string;
-
-if($ok eq 'abcd') {print "ok 7\n"}
-else {print "not ok 7 $ok\n"}
-
-$ok = '';
-
-{
-my $mpc1 = Math::MPC->new(6, $mpfr);
-my $mpc2 = Math::MPC::new(6, $mpfr);
-$mpc3 = Math::MPC->new($mpc1);
-$mpc4 = Math::MPC::new($mpc1);
-RMPC_RE($mpfr1, $mpc1);
-RMPC_IM($mpfr2, $mpc1);
-RMPC_RE($mpfr3, $mpc2);
-RMPC_IM($mpfr4, $mpc2);
-}
-
-$ok .= 'a' if $mpfr1 == 6;
-$ok .= 'b' if $mpfr2 == $mpfr;
-$ok .= 'c' if $mpfr3 == 6;
-$ok .= 'd' if $mpfr4 == $mpfr;
-
-if($ok eq 'abcd') {print "ok 8\n"}
-else {print "not ok 8 $ok\n"}
-
-$ok = '';
-
-{
-my $mpc1 = Math::MPC->new($mpc3);
-my $mpc2 = Math::MPC::new($mpc4);
-if($mpc3 == $mpc1) {$ok .= 'a'}
-if($mpc4 == $mpc2) {$ok .= 'b'}
-if($mpc1 == $mpc2) {$ok .= 'c'}
-}
-
-if($ok eq 'abc'){print "ok 9\n"}
-else {print "not ok 9 $ok\n"}
-
-$ok = '';
-
-{
-my $mpc1 = Math::MPC->new('0b111', '0xff');
-my $mpc2 = Math::MPC::new('0B111', '0XFF');
-RMPC_RE($mpfr1, $mpc1);
-RMPC_IM($mpfr2, $mpc1);
-RMPC_RE($mpfr3, $mpc2);
-RMPC_IM($mpfr4, $mpc2);
-}
-
-$ok .= 'a' if $mpfr1 == 7;
-$ok .= 'b' if $mpfr2 == 255;
-$ok .= 'c' if $mpfr3 == 7;
-$ok .= 'd' if $mpfr4 == 255;
-
-if($ok eq 'abcd') {print "ok 10\n"}
-else {print "not ok 10 $ok\n"}
-
-$ok = '';
-
-eval{my $m_p_c = Math::MPC->new(1, 2, 3);};
-if($@ =~ /Too many arguments supplied to new/) {$ok .= 'a'}
-
-$mpc = Math::MPC->new(6, 5);
-
-eval{my $m_p_c = Math::MPC->new($mpc, 2);};
-if($@ =~ /Too many arguments supplied to new\(\) \- expected no more than one/) {$ok .= 'b'}
-
-eval{my $m_p_c = Math::MPC::new(1, 2, 3);};
-if($@ =~ /Too many arguments supplied to new\(\) \- expected no more than two/) {$ok .= 'c'}
-
-eval{my $m_p_c = Math::MPC->new($mbi, 2);};
-if($@ =~ /First argument to new\(\) is inappropriate/) {$ok .= 'd'}
-
-eval{my $m_p_c = Math::MPC->new(2, $mbi);};
-if($@ =~ /Second argument to new\(\) is inappropriate/) {$ok .= 'e'}
-
-if($ok eq 'abcde') {print "ok 11\n"}
-else {print "not ok 11 $ok\n"}
-
-$ok = '';
-
-my ($have_GMP, $have_GMPz, $have_GMPq, $have_GMPf) = (0, 0, 0, 0);
-
-eval{require Math::GMP;};
-$have_GMP = 1 if !$@;
-
-eval{require Math::GMPz;};
-$have_GMPz = 1 if !$@;
-
-eval{require Math::GMPq;};
-$have_GMPq = 1 if !$@;
-
-eval{require Math::GMPf;};
-$have_GMPf = 1 if !$@;
-
-if($have_GMP) {
- $ok = '';
- my $gmp = Math::GMP->new(1234567);
- my $gmp2 = Math::GMP->new(890);
- my $mpc1 = Math::MPC->new($gmp);
- if($mpc1 == 1234567){$ok .= 'a'}
- else {warn "12a: $mpc1\n"}
- my $mpc2 = Math::MPC->new($gmp, $gmp2);
- Rmpc_real($mpfr_re, $mpc2, MPC_RNDNN);
- Rmpc_imag($mpfr_im, $mpc2, MPC_RNDNN);
- if($mpfr_re == 1234567 && $mpfr_im == 890) {$ok .= 'b'}
- else {warn "12b: $mpc2\n"}
-
- if($ok eq 'ab') {print "ok 12\n"}
- else {print "not ok 12 $ok\n"}
-}
-else {
- print "ok 12 - skipped, no Math::GMP\n";
-}
-
-if($have_GMPz) {
- $ok = '';
- my $gmp = Math::GMPz->new(1234567);
- my $gmp2 = Math::GMPz->new(890);
- my $mpc1 = Math::MPC->new($gmp);
- if($mpc1 == 1234567){$ok .= 'a'}
- else {warn "13a: $mpc1\n"}
- my $mpc2 = Math::MPC->new($gmp, $gmp2);
- Rmpc_real($mpfr_re, $mpc2, MPC_RNDNN);
- Rmpc_imag($mpfr_im, $mpc2, MPC_RNDNN);
- if($mpfr_re == 1234567 && $mpfr_im == 890) {$ok .= 'b'}
- else {warn "13b: $mpc2\n"}
-
- if($ok eq 'ab') {print "ok 13\n"}
- else {print "not ok 13 $ok\n"}
-}
-else {
- print "ok 13 - skipped, no Math::GMPz\n";
-}
-
-
-if($have_GMPq) {
- $ok = '';
- my $gmp = Math::GMPq->new(1234567);
- my $gmp2 = Math::GMPq->new(890);
- my $mpc1 = Math::MPC->new($gmp);
- if($mpc1 == 1234567){$ok .= 'a'}
- else {warn "14a: $mpc1\n"}
- my $mpc2 = Math::MPC->new($gmp, $gmp2);
- Rmpc_real($mpfr_re, $mpc2, MPC_RNDNN);
- Rmpc_imag($mpfr_im, $mpc2, MPC_RNDNN);
- if($mpfr_re == 1234567 && $mpfr_im == 890) {$ok .= 'b'}
- else {warn "14b: $mpc2\n"}
-
- if($ok eq 'ab') {print "ok 14\n"}
- else {print "not ok 14 $ok\n"}
-}
-else {
- print "ok 14 - skipped, no Math::GMPq\n";
-}
-
-if($have_GMPf) {
- $ok = '';
- my $gmp = Math::GMPf->new(1234567.5);
- my $gmp2 = Math::GMPf->new(890.5);
- my $mpc1 = Math::MPC->new($gmp);
- if($mpc1 == 1234567.5){$ok .= 'a'}
- else {warn "15a: $mpc1\n"}
- my $mpc2 = Math::MPC->new($gmp, $gmp2);
- Rmpc_real($mpfr_re, $mpc2, MPC_RNDNN);
- Rmpc_imag($mpfr_im, $mpc2, MPC_RNDNN);
- if($mpfr_re == 1234567.5 && $mpfr_im == 890.5) {$ok .= 'b'}
- else {warn "15b: $mpc2\n"}
-
- if($ok eq 'ab') {print "ok 15\n"}
- else {print "not ok 15 $ok\n"}
-}
-else {
- print "ok 15 - skipped, no Math::GMPf\n";
-}
-
-
-
+use warnings;
+use strict;
+use Math::MPC qw(:mpc);
+use Math::MPFR qw(:mpfr);
+use Math::BigInt;
+
+print "1..15\n";
+
+Rmpc_set_default_prec2(5000, 5000);
+Rmpfr_set_default_prec(5000);
+
+my ($mpc, $mpc3, $mpc4, $mpfr, $mpfr1, $mpfr2, $mpfr3, $mpfr4, $mpfr5);
+my $ok = '';
+my $string = 'hello world';
+my $mbi = Math::BigInt->new(123456);
+my $mpfr_re = Math::MPFR->new();
+my $mpfr_im = Math::MPFR->new();
+
+eval {$mpc = Math::MPC->new($string);};
+if($@ =~ /Math::MPC::new/) {$ok = 'a'}
+eval {$mpc = new Math::MPC($string);};
+if($@ =~ /Math::MPC::new/) {$ok .= 'b'}
+eval {$mpc = Math::MPC::new($string);};
+if($@ =~ /Math::MPC::new/) {$ok .= 'c'}
+eval {$mpc = Math::MPC->new($string, 0);};
+if($@ =~ /Math::MPC::new/) {$ok .= 'd'}
+eval {$mpc = new Math::MPC($string, 0);};
+if($@ =~ /Math::MPC::new/) {$ok .= 'e'}
+eval {$mpc = Math::MPC::new($string, 0);};
+if($@ =~ /Math::MPC::new/) {$ok .= 'f'}
+eval {$mpc = Math::MPC->new(0, $string);};
+if($@ =~ /Math::MPC::new/) {$ok .= 'g'}
+eval {$mpc = new Math::MPC(0, $string);};
+if($@ =~ /Math::MPC::new/) {$ok .= 'h'}
+eval {$mpc = Math::MPC::new(0, $string);};
+if($@ =~ /Math::MPC::new/) {$ok .= 'i'}
+
+eval {$mpc = Math::MPC->new($mbi);};
+if($@ =~ /First /) {$ok .= 'j'}
+eval {$mpc = new Math::MPC($mbi);};
+if($@ =~ /First /) {$ok .= 'k'}
+eval {$mpc = Math::MPC::new($mbi);};
+if($@ =~ /First/) {$ok .= 'l'}
+eval {$mpc = Math::MPC->new($mbi, 0);};
+if($@ =~ /First /) {$ok .= 'm'}
+eval {$mpc = new Math::MPC($mbi, 0);};
+if($@ =~ /First /) {$ok .= 'n'}
+eval {$mpc = Math::MPC::new($mbi, 0);};
+if($@ =~ /First /) {$ok .= 'o'}
+eval {$mpc = Math::MPC->new(0, $mbi);};
+if($@ =~ /Second /) {$ok .= 'p'}
+eval {$mpc = new Math::MPC(0, $mbi);};
+if($@ =~ /Second /) {$ok .= 'q'}
+eval {$mpc = Math::MPC::new(0, $mbi);};
+if($@ =~ /Second /) {$ok .= 'r'}
+
+eval{$mpc = Math::MPC->new(0, '0b115');};
+if($@ =~ /Invalid string/) {$ok .= 's'}
+eval{$mpc = Math::MPC::new(0, '0B115');};
+if($@ =~ /Invalid string/) {$ok .= 't'}
+
+eval{$mpc = Math::MPC->new(0, '0xz115');};
+if($@ =~ /Invalid string/) {$ok .= 'u'}
+eval{$mpc = Math::MPC::new(0, '0Xz115');};
+if($@ =~ /Invalid string/) {$ok .= 'v'}
+
+eval{$mpc = Math::MPC->new('0b115');};
+if($@ =~ /Invalid string/) {$ok .= 'w'}
+eval{$mpc = Math::MPC::new('0B115');};
+if($@ =~ /Invalid string/) {$ok .= 'x'}
+
+eval{$mpc = Math::MPC->new('0xz115');};
+if($@ =~ /Invalid string/) {$ok .= 'y'}
+eval{$mpc = Math::MPC::new('0Xz115');};
+if($@ =~ /Invalid string/) {$ok .= 'z'}
+
+if($ok eq 'abcdefghijklmnopqrstuvwxyz') {print "ok 1\n"}
+else {print "not ok 1 $ok\n"}
+
+$ok = '';
+
+($mpfr1, $mpfr2, $mpfr3, $mpfr4, $mpfr5) = (Rmpfr_init(), Rmpfr_init(), Rmpfr_init(), Rmpfr_init(), Rmpfr_init());
+
+{
+my $mpc1 = Math::MPC->new();
+my $mpc2 = Math::MPC::new();
+RMPC_RE($mpfr1, $mpc1);
+RMPC_IM($mpfr2, $mpc1);
+RMPC_RE($mpfr3, $mpc2);
+RMPC_IM($mpfr4, $mpc2);
+}
+$ok .= 'a' if Rmpfr_nan_p($mpfr1);
+$ok .= 'b' if Rmpfr_nan_p($mpfr2);
+$ok .= 'c' if Rmpfr_nan_p($mpfr3);
+$ok .= 'd' if Rmpfr_nan_p($mpfr4);
+
+if($ok eq 'abcd') {print "ok 2\n"}
+else {print "not ok 2 $ok\n"}
+
+$ok = '';
+
+{
+my $mpc1 = Math::MPC->new(~0);
+my $mpc2 = Math::MPC::new(~0);
+RMPC_RE($mpfr1, $mpc1);
+RMPC_IM($mpfr2, $mpc1);
+RMPC_RE($mpfr3, $mpc2);
+RMPC_IM($mpfr4, $mpc2);
+}
+
+$ok .= 'a' if $mpfr1 == ~0;
+$ok .= 'b' if $mpfr2 == 0;
+$ok .= 'c' if $mpfr3 == ~0;
+$ok .= 'd' if $mpfr4 == 0;
+
+if($ok eq 'abcd') {print "ok 3\n"}
+else {print "not ok 3 $ok\n"}
+
+$ok = '';
+
+{
+my $mpc1 = Math::MPC->new(-7, ~0);
+my $mpc2 = Math::MPC::new(-7, ~0);
+RMPC_RE($mpfr1, $mpc1);
+RMPC_IM($mpfr2, $mpc1);
+RMPC_RE($mpfr3, $mpc2);
+RMPC_IM($mpfr4, $mpc2);
+}
+
+$ok .= 'a' if $mpfr1 == -7;
+$ok .= 'b' if $mpfr2 == ~0;
+$ok .= 'c' if $mpfr3 == -7;
+$ok .= 'd' if $mpfr4 == ~0;
+
+if($ok eq 'abcd') {print "ok 4\n"}
+else {print "not ok 4 $ok\n"}
+
+$ok = '';
+
+{
+my $mpc1 = Math::MPC->new(2199023255552.5, -7);
+my $mpc2 = Math::MPC::new(2199023255552.5, -7);
+RMPC_RE($mpfr1, $mpc1);
+RMPC_IM($mpfr2, $mpc1);
+RMPC_RE($mpfr3, $mpc2);
+RMPC_IM($mpfr4, $mpc2);
+}
+
+$ok .= 'a' if $mpfr1 == 2199023255552.5;
+$ok .= 'b' if $mpfr2 == -7;
+$ok .= 'c' if $mpfr3 == 2199023255552.5;
+$ok .= 'd' if $mpfr4 == -7;
+
+if($ok eq 'abcd') {print "ok 5\n"}
+else {print "not ok 5 $ok\n"}
+
+$ok = '';
+
+{
+my $mpc1 = Math::MPC->new('2199023255552' x 7, -2199023255552.5);
+my $mpc2 = Math::MPC::new('2199023255552' x 7, -2199023255552.5);
+RMPC_RE($mpfr1, $mpc1);
+RMPC_IM($mpfr2, $mpc1);
+RMPC_RE($mpfr3, $mpc2);
+RMPC_IM($mpfr4, $mpc2);
+$mpfr = Math::MPFR->new($mpfr1);
+}
+
+$ok .= 'a' if $mpfr1 == '2199023255552' x 7;
+$ok .= 'b' if $mpfr2 == -2199023255552.5;
+$ok .= 'c' if $mpfr3 == '2199023255552' x 7;
+$ok .= 'd' if $mpfr4 == -2199023255552.5;
+
+if($ok eq 'abcd') {print "ok 6\n"}
+else {print "not ok 6 $ok\n"}
+
+$ok = '';
+
+$string = '2199023255552' x 7;
+$string = '-' . $string;
+
+{
+my $mpc1 = Math::MPC->new($mpfr, $string);
+my $mpc2 = Math::MPC::new($mpfr, $string);
+RMPC_RE($mpfr1, $mpc1);
+RMPC_IM($mpfr2, $mpc1);
+RMPC_RE($mpfr3, $mpc2);
+RMPC_IM($mpfr4, $mpc2);
+}
+
+$ok .= 'a' if $mpfr1 == $mpfr;
+$ok .= 'b' if $mpfr2 == $string;
+$ok .= 'c' if $mpfr3 == $mpfr;
+$ok .= 'd' if $mpfr4 == $string;
+
+if($ok eq 'abcd') {print "ok 7\n"}
+else {print "not ok 7 $ok\n"}
+
+$ok = '';
+
+{
+my $mpc1 = Math::MPC->new(6, $mpfr);
+my $mpc2 = Math::MPC::new(6, $mpfr);
+$mpc3 = Math::MPC->new($mpc1);
+$mpc4 = Math::MPC::new($mpc1);
+RMPC_RE($mpfr1, $mpc1);
+RMPC_IM($mpfr2, $mpc1);
+RMPC_RE($mpfr3, $mpc2);
+RMPC_IM($mpfr4, $mpc2);
+}
+
+$ok .= 'a' if $mpfr1 == 6;
+$ok .= 'b' if $mpfr2 == $mpfr;
+$ok .= 'c' if $mpfr3 == 6;
+$ok .= 'd' if $mpfr4 == $mpfr;
+
+if($ok eq 'abcd') {print "ok 8\n"}
+else {print "not ok 8 $ok\n"}
+
+$ok = '';
+
+{
+my $mpc1 = Math::MPC->new($mpc3);
+my $mpc2 = Math::MPC::new($mpc4);
+if($mpc3 == $mpc1) {$ok .= 'a'}
+if($mpc4 == $mpc2) {$ok .= 'b'}
+if($mpc1 == $mpc2) {$ok .= 'c'}
+}
+
+if($ok eq 'abc'){print "ok 9\n"}
+else {print "not ok 9 $ok\n"}
+
+$ok = '';
+
+{
+my $mpc1 = Math::MPC->new('0b111', '0xff');
+my $mpc2 = Math::MPC::new('0B111', '0XFF');
+RMPC_RE($mpfr1, $mpc1);
+RMPC_IM($mpfr2, $mpc1);
+RMPC_RE($mpfr3, $mpc2);
+RMPC_IM($mpfr4, $mpc2);
+}
+
+$ok .= 'a' if $mpfr1 == 7;
+$ok .= 'b' if $mpfr2 == 255;
+$ok .= 'c' if $mpfr3 == 7;
+$ok .= 'd' if $mpfr4 == 255;
+
+if($ok eq 'abcd') {print "ok 10\n"}
+else {print "not ok 10 $ok\n"}
+
+$ok = '';
+
+eval{my $m_p_c = Math::MPC->new(1, 2, 3);};
+if($@ =~ /Too many arguments supplied to new/) {$ok .= 'a'}
+
+$mpc = Math::MPC->new(6, 5);
+
+eval{my $m_p_c = Math::MPC->new($mpc, 2);};
+if($@ =~ /Too many arguments supplied to new\(\) \- expected no more than one/) {$ok .= 'b'}
+
+eval{my $m_p_c = Math::MPC::new(1, 2, 3);};
+if($@ =~ /Too many arguments supplied to new\(\) \- expected no more than two/) {$ok .= 'c'}
+
+eval{my $m_p_c = Math::MPC->new($mbi, 2);};
+if($@ =~ /First argument to new\(\) is inappropriate/) {$ok .= 'd'}
+
+eval{my $m_p_c = Math::MPC->new(2, $mbi);};
+if($@ =~ /Second argument to new\(\) is inappropriate/) {$ok .= 'e'}
+
+if($ok eq 'abcde') {print "ok 11\n"}
+else {print "not ok 11 $ok\n"}
+
+$ok = '';
+
+my ($have_GMP, $have_GMPz, $have_GMPq, $have_GMPf) = (0, 0, 0, 0);
+
+eval{require Math::GMP;};
+$have_GMP = 1 if !$@;
+
+eval{require Math::GMPz;};
+$have_GMPz = 1 if !$@;
+
+eval{require Math::GMPq;};
+$have_GMPq = 1 if !$@;
+
+eval{require Math::GMPf;};
+$have_GMPf = 1 if !$@;
+
+if($have_GMP) {
+ $ok = '';
+ my $gmp = Math::GMP->new(1234567);
+ my $gmp2 = Math::GMP->new(890);
+ my $mpc1 = Math::MPC->new($gmp);
+ if($mpc1 == 1234567){$ok .= 'a'}
+ else {warn "12a: $mpc1\n"}
+ my $mpc2 = Math::MPC->new($gmp, $gmp2);
+ Rmpc_real($mpfr_re, $mpc2, MPC_RNDNN);
+ Rmpc_imag($mpfr_im, $mpc2, MPC_RNDNN);
+ if($mpfr_re == 1234567 && $mpfr_im == 890) {$ok .= 'b'}
+ else {warn "12b: $mpc2\n"}
+
+ if($ok eq 'ab') {print "ok 12\n"}
+ else {print "not ok 12 $ok\n"}
+}
+else {
+ print "ok 12 - skipped, no Math::GMP\n";
+}
+
+if($have_GMPz) {
+ $ok = '';
+ my $gmp = Math::GMPz->new(1234567);
+ my $gmp2 = Math::GMPz->new(890);
+ my $mpc1 = Math::MPC->new($gmp);
+ if($mpc1 == 1234567){$ok .= 'a'}
+ else {warn "13a: $mpc1\n"}
+ my $mpc2 = Math::MPC->new($gmp, $gmp2);
+ Rmpc_real($mpfr_re, $mpc2, MPC_RNDNN);
+ Rmpc_imag($mpfr_im, $mpc2, MPC_RNDNN);
+ if($mpfr_re == 1234567 && $mpfr_im == 890) {$ok .= 'b'}
+ else {warn "13b: $mpc2\n"}
+
+ if($ok eq 'ab') {print "ok 13\n"}
+ else {print "not ok 13 $ok\n"}
+}
+else {
+ print "ok 13 - skipped, no Math::GMPz\n";
+}
+
+
+if($have_GMPq) {
+ $ok = '';
+ my $gmp = Math::GMPq->new(1234567);
+ my $gmp2 = Math::GMPq->new(890);
+ my $mpc1 = Math::MPC->new($gmp);
+ if($mpc1 == 1234567){$ok .= 'a'}
+ else {warn "14a: $mpc1\n"}
+ my $mpc2 = Math::MPC->new($gmp, $gmp2);
+ Rmpc_real($mpfr_re, $mpc2, MPC_RNDNN);
+ Rmpc_imag($mpfr_im, $mpc2, MPC_RNDNN);
+ if($mpfr_re == 1234567 && $mpfr_im == 890) {$ok .= 'b'}
+ else {warn "14b: $mpc2\n"}
+
+ if($ok eq 'ab') {print "ok 14\n"}
+ else {print "not ok 14 $ok\n"}
+}
+else {
+ print "ok 14 - skipped, no Math::GMPq\n";
+}
+
+if($have_GMPf) {
+ $ok = '';
+ my $gmp = Math::GMPf->new(1234567.5);
+ my $gmp2 = Math::GMPf->new(890.5);
+ my $mpc1 = Math::MPC->new($gmp);
+ if($mpc1 == 1234567.5){$ok .= 'a'}
+ else {warn "15a: $mpc1\n"}
+ my $mpc2 = Math::MPC->new($gmp, $gmp2);
+ Rmpc_real($mpfr_re, $mpc2, MPC_RNDNN);
+ Rmpc_imag($mpfr_im, $mpc2, MPC_RNDNN);
+ if($mpfr_re == 1234567.5 && $mpfr_im == 890.5) {$ok .= 'b'}
+ else {warn "15b: $mpc2\n"}
+
+ if($ok eq 'ab') {print "ok 15\n"}
+ else {print "not ok 15 $ok\n"}
+}
+else {
+ print "ok 15 - skipped, no Math::GMPf\n";
+}
+
+
+
@@ -1,310 +1,310 @@
-use warnings;
-use strict;
-use Math::MPC qw(:mpc);
-use Math::MPFR qw(:mpfr);
-use Math::BigInt;
-
-print "1..7\n";
-
-my $mbi2;
-my $ok = '';
-my $string = 'hello world';
-my $mbi = Math::BigInt->new(123456);
-my @prec = Rmpc_get_default_prec2();
-my $mpc = Rmpc_init3(@prec);
-Rmpc_set_ui_ui($mpc, 10, 10, MPC_RNDNN);
-
-eval {$mbi2 = $mpc + $string;};
-if($@ =~ /Math::MPC::overload_add/) {$ok = 'a'}
-eval {$mbi2 = $mpc - $string;};
-if($@ =~ /Math::MPC::overload_sub/) {$ok .= 'b'}
-eval {$mbi2 = $mpc / $string;};
-if($@ =~ /Math::MPC::overload_div/) {$ok .= 'c'}
-eval {$mbi2 = $mpc * $string;};
-if($@ =~ /Math::MPC::overload_mul/) {$ok .= 'd'}
-eval {$mbi2 = $mpc + $mbi;};
-if($@ =~ /Math::MPC::overload_add/) {$ok .= 'e'}
-eval {$mbi2 = $mpc - $mbi;};
-if($@ =~ /Math::MPC::overload_sub/) {$ok .= 'f'}
-eval {$mbi2 = $mpc / $mbi;};
-if($@ =~ /Math::MPC::overload_div/) {$ok .= 'g'}
-eval {$mbi2 = $mpc * $mbi;};
-if($@ =~ /Math::MPC::overload_mul/) {$ok .= 'h'}
-eval {$mbi2 = $mpc ** $mbi;};
-if($@ =~ /Math::MPC::overload_pow/) {$ok .= 'i'}
-
-eval {$mpc += $string;};
-if($@ =~ /Math::MPC::overload_add_eq/) {$ok .= 'j'}
-eval {$mpc -= $string;};
-if($@ =~ /Math::MPC::overload_sub_eq/) {$ok .= 'k'}
-eval {$mpc /= $string;};
-if($@ =~ /Math::MPC::overload_div_eq/) {$ok .= 'l'}
-eval {$mpc *= $string;};
-if($@ =~ /Math::MPC::overload_mul_eq/) {$ok .= 'm'}
-eval {$mpc += $mbi;};
-if($@ =~ /Math::MPC::overload_add_eq/) {$ok .= 'n'}
-eval {$mpc -= $mbi;};
-if($@ =~ /Math::MPC::overload_sub_eq/) {$ok .= 'o'}
-eval {$mpc /= $mbi;};
-if($@ =~ /Math::MPC::overload_div_eq/) {$ok .= 'p'}
-eval {$mpc *= $mbi;};
-if($@ =~ /Math::MPC::overload_mul_eq/) {$ok .= 'q'}
-eval {$mpc **= $mbi;};
-if($@ =~ /Math::MPC::overload_pow_eq/) {$ok .= 'r'}
-
-if($ok eq 'abcdefghijklmnopqr') {print "ok 1\n"}
-else {print "not ok 1 $ok\n"}
-
-my $num = Math::MPC->new(200, 40);
-if(Math::MPC::overload_string($num) eq '(2e2 4e1)') {print "ok 2\n"}
-else {
- warn "\nTest 2 got: ", Math::MPC::overload_string($num), "\n";
- print "not ok 2\n";
-}
-
-# checking overload_copy subroutine
-$ok = '';
-$ok .= 'a' if $prec[0] == 53 && $prec[1] == 53;
-
-my $mpc1 = Math::MPC->new(12345, 67890);
-Rmpc_set_default_prec2(100, 112);
-my $mpc2 = $mpc1;
-
-my @p = Rmpc_get_prec2($mpc2);
-
-$ok .= 'b' if $p[0] == 53 && $p[1] == 53;
-
-$mpc2++;
-$ok .= 'c' if $mpc2 == $mpc1 + 1;
-
-@p = Rmpc_get_prec2($mpc2);
-$ok .= 'd' if $p[0] == 53 && $p[1] == 53;
-
-my $mpc3 = Rmpc_init3(70, 80);
-Rmpc_set_ui_ui($mpc3, 54321, 9876, MPC_RNDNN);
-
-my $mpc4 = $mpc3;
-@p = Rmpc_get_prec2($mpc4);
-
-$ok .= 'e' if $p[0] == 70 && $p[1] == 80;
-
-$mpc4 += 1;
-$ok .= 'f' if $mpc4 == $mpc3 + 1;
-
-@p = Rmpc_get_prec2($mpc4);
-$ok .= 'g' if $p[0] == 70 && $p[1] == 80;
-
-my $mpc5 = $mpc3;
-$mpc3 += 1;
-@p = Rmpc_get_prec2($mpc5);
-$ok .= 'h' if $p[0] == 70 && $p[1] == 80 && $mpc5 == $mpc3 - 1;
-
-$mpc5 -= -1;
-
-if($mpc3 == $mpc5) {$ok .= 'i'}
-if(Math::MPC::overload_string($mpc5) eq
- Math::MPC::overload_string($mpc3)) {$ok .= 'j'}
-
-if($ok eq 'abcdefghij') {print "ok 3\n"}
-else {print "not ok 3 $ok\n"}
-
-Rmpc_set_default_prec2(70, 80);
-$ok = '';
-$string = '(1.5 +1.5)';
-
-## plus ##
-$mpc5 += 2;
-$mpc3 = $mpc3 + 2;
-
-if($mpc3 == $mpc5) {$ok .= 'a'}
-if(Math::MPC::overload_string($mpc5) eq
- Math::MPC::overload_string($mpc3)) {$ok .= 'b'}
-
-$mpc5 += 2.5;
-$mpc3 = $mpc3 + 2.5;
-
-if($mpc3 == $mpc5) {$ok .= 'c'}
-if(Math::MPC::overload_string($mpc5) eq
- Math::MPC::overload_string($mpc3)) {$ok .= 'd'}
-
-$mpc5 += $string;
-$mpc3 = $mpc3 + $string;
-
-if($mpc3 == $mpc5) {$ok .= 'e'}
-if(Math::MPC::overload_string($mpc5) eq
- Math::MPC::overload_string($mpc3)) {$ok .= 'f'}
-
-$mpc5 += $mpc4;
-$mpc3 = $mpc3 + $mpc4;
-
-if($mpc3 == $mpc5) {$ok .= 'g'}
-if(Math::MPC::overload_string($mpc5) eq
- Math::MPC::overload_string($mpc3)) {$ok .= 'h'}
-
-## minus ##
-
-$mpc5 -= 2;
-$mpc3 = $mpc3 - 2;
-
-if($mpc3 == $mpc5) {$ok .= 'i'}
-if(Math::MPC::overload_string($mpc5) eq
- Math::MPC::overload_string($mpc3)) {$ok .= 'j'}
-
-$mpc5 -= 2.5;
-$mpc3 = $mpc3 - 2.5;
-
-if($mpc3 == $mpc5) {$ok .= 'k'}
-if(Math::MPC::overload_string($mpc5) eq
- Math::MPC::overload_string($mpc3)) {$ok .= 'l'}
-
-$mpc5 -= $string;
-$mpc3 = $mpc3 - $string;
-
-if($mpc3 == $mpc5) {$ok .= 'm'}
-if(Math::MPC::overload_string($mpc5) eq
- Math::MPC::overload_string($mpc3)) {$ok .= 'n'}
-
-$mpc5 -= $mpc4;
-$mpc3 = $mpc3 - $mpc4;
-
-if($mpc3 == $mpc5) {$ok .= 'o'}
-if(Math::MPC::overload_string($mpc5) eq
- Math::MPC::overload_string($mpc3)) {$ok .= 'p'}
-
-## mul ##
-
-$mpc5 *= 2;
-$mpc3 = $mpc3 * 2;
-
-if($mpc3 == $mpc5) {$ok .= 'q'}
-if(Math::MPC::overload_string($mpc5) eq
- Math::MPC::overload_string($mpc3)) {$ok .= 'r'}
-
-$mpc5 *= 2.5;
-$mpc3 = $mpc3 * 2.5;
-
-if($mpc3 == $mpc5) {$ok .= 's'}
-if(Math::MPC::overload_string($mpc5) eq
- Math::MPC::overload_string($mpc3)) {$ok .= 't'}
-
-$mpc5 *= $string;
-$mpc3 = $mpc3 * $string;
-
-if($mpc3 == $mpc5) {$ok .= 'u'}
-if(Math::MPC::overload_string($mpc5) eq
- Math::MPC::overload_string($mpc3)) {$ok .= 'v'}
-
-$mpc5 *= $mpc4;
-$mpc3 = $mpc3 * $mpc4;
-
-if($mpc3 == $mpc5) {$ok .= 'w'}
-if(Math::MPC::overload_string($mpc5) eq
- Math::MPC::overload_string($mpc3)) {$ok .= 'x'}
-
-## div ##
-
-$mpc5 /= 2;
-$mpc3 = $mpc3 / 2;
-
-if($mpc3 == $mpc5) {$ok .= 'y'}
-if(Math::MPC::overload_string($mpc5) eq
- Math::MPC::overload_string($mpc3)) {$ok .= 'z'}
-
-$mpc5 /= 2.5;
-$mpc3 = $mpc3 / 2.5;
-
-if($mpc3 == $mpc5) {$ok .= 'A'}
-if(Math::MPC::overload_string($mpc5) eq
- Math::MPC::overload_string($mpc3)) {$ok .= 'B'}
-
-$mpc5 /= $string;
-$mpc3 = $mpc3 / $string;
-
-if($mpc3 == $mpc5) {$ok .= 'C'}
-if(Math::MPC::overload_string($mpc5) eq
- Math::MPC::overload_string($mpc3)) {$ok .= 'D'}
-
-$mpc5 /= $mpc4;
-$mpc3 = $mpc3 / $mpc4;
-
-if($mpc3 == $mpc5) {$ok .= 'E'}
-if(Math::MPC::overload_string($mpc5) eq
- Math::MPC::overload_string($mpc3)) {$ok .= 'F'}
-
-## pow ##
-
-$mpc5 **= 2;
-$mpc3 = $mpc3 ** 2;
-
-if($mpc3 == $mpc5) {$ok .= 'G'}
-if(Math::MPC::overload_string($mpc5) eq
- Math::MPC::overload_string($mpc3)) {$ok .= 'H'}
-
-$mpc5 **= 2.5;
-$mpc3 = $mpc3 ** 2.5;
-
-if($mpc3 == $mpc5) {$ok .= 'I'}
-if(Math::MPC::overload_string($mpc5) eq
- Math::MPC::overload_string($mpc3)) {$ok .= 'J'}
-
-$mpc5 **= '(1.5 +1.5)';
-$mpc3 = $mpc3 ** '(1.5 +1.5)';
-
-if($mpc3 == $mpc5) {$ok .= 'K'}
-if(Math::MPC::overload_string($mpc5) eq
- Math::MPC::overload_string($mpc3)) {$ok .= 'L'}
-
-my $power = Math::MPC->new(1.5, 1.5);
-
-$mpc5 **= $power;
-$mpc3 = $mpc3 ** $power;
-
-if($mpc3 == $mpc5) {$ok .= 'M'}
-if(Math::MPC::overload_string($mpc5) eq
- Math::MPC::overload_string($mpc3)) {$ok .= 'N'}
-
-if($ok eq 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMN') {print "ok 4\n"}
-else {
- warn "$ok\n";
- print "not ok 4\n";
-}
-
-$ok = '';
-my $mpc6 = Math::MPC->new(1, 2);
-my $mpc7 = Math::MPC->new(3, 4);
-
-$mpc6 = atan2($mpc6, $mpc7);
-my $mpfr = Math::MPFR->new();
-
-RMPC_RE($mpfr, $mpc6);
-if($mpfr > 0.4164906 && $mpfr < 0.4164907) {$ok .= 'a'}
-
-RMPC_IM($mpfr, $mpc6);
-if($mpfr > 0.06706599 && $mpfr < 0.067066) {$ok .= 'b'}
-
-if($ok eq 'ab') {print "ok 5\n"}
-else {
- warn "$ok $mpc6\n";
- print "not ok 5\n";
-}
-
-my $nan;
-
-if(Math::MPC::_has_longdouble()) {
- $nan = Rmpfr_get_ld(Math::MPFR->new(), GMP_RNDN);
-}
-else {
- $nan = Rmpfr_get_d(Math::MPFR->new(), GMP_RNDN);
-}
-
-if($nan == $nan) {
- warn "If test 6 fails, it is probably due to a bug in perl itself\n";
- print "not ok 6\n";
-}
-else {print "ok 6\n"}
-
-if($mpc6 == $nan) {print "not ok 7\n"}
-else {print "ok 7\n"}
-
-
-
+use warnings;
+use strict;
+use Math::MPC qw(:mpc);
+use Math::MPFR qw(:mpfr);
+use Math::BigInt;
+
+print "1..7\n";
+
+my $mbi2;
+my $ok = '';
+my $string = 'hello world';
+my $mbi = Math::BigInt->new(123456);
+my @prec = Rmpc_get_default_prec2();
+my $mpc = Rmpc_init3(@prec);
+Rmpc_set_ui_ui($mpc, 10, 10, MPC_RNDNN);
+
+eval {$mbi2 = $mpc + $string;};
+if($@ =~ /Math::MPC::overload_add/) {$ok = 'a'}
+eval {$mbi2 = $mpc - $string;};
+if($@ =~ /Math::MPC::overload_sub/) {$ok .= 'b'}
+eval {$mbi2 = $mpc / $string;};
+if($@ =~ /Math::MPC::overload_div/) {$ok .= 'c'}
+eval {$mbi2 = $mpc * $string;};
+if($@ =~ /Math::MPC::overload_mul/) {$ok .= 'd'}
+eval {$mbi2 = $mpc + $mbi;};
+if($@ =~ /Math::MPC::overload_add/) {$ok .= 'e'}
+eval {$mbi2 = $mpc - $mbi;};
+if($@ =~ /Math::MPC::overload_sub/) {$ok .= 'f'}
+eval {$mbi2 = $mpc / $mbi;};
+if($@ =~ /Math::MPC::overload_div/) {$ok .= 'g'}
+eval {$mbi2 = $mpc * $mbi;};
+if($@ =~ /Math::MPC::overload_mul/) {$ok .= 'h'}
+eval {$mbi2 = $mpc ** $mbi;};
+if($@ =~ /Math::MPC::overload_pow/) {$ok .= 'i'}
+
+eval {$mpc += $string;};
+if($@ =~ /Math::MPC::overload_add_eq/) {$ok .= 'j'}
+eval {$mpc -= $string;};
+if($@ =~ /Math::MPC::overload_sub_eq/) {$ok .= 'k'}
+eval {$mpc /= $string;};
+if($@ =~ /Math::MPC::overload_div_eq/) {$ok .= 'l'}
+eval {$mpc *= $string;};
+if($@ =~ /Math::MPC::overload_mul_eq/) {$ok .= 'm'}
+eval {$mpc += $mbi;};
+if($@ =~ /Math::MPC::overload_add_eq/) {$ok .= 'n'}
+eval {$mpc -= $mbi;};
+if($@ =~ /Math::MPC::overload_sub_eq/) {$ok .= 'o'}
+eval {$mpc /= $mbi;};
+if($@ =~ /Math::MPC::overload_div_eq/) {$ok .= 'p'}
+eval {$mpc *= $mbi;};
+if($@ =~ /Math::MPC::overload_mul_eq/) {$ok .= 'q'}
+eval {$mpc **= $mbi;};
+if($@ =~ /Math::MPC::overload_pow_eq/) {$ok .= 'r'}
+
+if($ok eq 'abcdefghijklmnopqr') {print "ok 1\n"}
+else {print "not ok 1 $ok\n"}
+
+my $num = Math::MPC->new(200, 40);
+if(Math::MPC::overload_string($num) eq '(2e2 4e1)') {print "ok 2\n"}
+else {
+ warn "\nTest 2 got: ", Math::MPC::overload_string($num), "\n";
+ print "not ok 2\n";
+}
+
+# checking overload_copy subroutine
+$ok = '';
+$ok .= 'a' if $prec[0] == 53 && $prec[1] == 53;
+
+my $mpc1 = Math::MPC->new(12345, 67890);
+Rmpc_set_default_prec2(100, 112);
+my $mpc2 = $mpc1;
+
+my @p = Rmpc_get_prec2($mpc2);
+
+$ok .= 'b' if $p[0] == 53 && $p[1] == 53;
+
+$mpc2++;
+$ok .= 'c' if $mpc2 == $mpc1 + 1;
+
+@p = Rmpc_get_prec2($mpc2);
+$ok .= 'd' if $p[0] == 53 && $p[1] == 53;
+
+my $mpc3 = Rmpc_init3(70, 80);
+Rmpc_set_ui_ui($mpc3, 54321, 9876, MPC_RNDNN);
+
+my $mpc4 = $mpc3;
+@p = Rmpc_get_prec2($mpc4);
+
+$ok .= 'e' if $p[0] == 70 && $p[1] == 80;
+
+$mpc4 += 1;
+$ok .= 'f' if $mpc4 == $mpc3 + 1;
+
+@p = Rmpc_get_prec2($mpc4);
+$ok .= 'g' if $p[0] == 70 && $p[1] == 80;
+
+my $mpc5 = $mpc3;
+$mpc3 += 1;
+@p = Rmpc_get_prec2($mpc5);
+$ok .= 'h' if $p[0] == 70 && $p[1] == 80 && $mpc5 == $mpc3 - 1;
+
+$mpc5 -= -1;
+
+if($mpc3 == $mpc5) {$ok .= 'i'}
+if(Math::MPC::overload_string($mpc5) eq
+ Math::MPC::overload_string($mpc3)) {$ok .= 'j'}
+
+if($ok eq 'abcdefghij') {print "ok 3\n"}
+else {print "not ok 3 $ok\n"}
+
+Rmpc_set_default_prec2(70, 80);
+$ok = '';
+$string = '(1.5 +1.5)';
+
+## plus ##
+$mpc5 += 2;
+$mpc3 = $mpc3 + 2;
+
+if($mpc3 == $mpc5) {$ok .= 'a'}
+if(Math::MPC::overload_string($mpc5) eq
+ Math::MPC::overload_string($mpc3)) {$ok .= 'b'}
+
+$mpc5 += 2.5;
+$mpc3 = $mpc3 + 2.5;
+
+if($mpc3 == $mpc5) {$ok .= 'c'}
+if(Math::MPC::overload_string($mpc5) eq
+ Math::MPC::overload_string($mpc3)) {$ok .= 'd'}
+
+$mpc5 += $string;
+$mpc3 = $mpc3 + $string;
+
+if($mpc3 == $mpc5) {$ok .= 'e'}
+if(Math::MPC::overload_string($mpc5) eq
+ Math::MPC::overload_string($mpc3)) {$ok .= 'f'}
+
+$mpc5 += $mpc4;
+$mpc3 = $mpc3 + $mpc4;
+
+if($mpc3 == $mpc5) {$ok .= 'g'}
+if(Math::MPC::overload_string($mpc5) eq
+ Math::MPC::overload_string($mpc3)) {$ok .= 'h'}
+
+## minus ##
+
+$mpc5 -= 2;
+$mpc3 = $mpc3 - 2;
+
+if($mpc3 == $mpc5) {$ok .= 'i'}
+if(Math::MPC::overload_string($mpc5) eq
+ Math::MPC::overload_string($mpc3)) {$ok .= 'j'}
+
+$mpc5 -= 2.5;
+$mpc3 = $mpc3 - 2.5;
+
+if($mpc3 == $mpc5) {$ok .= 'k'}
+if(Math::MPC::overload_string($mpc5) eq
+ Math::MPC::overload_string($mpc3)) {$ok .= 'l'}
+
+$mpc5 -= $string;
+$mpc3 = $mpc3 - $string;
+
+if($mpc3 == $mpc5) {$ok .= 'm'}
+if(Math::MPC::overload_string($mpc5) eq
+ Math::MPC::overload_string($mpc3)) {$ok .= 'n'}
+
+$mpc5 -= $mpc4;
+$mpc3 = $mpc3 - $mpc4;
+
+if($mpc3 == $mpc5) {$ok .= 'o'}
+if(Math::MPC::overload_string($mpc5) eq
+ Math::MPC::overload_string($mpc3)) {$ok .= 'p'}
+
+## mul ##
+
+$mpc5 *= 2;
+$mpc3 = $mpc3 * 2;
+
+if($mpc3 == $mpc5) {$ok .= 'q'}
+if(Math::MPC::overload_string($mpc5) eq
+ Math::MPC::overload_string($mpc3)) {$ok .= 'r'}
+
+$mpc5 *= 2.5;
+$mpc3 = $mpc3 * 2.5;
+
+if($mpc3 == $mpc5) {$ok .= 's'}
+if(Math::MPC::overload_string($mpc5) eq
+ Math::MPC::overload_string($mpc3)) {$ok .= 't'}
+
+$mpc5 *= $string;
+$mpc3 = $mpc3 * $string;
+
+if($mpc3 == $mpc5) {$ok .= 'u'}
+if(Math::MPC::overload_string($mpc5) eq
+ Math::MPC::overload_string($mpc3)) {$ok .= 'v'}
+
+$mpc5 *= $mpc4;
+$mpc3 = $mpc3 * $mpc4;
+
+if($mpc3 == $mpc5) {$ok .= 'w'}
+if(Math::MPC::overload_string($mpc5) eq
+ Math::MPC::overload_string($mpc3)) {$ok .= 'x'}
+
+## div ##
+
+$mpc5 /= 2;
+$mpc3 = $mpc3 / 2;
+
+if($mpc3 == $mpc5) {$ok .= 'y'}
+if(Math::MPC::overload_string($mpc5) eq
+ Math::MPC::overload_string($mpc3)) {$ok .= 'z'}
+
+$mpc5 /= 2.5;
+$mpc3 = $mpc3 / 2.5;
+
+if($mpc3 == $mpc5) {$ok .= 'A'}
+if(Math::MPC::overload_string($mpc5) eq
+ Math::MPC::overload_string($mpc3)) {$ok .= 'B'}
+
+$mpc5 /= $string;
+$mpc3 = $mpc3 / $string;
+
+if($mpc3 == $mpc5) {$ok .= 'C'}
+if(Math::MPC::overload_string($mpc5) eq
+ Math::MPC::overload_string($mpc3)) {$ok .= 'D'}
+
+$mpc5 /= $mpc4;
+$mpc3 = $mpc3 / $mpc4;
+
+if($mpc3 == $mpc5) {$ok .= 'E'}
+if(Math::MPC::overload_string($mpc5) eq
+ Math::MPC::overload_string($mpc3)) {$ok .= 'F'}
+
+## pow ##
+
+$mpc5 **= 2;
+$mpc3 = $mpc3 ** 2;
+
+if($mpc3 == $mpc5) {$ok .= 'G'}
+if(Math::MPC::overload_string($mpc5) eq
+ Math::MPC::overload_string($mpc3)) {$ok .= 'H'}
+
+$mpc5 **= 2.5;
+$mpc3 = $mpc3 ** 2.5;
+
+if($mpc3 == $mpc5) {$ok .= 'I'}
+if(Math::MPC::overload_string($mpc5) eq
+ Math::MPC::overload_string($mpc3)) {$ok .= 'J'}
+
+$mpc5 **= '(1.5 +1.5)';
+$mpc3 = $mpc3 ** '(1.5 +1.5)';
+
+if($mpc3 == $mpc5) {$ok .= 'K'}
+if(Math::MPC::overload_string($mpc5) eq
+ Math::MPC::overload_string($mpc3)) {$ok .= 'L'}
+
+my $power = Math::MPC->new(1.5, 1.5);
+
+$mpc5 **= $power;
+$mpc3 = $mpc3 ** $power;
+
+if($mpc3 == $mpc5) {$ok .= 'M'}
+if(Math::MPC::overload_string($mpc5) eq
+ Math::MPC::overload_string($mpc3)) {$ok .= 'N'}
+
+if($ok eq 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMN') {print "ok 4\n"}
+else {
+ warn "$ok\n";
+ print "not ok 4\n";
+}
+
+$ok = '';
+my $mpc6 = Math::MPC->new(1, 2);
+my $mpc7 = Math::MPC->new(3, 4);
+
+$mpc6 = atan2($mpc6, $mpc7);
+my $mpfr = Math::MPFR->new();
+
+RMPC_RE($mpfr, $mpc6);
+if($mpfr > 0.4164906 && $mpfr < 0.4164907) {$ok .= 'a'}
+
+RMPC_IM($mpfr, $mpc6);
+if($mpfr > 0.06706599 && $mpfr < 0.067066) {$ok .= 'b'}
+
+if($ok eq 'ab') {print "ok 5\n"}
+else {
+ warn "$ok $mpc6\n";
+ print "not ok 5\n";
+}
+
+my $nan;
+
+if(Math::MPC::_has_longdouble()) {
+ $nan = Rmpfr_get_ld(Math::MPFR->new(), GMP_RNDN);
+}
+else {
+ $nan = Rmpfr_get_d(Math::MPFR->new(), GMP_RNDN);
+}
+
+if($nan == $nan) {
+ warn "If test 6 fails, it is probably due to a bug in perl itself\n";
+ print "not ok 6\n";
+}
+else {print "ok 6\n"}
+
+if($mpc6 == $nan) {print "not ok 7\n"}
+else {print "ok 7\n"}
+
+
+
@@ -1,198 +1,198 @@
-use warnings;
-use strict;
-use Math::MPFR qw(:mpfr);
-use Math::MPC qw(:mpc);
-
-print "1..8\n";
-
-my($have_gmpz, $have_gmp) = (0, 0);
-my $ok = '';
-
-eval {require Math::GMPz;};
-if(!$@) { $have_gmpz = 1 }
-
-eval {require Math::GMP;};
-if(!$@) { $have_gmp = 1 }
-
-my($mp1, $mp2);
-
-$mp1 = Math::GMPz->new(2) if $have_gmpz;
-$mp2 = Math::GMP->new(2) if $have_gmp;
-my $fr = Math::MPFR->new(2.5);
-my $d = 2.5;
-my $ld = 2.5;
-my $si = -2;
-my $ui = 2;
-my $mpc = Math::MPC->new(3, 4);
-my $rop = Math::MPC->new();
-my $mpfr = Math::MPFR->new();
-
-Rmpc_pow_d($rop, $mpc, $d, MPC_RNDNN);
-RMPC_RE($mpfr, $rop);
-if($mpfr == -38) {$ok .= 'a'}
-RMPC_IM($mpfr, $rop);
-if($mpfr == 41) {$ok .= 'b'}
-
-eval {Rmpc_pow_ld($rop, $mpc, $ld, MPC_RNDNN);};
-if(!$@) {
- RMPC_RE($mpfr, $rop);
- if($mpfr == -38) {$ok .= 'c'}
- RMPC_IM($mpfr, $rop);
- if($mpfr == 41) {$ok .= 'd'}
-}
-else {
- if(! Math::MPC::_has_longdouble() && $@ =~ /not implemented/) {$ok .= 'cd'}
-}
-
-Rmpc_pow_si($rop, $mpc, $si, MPC_RNDNN);
-RMPC_RE($mpfr, $rop);
-if($mpfr > -0.0112001 && $mpfr < -0.0111999) {$ok .= 'e'}
-RMPC_IM($mpfr, $rop);
-if($mpfr > -0.0384001 && $mpfr < -0.0383999) {$ok .= 'f'}
-
-Rmpc_pow_ui($rop, $mpc, $ui, MPC_RNDNN);
-RMPC_RE($mpfr, $rop);
-if($mpfr == -7) {$ok .= 'g'}
-RMPC_IM($mpfr, $rop);
-if($mpfr == 24) {$ok .= 'h'}
-
-if($have_gmpz) {
- Rmpc_pow_z($rop, $mpc, $mp1, MPC_RNDNN);
- RMPC_RE($mpfr, $rop);
- if($mpfr == -7) {$ok .= 'i'}
- RMPC_IM($mpfr, $rop);
- if($mpfr == 24) {$ok .= 'j'}
-}
-else {
- warn "No Math::GMPz - skipping tests 1(i) and 1(j)\n";
- $ok .= 'ij';
-}
-
-if($have_gmp) {
- Rmpc_pow_z($rop, $mpc, $mp2, MPC_RNDNN);
- RMPC_RE($mpfr, $rop);
- if($mpfr == -7) {$ok .= 'k'}
- RMPC_IM($mpfr, $rop);
- if($mpfr == 24) {$ok .= 'l'}
-}
-else {
- warn "No Math::GMP - skipping tests 1(k) and 1(l)\n";
- $ok .= 'kl';
-}
-
-Rmpc_pow_fr($rop, $mpc, $fr, MPC_RNDNN);
-RMPC_RE($mpfr, $rop);
-if($mpfr == -38) {$ok .= 'm'}
-RMPC_IM($mpfr, $rop);
-if($mpfr == 41) {$ok .= 'n'}
-
-Rmpc_pow($rop, $mpc, $mpc, MPC_RNDNN);
-RMPC_RE($mpfr, $rop);
-if($mpfr < -2.997990598 && $mpfr > -2.997990599) {$ok .= 'o'}
-RMPC_IM($mpfr, $rop);
-if($mpfr > 0.6237845862 && $mpfr < 0.62378458628) {$ok .= 'p'}
-
-if($ok eq 'abcdefghijklmnop') { print "ok 1\n" }
-else { print "not ok 1 $ok\n" }
-
-$ok = '';
-
-$rop = $mpc ** $d;
-RMPC_RE($mpfr, $rop);
-if($mpfr == -38) {$ok .= 'a'}
-RMPC_IM($mpfr, $rop);
-if($mpfr == 41) {$ok .= 'b'}
-
-$rop = $mpc ** $si;
-RMPC_RE($mpfr, $rop);
-if($mpfr > -0.0112001 && $mpfr < -0.0111999) {$ok .= 'c'}
-RMPC_IM($mpfr, $rop);
-if($mpfr > -0.0384001 && $mpfr < -0.0383999) {$ok .= 'd'}
-
-$rop = $mpc ** $mpc;
-RMPC_RE($mpfr, $rop);
-if($mpfr < -2.997990598 && $mpfr > -2.997990599) {$ok .= 'e'}
-RMPC_IM($mpfr, $rop);
-if($mpfr > 0.6237845862 && $mpfr < 0.62378458628) {$ok .= 'f'}
-
-if($ok eq 'abcdef') {print "ok 2\n"}
-else {print "not ok 2 $ok\n"}
-
-Rmpc_set_ui($mpc, 5, MPC_RNDNN);
-
-Rmpc_mul_2exp($mpc, $mpc, 4, MPC_RNDNN);
-
-if($mpc == 80) {print "ok 3\n"}
-else {
- warn "\$mpc: $mpc\n";
- print "not ok 3\n";
-}
-
-eval{Rmpc_mul_2si($mpc, $mpc, -4, MPC_RNDNN);};
-
-if(MPC_VERSION >= 65536) {
- if($mpc == 5) {print "ok 4\n"}
- else {
- warn "\$mpc: $mpc\n";
- print "not ok 4\n";
- }
-}
-else {
- if($@ =~ /mpc_mul_2si not implemented until mpc\-1\.0/) {print "ok 4\n"}
- else {
- warn "\$\@: $@\n";
- print "not ok 4\n";
- }
-}
-
-#####################################
-Rmpc_set_ui($mpc, 5, MPC_RNDNN);
-
-Rmpc_mul_2ui($mpc, $mpc, 4, MPC_RNDNN);
-
-if($mpc == 80) {print "ok 5\n"}
-else {
- warn "\$mpc: $mpc\n";
- print "not ok 5\n";
-}
-
-Rmpc_div_2ui($mpc, $mpc, 4, MPC_RNDNN);
-
-if($mpc == 5) {print "ok 6\n"}
-else {
- warn "\$mpc: $mpc\n";
- print "not ok 6\n";
-}
-#####################################
-
-Rmpc_set_ui($mpc, 5, MPC_RNDNN);
-
-eval {Rmpc_div_2si($mpc, $mpc, -4, MPC_RNDNN);};
-
-if(MPC_VERSION >= 65536) {
- if($mpc == 80) {print "ok 7\n"}
- else {
- warn "\$mpc: $mpc\n";
- print "not ok 7\n";
- }
-}
-else {
- if($@ =~ /mpc_div_2si not implemented until mpc\-1\.0/) {print "ok 7\n"}
- else {
- warn "\$\@: $@\n";
- print "not ok 7\n";
- }
-}
-
-Rmpc_set_ui($mpc, 80, MPC_RNDNN);
-Rmpc_div_2exp($mpc, $mpc, 4, MPC_RNDNN);
-
-if($mpc == 5) {print "ok 8\n"}
-else {
- warn "\$mpc: $mpc\n";
- print "not ok 8\n";
-}
-
-print "$mpc\n";
-
-
+use warnings;
+use strict;
+use Math::MPFR qw(:mpfr);
+use Math::MPC qw(:mpc);
+
+print "1..8\n";
+
+my($have_gmpz, $have_gmp) = (0, 0);
+my $ok = '';
+
+eval {require Math::GMPz;};
+if(!$@) { $have_gmpz = 1 }
+
+eval {require Math::GMP;};
+if(!$@) { $have_gmp = 1 }
+
+my($mp1, $mp2);
+
+$mp1 = Math::GMPz->new(2) if $have_gmpz;
+$mp2 = Math::GMP->new(2) if $have_gmp;
+my $fr = Math::MPFR->new(2.5);
+my $d = 2.5;
+my $ld = 2.5;
+my $si = -2;
+my $ui = 2;
+my $mpc = Math::MPC->new(3, 4);
+my $rop = Math::MPC->new();
+my $mpfr = Math::MPFR->new();
+
+Rmpc_pow_d($rop, $mpc, $d, MPC_RNDNN);
+RMPC_RE($mpfr, $rop);
+if($mpfr == -38) {$ok .= 'a'}
+RMPC_IM($mpfr, $rop);
+if($mpfr == 41) {$ok .= 'b'}
+
+eval {Rmpc_pow_ld($rop, $mpc, $ld, MPC_RNDNN);};
+if(!$@) {
+ RMPC_RE($mpfr, $rop);
+ if($mpfr == -38) {$ok .= 'c'}
+ RMPC_IM($mpfr, $rop);
+ if($mpfr == 41) {$ok .= 'd'}
+}
+else {
+ if(! Math::MPC::_has_longdouble() && $@ =~ /not implemented/) {$ok .= 'cd'}
+}
+
+Rmpc_pow_si($rop, $mpc, $si, MPC_RNDNN);
+RMPC_RE($mpfr, $rop);
+if($mpfr > -0.0112001 && $mpfr < -0.0111999) {$ok .= 'e'}
+RMPC_IM($mpfr, $rop);
+if($mpfr > -0.0384001 && $mpfr < -0.0383999) {$ok .= 'f'}
+
+Rmpc_pow_ui($rop, $mpc, $ui, MPC_RNDNN);
+RMPC_RE($mpfr, $rop);
+if($mpfr == -7) {$ok .= 'g'}
+RMPC_IM($mpfr, $rop);
+if($mpfr == 24) {$ok .= 'h'}
+
+if($have_gmpz) {
+ Rmpc_pow_z($rop, $mpc, $mp1, MPC_RNDNN);
+ RMPC_RE($mpfr, $rop);
+ if($mpfr == -7) {$ok .= 'i'}
+ RMPC_IM($mpfr, $rop);
+ if($mpfr == 24) {$ok .= 'j'}
+}
+else {
+ warn "No Math::GMPz - skipping tests 1(i) and 1(j)\n";
+ $ok .= 'ij';
+}
+
+if($have_gmp) {
+ Rmpc_pow_z($rop, $mpc, $mp2, MPC_RNDNN);
+ RMPC_RE($mpfr, $rop);
+ if($mpfr == -7) {$ok .= 'k'}
+ RMPC_IM($mpfr, $rop);
+ if($mpfr == 24) {$ok .= 'l'}
+}
+else {
+ warn "No Math::GMP - skipping tests 1(k) and 1(l)\n";
+ $ok .= 'kl';
+}
+
+Rmpc_pow_fr($rop, $mpc, $fr, MPC_RNDNN);
+RMPC_RE($mpfr, $rop);
+if($mpfr == -38) {$ok .= 'm'}
+RMPC_IM($mpfr, $rop);
+if($mpfr == 41) {$ok .= 'n'}
+
+Rmpc_pow($rop, $mpc, $mpc, MPC_RNDNN);
+RMPC_RE($mpfr, $rop);
+if($mpfr < -2.997990598 && $mpfr > -2.997990599) {$ok .= 'o'}
+RMPC_IM($mpfr, $rop);
+if($mpfr > 0.6237845862 && $mpfr < 0.62378458628) {$ok .= 'p'}
+
+if($ok eq 'abcdefghijklmnop') { print "ok 1\n" }
+else { print "not ok 1 $ok\n" }
+
+$ok = '';
+
+$rop = $mpc ** $d;
+RMPC_RE($mpfr, $rop);
+if($mpfr == -38) {$ok .= 'a'}
+RMPC_IM($mpfr, $rop);
+if($mpfr == 41) {$ok .= 'b'}
+
+$rop = $mpc ** $si;
+RMPC_RE($mpfr, $rop);
+if($mpfr > -0.0112001 && $mpfr < -0.0111999) {$ok .= 'c'}
+RMPC_IM($mpfr, $rop);
+if($mpfr > -0.0384001 && $mpfr < -0.0383999) {$ok .= 'd'}
+
+$rop = $mpc ** $mpc;
+RMPC_RE($mpfr, $rop);
+if($mpfr < -2.997990598 && $mpfr > -2.997990599) {$ok .= 'e'}
+RMPC_IM($mpfr, $rop);
+if($mpfr > 0.6237845862 && $mpfr < 0.62378458628) {$ok .= 'f'}
+
+if($ok eq 'abcdef') {print "ok 2\n"}
+else {print "not ok 2 $ok\n"}
+
+Rmpc_set_ui($mpc, 5, MPC_RNDNN);
+
+Rmpc_mul_2exp($mpc, $mpc, 4, MPC_RNDNN);
+
+if($mpc == 80) {print "ok 3\n"}
+else {
+ warn "\$mpc: $mpc\n";
+ print "not ok 3\n";
+}
+
+eval{Rmpc_mul_2si($mpc, $mpc, -4, MPC_RNDNN);};
+
+if(MPC_VERSION >= 65536) {
+ if($mpc == 5) {print "ok 4\n"}
+ else {
+ warn "\$mpc: $mpc\n";
+ print "not ok 4\n";
+ }
+}
+else {
+ if($@ =~ /mpc_mul_2si not implemented until mpc\-1\.0/) {print "ok 4\n"}
+ else {
+ warn "\$\@: $@\n";
+ print "not ok 4\n";
+ }
+}
+
+#####################################
+Rmpc_set_ui($mpc, 5, MPC_RNDNN);
+
+Rmpc_mul_2ui($mpc, $mpc, 4, MPC_RNDNN);
+
+if($mpc == 80) {print "ok 5\n"}
+else {
+ warn "\$mpc: $mpc\n";
+ print "not ok 5\n";
+}
+
+Rmpc_div_2ui($mpc, $mpc, 4, MPC_RNDNN);
+
+if($mpc == 5) {print "ok 6\n"}
+else {
+ warn "\$mpc: $mpc\n";
+ print "not ok 6\n";
+}
+#####################################
+
+Rmpc_set_ui($mpc, 5, MPC_RNDNN);
+
+eval {Rmpc_div_2si($mpc, $mpc, -4, MPC_RNDNN);};
+
+if(MPC_VERSION >= 65536) {
+ if($mpc == 80) {print "ok 7\n"}
+ else {
+ warn "\$mpc: $mpc\n";
+ print "not ok 7\n";
+ }
+}
+else {
+ if($@ =~ /mpc_div_2si not implemented until mpc\-1\.0/) {print "ok 7\n"}
+ else {
+ warn "\$\@: $@\n";
+ print "not ok 7\n";
+ }
+}
+
+Rmpc_set_ui($mpc, 80, MPC_RNDNN);
+Rmpc_div_2exp($mpc, $mpc, 4, MPC_RNDNN);
+
+if($mpc == 5) {print "ok 8\n"}
+else {
+ warn "\$mpc: $mpc\n";
+ print "not ok 8\n";
+}
+
+print "$mpc\n";
+
+
@@ -1,128 +1,128 @@
-use warnings;
-use strict;
-use Math::MPFR qw(:mpfr);
-use Math::MPC qw(:mpc);
-
-print "1..4\n";
-
-my $mpc1 = Math::MPC->new();
-my @prec = Rmpc_get_default_prec2();
-my $mpc2 = Rmpc_init3(@prec);
-
-Rmpc_set_default_prec2(100, 121);
-Rmpfr_set_default_prec(150);
-
-my $mpc3 = Math::MPC->new();
-@prec = Rmpc_get_default_prec2();
-my $mpc4 = Rmpc_init3(@prec);
-my $mpc5 = Rmpc_init2(200);
-my $mpc6 = Rmpc_init3(150, 180);
-
-my $ok = '';
-
-$ok .= 'a' if $prec[0] == 100 && $prec[1] == 121;
-
-$ok .= 'b' if Rmpfr_get_default_prec() == 150;
-$ok .= 'c' if Rmpc_get_re_prec($mpc1) == 53;
-$ok .= 'd' if Rmpc_get_im_prec($mpc1) == 53;
-$ok .= 'e' if Rmpc_get_re_prec($mpc2) == 53;
-$ok .= 'f' if Rmpc_get_im_prec($mpc2) == 53;
-
-$ok .= 'g' if Rmpc_get_re_prec($mpc3) == 100;
-$ok .= 'h' if Rmpc_get_im_prec($mpc3) == 121;
-$ok .= 'i' if Rmpc_get_re_prec($mpc4) == 100;
-$ok .= 'j' if Rmpc_get_im_prec($mpc4) == 121;
-
-$ok .= 'k' if Rmpc_get_re_prec($mpc5) == 200;
-$ok .= 'l' if Rmpc_get_im_prec($mpc5) == 200;
-$ok .= 'm' if Rmpc_get_re_prec($mpc6) == 150;
-$ok .= 'n' if Rmpc_get_im_prec($mpc6) == 180;
-
-my($re_prec, $im_prec) = Rmpc_get_prec2($mpc6);
-
-$ok .= 'o' if $re_prec == 150;
-$ok .= 'p' if $im_prec == 180;
-
-my $prec = Rmpc_get_prec($mpc6);
-$ok .= 'q' if !$prec;
-
-$prec = Rmpc_get_prec($mpc5);
-$ok .= 'r' if $prec == 200;
-
-$prec = Rmpc_get_prec($mpc4);
-$ok .= 's' if $prec == 0;
-
-@prec = Rmpc_get_prec2($mpc4);
-$ok .= 't' if $prec[0] == 100 && $prec[1] == 121;
-
-Rmpc_set_default_prec2(401, 400);
-$ok .= 'u' if Rmpc_get_default_prec() == 0;
-
-Rmpc_set_default_prec(401);
-$ok .= 'v' if Rmpc_get_default_prec() == 401;
-
-if($ok eq 'abcdefghijklmnopqrstuv') {print "ok 1\n"}
-else {print "not ok 1 $ok\n"}
-
-$ok = '';
-
-Rmpfr_set_default_prec(60);
-
-my $mpfr = Math::MPFR->new();
-
-$ok .= 'a' if Rmpfr_get_prec($mpfr) == 60;
-
-RMPC_RE($mpfr, $mpc6);
-
-$ok .= 'b' if Rmpfr_get_prec($mpfr) == 150;
-
-RMPC_IM($mpfr, $mpc6);
-
-$ok .= 'c' if Rmpfr_get_prec($mpfr) == 180;
-
-
-if($ok eq 'abc') {print "ok 2\n"}
-else {print "not ok 2 $ok\n"}
-
-$ok = '';
-
-Rmpc_set_ui_ui($mpc3, ~0, ~0, MPC_RNDNN);
-
-Rmpc_set_re_prec($mpc3, 111);
-Rmpc_set_im_prec($mpc3, 222);
-
-$ok .= 'a' if Rmpc_get_re_prec($mpc3) == 111;
-$ok .= 'b' if Rmpc_get_im_prec($mpc3) == 222;
-
-RMPC_RE($mpfr, $mpc3);
-
-$ok .= 'c' if Rmpfr_nan_p($mpfr);
-
-RMPC_IM($mpfr, $mpc3);
-
-$ok .= 'd' if Rmpfr_nan_p($mpfr);
-
-if($ok eq 'abcd') {print "ok 3\n"}
-else {print "not ok 3 $ok\n"}
-
-$ok = '';
-
-Rmpfr_set_prec($mpfr, 71);
-my $mpc7 = Math::MPC->new(1234, 5678);
-my $ret = Rmpc_real($mpfr, $mpc7, GMP_RNDN);
-if($ret == 0) {$ok .= 'a'}
-if($mpfr == 1234) {$ok .= 'b'}
-if(Rmpfr_get_prec($mpfr) == 71) {$ok .= 'c'}
-Rmpfr_set_prec($mpfr, 72);
-$ret = Rmpc_imag($mpfr, $mpc7, GMP_RNDN);
-if($ret == 0) {$ok .= 'd'}
-if($mpfr == 5678) {$ok .= 'e'}
-if(Rmpfr_get_prec($mpfr) == 72) {$ok .= 'f'}
-
-if($ok eq 'abcdef') {print "ok 4\n"}
-else {print "not ok 4 $ok\n"}
-
-# Not yet implemented
-#if(RMPC_MAX_PREC($mpc6) > 0) {print "ok 4\n"}
-#else {print "not ok 4: ", RMPC_MAX_PREC($mpc6), "\n"}
-
+use warnings;
+use strict;
+use Math::MPFR qw(:mpfr);
+use Math::MPC qw(:mpc);
+
+print "1..4\n";
+
+my $mpc1 = Math::MPC->new();
+my @prec = Rmpc_get_default_prec2();
+my $mpc2 = Rmpc_init3(@prec);
+
+Rmpc_set_default_prec2(100, 121);
+Rmpfr_set_default_prec(150);
+
+my $mpc3 = Math::MPC->new();
+@prec = Rmpc_get_default_prec2();
+my $mpc4 = Rmpc_init3(@prec);
+my $mpc5 = Rmpc_init2(200);
+my $mpc6 = Rmpc_init3(150, 180);
+
+my $ok = '';
+
+$ok .= 'a' if $prec[0] == 100 && $prec[1] == 121;
+
+$ok .= 'b' if Rmpfr_get_default_prec() == 150;
+$ok .= 'c' if Rmpc_get_re_prec($mpc1) == 53;
+$ok .= 'd' if Rmpc_get_im_prec($mpc1) == 53;
+$ok .= 'e' if Rmpc_get_re_prec($mpc2) == 53;
+$ok .= 'f' if Rmpc_get_im_prec($mpc2) == 53;
+
+$ok .= 'g' if Rmpc_get_re_prec($mpc3) == 100;
+$ok .= 'h' if Rmpc_get_im_prec($mpc3) == 121;
+$ok .= 'i' if Rmpc_get_re_prec($mpc4) == 100;
+$ok .= 'j' if Rmpc_get_im_prec($mpc4) == 121;
+
+$ok .= 'k' if Rmpc_get_re_prec($mpc5) == 200;
+$ok .= 'l' if Rmpc_get_im_prec($mpc5) == 200;
+$ok .= 'm' if Rmpc_get_re_prec($mpc6) == 150;
+$ok .= 'n' if Rmpc_get_im_prec($mpc6) == 180;
+
+my($re_prec, $im_prec) = Rmpc_get_prec2($mpc6);
+
+$ok .= 'o' if $re_prec == 150;
+$ok .= 'p' if $im_prec == 180;
+
+my $prec = Rmpc_get_prec($mpc6);
+$ok .= 'q' if !$prec;
+
+$prec = Rmpc_get_prec($mpc5);
+$ok .= 'r' if $prec == 200;
+
+$prec = Rmpc_get_prec($mpc4);
+$ok .= 's' if $prec == 0;
+
+@prec = Rmpc_get_prec2($mpc4);
+$ok .= 't' if $prec[0] == 100 && $prec[1] == 121;
+
+Rmpc_set_default_prec2(401, 400);
+$ok .= 'u' if Rmpc_get_default_prec() == 0;
+
+Rmpc_set_default_prec(401);
+$ok .= 'v' if Rmpc_get_default_prec() == 401;
+
+if($ok eq 'abcdefghijklmnopqrstuv') {print "ok 1\n"}
+else {print "not ok 1 $ok\n"}
+
+$ok = '';
+
+Rmpfr_set_default_prec(60);
+
+my $mpfr = Math::MPFR->new();
+
+$ok .= 'a' if Rmpfr_get_prec($mpfr) == 60;
+
+RMPC_RE($mpfr, $mpc6);
+
+$ok .= 'b' if Rmpfr_get_prec($mpfr) == 150;
+
+RMPC_IM($mpfr, $mpc6);
+
+$ok .= 'c' if Rmpfr_get_prec($mpfr) == 180;
+
+
+if($ok eq 'abc') {print "ok 2\n"}
+else {print "not ok 2 $ok\n"}
+
+$ok = '';
+
+Rmpc_set_ui_ui($mpc3, ~0, ~0, MPC_RNDNN);
+
+Rmpc_set_re_prec($mpc3, 111);
+Rmpc_set_im_prec($mpc3, 222);
+
+$ok .= 'a' if Rmpc_get_re_prec($mpc3) == 111;
+$ok .= 'b' if Rmpc_get_im_prec($mpc3) == 222;
+
+RMPC_RE($mpfr, $mpc3);
+
+$ok .= 'c' if Rmpfr_nan_p($mpfr);
+
+RMPC_IM($mpfr, $mpc3);
+
+$ok .= 'd' if Rmpfr_nan_p($mpfr);
+
+if($ok eq 'abcd') {print "ok 3\n"}
+else {print "not ok 3 $ok\n"}
+
+$ok = '';
+
+Rmpfr_set_prec($mpfr, 71);
+my $mpc7 = Math::MPC->new(1234, 5678);
+my $ret = Rmpc_real($mpfr, $mpc7, GMP_RNDN);
+if($ret == 0) {$ok .= 'a'}
+if($mpfr == 1234) {$ok .= 'b'}
+if(Rmpfr_get_prec($mpfr) == 71) {$ok .= 'c'}
+Rmpfr_set_prec($mpfr, 72);
+$ret = Rmpc_imag($mpfr, $mpc7, GMP_RNDN);
+if($ret == 0) {$ok .= 'd'}
+if($mpfr == 5678) {$ok .= 'e'}
+if(Rmpfr_get_prec($mpfr) == 72) {$ok .= 'f'}
+
+if($ok eq 'abcdef') {print "ok 4\n"}
+else {print "not ok 4 $ok\n"}
+
+# Not yet implemented
+#if(RMPC_MAX_PREC($mpc6) > 0) {print "ok 4\n"}
+#else {print "not ok 4: ", RMPC_MAX_PREC($mpc6), "\n"}
+
@@ -1,121 +1,121 @@
-use warnings;
-use strict;
-use Math::MPFR qw(:mpfr);
-use Math::MPC qw(:mpc);
-
-print "1..2\n";
-
-my $ok = '';
-
-Rmpc_set_default_rounding_mode(MPC_RNDNN);
-if(Rmpc_get_default_rounding_mode == 0) {$ok = 'a'}
-Rmpc_set_default_rounding_mode(MPC_RNDZN);
-if(Rmpc_get_default_rounding_mode == 1) {$ok .= 'b'}
-Rmpc_set_default_rounding_mode(MPC_RNDUN);
-if(Rmpc_get_default_rounding_mode == 2) {$ok .= 'c'}
-Rmpc_set_default_rounding_mode(MPC_RNDDN);
-if(Rmpc_get_default_rounding_mode == 3) {$ok .= 'd'}
-Rmpc_set_default_rounding_mode(MPC_RNDNZ);
-if(Rmpc_get_default_rounding_mode == 16) {$ok .= 'e'}
-Rmpc_set_default_rounding_mode(MPC_RNDZZ);
-if(Rmpc_get_default_rounding_mode == 17) {$ok .= 'f'}
-Rmpc_set_default_rounding_mode(MPC_RNDUZ);
-if(Rmpc_get_default_rounding_mode == 18) {$ok .= 'g'}
-Rmpc_set_default_rounding_mode(MPC_RNDDZ);
-if(Rmpc_get_default_rounding_mode == 19) {$ok .= 'h'}
-Rmpc_set_default_rounding_mode(MPC_RNDNU);
-if(Rmpc_get_default_rounding_mode == 32) {$ok .= 'i'}
-Rmpc_set_default_rounding_mode(MPC_RNDZU);
-if(Rmpc_get_default_rounding_mode == 33) {$ok .= 'j'}
-Rmpc_set_default_rounding_mode(MPC_RNDUU);
-if(Rmpc_get_default_rounding_mode == 34) {$ok .= 'k'}
-Rmpc_set_default_rounding_mode(MPC_RNDDU);
-if(Rmpc_get_default_rounding_mode == 35) {$ok .= 'l'}
-Rmpc_set_default_rounding_mode(MPC_RNDND);
-if(Rmpc_get_default_rounding_mode == 48) {$ok .= 'm'}
-Rmpc_set_default_rounding_mode(MPC_RNDZD);
-if(Rmpc_get_default_rounding_mode == 49) {$ok .= 'n'}
-Rmpc_set_default_rounding_mode(MPC_RNDUD);
-if(Rmpc_get_default_rounding_mode == 50) {$ok .= 'o'}
-Rmpc_set_default_rounding_mode(MPC_RNDDD);
-if(Rmpc_get_default_rounding_mode == 51) {$ok .= 'p'}
-
-if($ok eq 'abcdefghijklmnop') {print "ok 1\n"}
-else {print "not ok 1 $ok \n"}
-
-$ok = '';
-
-$ok .= 'a' if GMP_RNDN == (MPC_RNDNN & 3);
-$ok .= 'b' if GMP_RNDZ == (MPC_RNDZN & 3);
-$ok .= 'c' if GMP_RNDU == (MPC_RNDUN & 3);
-$ok .= 'd' if GMP_RNDD == (MPC_RNDDN & 3);
-$ok .= 'e' if GMP_RNDN == (MPC_RNDNZ & 3);
-$ok .= 'f' if GMP_RNDZ == (MPC_RNDZZ & 3);
-$ok .= 'g' if GMP_RNDU == (MPC_RNDUZ & 3);
-$ok .= 'h' if GMP_RNDD == (MPC_RNDDZ & 3);
-$ok .= 'i' if GMP_RNDN == (MPC_RNDNU & 3);
-$ok .= 'j' if GMP_RNDZ == (MPC_RNDZU & 3);
-$ok .= 'k' if GMP_RNDU == (MPC_RNDUU & 3);
-$ok .= 'l' if GMP_RNDD == (MPC_RNDDU & 3);
-$ok .= 'm' if GMP_RNDN == (MPC_RNDND & 3);
-$ok .= 'n' if GMP_RNDZ == (MPC_RNDZD & 3);
-$ok .= 'o' if GMP_RNDU == (MPC_RNDUD & 3);
-$ok .= 'p' if GMP_RNDD == (MPC_RNDDD & 3);
-
-$ok .= 'q' if GMP_RNDN == int(MPC_RNDNN / 16);
-$ok .= 'r' if GMP_RNDN == int(MPC_RNDZN / 16);
-$ok .= 's' if GMP_RNDN == int(MPC_RNDUN / 16);
-$ok .= 't' if GMP_RNDN == int(MPC_RNDDN / 16);
-$ok .= 'u' if GMP_RNDZ == int(MPC_RNDNZ / 16);
-$ok .= 'v' if GMP_RNDZ == int(MPC_RNDZZ / 16);
-$ok .= 'w' if GMP_RNDZ == int(MPC_RNDUZ / 16);
-$ok .= 'x' if GMP_RNDZ == int(MPC_RNDDZ / 16);
-$ok .= 'y' if GMP_RNDU == int(MPC_RNDNU / 16);
-$ok .= 'z' if GMP_RNDU == int(MPC_RNDZU / 16);
-$ok .= 'A' if GMP_RNDU == int(MPC_RNDUU / 16);
-$ok .= 'B' if GMP_RNDU == int(MPC_RNDDU / 16);
-$ok .= 'C' if GMP_RNDD == int(MPC_RNDND / 16);
-$ok .= 'D' if GMP_RNDD == int(MPC_RNDZD / 16);
-$ok .= 'E' if GMP_RNDD == int(MPC_RNDUD / 16);
-$ok .= 'F' if GMP_RNDD == int(MPC_RNDDD / 16);
-
-$ok .= 'G' if GMP_RNDN == (GMP_RNDN & 3);
-$ok .= 'H' if GMP_RNDZ == (GMP_RNDZ & 3);
-$ok .= 'I' if GMP_RNDU == (GMP_RNDU & 3);
-$ok .= 'J' if GMP_RNDD == (GMP_RNDD & 3);
-
-if($ok eq 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJ') {print "ok 2\n"}
-else {print "not ok 2 $ok\n"}
-__END__
-N => 0
-Z => 1
-U => 2
-D => 3
-
-0,1,2,3 => 0
-16,17,18,19 => 1
-32,33,34,35 => 2
-48,49,50,51 => 3
-
-RE => RND & 3
-IM => int(RND / 16)
-
-MPC_RNDNN => 0;
-MPC_RNDZN => 1;
-MPC_RNDUN => 2;
-MPC_RNDDN => 3;
-
-MPC_RNDNZ => 16;
-MPC_RNDZZ => 17;
-MPC_RNDUZ => 18;
-MPC_RNDDZ => 19;
-
-MPC_RNDNU => 32;
-MPC_RNDZU => 33;
-MPC_RNDUU => 34;
-MPC_RNDDU => 35;
-
-MPC_RNDND => 48;
-MPC_RNDZD => 49;
-MPC_RNDUD => 50;
-MPC_RNDDD => 51;
\ No newline at end of file
+use warnings;
+use strict;
+use Math::MPFR qw(:mpfr);
+use Math::MPC qw(:mpc);
+
+print "1..2\n";
+
+my $ok = '';
+
+Rmpc_set_default_rounding_mode(MPC_RNDNN);
+if(Rmpc_get_default_rounding_mode == 0) {$ok = 'a'}
+Rmpc_set_default_rounding_mode(MPC_RNDZN);
+if(Rmpc_get_default_rounding_mode == 1) {$ok .= 'b'}
+Rmpc_set_default_rounding_mode(MPC_RNDUN);
+if(Rmpc_get_default_rounding_mode == 2) {$ok .= 'c'}
+Rmpc_set_default_rounding_mode(MPC_RNDDN);
+if(Rmpc_get_default_rounding_mode == 3) {$ok .= 'd'}
+Rmpc_set_default_rounding_mode(MPC_RNDNZ);
+if(Rmpc_get_default_rounding_mode == 16) {$ok .= 'e'}
+Rmpc_set_default_rounding_mode(MPC_RNDZZ);
+if(Rmpc_get_default_rounding_mode == 17) {$ok .= 'f'}
+Rmpc_set_default_rounding_mode(MPC_RNDUZ);
+if(Rmpc_get_default_rounding_mode == 18) {$ok .= 'g'}
+Rmpc_set_default_rounding_mode(MPC_RNDDZ);
+if(Rmpc_get_default_rounding_mode == 19) {$ok .= 'h'}
+Rmpc_set_default_rounding_mode(MPC_RNDNU);
+if(Rmpc_get_default_rounding_mode == 32) {$ok .= 'i'}
+Rmpc_set_default_rounding_mode(MPC_RNDZU);
+if(Rmpc_get_default_rounding_mode == 33) {$ok .= 'j'}
+Rmpc_set_default_rounding_mode(MPC_RNDUU);
+if(Rmpc_get_default_rounding_mode == 34) {$ok .= 'k'}
+Rmpc_set_default_rounding_mode(MPC_RNDDU);
+if(Rmpc_get_default_rounding_mode == 35) {$ok .= 'l'}
+Rmpc_set_default_rounding_mode(MPC_RNDND);
+if(Rmpc_get_default_rounding_mode == 48) {$ok .= 'm'}
+Rmpc_set_default_rounding_mode(MPC_RNDZD);
+if(Rmpc_get_default_rounding_mode == 49) {$ok .= 'n'}
+Rmpc_set_default_rounding_mode(MPC_RNDUD);
+if(Rmpc_get_default_rounding_mode == 50) {$ok .= 'o'}
+Rmpc_set_default_rounding_mode(MPC_RNDDD);
+if(Rmpc_get_default_rounding_mode == 51) {$ok .= 'p'}
+
+if($ok eq 'abcdefghijklmnop') {print "ok 1\n"}
+else {print "not ok 1 $ok \n"}
+
+$ok = '';
+
+$ok .= 'a' if GMP_RNDN == (MPC_RNDNN & 3);
+$ok .= 'b' if GMP_RNDZ == (MPC_RNDZN & 3);
+$ok .= 'c' if GMP_RNDU == (MPC_RNDUN & 3);
+$ok .= 'd' if GMP_RNDD == (MPC_RNDDN & 3);
+$ok .= 'e' if GMP_RNDN == (MPC_RNDNZ & 3);
+$ok .= 'f' if GMP_RNDZ == (MPC_RNDZZ & 3);
+$ok .= 'g' if GMP_RNDU == (MPC_RNDUZ & 3);
+$ok .= 'h' if GMP_RNDD == (MPC_RNDDZ & 3);
+$ok .= 'i' if GMP_RNDN == (MPC_RNDNU & 3);
+$ok .= 'j' if GMP_RNDZ == (MPC_RNDZU & 3);
+$ok .= 'k' if GMP_RNDU == (MPC_RNDUU & 3);
+$ok .= 'l' if GMP_RNDD == (MPC_RNDDU & 3);
+$ok .= 'm' if GMP_RNDN == (MPC_RNDND & 3);
+$ok .= 'n' if GMP_RNDZ == (MPC_RNDZD & 3);
+$ok .= 'o' if GMP_RNDU == (MPC_RNDUD & 3);
+$ok .= 'p' if GMP_RNDD == (MPC_RNDDD & 3);
+
+$ok .= 'q' if GMP_RNDN == int(MPC_RNDNN / 16);
+$ok .= 'r' if GMP_RNDN == int(MPC_RNDZN / 16);
+$ok .= 's' if GMP_RNDN == int(MPC_RNDUN / 16);
+$ok .= 't' if GMP_RNDN == int(MPC_RNDDN / 16);
+$ok .= 'u' if GMP_RNDZ == int(MPC_RNDNZ / 16);
+$ok .= 'v' if GMP_RNDZ == int(MPC_RNDZZ / 16);
+$ok .= 'w' if GMP_RNDZ == int(MPC_RNDUZ / 16);
+$ok .= 'x' if GMP_RNDZ == int(MPC_RNDDZ / 16);
+$ok .= 'y' if GMP_RNDU == int(MPC_RNDNU / 16);
+$ok .= 'z' if GMP_RNDU == int(MPC_RNDZU / 16);
+$ok .= 'A' if GMP_RNDU == int(MPC_RNDUU / 16);
+$ok .= 'B' if GMP_RNDU == int(MPC_RNDDU / 16);
+$ok .= 'C' if GMP_RNDD == int(MPC_RNDND / 16);
+$ok .= 'D' if GMP_RNDD == int(MPC_RNDZD / 16);
+$ok .= 'E' if GMP_RNDD == int(MPC_RNDUD / 16);
+$ok .= 'F' if GMP_RNDD == int(MPC_RNDDD / 16);
+
+$ok .= 'G' if GMP_RNDN == (GMP_RNDN & 3);
+$ok .= 'H' if GMP_RNDZ == (GMP_RNDZ & 3);
+$ok .= 'I' if GMP_RNDU == (GMP_RNDU & 3);
+$ok .= 'J' if GMP_RNDD == (GMP_RNDD & 3);
+
+if($ok eq 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJ') {print "ok 2\n"}
+else {print "not ok 2 $ok\n"}
+__END__
+N => 0
+Z => 1
+U => 2
+D => 3
+
+0,1,2,3 => 0
+16,17,18,19 => 1
+32,33,34,35 => 2
+48,49,50,51 => 3
+
+RE => RND & 3
+IM => int(RND / 16)
+
+MPC_RNDNN => 0;
+MPC_RNDZN => 1;
+MPC_RNDUN => 2;
+MPC_RNDDN => 3;
+
+MPC_RNDNZ => 16;
+MPC_RNDZZ => 17;
+MPC_RNDUZ => 18;
+MPC_RNDDZ => 19;
+
+MPC_RNDNU => 32;
+MPC_RNDZU => 33;
+MPC_RNDUU => 34;
+MPC_RNDDU => 35;
+
+MPC_RNDND => 48;
+MPC_RNDZD => 49;
+MPC_RNDUD => 50;
+MPC_RNDDD => 51;
@@ -1,1239 +1,1239 @@
-use warnings;
-use strict;
-use Math::MPC qw(:mpc);
-use Math::MPFR qw(:mpfr);
-
-print "1..8\n";
-
-print "# Using mpfr version ", MPFR_VERSION_STRING, "\n";
-print "# Usinf mpc library version ", MPC_VERSION_STRING, "\n";
-
-my ($ok, $ret);
-my $round = MPC_RNDNN;
-Rmpc_set_default_prec2(128, 128);
-Rmpfr_set_default_prec(128);
-my $mpc = Math::MPC->new();
-my $mpfr = Math::MPFR->new(12.625);
-my $mpfr2 = $mpfr - 11;
-my $mpfr_re = Math::MPFR->new();
-my $mpfr_im = Math::MPFR->new();
-my $d = 6.5;
-my $d2 = $d - 11;
-my $si = -117;
-my $si2 = $si - 11;
-my $ui = 4294912975;
-my $ui2 = $ui - 11;
-my $uj = 9223372036854721487;
-my $uj2 = $uj - 11;
-my $sj = -36028797018909647;
-my $sj2 = $sj - 11;
-my $ld = -(2 ** 57) + 0.5;
-my $ld2 = $ld - 11;
-
-$ret = Rmpc_set_d_ui($mpc, $d, $ui, $round);
-Rmpc_real($mpfr_re, $mpc, $round);
-Rmpc_imag($mpfr_im, $mpc, $round);
-if($ret == 0 && $mpfr_re == $d && $mpfr_im == $ui) {$ok .= 'a'}
-else {warn "a: $ret $mpfr_re $mpfr_im\n$mpc\n"}
-
-$ret = Rmpc_set_d_si($mpc, $d, $si, $round);
-Rmpc_real($mpfr_re, $mpc, $round);
-Rmpc_imag($mpfr_im, $mpc, $round);
-if($ret == 0 && $mpfr_re == $d && $mpfr_im == $si) {$ok .= 'b'}
-else {warn "b: $ret $mpfr_re $mpfr_im\n$mpc\n"}
-
-$ret = Rmpc_set_d_fr($mpc, $d, $mpfr, $round);
-Rmpc_real($mpfr_re, $mpc, $round);
-Rmpc_imag($mpfr_im, $mpc, $round);
-if($ret == 0 && $mpfr_re == $d && $mpfr_im == $mpfr) {$ok .= 'c'}
-else {warn "c: $ret $mpfr_re $mpfr_im\n$mpc\n"}
-
-$ret = Rmpc_set_ui_d($mpc, $ui, $d, $round);
-Rmpc_real($mpfr_re, $mpc, $round);
-Rmpc_imag($mpfr_im, $mpc, $round);
-if($ret == 0 && $mpfr_re == $ui && $mpfr_im == $d) {$ok .= 'd'}
-else {warn "d: $ret $mpfr_re $mpfr_im\n$mpc\n"}
-
-$ret = Rmpc_set_ui_si($mpc, $ui, $si, $round);
-Rmpc_real($mpfr_re, $mpc, $round);
-Rmpc_imag($mpfr_im, $mpc, $round);
-if($ret == 0 && $mpfr_re == $ui && $mpfr_im == $si) {$ok .= 'e'}
-else {warn "e: $ret $mpfr_re $mpfr_im\n$mpc\n"}
-
-$ret = Rmpc_set_ui_fr($mpc, $ui, $mpfr, $round);
-Rmpc_real($mpfr_re, $mpc, $round);
-Rmpc_imag($mpfr_im, $mpc, $round);
-if($ret == 0 && $mpfr_re == $ui && $mpfr_im == $mpfr) {$ok .= 'f'}
-else {warn "f: $ret $mpfr_re $mpfr_im\n$mpc\n"}
-
-$ret = Rmpc_set_si_d($mpc, $si, $d, $round);
-Rmpc_real($mpfr_re, $mpc, $round);
-Rmpc_imag($mpfr_im, $mpc, $round);
-if($ret == 0 && $mpfr_re == $si && $mpfr_im == $d) {$ok .= 'g'}
-else {warn "g: $ret $mpfr_re $mpfr_im\n$mpc\n"}
-
-$ret = Rmpc_set_si_ui($mpc, $si, $ui, $round);
-Rmpc_real($mpfr_re, $mpc, $round);
-Rmpc_imag($mpfr_im, $mpc, $round);
-if($ret == 0 && $mpfr_re == $si && $mpfr_im == $ui) {$ok .= 'h'}
-else {warn "h: $ret $mpfr_re $mpfr_im\n$mpc\n"}
-
-$ret = Rmpc_set_si_fr($mpc, $si, $mpfr, $round);
-Rmpc_real($mpfr_re, $mpc, $round);
-Rmpc_imag($mpfr_im, $mpc, $round);
-if($ret == 0 && $mpfr_re == $si && $mpfr_im == $mpfr) {$ok .= 'i'}
-else {warn "i: $ret $mpfr_re $mpfr_im\n$mpc\n"}
-
-$ret = Rmpc_set_fr_d($mpc, $mpfr, $d, $round);
-Rmpc_real($mpfr_re, $mpc, $round);
-Rmpc_imag($mpfr_im, $mpc, $round);
-if($ret == 0 && $mpfr_re == $mpfr && $mpfr_im == $d) {$ok .= 'j'}
-else {warn "j: $ret $mpfr_re $mpfr_im\n$mpc\n"}
-
-$ret = Rmpc_set_fr_ui($mpc, $mpfr, $ui, $round);
-Rmpc_real($mpfr_re, $mpc, $round);
-Rmpc_imag($mpfr_im, $mpc, $round);
-if($ret == 0 && $mpfr_re == $mpfr && $mpfr_im == $ui) {$ok .= 'k'}
-else {warn "k: $ret $mpfr_re $mpfr_im\n$mpc\n"}
-
-$ret = Rmpc_set_fr_si($mpc, $mpfr, $si, $round);
-Rmpc_real($mpfr_re, $mpc, $round);
-Rmpc_imag($mpfr_im, $mpc, $round);
-if($ret == 0 && $mpfr_re == $mpfr && $mpfr_im == $si) {$ok .= 'l'}
-else {warn "l: $ret $mpfr_re $mpfr_im\n$mpc\n"}
-
-### 64-bit int
-if(Math::MPC::_has_longlong()) {
- $ret = Rmpc_set_d_uj($mpc, $d, $uj, $round);
- Rmpc_real($mpfr_re, $mpc, $round);
- Rmpc_imag($mpfr_im, $mpc, $round);
- if($ret == 0 && $mpfr_re == $d && $mpfr_im == $uj) {$ok .= 'm'}
- else {warn "m: $ret $mpfr_re $mpfr_im\n$mpc\n"}
-
- $ret = Rmpc_set_d_sj($mpc, $d, $sj, $round);
- Rmpc_real($mpfr_re, $mpc, $round);
- Rmpc_imag($mpfr_im, $mpc, $round);
- if($ret == 0 && $mpfr_re == $d && $mpfr_im == $sj) {$ok .= 'n'}
- else {warn "n: $ret $mpfr_re $mpfr_im\n$mpc\n"}
-
- $ret = Rmpc_set_uj_d($mpc, $uj, $d, $round);
- Rmpc_real($mpfr_re, $mpc, $round);
- Rmpc_imag($mpfr_im, $mpc, $round);
- if($ret == 0 && $mpfr_re == $uj && $mpfr_im == $d) {$ok .= 'o'}
- else {warn "o: $ret $mpfr_re $mpfr_im\n$mpc\n"}
-
- $ret = Rmpc_set_sj_d($mpc, $sj, $d, $round);
- Rmpc_real($mpfr_re, $mpc, $round);
- Rmpc_imag($mpfr_im, $mpc, $round);
- if($ret == 0 && $mpfr_re == $sj && $mpfr_im == $d) {$ok .= 'p'}
- else {warn "p: $ret $mpfr_re $mpfr_im\n$mpc\n"}
-
- $ret = Rmpc_set_uj_fr($mpc, $uj, $mpfr, $round);
- Rmpc_real($mpfr_re, $mpc, $round);
- Rmpc_imag($mpfr_im, $mpc, $round);
- if($ret == 0 && $mpfr_re == $uj && $mpfr_im == $mpfr) {$ok .= 'q'}
- else {warn "q: $ret $mpfr_re $mpfr_im\n$mpc\n"}
-
- $ret = Rmpc_set_sj_fr($mpc, $sj, $mpfr, $round);
- Rmpc_real($mpfr_re, $mpc, $round);
- Rmpc_imag($mpfr_im, $mpc, $round);
- if($ret == 0 && $mpfr_re == $sj && $mpfr_im == $mpfr) {$ok .= 'r'}
- else {warn "r: $ret $mpfr_re $mpfr_im\n$mpc\n"}
-
- $ret = Rmpc_set_fr_uj($mpc, $mpfr, $uj, $round);
- Rmpc_real($mpfr_re, $mpc, $round);
- Rmpc_imag($mpfr_im, $mpc, $round);
- if($ret == 0 && $mpfr_re == $mpfr && $mpfr_im == $uj) {$ok .= 's'}
- else {warn "s: $ret $mpfr_re $mpfr_im\n$mpc\n"}
-
- $ret = Rmpc_set_fr_sj($mpc, $mpfr, $sj, $round);
- Rmpc_real($mpfr_re, $mpc, $round);
- Rmpc_imag($mpfr_im, $mpc, $round);
- if($ret == 0 && $mpfr_re == $mpfr && $mpfr_im == $sj) {$ok .= 't'}
- else {warn "t: $ret $mpfr_re $mpfr_im\n$mpc\n"}
-
- $ret = Rmpc_set_uj_sj($mpc, $uj, $sj, $round);
- Rmpc_real($mpfr_re, $mpc, $round);
- Rmpc_imag($mpfr_im, $mpc, $round);
- if($ret == 0 && $mpfr_re == $uj && $mpfr_im == $sj) {$ok .= 'u'}
- else {warn "u: $ret $mpfr_re $mpfr_im\n$mpc\n"}
-
- $ret = Rmpc_set_sj_uj($mpc, $sj, $uj, $round);
- Rmpc_real($mpfr_re, $mpc, $round);
- Rmpc_imag($mpfr_im, $mpc, $round);
- if($ret == 0 && $mpfr_re == $sj && $mpfr_im == $uj) {$ok .= 'v'}
- else {warn "v: $ret $mpfr_re $mpfr_im\n$mpc\n"}
-}
-else {
- eval {Rmpc_set_d_uj($mpc, $d, $uj, $round);};
- if($@ =~ /Rmpc_set_d_uj not implemented/) {$ok .= 'm'}
- else {warn "m: \$\@: $@\n"}
- eval {Rmpc_set_d_sj($mpc, $d, $sj, $round);};
- if($@ =~ /Rmpc_set_d_sj not implemented/) {$ok .= 'n'}
- else {warn "n: \$\@: $@\n"}
- eval {Rmpc_set_uj_d($mpc, $uj, $d, $round);};
- if($@ =~ /Rmpc_set_uj_d not implemented/) {$ok .= 'o'}
- else {warn "o: \$\@: $@\n"}
- eval {Rmpc_set_sj_d($mpc, $sj, $d, $round);};
- if($@ =~ /Rmpc_set_sj_d not implemented/) {$ok .= 'p'}
- else {warn "p: \$\@: $@\n"}
- eval {Rmpc_set_uj_fr($mpc, $uj, $mpfr, $round);};
- if($@ =~ /Rmpc_set_uj_fr not implemented/) {$ok .= 'q'}
- else {warn "q: \$\@: $@\n"}
- eval {Rmpc_set_sj_fr($mpc, $sj, $mpfr, $round);};
- if($@ =~ /Rmpc_set_sj_fr not implemented/) {$ok .= 'r'}
- else {warn "r: \$\@: $@\n"}
- eval {Rmpc_set_fr_uj($mpc, $mpfr, $uj, $round);};
- if($@ =~ /Rmpc_set_fr_uj not implemented/) {$ok .= 's'}
- else {warn "s: \$\@: $@\n"}
- eval {Rmpc_set_fr_sj($mpc, $mpfr, $sj, $round);};
- if($@ =~ /Rmpc_set_fr_sj not implemented/) {$ok .= 't'}
- else {warn "t: \$\@: $@\n"}
- eval {Rmpc_set_uj_sj($mpc, $uj, $sj, $round);};
- if($@ =~ /Rmpc_set_uj_sj not implemented/) {$ok .= 'u'}
- else {warn "u: \$\@: $@\n"}
- eval {Rmpc_set_sj_uj($mpc, $sj, $uj, $round);};
- if($@ =~ /Rmpc_set_sj_uj not implemented/) {$ok .= 'v'}
- else {warn "v: \$\@: $@\n"}
-}
-
-if(Math::MPC::_has_longdouble()) {
- $ret = Rmpc_set_ui_ld($mpc, $ui, $ld, $round);
- Rmpc_real($mpfr_re, $mpc, $round);
- Rmpc_imag($mpfr_im, $mpc, $round);
- if($ret == 0 && $mpfr_re == $ui && $mpfr_im == $ld) {$ok .= 'w'}
- else {warn "w: $ret $mpfr_re $mpfr_im\n$mpc\n"}
-
- $ret = Rmpc_set_si_ld($mpc, $si, $ld, $round);
- Rmpc_real($mpfr_re, $mpc, $round);
- Rmpc_imag($mpfr_im, $mpc, $round);
- if($ret == 0 && $mpfr_re == $si && $mpfr_im == $ld) {$ok .= 'x'}
- else {warn "x: $ret $mpfr_re $mpfr_im\n$mpc\n"}
-
- $ret = Rmpc_set_fr_ld($mpc, $mpfr, $ld, $round);
- Rmpc_real($mpfr_re, $mpc, $round);
- Rmpc_imag($mpfr_im, $mpc, $round);
- if($ret == 0 && $mpfr_re == $mpfr && $mpfr_im == $ld) {$ok .= 'y'}
- else {warn "y: $ret $mpfr_re $mpfr_im\n$mpc\n"}
-
- $ret = Rmpc_set_ld_ui($mpc, $ld, $ui, $round);
- Rmpc_real($mpfr_re, $mpc, $round);
- Rmpc_imag($mpfr_im, $mpc, $round);
- if($ret == 0 && $mpfr_re == $ld && $mpfr_im == $ui) {$ok .= 'z'}
- else {warn "z: $ret $mpfr_re $mpfr_im\n$mpc\n"}
-
- $ret = Rmpc_set_ld_si($mpc, $ld, $si, $round);
- Rmpc_real($mpfr_re, $mpc, $round);
- Rmpc_imag($mpfr_im, $mpc, $round);
- if($ret == 0 && $mpfr_re == $ld && $mpfr_im == $si) {$ok .= 'A'}
- else {warn "A: $ret $mpfr_re $mpfr_im\n$mpc\n"}
-
- $ret = Rmpc_set_ld_fr($mpc, $ld, $mpfr, $round);
- Rmpc_real($mpfr_re, $mpc, $round);
- Rmpc_imag($mpfr_im, $mpc, $round);
- if($ret == 0 && $mpfr_re == $ld && $mpfr_im == $mpfr) {$ok .= 'B'}
- else {warn "B: $ret $mpfr_re $mpfr_im\n$mpc\n"}
-}else {
- eval {Rmpc_set_ui_ld($mpc, $ui, $ld, $round);};
- if($@ =~ /Rmpc_set_ui_ld not implemented/) {$ok .= 'w'}
- else {warn "w: \$\@: $@\n"}
- eval {Rmpc_set_si_ld($mpc, $si, $ld, $round);};
- if($@ =~ /Rmpc_set_si_ld not implemented/) {$ok .= 'x'}
- else {warn "x: \$\@: $@\n"}
- eval {Rmpc_set_fr_ld($mpc, $mpfr, $ld, $round);};
- if($@ =~ /Rmpc_set_fr_ld not implemented/) {$ok .= 'y'}
- else {warn "y: \$\@: $@\n"}
- eval {Rmpc_set_ld_ui($mpc, $ld, $ui, $round);};
- if($@ =~ /Rmpc_set_ld_ui not implemented/) {$ok .= 'z'}
- else {warn "z: \$\@: $@\n"}
- eval {Rmpc_set_ld_si($mpc, $ld, $si, $round);};
- if($@ =~ /Rmpc_set_ld_si not implemented/) {$ok .= 'A'}
- else {warn "A: \$\@: $@\n"}
- eval {Rmpc_set_ld_fr($mpc, $ld, $mpfr, $round);};
- if($@ =~ /Rmpc_set_ld_fr not implemented/) {$ok .= 'B'}
- else {warn "B: \$\@: $@\n"}
-}
-
-if(Math::MPC::_has_longlong() && Math::MPC::_has_longdouble()) {
- $ret = Rmpc_set_ld_uj($mpc, $ld, $uj, $round);
- Rmpc_real($mpfr_re, $mpc, $round);
- Rmpc_imag($mpfr_im, $mpc, $round);
- if($ret == 0 && $mpfr_re == $ld && $mpfr_im == $uj) {$ok .= 'C'}
- else {warn "C: $ret $mpfr_re $mpfr_im\n$mpc\n"}
-
- $ret = Rmpc_set_ld_sj($mpc, $ld, $sj, $round);
- Rmpc_real($mpfr_re, $mpc, $round);
- Rmpc_imag($mpfr_im, $mpc, $round);
- if($ret == 0 && $mpfr_re == $ld && $mpfr_im == $sj) {$ok .= 'D'}
- else {warn "D: $ret $mpfr_re $mpfr_im\n$mpc\n"}
-
- $ret = Rmpc_set_uj_ld($mpc, $uj, $ld, $round);
- Rmpc_real($mpfr_re, $mpc, $round);
- Rmpc_imag($mpfr_im, $mpc, $round);
- if($ret == 0 && $mpfr_re == $uj && $mpfr_im == $ld) {$ok .= 'E'}
- else {warn "E: $ret $mpfr_re $mpfr_im\n$mpc\n"}
-
- $ret = Rmpc_set_sj_ld($mpc, $sj, $ld, $round);
- Rmpc_real($mpfr_re, $mpc, $round);
- Rmpc_imag($mpfr_im, $mpc, $round);
- if($ret == 0 && $mpfr_re == $sj && $mpfr_im == $ld) {$ok .= 'F'}
- else {warn "F: $ret $mpfr_re $mpfr_im\n$mpc\n"}
-}
-else {
- eval {Rmpc_set_uj_ld($mpc, $ui, $ld, $round);};
- if($@ =~ /Rmpc_set_uj_ld not implemented/) {$ok .= 'C'}
- else {warn "C: \$\@: $@\n"}
- eval {Rmpc_set_sj_ld($mpc, $sj, $ld, $round);};
- if($@ =~ /Rmpc_set_sj_ld not implemented/) {$ok .= 'D'}
- else {warn "D: \$\@: $@\n"}
- eval {Rmpc_set_ld_sj($mpc, $ld, $sj, $round);};
- if($@ =~ /Rmpc_set_ld_sj not implemented/) {$ok .= 'E'}
- else {warn "E: \$\@: $@\n"}
- eval {Rmpc_set_ld_uj($mpc, $ld, $uj, $round);};
- if($@ =~ /Rmpc_set_ld_uj not implemented/) {$ok .= 'F'}
- else {warn "F: \$\@: $@\n"}
-}
-
-### X_X (d_d, ui_ui, si_si, fr_fr)
-
-$ret = Rmpc_set_ui_ui($mpc, $ui, $ui2, $round);
-Rmpc_real($mpfr_re, $mpc, $round);
-Rmpc_imag($mpfr_im, $mpc, $round);
-if($ret == 0 && $mpfr_re == $ui && $mpfr_im == $ui - 11) {$ok .= 'G'}
-else {warn "G: $ret $mpfr_re $mpfr_im\n$mpc\n"}
-
-$ret = Rmpc_set_d_d($mpc, $d, $d2, $round);
-Rmpc_real($mpfr_re, $mpc, $round);
-Rmpc_imag($mpfr_im, $mpc, $round);
-if($ret == 0 && $mpfr_re == $d && $mpfr_im == $d - 11) {$ok .= 'H'}
-else {warn "H: $ret $mpfr_re $mpfr_im\n$mpc\n"}
-
-$ret = Rmpc_set_si_si($mpc, $si, $si2, $round);
-Rmpc_real($mpfr_re, $mpc, $round);
-Rmpc_imag($mpfr_im, $mpc, $round);
-if($ret == 0 && $mpfr_re == $si && $mpfr_im == $si - 11) {$ok .= 'I'}
-else {warn "I: $ret $mpfr_re $mpfr_im\n$mpc\n"}
-
-$ret = Rmpc_set_fr_fr($mpc, $mpfr, $mpfr2, $round);
-Rmpc_real($mpfr_re, $mpc, $round);
-Rmpc_imag($mpfr_im, $mpc, $round);
-if($ret == 0 && $mpfr_re == $mpfr && $mpfr_im == $mpfr - 11) {$ok .= 'J'}
-else {warn "J: $ret $mpfr_re $mpfr_im\n$mpc\n"}
-
-if(Math::MPC::_has_longlong()) {
- $ret = Rmpc_set_uj_uj($mpc, $uj, $uj2, $round);
- Rmpc_real($mpfr_re, $mpc, $round);
- Rmpc_imag($mpfr_im, $mpc, $round);
- if($ret == 0 && $mpfr_re == $uj && $mpfr_im == $uj - 11) {$ok .= 'K'}
- else {warn "K: $ret $mpfr_re $mpfr_im\n$mpc\n"}
-
- $ret = Rmpc_set_sj_sj($mpc, $sj, $sj2, $round);
- Rmpc_real($mpfr_re, $mpc, $round);
- Rmpc_imag($mpfr_im, $mpc, $round);
- if($ret == 0 && $mpfr_re == $sj && $mpfr_im == $sj - 11) {$ok .= 'L'}
- else {warn "L: $ret $mpfr_re $mpfr_im\n$mpc\n"}
-
- $ret = Rmpc_set_uj_si($mpc, $uj, $si, $round);
- Rmpc_real($mpfr_re, $mpc, $round);
- Rmpc_imag($mpfr_im, $mpc, $round);
- if($ret == 0 && $mpfr_re == $uj && $mpfr_im == $si) {$ok .= 'M'}
- else {warn "M: $ret $mpfr_re $mpfr_im\n$mpc\n"}
-
- $ret = Rmpc_set_ui_sj($mpc, $ui, $sj, $round);
- Rmpc_real($mpfr_re, $mpc, $round);
- Rmpc_imag($mpfr_im, $mpc, $round);
- if($ret == 0 && $mpfr_re == $ui && $mpfr_im == $sj) {$ok .= 'N'}
- else {warn "N: $ret $mpfr_re $mpfr_im\n$mpc\n"}
-
- $ret = Rmpc_set_sj_ui($mpc, $sj, $ui, $round);
- Rmpc_real($mpfr_re, $mpc, $round);
- Rmpc_imag($mpfr_im, $mpc, $round);
- if($ret == 0 && $mpfr_re == $sj && $mpfr_im == $ui) {$ok .= 'O'}
- else {warn "O: $ret $mpfr_re $mpfr_im\n$mpc\n"}
-
- $ret = Rmpc_set_si_uj($mpc, $si, $uj, $round);
- Rmpc_real($mpfr_re, $mpc, $round);
- Rmpc_imag($mpfr_im, $mpc, $round);
- if($ret == 0 && $mpfr_re == $si && $mpfr_im == $uj) {$ok .= 'P'}
- else {warn "P: $ret $mpfr_re $mpfr_im\n$mpc\n"}
-
- $ret = Rmpc_set_uj_ui($mpc, $uj, $ui, $round);
- Rmpc_real($mpfr_re, $mpc, $round);
- Rmpc_imag($mpfr_im, $mpc, $round);
- if($ret == 0 && $mpfr_re == $uj && $mpfr_im == $ui) {$ok .= 'Q'}
- else {warn "Q: $ret $mpfr_re $mpfr_im\n$mpc\n"}
-
- $ret = Rmpc_set_ui_uj($mpc, $ui, $uj, $round);
- Rmpc_real($mpfr_re, $mpc, $round);
- Rmpc_imag($mpfr_im, $mpc, $round);
- if($ret == 0 && $mpfr_re == $ui && $mpfr_im == $uj) {$ok .= 'R'}
- else {warn "R: $ret $mpfr_re $mpfr_im\n$mpc\n"}
-
- $ret = Rmpc_set_sj_si($mpc, $sj, $si, $round);
- Rmpc_real($mpfr_re, $mpc, $round);
- Rmpc_imag($mpfr_im, $mpc, $round);
- if($ret == 0 && $mpfr_re == $sj && $mpfr_im == $si) {$ok .= 'S'}
- else {warn "S: $ret $mpfr_re $mpfr_im\n$mpc\n"}
-
- $ret = Rmpc_set_si_sj($mpc, $si, $sj, $round);
- Rmpc_real($mpfr_re, $mpc, $round);
- Rmpc_imag($mpfr_im, $mpc, $round);
- if($ret == 0 && $mpfr_re == $si && $mpfr_im == $sj) {$ok .= 'T'}
- else {warn "T: $ret $mpfr_re $mpfr_im\n$mpc\n"}
-}
-else {
- eval {Rmpc_set_uj_uj($mpc, $uj, $uj2, $round);};
- if($@ =~ /Rmpc_set_uj_uj not implemented/) {$ok .= 'K'}
- else {warn "K: \$\@: $@\n"}
-
- eval {Rmpc_set_sj_sj($mpc, $sj, $sj, $round);};
- if($@ =~ /Rmpc_set_sj_sj not implemented/) {$ok .= 'L'}
- else {warn "L: \$\@: $@\n"}
-
- eval {Rmpc_set_uj_si($mpc, $uj, $si, $round);};
- if($@ =~ /Rmpc_set_uj_sj not implemented/) {$ok .= 'M'}
- else {warn "M: \$\@: $@\n"}
-
- eval {Rmpc_set_ui_sj($mpc, $ui, $sj, $round);};
- if($@ =~ /Rmpc_set_uj_sj not implemented/) {$ok .= 'N'}
- else {warn "N: \$\@: $@\n"}
-
- eval {Rmpc_set_sj_ui($mpc, $sj, $ui, $round);};
- if($@ =~ /Rmpc_set_sj_uj not implemented/) {$ok .= 'O'}
- else {warn "O: \$\@: $@\n"}
-
- eval {Rmpc_set_si_uj($mpc, $si, $uj, $round);};
- if($@ =~ /Rmpc_set_sj_uj not implemented/) {$ok .= 'P'}
- else {warn "P: \$\@: $@\n"}
-
- eval {Rmpc_set_uj_ui($mpc, $uj, $ui, $round);};
- if($@ =~ /Rmpc_set_uj_uj not implemented/) {$ok .= 'Q'}
- else {warn "Q: \$\@: $@\n"}
-
- eval {Rmpc_set_ui_uj($mpc, $ui, $uj, $round);};
- if($@ =~ /Rmpc_set_uj_uj not implemented/) {$ok .= 'R'}
- else {warn "R: \$\@: $@\n"}
-
- eval {Rmpc_set_sj_si($mpc, $sj, $si, $round);};
- if($@ =~ /Rmpc_set_sj_sj not implemented/) {$ok .= 'S'}
- else {warn "S: \$\@: $@\n"}
-
- eval {Rmpc_set_si_sj($mpc, $si, $sj, $round);};
- if($@ =~ /Rmpc_set_sj_sj not implemented/) {$ok .= 'T'}
- else {warn "T: \$\@: $@\n"}
-}
-
-if(Math::MPC::_has_longdouble()) {
- $ret = Rmpc_set_ld_ld($mpc, $ld, $ld2, $round);
- Rmpc_real($mpfr_re, $mpc, $round);
- Rmpc_imag($mpfr_im, $mpc, $round);
- if($ret == 0 && $mpfr_re == $ld && $mpfr_im == $ld - 11) {$ok .= 'U'}
- else {warn "U: $ret $mpfr_re $mpfr_im\n$mpc\n"}
-
- $ret = Rmpc_set_d_ld($mpc, $d, $ld, $round);
- Rmpc_real($mpfr_re, $mpc, $round);
- Rmpc_imag($mpfr_im, $mpc, $round);
- if($ret == 0 && $mpfr_re == $d && $mpfr_im == $ld) {$ok .= 'V'}
- else {warn "V: $ret $mpfr_re $mpfr_im\n$mpc\n"}
-
- $ret = Rmpc_set_ld_d($mpc, $ld, $d, $round);
- Rmpc_real($mpfr_re, $mpc, $round);
- Rmpc_imag($mpfr_im, $mpc, $round);
- if($ret == 0 && $mpfr_re == $ld && $mpfr_im == $d) {$ok .= 'W'}
- else {warn "W: $ret $mpfr_re $mpfr_im\n$mpc\n"}
-
- $ret = Rmpc_set_ld($mpc, $ld, $round);
- Rmpc_real($mpfr_re, $mpc, $round);
- Rmpc_imag($mpfr_im, $mpc, $round);
- if($ret == 0 && $mpfr_re == $ld && $mpfr_im == 0) {$ok .= 'X'}
- else {warn "X: $ret $mpfr_re $mpfr_im\n$mpc\n"}
-}
-else{
- eval {Rmpc_set_ld_ld($mpc, $ld, $ld2, $round);};
- if($@ =~ /Rmpc_set_ld_ld not implemented/) {$ok .= 'U'}
- else {warn "U: \$\@: $@\n"}
-
- eval {Rmpc_set_d_ld($mpc, $d, $ld, $round);};
- if($@ =~ /Rmpc_set_ld_ld not implemented/) {$ok .= 'V'}
- else {warn "V: \$\@: $@\n"}
-
- eval {Rmpc_set_ld_d($mpc, $ld, $d, $round);};
- if($@ =~ /Rmpc_set_ld_ld not implemented/) {$ok .= 'W'}
- else {warn "W: \$\@: $@\n"}
-
- eval {Rmpc_set_ld($mpc, $ld, $round);};
- if($@ =~ /Rmpc_set_ld not implemented/) {$ok .= 'X'}
- else {warn "X: \$\@: $@\n"}
-}
-
-if($ok eq 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWX') {print "ok 1\n"}
-else {print "not ok 1\n$ok\n"}
-
-$ok = '';
-
-$ret = Rmpc_set_ui($mpc, $ui, $round);
-Rmpc_real($mpfr_re, $mpc, $round);
-Rmpc_imag($mpfr_im, $mpc, $round);
-if($ret == 0 && $mpfr_re == $ui && $mpfr_im == 0) {$ok .= 'a'}
-else {warn "2a: $ret $mpfr_re $mpfr_im\n$mpc\n"}
-
-$ret = Rmpc_set_si($mpc, $si, $round);
-Rmpc_real($mpfr_re, $mpc, $round);
-Rmpc_imag($mpfr_im, $mpc, $round);
-if($ret == 0 && $mpfr_re == $si && $mpfr_im == 0) {$ok .= 'b'}
-else {warn "2b: $ret $mpfr_re $mpfr_im\n$mpc\n"}
-
-$ret = Rmpc_set_d($mpc, $d, $round);
-Rmpc_real($mpfr_re, $mpc, $round);
-Rmpc_imag($mpfr_im, $mpc, $round);
-if($ret == 0 && $mpfr_re == $d && $mpfr_im == 0) {$ok .= 'c'}
-else {warn "2c: $ret $mpfr_re $mpfr_im\n$mpc\n"}
-
-if(Math::MPC::_has_longlong()) {
- $ret = Rmpc_set_uj($mpc, $uj, $round);
- Rmpc_real($mpfr_re, $mpc, $round);
- Rmpc_imag($mpfr_im, $mpc, $round);
- if($ret == 0 && $mpfr_re == $uj && $mpfr_im == 0) {$ok .= 'd'}
- else {warn "2d: $ret $mpfr_re $mpfr_im\n$mpc\n"}
-
- $ret = Rmpc_set_sj($mpc, $sj, $round);
- Rmpc_real($mpfr_re, $mpc, $round);
- Rmpc_imag($mpfr_im, $mpc, $round);
- if($ret == 0 && $mpfr_re == $sj && $mpfr_im == 0) {$ok .= 'e'}
- else {warn "2e: $ret $mpfr_re $mpfr_im\n$mpc\n"}
-}
-else {
- eval {Rmpc_set_uj($mpc, $uj, $round);};
- if($@ =~ /Rmpc_set_uj not implemented/) {$ok .= 'd'}
- else {warn "2d: \$\@: $@\n"}
-
- eval {Rmpc_set_sj($mpc, $sj, $round);};
- if($@ =~ /Rmpc_set_sj not implemented/) {$ok .= 'e'}
- else {warn "2e: \$\@: $@\n"}
-}
-
-# Rmpc_set_ld is already checked above
-
-$ret = Rmpc_set_fr($mpc, $mpfr, $round);
-Rmpc_real($mpfr_re, $mpc, $round);
-Rmpc_imag($mpfr_im, $mpc, $round);
-if($ret == 0 && $mpfr_re == $mpfr && $mpfr_im == 0) {$ok .= 'f'}
-else {warn "2d: $ret $mpfr_re $mpfr_im\n$mpc\n"}
-
-if($ok eq 'abcdef') {print "ok 2\n"}
-else {print "not ok 2\n$ok\n"}
-
-my ($have_GMP, $have_GMPz, $have_GMPq, $have_GMPf) = (0, 0, 0, 0);
-
-eval{require Math::GMP;};
-$have_GMP = 1 if !$@;
-
-eval{require Math::GMPz;};
-$have_GMPz = 1 if !$@;
-
-eval{require Math::GMPq;};
-$have_GMPq = 1 if !$@;
-
-eval{require Math::GMPf;};
-$have_GMPf = 1 if !$@;
-
-if($have_GMP) {
- $ok = '';
- my $gmp = Math::GMP->new(1234567);
- $ret = Rmpc_set_z($mpc, $gmp, $round);
- Rmpc_real($mpfr_re, $mpc, $round);
- Rmpc_imag($mpfr_im, $mpc, $round);
- if($ret == 0 && $mpfr_re == 1234567 && $mpfr_im == 0) {$ok .= 'a'}
- else {warn "3a: $ret $mpfr_re $mpfr_im\n$mpc\n"}
-
- my $gmp2 = Math::GMP->new(890);
- $ret = Rmpc_set_z_z($mpc, $gmp, $gmp2, $round);
- Rmpc_real($mpfr_re, $mpc, $round);
- Rmpc_imag($mpfr_im, $mpc, $round);
- if($ret == 0 && $mpfr_re == 1234567 && $mpfr_im == 890) {$ok .= 'b'}
- else {warn "3b: $ret $mpfr_re $mpfr_im\n$mpc\n"}
-
-
- $ret = Rmpc_set_z_ui($mpc, $gmp, $ui, $round);
- Rmpc_real($mpfr_re, $mpc, $round);
- Rmpc_imag($mpfr_im, $mpc, $round);
- if($ret == 0 && $mpfr_re == 1234567 && $mpfr_im == $ui) {$ok .= 'c'}
- else {warn "3c: $ret $mpfr_re $mpfr_im\n$mpc\n"}
-
- $ret = Rmpc_set_ui_z($mpc, $ui, $gmp, $round);
- Rmpc_real($mpfr_re, $mpc, $round);
- Rmpc_imag($mpfr_im, $mpc, $round);
- if($ret == 0 && $mpfr_re == $ui && $mpfr_im == 1234567) {$ok .= 'd'}
- else {warn "3d: $ret $mpfr_re $mpfr_im\n$mpc\n"}
-
- $ret = Rmpc_set_z_si($mpc, $gmp, $si, $round);
- Rmpc_real($mpfr_re, $mpc, $round);
- Rmpc_imag($mpfr_im, $mpc, $round);
- if($ret == 0 && $mpfr_re == 1234567 && $mpfr_im == $si) {$ok .= 'e'}
- else {warn "4e: $ret $mpfr_re $mpfr_im\n$mpc\n"}
-
- $ret = Rmpc_set_si_z($mpc, $si, $gmp, $round);
- Rmpc_real($mpfr_re, $mpc, $round);
- Rmpc_imag($mpfr_im, $mpc, $round);
- if($ret == 0 && $mpfr_re == $si && $mpfr_im == 1234567) {$ok .= 'f'}
- else {warn "3f: $ret $mpfr_re $mpfr_im\n$mpc\n"}
-
- $ret = Rmpc_set_z_d($mpc, $gmp, $d, $round);
- Rmpc_real($mpfr_re, $mpc, $round);
- Rmpc_imag($mpfr_im, $mpc, $round);
- if($ret == 0 && $mpfr_re == 1234567 && $mpfr_im == $d) {$ok .= 'g'}
- else {warn "3g: $ret $mpfr_re $mpfr_im\n$mpc\n"}
-
- $ret = Rmpc_set_d_z($mpc, $d, $gmp, $round);
- Rmpc_real($mpfr_re, $mpc, $round);
- Rmpc_imag($mpfr_im, $mpc, $round);
- if($ret == 0 && $mpfr_re == $d && $mpfr_im == 1234567) {$ok .= 'h'}
- else {warn "3h: $ret $mpfr_re $mpfr_im\n$mpc\n"}
-
- if(Math::MPC::_has_longlong()) {
- $ret = Rmpc_set_z_uj($mpc, $gmp, $uj, $round);
- Rmpc_real($mpfr_re, $mpc, $round);
- Rmpc_imag($mpfr_im, $mpc, $round);
- if($ret == 0 && $mpfr_re == 1234567 && $mpfr_im == $uj) {$ok .= 'i'}
- else {warn "3i: $ret $mpfr_re $mpfr_im\n$mpc\n"}
-
- $ret = Rmpc_set_uj_z($mpc, $uj, $gmp, $round);
- Rmpc_real($mpfr_re, $mpc, $round);
- Rmpc_imag($mpfr_im, $mpc, $round);
- if($ret == 0 && $mpfr_re == $uj && $mpfr_im == 1234567) {$ok .= 'j'}
- else {warn "3j: $ret $mpfr_re $mpfr_im\n$mpc\n"}
-
- $ret = Rmpc_set_z_sj($mpc, $gmp, $sj, $round);
- Rmpc_real($mpfr_re, $mpc, $round);
- Rmpc_imag($mpfr_im, $mpc, $round);
- if($ret == 0 && $mpfr_re == 1234567 && $mpfr_im == $sj) {$ok .= 'k'}
- else {warn "3k: $ret $mpfr_re $mpfr_im\n$mpc\n"}
-
- $ret = Rmpc_set_sj_z($mpc, $sj, $gmp, $round);
- Rmpc_real($mpfr_re, $mpc, $round);
- Rmpc_imag($mpfr_im, $mpc, $round);
- if($ret == 0 && $mpfr_re == $sj && $mpfr_im == 1234567) {$ok .= 'l'}
- else {warn "3l: $ret $mpfr_re $mpfr_im\n$mpc\n"}
- }
- else {
- eval {Rmpc_set_z_uj($mpc, $gmp, $uj, $round);};
- if($@ =~ /Rmpc_set_z_uj not implemented/) {$ok .= 'i'}
- else {warn "3i: \$\@: $@\n"}
-
- eval {Rmpc_set_uj_z($mpc, $uj, $gmp, $round);};
- if($@ =~ /Rmpc_set_uj_z not implemented/) {$ok .= 'j'}
- else {warn "3j: \$\@: $@\n"}
-
- eval {Rmpc_set_z_sj($mpc, $gmp, $sj, $round);};
- if($@ =~ /Rmpc_set_z_sj not implemented/) {$ok .= 'k'}
- else {warn "3k: \$\@: $@\n"}
-
- eval {Rmpc_set_sj_z($mpc, $sj, $gmp, $round);};
- if($@ =~ /Rmpc_set_sj_z not implemented/) {$ok .= 'l'}
- else {warn "3l: \$\@: $@\n"}
- }
-
- if(Math::MPC::_has_longdouble()) {
- $ret = Rmpc_set_z_ld($mpc, $gmp, $ld, $round);
- Rmpc_real($mpfr_re, $mpc, $round);
- Rmpc_imag($mpfr_im, $mpc, $round);
- if($ret == 0 && $mpfr_re == 1234567 && $mpfr_im == $ld) {$ok .= 'm'}
- else {warn "3m: $ret $mpfr_re $mpfr_im\n$mpc\n"}
-
- $ret = Rmpc_set_ld_z($mpc, $ld, $gmp, $round);
- Rmpc_real($mpfr_re, $mpc, $round);
- Rmpc_imag($mpfr_im, $mpc, $round);
- if($ret == 0 && $mpfr_re == $ld && $mpfr_im == 1234567) {$ok .= 'n'}
- else {warn "3n: $ret $mpfr_re $mpfr_im\n$mpc\n"}
- }
- else {
- eval {Rmpc_set_z_ld($mpc, $gmp, $ld, $round);};
- if($@ =~ /Rmpc_set_z_ld not implemented/) {$ok .= 'm'}
- else {warn "3m: \$\@: $@\n"}
-
- eval {Rmpc_set_ld_z($mpc, $ld, $gmp, $round);};
- if($@ =~ /Rmpc_set_ld_z not implemented/) {$ok .= 'n'}
- else {warn "3n: \$\@: $@\n"}
- }
-
- $ret = Rmpc_set_z_fr($mpc, $gmp, $mpfr, $round);
- Rmpc_real($mpfr_re, $mpc, $round);
- Rmpc_imag($mpfr_im, $mpc, $round);
- if($ret == 0 && $mpfr_re == 1234567 && $mpfr_im == $mpfr) {$ok .= 'o'}
- else {warn "3o: $ret $mpfr_re $mpfr_im\n$mpc\n"}
-
- $ret = Rmpc_set_fr_z($mpc, $mpfr, $gmp, $round);
- Rmpc_real($mpfr_re, $mpc, $round);
- Rmpc_imag($mpfr_im, $mpc, $round);
- if($ret == 0 && $mpfr_re == $mpfr && $mpfr_im == 1234567) {$ok .= 'p'}
- else {warn "3p: $ret $mpfr_re $mpfr_im\n$mpc\n"}
-
- if($have_GMPq) {
- my $gmpq = Math::GMPq->new(89083);
- $ret = Rmpc_set_z_q($mpc, $gmp, $gmpq, $round);
- Rmpc_real($mpfr_re, $mpc, $round);
- Rmpc_imag($mpfr_im, $mpc, $round);
- if($ret == 0 && $mpfr_re == 1234567 && $mpfr_im == 89083) {$ok .= 'q'}
- else {warn "3q: $ret $mpfr_re $mpfr_im\n$mpc\n"}
-
- $ret = Rmpc_set_q_z($mpc, $gmpq, $gmp, $round);
- Rmpc_real($mpfr_re, $mpc, $round);
- Rmpc_imag($mpfr_im, $mpc, $round);
- if($ret == 0 && $mpfr_re == 89083 && $mpfr_im == 1234567) {$ok .= 'r'}
- else {warn "3r: $ret $mpfr_re $mpfr_im\n$mpc\n"}
- }
- else {
- warn " skipping 3q and 3r - no Math::GMPq\n";
- $ok .= 'qr';
- }
-
- if($have_GMPf) {
- my $gmpf = Math::GMPf->new(890213.5);
- $ret = Rmpc_set_z_f($mpc, $gmp, $gmpf, $round);
- Rmpc_real($mpfr_re, $mpc, $round);
- Rmpc_imag($mpfr_im, $mpc, $round);
- if($ret == 0 && $mpfr_re == 1234567 && $mpfr_im == 890213.5) {$ok .= 's'}
- else {warn "3s: $ret $mpfr_re $mpfr_im\n$mpc\n"}
-
- $ret = Rmpc_set_f_z($mpc, $gmpf, $gmp, $round);
- Rmpc_real($mpfr_re, $mpc, $round);
- Rmpc_imag($mpfr_im, $mpc, $round);
- if($ret == 0 && $mpfr_re == 890213.5 && $mpfr_im == 1234567) {$ok .= 't'}
- else {warn "3t: $ret $mpfr_re $mpfr_im\n$mpc\n"}
- }
- else {
- warn " skipping 3s and 3t - no Math::GMPf\n";
- $ok .= 'st';
- }
-
- if($ok eq 'abcdefghijklmnopqrst') {print "ok 3\n"}
- else {print "not ok 3\n$ok\n"}
-}
-else {
- print "ok 3 - skipped, no Math::GMP\n";
-}
-
-if($have_GMPz) {
- $ok = '';
- my $gmp = Math::GMPz->new(1234566);
- $ret = Rmpc_set_z($mpc, $gmp, $round);
- Rmpc_real($mpfr_re, $mpc, $round);
- Rmpc_imag($mpfr_im, $mpc, $round);
- if($ret == 0 && $mpfr_re == 1234566 && $mpfr_im == 0) {$ok .= 'a'}
- else {warn "4a: $ret $mpfr_re $mpfr_im\n$mpc\n"}
-
- my $gmp2 = Math::GMPz->new(891);
- $ret = Rmpc_set_z_z($mpc, $gmp, $gmp2, $round);
- Rmpc_real($mpfr_re, $mpc, $round);
- Rmpc_imag($mpfr_im, $mpc, $round);
- if($ret == 0 && $mpfr_re == 1234566 && $mpfr_im == 891) {$ok .= 'b'}
- else {warn "4b: $ret $mpfr_re $mpfr_im\n$mpc\n"}
-
- $ret = Rmpc_set_z_ui($mpc, $gmp, $ui, $round);
- Rmpc_real($mpfr_re, $mpc, $round);
- Rmpc_imag($mpfr_im, $mpc, $round);
- if($ret == 0 && $mpfr_re == 1234566 && $mpfr_im == $ui) {$ok .= 'c'}
- else {warn "4c: $ret $mpfr_re $mpfr_im\n$mpc\n"}
-
- $ret = Rmpc_set_ui_z($mpc, $ui, $gmp, $round);
- Rmpc_real($mpfr_re, $mpc, $round);
- Rmpc_imag($mpfr_im, $mpc, $round);
- if($ret == 0 && $mpfr_re == $ui && $mpfr_im == 1234566) {$ok .= 'd'}
- else {warn "4d: $ret $mpfr_re $mpfr_im\n$mpc\n"}
-
- $ret = Rmpc_set_z_si($mpc, $gmp, $si, $round);
- Rmpc_real($mpfr_re, $mpc, $round);
- Rmpc_imag($mpfr_im, $mpc, $round);
- if($ret == 0 && $mpfr_re == 1234566 && $mpfr_im == $si) {$ok .= 'e'}
- else {warn "4e: $ret $mpfr_re $mpfr_im\n$mpc\n"}
-
- $ret = Rmpc_set_si_z($mpc, $si, $gmp, $round);
- Rmpc_real($mpfr_re, $mpc, $round);
- Rmpc_imag($mpfr_im, $mpc, $round);
- if($ret == 0 && $mpfr_re == $si && $mpfr_im == 1234566) {$ok .= 'f'}
- else {warn "4f: $ret $mpfr_re $mpfr_im\n$mpc\n"}
-
- $ret = Rmpc_set_z_d($mpc, $gmp, $d, $round);
- Rmpc_real($mpfr_re, $mpc, $round);
- Rmpc_imag($mpfr_im, $mpc, $round);
- if($ret == 0 && $mpfr_re == 1234566 && $mpfr_im == $d) {$ok .= 'g'}
- else {warn "4g: $ret $mpfr_re $mpfr_im\n$mpc\n"}
-
- $ret = Rmpc_set_d_z($mpc, $d, $gmp, $round);
- Rmpc_real($mpfr_re, $mpc, $round);
- Rmpc_imag($mpfr_im, $mpc, $round);
- if($ret == 0 && $mpfr_re == $d && $mpfr_im == 1234566) {$ok .= 'h'}
- else {warn "4h: $ret $mpfr_re $mpfr_im\n$mpc\n"}
-
- if(Math::MPC::_has_longlong()) {
- $ret = Rmpc_set_z_uj($mpc, $gmp, $uj, $round);
- Rmpc_real($mpfr_re, $mpc, $round);
- Rmpc_imag($mpfr_im, $mpc, $round);
- if($ret == 0 && $mpfr_re == 1234566 && $mpfr_im == $uj) {$ok .= 'i'}
- else {warn "4i: $ret $mpfr_re $mpfr_im\n$mpc\n"}
-
- $ret = Rmpc_set_uj_z($mpc, $uj, $gmp, $round);
- Rmpc_real($mpfr_re, $mpc, $round);
- Rmpc_imag($mpfr_im, $mpc, $round);
- if($ret == 0 && $mpfr_re == $uj && $mpfr_im == 1234566) {$ok .= 'j'}
- else {warn "4j: $ret $mpfr_re $mpfr_im\n$mpc\n"}
-
- $ret = Rmpc_set_z_sj($mpc, $gmp, $sj, $round);
- Rmpc_real($mpfr_re, $mpc, $round);
- Rmpc_imag($mpfr_im, $mpc, $round);
- if($ret == 0 && $mpfr_re == 1234566 && $mpfr_im == $sj) {$ok .= 'k'}
- else {warn "4k: $ret $mpfr_re $mpfr_im\n$mpc\n"}
-
- $ret = Rmpc_set_sj_z($mpc, $sj, $gmp, $round);
- Rmpc_real($mpfr_re, $mpc, $round);
- Rmpc_imag($mpfr_im, $mpc, $round);
- if($ret == 0 && $mpfr_re == $sj && $mpfr_im == 1234566) {$ok .= 'l'}
- else {warn "4l: $ret $mpfr_re $mpfr_im\n$mpc\n"}
- }
- else {
- eval {Rmpc_set_z_uj($mpc, $gmp, $uj, $round);};
- if($@ =~ /Rmpc_set_z_uj not implemented/) {$ok .= 'i'}
- else {warn "4i: \$\@: $@\n"}
-
- eval {Rmpc_set_uj_z($mpc, $uj, $gmp, $round);};
- if($@ =~ /Rmpc_set_uj_z not implemented/) {$ok .= 'j'}
- else {warn "4j: \$\@: $@\n"}
-
- eval {Rmpc_set_z_sj($mpc, $gmp, $sj, $round);};
- if($@ =~ /Rmpc_set_z_sj not implemented/) {$ok .= 'k'}
- else {warn "4k: \$\@: $@\n"}
-
- eval {Rmpc_set_sj_z($mpc, $sj, $gmp, $round);};
- if($@ =~ /Rmpc_set_sj_z not implemented/) {$ok .= 'l'}
- else {warn "4l: \$\@: $@\n"}
- }
-
- if(Math::MPC::_has_longdouble()) {
- $ret = Rmpc_set_z_ld($mpc, $gmp, $ld, $round);
- Rmpc_real($mpfr_re, $mpc, $round);
- Rmpc_imag($mpfr_im, $mpc, $round);
- if($ret == 0 && $mpfr_re == 1234566 && $mpfr_im == $ld) {$ok .= 'm'}
- else {warn "4m: $ret $mpfr_re $mpfr_im\n$mpc\n"}
-
- $ret = Rmpc_set_ld_z($mpc, $ld, $gmp, $round);
- Rmpc_real($mpfr_re, $mpc, $round);
- Rmpc_imag($mpfr_im, $mpc, $round);
- if($ret == 0 && $mpfr_re == $ld && $mpfr_im == 1234566) {$ok .= 'n'}
- else {warn "4n: $ret $mpfr_re $mpfr_im\n$mpc\n"}
- }
- else {
- eval {Rmpc_set_z_ld($mpc, $gmp, $ld, $round);};
- if($@ =~ /Rmpc_set_z_ld not implemented/) {$ok .= 'm'}
- else {warn "4m: \$\@: $@\n"}
-
- eval {Rmpc_set_ld_z($mpc, $ld, $gmp, $round);};
- if($@ =~ /Rmpc_set_ld_z not implemented/) {$ok .= 'n'}
- else {warn "4n: \$\@: $@\n"}
- }
-
- $ret = Rmpc_set_z_fr($mpc, $gmp, $mpfr, $round);
- Rmpc_real($mpfr_re, $mpc, $round);
- Rmpc_imag($mpfr_im, $mpc, $round);
- if($ret == 0 && $mpfr_re == 1234566 && $mpfr_im == $mpfr) {$ok .= 'o'}
- else {warn "4o: $ret $mpfr_re $mpfr_im\n$mpc\n"}
-
- $ret = Rmpc_set_fr_z($mpc, $mpfr, $gmp, $round);
- Rmpc_real($mpfr_re, $mpc, $round);
- Rmpc_imag($mpfr_im, $mpc, $round);
- if($ret == 0 && $mpfr_re == $mpfr && $mpfr_im == 1234566) {$ok .= 'p'}
- else {warn "4p: $ret $mpfr_re $mpfr_im\n$mpc\n"}
-
- if($have_GMPq) {
- my $gmpq = Math::GMPq->new(8903);
- $ret = Rmpc_set_z_q($mpc, $gmp, $gmpq, $round);
- Rmpc_real($mpfr_re, $mpc, $round);
- Rmpc_imag($mpfr_im, $mpc, $round);
- if($ret == 0 && $mpfr_re == 1234566 && $mpfr_im == 8903) {$ok .= 'q'}
- else {warn "4q: $ret $mpfr_re $mpfr_im\n$mpc\n"}
-
- $ret = Rmpc_set_q_z($mpc, $gmpq, $gmp, $round);
- Rmpc_real($mpfr_re, $mpc, $round);
- Rmpc_imag($mpfr_im, $mpc, $round);
- if($ret == 0 && $mpfr_re == 8903 && $mpfr_im == 1234566) {$ok .= 'r'}
- else {warn "4r: $ret $mpfr_re $mpfr_im\n$mpc\n"}
- }
- else {
- warn " skipping 4q and 4r - no Math::GMPq\n";
- $ok .= 'qr';
- }
-
- if($have_GMPf) {
- my $gmpf = Math::GMPf->new(89023.5);
- $ret = Rmpc_set_z_f($mpc, $gmp, $gmpf, $round);
- Rmpc_real($mpfr_re, $mpc, $round);
- Rmpc_imag($mpfr_im, $mpc, $round);
- if($ret == 0 && $mpfr_re == 1234566 && $mpfr_im == 89023.5) {$ok .= 's'}
- else {warn "4s: $ret $mpfr_re $mpfr_im\n$mpc\n"}
-
- $ret = Rmpc_set_f_z($mpc, $gmpf, $gmp, $round);
- Rmpc_real($mpfr_re, $mpc, $round);
- Rmpc_imag($mpfr_im, $mpc, $round);
- if($ret == 0 && $mpfr_re == 89023.5 && $mpfr_im == 1234566) {$ok .= 't'}
- else {warn "4t: $ret $mpfr_re $mpfr_im\n$mpc\n"}
- }
- else {
- warn " skipping 4s and 4t - no Math::GMPf\n";
- $ok .= 'st';
- }
-
- if($ok eq 'abcdefghijklmnopqrst') {print "ok 4\n"}
- else {print "not ok 4\n$ok\n"}
-}
-else {
- print "ok 4 - skipped, no Math::GMPz\n";
-}
-
-if($have_GMPq) {
- $ok = '';
- my $gmp = Math::GMPq->new(1234565);
- $ret = Rmpc_set_q($mpc, $gmp, $round);
- Rmpc_real($mpfr_re, $mpc, $round);
- Rmpc_imag($mpfr_im, $mpc, $round);
- if($ret == 0 && $mpfr_re == 1234565 && $mpfr_im == 0) {$ok .= 'a'}
- else {warn "5a: $ret $mpfr_re $mpfr_im\n$mpc\n"}
-
- my $gmp2 = Math::GMPq->new(8921);
- $ret = Rmpc_set_q_q($mpc, $gmp, $gmp2, $round);
- Rmpc_real($mpfr_re, $mpc, $round);
- Rmpc_imag($mpfr_im, $mpc, $round);
- if($ret == 0 && $mpfr_re == 1234565 && $mpfr_im == 8921) {$ok .= 'b'}
- else {warn "5b: $ret $mpfr_re $mpfr_im\n$mpc\n"}
-
- $ret = Rmpc_set_q_ui($mpc, $gmp, $ui, $round);
- Rmpc_real($mpfr_re, $mpc, $round);
- Rmpc_imag($mpfr_im, $mpc, $round);
- if($ret == 0 && $mpfr_re == 1234565 && $mpfr_im == $ui) {$ok .= 'c'}
- else {warn "5c: $ret $mpfr_re $mpfr_im\n$mpc\n"}
-
- $ret = Rmpc_set_ui_q($mpc, $ui, $gmp, $round);
- Rmpc_real($mpfr_re, $mpc, $round);
- Rmpc_imag($mpfr_im, $mpc, $round);
- if($ret == 0 && $mpfr_re == $ui && $mpfr_im == 1234565) {$ok .= 'd'}
- else {warn "5d: $ret $mpfr_re $mpfr_im\n$mpc\n"}
-
- $ret = Rmpc_set_q_si($mpc, $gmp, $si, $round);
- Rmpc_real($mpfr_re, $mpc, $round);
- Rmpc_imag($mpfr_im, $mpc, $round);
- if($ret == 0 && $mpfr_re == 1234565 && $mpfr_im == $si) {$ok .= 'e'}
- else {warn "5e: $ret $mpfr_re $mpfr_im\n$mpc\n"}
-
- $ret = Rmpc_set_si_q($mpc, $si, $gmp, $round);
- Rmpc_real($mpfr_re, $mpc, $round);
- Rmpc_imag($mpfr_im, $mpc, $round);
- if($ret == 0 && $mpfr_re == $si && $mpfr_im == 1234565) {$ok .= 'f'}
- else {warn "5f: $ret $mpfr_re $mpfr_im\n$mpc\n"}
-
- $ret = Rmpc_set_q_d($mpc, $gmp, $d, $round);
- Rmpc_real($mpfr_re, $mpc, $round);
- Rmpc_imag($mpfr_im, $mpc, $round);
- if($ret == 0 && $mpfr_re == 1234565 && $mpfr_im == $d) {$ok .= 'g'}
- else {warn "5g: $ret $mpfr_re $mpfr_im\n$mpc\n"}
-
- $ret = Rmpc_set_d_q($mpc, $d, $gmp, $round);
- Rmpc_real($mpfr_re, $mpc, $round);
- Rmpc_imag($mpfr_im, $mpc, $round);
- if($ret == 0 && $mpfr_re == $d && $mpfr_im == 1234565) {$ok .= 'h'}
- else {warn "5h: $ret $mpfr_re $mpfr_im\n$mpc\n"}
-
- if(Math::MPC::_has_longlong()) {
- $ret = Rmpc_set_q_uj($mpc, $gmp, $uj, $round);
- Rmpc_real($mpfr_re, $mpc, $round);
- Rmpc_imag($mpfr_im, $mpc, $round);
- if($ret == 0 && $mpfr_re == 1234565 && $mpfr_im == $uj) {$ok .= 'i'}
- else {warn "5i: $ret $mpfr_re $mpfr_im\n$mpc\n"}
-
- $ret = Rmpc_set_uj_q($mpc, $uj, $gmp, $round);
- Rmpc_real($mpfr_re, $mpc, $round);
- Rmpc_imag($mpfr_im, $mpc, $round);
- if($ret == 0 && $mpfr_re == $uj && $mpfr_im == 1234565) {$ok .= 'j'}
- else {warn "5j: $ret $mpfr_re $mpfr_im\n$mpc\n"}
-
- $ret = Rmpc_set_q_sj($mpc, $gmp, $sj, $round);
- Rmpc_real($mpfr_re, $mpc, $round);
- Rmpc_imag($mpfr_im, $mpc, $round);
- if($ret == 0 && $mpfr_re == 1234565 && $mpfr_im == $sj) {$ok .= 'k'}
- else {warn "4k: $ret $mpfr_re $mpfr_im\n$mpc\n"}
-
- $ret = Rmpc_set_sj_q($mpc, $sj, $gmp, $round);
- Rmpc_real($mpfr_re, $mpc, $round);
- Rmpc_imag($mpfr_im, $mpc, $round);
- if($ret == 0 && $mpfr_re == $sj && $mpfr_im == 1234565) {$ok .= 'l'}
- else {warn "5l: $ret $mpfr_re $mpfr_im\n$mpc\n"}
- }
- else {
- eval {Rmpc_set_q_uj($mpc, $gmp, $uj, $round);};
- if($@ =~ /Rmpc_set_q_uj not implemented/) {$ok .= 'i'}
- else {warn "5i: \$\@: $@\n"}
-
- eval {Rmpc_set_uj_q($mpc, $uj, $gmp, $round);};
- if($@ =~ /Rmpc_set_uj_q not implemented/) {$ok .= 'j'}
- else {warn "5j: \$\@: $@\n"}
-
- eval {Rmpc_set_q_sj($mpc, $gmp, $sj, $round);};
- if($@ =~ /Rmpc_set_q_sj not implemented/) {$ok .= 'k'}
- else {warn "5k: \$\@: $@\n"}
-
- eval {Rmpc_set_sj_q($mpc, $sj, $gmp, $round);};
- if($@ =~ /Rmpc_set_sj_q not implemented/) {$ok .= 'l'}
- else {warn "5l: \$\@: $@\n"}
- }
-
- if(Math::MPC::_has_longdouble()) {
- $ret = Rmpc_set_q_ld($mpc, $gmp, $ld, $round);
- Rmpc_real($mpfr_re, $mpc, $round);
- Rmpc_imag($mpfr_im, $mpc, $round);
- if($ret == 0 && $mpfr_re == 1234565 && $mpfr_im == $ld) {$ok .= 'm'}
- else {warn "5m: $ret $mpfr_re $mpfr_im\n$mpc\n"}
-
- $ret = Rmpc_set_ld_q($mpc, $ld, $gmp, $round);
- Rmpc_real($mpfr_re, $mpc, $round);
- Rmpc_imag($mpfr_im, $mpc, $round);
- if($ret == 0 && $mpfr_re == $ld && $mpfr_im == 1234565) {$ok .= 'n'}
- else {warn "5n: $ret $mpfr_re $mpfr_im\n$mpc\n"}
- }
- else {
- eval {Rmpc_set_q_ld($mpc, $gmp, $ld, $round);};
- if($@ =~ /Rmpc_set_q_ld not implemented/) {$ok .= 'm'}
- else {warn "5m: \$\@: $@\n"}
-
- eval {Rmpc_set_ld_q($mpc, $ld, $gmp, $round);};
- if($@ =~ /Rmpc_set_ld_q not implemented/) {$ok .= 'n'}
- else {warn "5n: \$\@: $@\n"}
- }
-
- $ret = Rmpc_set_q_fr($mpc, $gmp, $mpfr, $round);
- Rmpc_real($mpfr_re, $mpc, $round);
- Rmpc_imag($mpfr_im, $mpc, $round);
- if($ret == 0 && $mpfr_re == 1234565 && $mpfr_im == $mpfr) {$ok .= 'o'}
- else {warn "5o: $ret $mpfr_re $mpfr_im\n$mpc\n"}
-
- $ret = Rmpc_set_fr_q($mpc, $mpfr, $gmp, $round);
- Rmpc_real($mpfr_re, $mpc, $round);
- Rmpc_imag($mpfr_im, $mpc, $round);
- if($ret == 0 && $mpfr_re == $mpfr && $mpfr_im == 1234565) {$ok .= 'p'}
- else {warn "5p: $ret $mpfr_re $mpfr_im\n$mpc\n"}
-
-
- if($have_GMPf) {
- my $gmpf = Math::GMPf->new(89024.5);
- $ret = Rmpc_set_q_f($mpc, $gmp, $gmpf, $round);
- Rmpc_real($mpfr_re, $mpc, $round);
- Rmpc_imag($mpfr_im, $mpc, $round);
- if($ret == 0 && $mpfr_re == 1234565 && $mpfr_im == 89024.5) {$ok .= 'q'}
- else {warn "5q: $ret $mpfr_re $mpfr_im\n$mpc\n"}
-
- $ret = Rmpc_set_f_q($mpc, $gmpf, $gmp, $round);
- Rmpc_real($mpfr_re, $mpc, $round);
- Rmpc_imag($mpfr_im, $mpc, $round);
- if($ret == 0 && $mpfr_re == 89024.5 && $mpfr_im == 1234565) {$ok .= 'r'}
- else {warn "5r: $ret $mpfr_re $mpfr_im\n$mpc\n"}
- }
- else {
- warn " skipping 5q and 5r - no Math::GMPf\n";
- $ok .= 'qr';
- }
-
- if($ok eq 'abcdefghijklmnopqr') {print "ok 5\n"}
- else {print "not ok 5\n$ok\n"}
-}
-else {
- print "ok 5 - skipped, no Math::GMPq\n";
-}
-
-if($have_GMPf) {
- $ok = '';
- my $gmp = Math::GMPf->new(1234564.5);
- $ret = Rmpc_set_f($mpc, $gmp, $round);
- Rmpc_real($mpfr_re, $mpc, $round);
- Rmpc_imag($mpfr_im, $mpc, $round);
- if($ret == 0 && $mpfr_re == 1234564.5 && $mpfr_im == 0) {$ok .= 'a'}
- else {warn "6a: $ret $mpfr_re $mpfr_im\n$mpc\n"}
-
- my $gmp2 = Math::GMPf->new(8921.5);
- $ret = Rmpc_set_f_f($mpc, $gmp, $gmp2, $round);
- Rmpc_real($mpfr_re, $mpc, $round);
- Rmpc_imag($mpfr_im, $mpc, $round);
- if($ret == 0 && $mpfr_re == 1234564.5 && $mpfr_im == 8921.5) {$ok .= 'b'}
- else {warn "6b: $ret $mpfr_re $mpfr_im\n$mpc\n"}
-
- $ret = Rmpc_set_f_ui($mpc, $gmp, $ui, $round);
- Rmpc_real($mpfr_re, $mpc, $round);
- Rmpc_imag($mpfr_im, $mpc, $round);
- if($ret == 0 && $mpfr_re == 1234564.5 && $mpfr_im == $ui) {$ok .= 'c'}
- else {warn "6c: $ret $mpfr_re $mpfr_im\n$mpc\n"}
-
- $ret = Rmpc_set_ui_f($mpc, $ui, $gmp, $round);
- Rmpc_real($mpfr_re, $mpc, $round);
- Rmpc_imag($mpfr_im, $mpc, $round);
- if($ret == 0 && $mpfr_re == $ui && $mpfr_im == 1234564.5) {$ok .= 'd'}
- else {warn "6d: $ret $mpfr_re $mpfr_im\n$mpc\n"}
-
- $ret = Rmpc_set_f_si($mpc, $gmp, $si, $round);
- Rmpc_real($mpfr_re, $mpc, $round);
- Rmpc_imag($mpfr_im, $mpc, $round);
- if($ret == 0 && $mpfr_re == 1234564.5 && $mpfr_im == $si) {$ok .= 'e'}
- else {warn "6e: $ret $mpfr_re $mpfr_im\n$mpc\n"}
-
- $ret = Rmpc_set_si_f($mpc, $si, $gmp, $round);
- Rmpc_real($mpfr_re, $mpc, $round);
- Rmpc_imag($mpfr_im, $mpc, $round);
- if($ret == 0 && $mpfr_re == $si && $mpfr_im == 1234564.5) {$ok .= 'f'}
- else {warn "6f: $ret $mpfr_re $mpfr_im\n$mpc\n"}
-
- $ret = Rmpc_set_f_d($mpc, $gmp, $d, $round);
- Rmpc_real($mpfr_re, $mpc, $round);
- Rmpc_imag($mpfr_im, $mpc, $round);
- if($ret == 0 && $mpfr_re == 1234564.5 && $mpfr_im == $d) {$ok .= 'g'}
- else {warn "6g: $ret $mpfr_re $mpfr_im\n$mpc\n"}
-
- $ret = Rmpc_set_d_f($mpc, $d, $gmp, $round);
- Rmpc_real($mpfr_re, $mpc, $round);
- Rmpc_imag($mpfr_im, $mpc, $round);
- if($ret == 0 && $mpfr_re == $d && $mpfr_im == 1234564.5) {$ok .= 'h'}
- else {warn "6h: $ret $mpfr_re $mpfr_im\n$mpc\n"}
-
- if(Math::MPC::_has_longlong()) {
- $ret = Rmpc_set_f_uj($mpc, $gmp, $uj, $round);
- Rmpc_real($mpfr_re, $mpc, $round);
- Rmpc_imag($mpfr_im, $mpc, $round);
- if($ret == 0 && $mpfr_re == 1234564.5 && $mpfr_im == $uj) {$ok .= 'i'}
- else {warn "6i: $ret $mpfr_re $mpfr_im\n$mpc\n"}
-
- $ret = Rmpc_set_uj_f($mpc, $uj, $gmp, $round);
- Rmpc_real($mpfr_re, $mpc, $round);
- Rmpc_imag($mpfr_im, $mpc, $round);
- if($ret == 0 && $mpfr_re == $uj && $mpfr_im == 1234564.5) {$ok .= 'j'}
- else {warn "6j: $ret $mpfr_re $mpfr_im\n$mpc\n"}
-
- $ret = Rmpc_set_f_sj($mpc, $gmp, $sj, $round);
- Rmpc_real($mpfr_re, $mpc, $round);
- Rmpc_imag($mpfr_im, $mpc, $round);
- if($ret == 0 && $mpfr_re == 1234564.5 && $mpfr_im == $sj) {$ok .= 'k'}
- else {warn "6k: $ret $mpfr_re $mpfr_im\n$mpc\n"}
-
- $ret = Rmpc_set_sj_f($mpc, $sj, $gmp, $round);
- Rmpc_real($mpfr_re, $mpc, $round);
- Rmpc_imag($mpfr_im, $mpc, $round);
- if($ret == 0 && $mpfr_re == $sj && $mpfr_im == 1234564.5) {$ok .= 'l'}
- else {warn "6l: $ret $mpfr_re $mpfr_im\n$mpc\n"}
- }
- else {
- eval {Rmpc_set_f_uj($mpc, $gmp, $uj, $round);};
- if($@ =~ /Rmpc_set_f_uj not implemented/) {$ok .= 'i'}
- else {warn "6i: \$\@: $@\n"}
-
- eval {Rmpc_set_uj_f($mpc, $uj, $gmp, $round);};
- if($@ =~ /Rmpc_set_uj_f not implemented/) {$ok .= 'j'}
- else {warn "6j: \$\@: $@\n"}
-
- eval {Rmpc_set_f_sj($mpc, $gmp, $sj, $round);};
- if($@ =~ /Rmpc_set_f_sj not implemented/) {$ok .= 'k'}
- else {warn "6k: \$\@: $@\n"}
-
- eval {Rmpc_set_sj_f($mpc, $sj, $gmp, $round);};
- if($@ =~ /Rmpc_set_sj_f not implemented/) {$ok .= 'l'}
- else {warn "6l: \$\@: $@\n"}
- }
-
- if(Math::MPC::_has_longdouble()) {
- $ret = Rmpc_set_f_ld($mpc, $gmp, $ld, $round);
- Rmpc_real($mpfr_re, $mpc, $round);
- Rmpc_imag($mpfr_im, $mpc, $round);
- if($ret == 0 && $mpfr_re == 1234564.5 && $mpfr_im == $ld) {$ok .= 'm'}
- else {warn "6m: $ret $mpfr_re $mpfr_im\n$mpc\n"}
-
- $ret = Rmpc_set_ld_f($mpc, $ld, $gmp, $round);
- Rmpc_real($mpfr_re, $mpc, $round);
- Rmpc_imag($mpfr_im, $mpc, $round);
- if($ret == 0 && $mpfr_re == $ld && $mpfr_im == 1234564.5) {$ok .= 'n'}
- else {warn "6n: $ret $mpfr_re $mpfr_im\n$mpc\n"}
- }
- else {
- eval {Rmpc_set_f_ld($mpc, $gmp, $ld, $round);};
- if($@ =~ /Rmpc_set_f_ld not implemented/) {$ok .= 'm'}
- else {warn "6m: \$\@: $@\n"}
-
- eval {Rmpc_set_ld_f($mpc, $ld, $gmp, $round);};
- if($@ =~ /Rmpc_set_ld_f not implemented/) {$ok .= 'n'}
- else {warn "6n: \$\@: $@\n"}
- }
-
- $ret = Rmpc_set_f_fr($mpc, $gmp, $mpfr, $round);
- Rmpc_real($mpfr_re, $mpc, $round);
- Rmpc_imag($mpfr_im, $mpc, $round);
- if($ret == 0 && $mpfr_re == 1234564.5 && $mpfr_im == $mpfr) {$ok .= 'o'}
- else {warn "6o: $ret $mpfr_re $mpfr_im\n$mpc\n"}
-
- $ret = Rmpc_set_fr_f($mpc, $mpfr, $gmp, $round);
- Rmpc_real($mpfr_re, $mpc, $round);
- Rmpc_imag($mpfr_im, $mpc, $round);
- if($ret == 0 && $mpfr_re == $mpfr && $mpfr_im == 1234564.5) {$ok .= 'p'}
- else {warn "6p: $ret $mpfr_re $mpfr_im\n$mpc\n"}
-
- if($ok eq 'abcdefghijklmnop') {print "ok 6\n"}
- else {print "not ok 6\n$ok\n"}
-}
-else {
- print "ok 6 - skipped, no Math::GMPf\n";
-}
-
-$ok = '';
-
-unless(Math::MPC::_have_Complex_h()) {
- eval{Rmpc_set_dc($mpc, $round, $round);};
- if($@){
- $ok .= 'a';
- if($@ =~ /not implemented/){$ok .= 'b'}
- else {warn "a: \$\@: $@\n"}
- }
-
- eval{Rmpc_set_ldc($mpc, $round, $round);};
- if($@){
- $ok .= 'c';
- if($@ =~ /not implemented/){$ok .= 'd'}
- else {warn "a: \$\@: $@\n"}
- }
-}
-else {
- warn "Skipping test 7 - Math::MPC::_have_complex_h returns true\n";
- $ok = 'abcd';
-}
-
-if($ok eq 'abcd') {print "ok 7\n"}
-else {
- warn "7: \$ok: $ok\n";
- print "not ok 7\n";
-}
-
-$ok = '';
-
-unless(Math::MPC::_have_Complex_h()) {
- eval{Rmpc_get_dc($round, $mpc, $round);};
- if($@){
- $ok .= 'a';
- if($@ =~ /not implemented/){$ok .= 'b'}
- else {warn "a: \$\@: $@\n"}
- }
-
- eval{Rmpc_get_ldc($round, $mpc, $round);};
- if($@){
- $ok .= 'c';
- if($@ =~ /not implemented/){$ok .= 'd'}
- else {warn "a: \$\@: $@\n"}
- }
-}
-else {
- warn "Skipping test 8 - Math::MPC::_have_complex_h returns true\n";
- $ok = 'abcd';
-}
-
-if($ok eq 'abcd') {print "ok 8\n"}
-else {
- warn "8: \$ok: $ok\n";
- print "not ok 8\n";
-}
\ No newline at end of file
+use warnings;
+use strict;
+use Math::MPC qw(:mpc);
+use Math::MPFR qw(:mpfr);
+
+print "1..8\n";
+
+print "# Using mpfr version ", MPFR_VERSION_STRING, "\n";
+print "# Usinf mpc library version ", MPC_VERSION_STRING, "\n";
+
+my ($ok, $ret);
+my $round = MPC_RNDNN;
+Rmpc_set_default_prec2(128, 128);
+Rmpfr_set_default_prec(128);
+my $mpc = Math::MPC->new();
+my $mpfr = Math::MPFR->new(12.625);
+my $mpfr2 = $mpfr - 11;
+my $mpfr_re = Math::MPFR->new();
+my $mpfr_im = Math::MPFR->new();
+my $d = 6.5;
+my $d2 = $d - 11;
+my $si = -117;
+my $si2 = $si - 11;
+my $ui = 4294912975;
+my $ui2 = $ui - 11;
+my $uj = 9223372036854721487;
+my $uj2 = $uj - 11;
+my $sj = -36028797018909647;
+my $sj2 = $sj - 11;
+my $ld = -(2 ** 57) + 0.5;
+my $ld2 = $ld - 11;
+
+$ret = Rmpc_set_d_ui($mpc, $d, $ui, $round);
+Rmpc_real($mpfr_re, $mpc, $round);
+Rmpc_imag($mpfr_im, $mpc, $round);
+if($ret == 0 && $mpfr_re == $d && $mpfr_im == $ui) {$ok .= 'a'}
+else {warn "a: $ret $mpfr_re $mpfr_im\n$mpc\n"}
+
+$ret = Rmpc_set_d_si($mpc, $d, $si, $round);
+Rmpc_real($mpfr_re, $mpc, $round);
+Rmpc_imag($mpfr_im, $mpc, $round);
+if($ret == 0 && $mpfr_re == $d && $mpfr_im == $si) {$ok .= 'b'}
+else {warn "b: $ret $mpfr_re $mpfr_im\n$mpc\n"}
+
+$ret = Rmpc_set_d_fr($mpc, $d, $mpfr, $round);
+Rmpc_real($mpfr_re, $mpc, $round);
+Rmpc_imag($mpfr_im, $mpc, $round);
+if($ret == 0 && $mpfr_re == $d && $mpfr_im == $mpfr) {$ok .= 'c'}
+else {warn "c: $ret $mpfr_re $mpfr_im\n$mpc\n"}
+
+$ret = Rmpc_set_ui_d($mpc, $ui, $d, $round);
+Rmpc_real($mpfr_re, $mpc, $round);
+Rmpc_imag($mpfr_im, $mpc, $round);
+if($ret == 0 && $mpfr_re == $ui && $mpfr_im == $d) {$ok .= 'd'}
+else {warn "d: $ret $mpfr_re $mpfr_im\n$mpc\n"}
+
+$ret = Rmpc_set_ui_si($mpc, $ui, $si, $round);
+Rmpc_real($mpfr_re, $mpc, $round);
+Rmpc_imag($mpfr_im, $mpc, $round);
+if($ret == 0 && $mpfr_re == $ui && $mpfr_im == $si) {$ok .= 'e'}
+else {warn "e: $ret $mpfr_re $mpfr_im\n$mpc\n"}
+
+$ret = Rmpc_set_ui_fr($mpc, $ui, $mpfr, $round);
+Rmpc_real($mpfr_re, $mpc, $round);
+Rmpc_imag($mpfr_im, $mpc, $round);
+if($ret == 0 && $mpfr_re == $ui && $mpfr_im == $mpfr) {$ok .= 'f'}
+else {warn "f: $ret $mpfr_re $mpfr_im\n$mpc\n"}
+
+$ret = Rmpc_set_si_d($mpc, $si, $d, $round);
+Rmpc_real($mpfr_re, $mpc, $round);
+Rmpc_imag($mpfr_im, $mpc, $round);
+if($ret == 0 && $mpfr_re == $si && $mpfr_im == $d) {$ok .= 'g'}
+else {warn "g: $ret $mpfr_re $mpfr_im\n$mpc\n"}
+
+$ret = Rmpc_set_si_ui($mpc, $si, $ui, $round);
+Rmpc_real($mpfr_re, $mpc, $round);
+Rmpc_imag($mpfr_im, $mpc, $round);
+if($ret == 0 && $mpfr_re == $si && $mpfr_im == $ui) {$ok .= 'h'}
+else {warn "h: $ret $mpfr_re $mpfr_im\n$mpc\n"}
+
+$ret = Rmpc_set_si_fr($mpc, $si, $mpfr, $round);
+Rmpc_real($mpfr_re, $mpc, $round);
+Rmpc_imag($mpfr_im, $mpc, $round);
+if($ret == 0 && $mpfr_re == $si && $mpfr_im == $mpfr) {$ok .= 'i'}
+else {warn "i: $ret $mpfr_re $mpfr_im\n$mpc\n"}
+
+$ret = Rmpc_set_fr_d($mpc, $mpfr, $d, $round);
+Rmpc_real($mpfr_re, $mpc, $round);
+Rmpc_imag($mpfr_im, $mpc, $round);
+if($ret == 0 && $mpfr_re == $mpfr && $mpfr_im == $d) {$ok .= 'j'}
+else {warn "j: $ret $mpfr_re $mpfr_im\n$mpc\n"}
+
+$ret = Rmpc_set_fr_ui($mpc, $mpfr, $ui, $round);
+Rmpc_real($mpfr_re, $mpc, $round);
+Rmpc_imag($mpfr_im, $mpc, $round);
+if($ret == 0 && $mpfr_re == $mpfr && $mpfr_im == $ui) {$ok .= 'k'}
+else {warn "k: $ret $mpfr_re $mpfr_im\n$mpc\n"}
+
+$ret = Rmpc_set_fr_si($mpc, $mpfr, $si, $round);
+Rmpc_real($mpfr_re, $mpc, $round);
+Rmpc_imag($mpfr_im, $mpc, $round);
+if($ret == 0 && $mpfr_re == $mpfr && $mpfr_im == $si) {$ok .= 'l'}
+else {warn "l: $ret $mpfr_re $mpfr_im\n$mpc\n"}
+
+### 64-bit int
+if(Math::MPC::_has_longlong()) {
+ $ret = Rmpc_set_d_uj($mpc, $d, $uj, $round);
+ Rmpc_real($mpfr_re, $mpc, $round);
+ Rmpc_imag($mpfr_im, $mpc, $round);
+ if($ret == 0 && $mpfr_re == $d && $mpfr_im == $uj) {$ok .= 'm'}
+ else {warn "m: $ret $mpfr_re $mpfr_im\n$mpc\n"}
+
+ $ret = Rmpc_set_d_sj($mpc, $d, $sj, $round);
+ Rmpc_real($mpfr_re, $mpc, $round);
+ Rmpc_imag($mpfr_im, $mpc, $round);
+ if($ret == 0 && $mpfr_re == $d && $mpfr_im == $sj) {$ok .= 'n'}
+ else {warn "n: $ret $mpfr_re $mpfr_im\n$mpc\n"}
+
+ $ret = Rmpc_set_uj_d($mpc, $uj, $d, $round);
+ Rmpc_real($mpfr_re, $mpc, $round);
+ Rmpc_imag($mpfr_im, $mpc, $round);
+ if($ret == 0 && $mpfr_re == $uj && $mpfr_im == $d) {$ok .= 'o'}
+ else {warn "o: $ret $mpfr_re $mpfr_im\n$mpc\n"}
+
+ $ret = Rmpc_set_sj_d($mpc, $sj, $d, $round);
+ Rmpc_real($mpfr_re, $mpc, $round);
+ Rmpc_imag($mpfr_im, $mpc, $round);
+ if($ret == 0 && $mpfr_re == $sj && $mpfr_im == $d) {$ok .= 'p'}
+ else {warn "p: $ret $mpfr_re $mpfr_im\n$mpc\n"}
+
+ $ret = Rmpc_set_uj_fr($mpc, $uj, $mpfr, $round);
+ Rmpc_real($mpfr_re, $mpc, $round);
+ Rmpc_imag($mpfr_im, $mpc, $round);
+ if($ret == 0 && $mpfr_re == $uj && $mpfr_im == $mpfr) {$ok .= 'q'}
+ else {warn "q: $ret $mpfr_re $mpfr_im\n$mpc\n"}
+
+ $ret = Rmpc_set_sj_fr($mpc, $sj, $mpfr, $round);
+ Rmpc_real($mpfr_re, $mpc, $round);
+ Rmpc_imag($mpfr_im, $mpc, $round);
+ if($ret == 0 && $mpfr_re == $sj && $mpfr_im == $mpfr) {$ok .= 'r'}
+ else {warn "r: $ret $mpfr_re $mpfr_im\n$mpc\n"}
+
+ $ret = Rmpc_set_fr_uj($mpc, $mpfr, $uj, $round);
+ Rmpc_real($mpfr_re, $mpc, $round);
+ Rmpc_imag($mpfr_im, $mpc, $round);
+ if($ret == 0 && $mpfr_re == $mpfr && $mpfr_im == $uj) {$ok .= 's'}
+ else {warn "s: $ret $mpfr_re $mpfr_im\n$mpc\n"}
+
+ $ret = Rmpc_set_fr_sj($mpc, $mpfr, $sj, $round);
+ Rmpc_real($mpfr_re, $mpc, $round);
+ Rmpc_imag($mpfr_im, $mpc, $round);
+ if($ret == 0 && $mpfr_re == $mpfr && $mpfr_im == $sj) {$ok .= 't'}
+ else {warn "t: $ret $mpfr_re $mpfr_im\n$mpc\n"}
+
+ $ret = Rmpc_set_uj_sj($mpc, $uj, $sj, $round);
+ Rmpc_real($mpfr_re, $mpc, $round);
+ Rmpc_imag($mpfr_im, $mpc, $round);
+ if($ret == 0 && $mpfr_re == $uj && $mpfr_im == $sj) {$ok .= 'u'}
+ else {warn "u: $ret $mpfr_re $mpfr_im\n$mpc\n"}
+
+ $ret = Rmpc_set_sj_uj($mpc, $sj, $uj, $round);
+ Rmpc_real($mpfr_re, $mpc, $round);
+ Rmpc_imag($mpfr_im, $mpc, $round);
+ if($ret == 0 && $mpfr_re == $sj && $mpfr_im == $uj) {$ok .= 'v'}
+ else {warn "v: $ret $mpfr_re $mpfr_im\n$mpc\n"}
+}
+else {
+ eval {Rmpc_set_d_uj($mpc, $d, $uj, $round);};
+ if($@ =~ /Rmpc_set_d_uj not implemented/) {$ok .= 'm'}
+ else {warn "m: \$\@: $@\n"}
+ eval {Rmpc_set_d_sj($mpc, $d, $sj, $round);};
+ if($@ =~ /Rmpc_set_d_sj not implemented/) {$ok .= 'n'}
+ else {warn "n: \$\@: $@\n"}
+ eval {Rmpc_set_uj_d($mpc, $uj, $d, $round);};
+ if($@ =~ /Rmpc_set_uj_d not implemented/) {$ok .= 'o'}
+ else {warn "o: \$\@: $@\n"}
+ eval {Rmpc_set_sj_d($mpc, $sj, $d, $round);};
+ if($@ =~ /Rmpc_set_sj_d not implemented/) {$ok .= 'p'}
+ else {warn "p: \$\@: $@\n"}
+ eval {Rmpc_set_uj_fr($mpc, $uj, $mpfr, $round);};
+ if($@ =~ /Rmpc_set_uj_fr not implemented/) {$ok .= 'q'}
+ else {warn "q: \$\@: $@\n"}
+ eval {Rmpc_set_sj_fr($mpc, $sj, $mpfr, $round);};
+ if($@ =~ /Rmpc_set_sj_fr not implemented/) {$ok .= 'r'}
+ else {warn "r: \$\@: $@\n"}
+ eval {Rmpc_set_fr_uj($mpc, $mpfr, $uj, $round);};
+ if($@ =~ /Rmpc_set_fr_uj not implemented/) {$ok .= 's'}
+ else {warn "s: \$\@: $@\n"}
+ eval {Rmpc_set_fr_sj($mpc, $mpfr, $sj, $round);};
+ if($@ =~ /Rmpc_set_fr_sj not implemented/) {$ok .= 't'}
+ else {warn "t: \$\@: $@\n"}
+ eval {Rmpc_set_uj_sj($mpc, $uj, $sj, $round);};
+ if($@ =~ /Rmpc_set_uj_sj not implemented/) {$ok .= 'u'}
+ else {warn "u: \$\@: $@\n"}
+ eval {Rmpc_set_sj_uj($mpc, $sj, $uj, $round);};
+ if($@ =~ /Rmpc_set_sj_uj not implemented/) {$ok .= 'v'}
+ else {warn "v: \$\@: $@\n"}
+}
+
+if(Math::MPC::_has_longdouble()) {
+ $ret = Rmpc_set_ui_ld($mpc, $ui, $ld, $round);
+ Rmpc_real($mpfr_re, $mpc, $round);
+ Rmpc_imag($mpfr_im, $mpc, $round);
+ if($ret == 0 && $mpfr_re == $ui && $mpfr_im == $ld) {$ok .= 'w'}
+ else {warn "w: $ret $mpfr_re $mpfr_im\n$mpc\n"}
+
+ $ret = Rmpc_set_si_ld($mpc, $si, $ld, $round);
+ Rmpc_real($mpfr_re, $mpc, $round);
+ Rmpc_imag($mpfr_im, $mpc, $round);
+ if($ret == 0 && $mpfr_re == $si && $mpfr_im == $ld) {$ok .= 'x'}
+ else {warn "x: $ret $mpfr_re $mpfr_im\n$mpc\n"}
+
+ $ret = Rmpc_set_fr_ld($mpc, $mpfr, $ld, $round);
+ Rmpc_real($mpfr_re, $mpc, $round);
+ Rmpc_imag($mpfr_im, $mpc, $round);
+ if($ret == 0 && $mpfr_re == $mpfr && $mpfr_im == $ld) {$ok .= 'y'}
+ else {warn "y: $ret $mpfr_re $mpfr_im\n$mpc\n"}
+
+ $ret = Rmpc_set_ld_ui($mpc, $ld, $ui, $round);
+ Rmpc_real($mpfr_re, $mpc, $round);
+ Rmpc_imag($mpfr_im, $mpc, $round);
+ if($ret == 0 && $mpfr_re == $ld && $mpfr_im == $ui) {$ok .= 'z'}
+ else {warn "z: $ret $mpfr_re $mpfr_im\n$mpc\n"}
+
+ $ret = Rmpc_set_ld_si($mpc, $ld, $si, $round);
+ Rmpc_real($mpfr_re, $mpc, $round);
+ Rmpc_imag($mpfr_im, $mpc, $round);
+ if($ret == 0 && $mpfr_re == $ld && $mpfr_im == $si) {$ok .= 'A'}
+ else {warn "A: $ret $mpfr_re $mpfr_im\n$mpc\n"}
+
+ $ret = Rmpc_set_ld_fr($mpc, $ld, $mpfr, $round);
+ Rmpc_real($mpfr_re, $mpc, $round);
+ Rmpc_imag($mpfr_im, $mpc, $round);
+ if($ret == 0 && $mpfr_re == $ld && $mpfr_im == $mpfr) {$ok .= 'B'}
+ else {warn "B: $ret $mpfr_re $mpfr_im\n$mpc\n"}
+}else {
+ eval {Rmpc_set_ui_ld($mpc, $ui, $ld, $round);};
+ if($@ =~ /Rmpc_set_ui_ld not implemented/) {$ok .= 'w'}
+ else {warn "w: \$\@: $@\n"}
+ eval {Rmpc_set_si_ld($mpc, $si, $ld, $round);};
+ if($@ =~ /Rmpc_set_si_ld not implemented/) {$ok .= 'x'}
+ else {warn "x: \$\@: $@\n"}
+ eval {Rmpc_set_fr_ld($mpc, $mpfr, $ld, $round);};
+ if($@ =~ /Rmpc_set_fr_ld not implemented/) {$ok .= 'y'}
+ else {warn "y: \$\@: $@\n"}
+ eval {Rmpc_set_ld_ui($mpc, $ld, $ui, $round);};
+ if($@ =~ /Rmpc_set_ld_ui not implemented/) {$ok .= 'z'}
+ else {warn "z: \$\@: $@\n"}
+ eval {Rmpc_set_ld_si($mpc, $ld, $si, $round);};
+ if($@ =~ /Rmpc_set_ld_si not implemented/) {$ok .= 'A'}
+ else {warn "A: \$\@: $@\n"}
+ eval {Rmpc_set_ld_fr($mpc, $ld, $mpfr, $round);};
+ if($@ =~ /Rmpc_set_ld_fr not implemented/) {$ok .= 'B'}
+ else {warn "B: \$\@: $@\n"}
+}
+
+if(Math::MPC::_has_longlong() && Math::MPC::_has_longdouble()) {
+ $ret = Rmpc_set_ld_uj($mpc, $ld, $uj, $round);
+ Rmpc_real($mpfr_re, $mpc, $round);
+ Rmpc_imag($mpfr_im, $mpc, $round);
+ if($ret == 0 && $mpfr_re == $ld && $mpfr_im == $uj) {$ok .= 'C'}
+ else {warn "C: $ret $mpfr_re $mpfr_im\n$mpc\n"}
+
+ $ret = Rmpc_set_ld_sj($mpc, $ld, $sj, $round);
+ Rmpc_real($mpfr_re, $mpc, $round);
+ Rmpc_imag($mpfr_im, $mpc, $round);
+ if($ret == 0 && $mpfr_re == $ld && $mpfr_im == $sj) {$ok .= 'D'}
+ else {warn "D: $ret $mpfr_re $mpfr_im\n$mpc\n"}
+
+ $ret = Rmpc_set_uj_ld($mpc, $uj, $ld, $round);
+ Rmpc_real($mpfr_re, $mpc, $round);
+ Rmpc_imag($mpfr_im, $mpc, $round);
+ if($ret == 0 && $mpfr_re == $uj && $mpfr_im == $ld) {$ok .= 'E'}
+ else {warn "E: $ret $mpfr_re $mpfr_im\n$mpc\n"}
+
+ $ret = Rmpc_set_sj_ld($mpc, $sj, $ld, $round);
+ Rmpc_real($mpfr_re, $mpc, $round);
+ Rmpc_imag($mpfr_im, $mpc, $round);
+ if($ret == 0 && $mpfr_re == $sj && $mpfr_im == $ld) {$ok .= 'F'}
+ else {warn "F: $ret $mpfr_re $mpfr_im\n$mpc\n"}
+}
+else {
+ eval {Rmpc_set_uj_ld($mpc, $ui, $ld, $round);};
+ if($@ =~ /Rmpc_set_uj_ld not implemented/) {$ok .= 'C'}
+ else {warn "C: \$\@: $@\n"}
+ eval {Rmpc_set_sj_ld($mpc, $sj, $ld, $round);};
+ if($@ =~ /Rmpc_set_sj_ld not implemented/) {$ok .= 'D'}
+ else {warn "D: \$\@: $@\n"}
+ eval {Rmpc_set_ld_sj($mpc, $ld, $sj, $round);};
+ if($@ =~ /Rmpc_set_ld_sj not implemented/) {$ok .= 'E'}
+ else {warn "E: \$\@: $@\n"}
+ eval {Rmpc_set_ld_uj($mpc, $ld, $uj, $round);};
+ if($@ =~ /Rmpc_set_ld_uj not implemented/) {$ok .= 'F'}
+ else {warn "F: \$\@: $@\n"}
+}
+
+### X_X (d_d, ui_ui, si_si, fr_fr)
+
+$ret = Rmpc_set_ui_ui($mpc, $ui, $ui2, $round);
+Rmpc_real($mpfr_re, $mpc, $round);
+Rmpc_imag($mpfr_im, $mpc, $round);
+if($ret == 0 && $mpfr_re == $ui && $mpfr_im == $ui - 11) {$ok .= 'G'}
+else {warn "G: $ret $mpfr_re $mpfr_im\n$mpc\n"}
+
+$ret = Rmpc_set_d_d($mpc, $d, $d2, $round);
+Rmpc_real($mpfr_re, $mpc, $round);
+Rmpc_imag($mpfr_im, $mpc, $round);
+if($ret == 0 && $mpfr_re == $d && $mpfr_im == $d - 11) {$ok .= 'H'}
+else {warn "H: $ret $mpfr_re $mpfr_im\n$mpc\n"}
+
+$ret = Rmpc_set_si_si($mpc, $si, $si2, $round);
+Rmpc_real($mpfr_re, $mpc, $round);
+Rmpc_imag($mpfr_im, $mpc, $round);
+if($ret == 0 && $mpfr_re == $si && $mpfr_im == $si - 11) {$ok .= 'I'}
+else {warn "I: $ret $mpfr_re $mpfr_im\n$mpc\n"}
+
+$ret = Rmpc_set_fr_fr($mpc, $mpfr, $mpfr2, $round);
+Rmpc_real($mpfr_re, $mpc, $round);
+Rmpc_imag($mpfr_im, $mpc, $round);
+if($ret == 0 && $mpfr_re == $mpfr && $mpfr_im == $mpfr - 11) {$ok .= 'J'}
+else {warn "J: $ret $mpfr_re $mpfr_im\n$mpc\n"}
+
+if(Math::MPC::_has_longlong()) {
+ $ret = Rmpc_set_uj_uj($mpc, $uj, $uj2, $round);
+ Rmpc_real($mpfr_re, $mpc, $round);
+ Rmpc_imag($mpfr_im, $mpc, $round);
+ if($ret == 0 && $mpfr_re == $uj && $mpfr_im == $uj - 11) {$ok .= 'K'}
+ else {warn "K: $ret $mpfr_re $mpfr_im\n$mpc\n"}
+
+ $ret = Rmpc_set_sj_sj($mpc, $sj, $sj2, $round);
+ Rmpc_real($mpfr_re, $mpc, $round);
+ Rmpc_imag($mpfr_im, $mpc, $round);
+ if($ret == 0 && $mpfr_re == $sj && $mpfr_im == $sj - 11) {$ok .= 'L'}
+ else {warn "L: $ret $mpfr_re $mpfr_im\n$mpc\n"}
+
+ $ret = Rmpc_set_uj_si($mpc, $uj, $si, $round);
+ Rmpc_real($mpfr_re, $mpc, $round);
+ Rmpc_imag($mpfr_im, $mpc, $round);
+ if($ret == 0 && $mpfr_re == $uj && $mpfr_im == $si) {$ok .= 'M'}
+ else {warn "M: $ret $mpfr_re $mpfr_im\n$mpc\n"}
+
+ $ret = Rmpc_set_ui_sj($mpc, $ui, $sj, $round);
+ Rmpc_real($mpfr_re, $mpc, $round);
+ Rmpc_imag($mpfr_im, $mpc, $round);
+ if($ret == 0 && $mpfr_re == $ui && $mpfr_im == $sj) {$ok .= 'N'}
+ else {warn "N: $ret $mpfr_re $mpfr_im\n$mpc\n"}
+
+ $ret = Rmpc_set_sj_ui($mpc, $sj, $ui, $round);
+ Rmpc_real($mpfr_re, $mpc, $round);
+ Rmpc_imag($mpfr_im, $mpc, $round);
+ if($ret == 0 && $mpfr_re == $sj && $mpfr_im == $ui) {$ok .= 'O'}
+ else {warn "O: $ret $mpfr_re $mpfr_im\n$mpc\n"}
+
+ $ret = Rmpc_set_si_uj($mpc, $si, $uj, $round);
+ Rmpc_real($mpfr_re, $mpc, $round);
+ Rmpc_imag($mpfr_im, $mpc, $round);
+ if($ret == 0 && $mpfr_re == $si && $mpfr_im == $uj) {$ok .= 'P'}
+ else {warn "P: $ret $mpfr_re $mpfr_im\n$mpc\n"}
+
+ $ret = Rmpc_set_uj_ui($mpc, $uj, $ui, $round);
+ Rmpc_real($mpfr_re, $mpc, $round);
+ Rmpc_imag($mpfr_im, $mpc, $round);
+ if($ret == 0 && $mpfr_re == $uj && $mpfr_im == $ui) {$ok .= 'Q'}
+ else {warn "Q: $ret $mpfr_re $mpfr_im\n$mpc\n"}
+
+ $ret = Rmpc_set_ui_uj($mpc, $ui, $uj, $round);
+ Rmpc_real($mpfr_re, $mpc, $round);
+ Rmpc_imag($mpfr_im, $mpc, $round);
+ if($ret == 0 && $mpfr_re == $ui && $mpfr_im == $uj) {$ok .= 'R'}
+ else {warn "R: $ret $mpfr_re $mpfr_im\n$mpc\n"}
+
+ $ret = Rmpc_set_sj_si($mpc, $sj, $si, $round);
+ Rmpc_real($mpfr_re, $mpc, $round);
+ Rmpc_imag($mpfr_im, $mpc, $round);
+ if($ret == 0 && $mpfr_re == $sj && $mpfr_im == $si) {$ok .= 'S'}
+ else {warn "S: $ret $mpfr_re $mpfr_im\n$mpc\n"}
+
+ $ret = Rmpc_set_si_sj($mpc, $si, $sj, $round);
+ Rmpc_real($mpfr_re, $mpc, $round);
+ Rmpc_imag($mpfr_im, $mpc, $round);
+ if($ret == 0 && $mpfr_re == $si && $mpfr_im == $sj) {$ok .= 'T'}
+ else {warn "T: $ret $mpfr_re $mpfr_im\n$mpc\n"}
+}
+else {
+ eval {Rmpc_set_uj_uj($mpc, $uj, $uj2, $round);};
+ if($@ =~ /Rmpc_set_uj_uj not implemented/) {$ok .= 'K'}
+ else {warn "K: \$\@: $@\n"}
+
+ eval {Rmpc_set_sj_sj($mpc, $sj, $sj, $round);};
+ if($@ =~ /Rmpc_set_sj_sj not implemented/) {$ok .= 'L'}
+ else {warn "L: \$\@: $@\n"}
+
+ eval {Rmpc_set_uj_si($mpc, $uj, $si, $round);};
+ if($@ =~ /Rmpc_set_uj_sj not implemented/) {$ok .= 'M'}
+ else {warn "M: \$\@: $@\n"}
+
+ eval {Rmpc_set_ui_sj($mpc, $ui, $sj, $round);};
+ if($@ =~ /Rmpc_set_uj_sj not implemented/) {$ok .= 'N'}
+ else {warn "N: \$\@: $@\n"}
+
+ eval {Rmpc_set_sj_ui($mpc, $sj, $ui, $round);};
+ if($@ =~ /Rmpc_set_sj_uj not implemented/) {$ok .= 'O'}
+ else {warn "O: \$\@: $@\n"}
+
+ eval {Rmpc_set_si_uj($mpc, $si, $uj, $round);};
+ if($@ =~ /Rmpc_set_sj_uj not implemented/) {$ok .= 'P'}
+ else {warn "P: \$\@: $@\n"}
+
+ eval {Rmpc_set_uj_ui($mpc, $uj, $ui, $round);};
+ if($@ =~ /Rmpc_set_uj_uj not implemented/) {$ok .= 'Q'}
+ else {warn "Q: \$\@: $@\n"}
+
+ eval {Rmpc_set_ui_uj($mpc, $ui, $uj, $round);};
+ if($@ =~ /Rmpc_set_uj_uj not implemented/) {$ok .= 'R'}
+ else {warn "R: \$\@: $@\n"}
+
+ eval {Rmpc_set_sj_si($mpc, $sj, $si, $round);};
+ if($@ =~ /Rmpc_set_sj_sj not implemented/) {$ok .= 'S'}
+ else {warn "S: \$\@: $@\n"}
+
+ eval {Rmpc_set_si_sj($mpc, $si, $sj, $round);};
+ if($@ =~ /Rmpc_set_sj_sj not implemented/) {$ok .= 'T'}
+ else {warn "T: \$\@: $@\n"}
+}
+
+if(Math::MPC::_has_longdouble()) {
+ $ret = Rmpc_set_ld_ld($mpc, $ld, $ld2, $round);
+ Rmpc_real($mpfr_re, $mpc, $round);
+ Rmpc_imag($mpfr_im, $mpc, $round);
+ if($ret == 0 && $mpfr_re == $ld && $mpfr_im == $ld - 11) {$ok .= 'U'}
+ else {warn "U: $ret $mpfr_re $mpfr_im\n$mpc\n"}
+
+ $ret = Rmpc_set_d_ld($mpc, $d, $ld, $round);
+ Rmpc_real($mpfr_re, $mpc, $round);
+ Rmpc_imag($mpfr_im, $mpc, $round);
+ if($ret == 0 && $mpfr_re == $d && $mpfr_im == $ld) {$ok .= 'V'}
+ else {warn "V: $ret $mpfr_re $mpfr_im\n$mpc\n"}
+
+ $ret = Rmpc_set_ld_d($mpc, $ld, $d, $round);
+ Rmpc_real($mpfr_re, $mpc, $round);
+ Rmpc_imag($mpfr_im, $mpc, $round);
+ if($ret == 0 && $mpfr_re == $ld && $mpfr_im == $d) {$ok .= 'W'}
+ else {warn "W: $ret $mpfr_re $mpfr_im\n$mpc\n"}
+
+ $ret = Rmpc_set_ld($mpc, $ld, $round);
+ Rmpc_real($mpfr_re, $mpc, $round);
+ Rmpc_imag($mpfr_im, $mpc, $round);
+ if($ret == 0 && $mpfr_re == $ld && $mpfr_im == 0) {$ok .= 'X'}
+ else {warn "X: $ret $mpfr_re $mpfr_im\n$mpc\n"}
+}
+else{
+ eval {Rmpc_set_ld_ld($mpc, $ld, $ld2, $round);};
+ if($@ =~ /Rmpc_set_ld_ld not implemented/) {$ok .= 'U'}
+ else {warn "U: \$\@: $@\n"}
+
+ eval {Rmpc_set_d_ld($mpc, $d, $ld, $round);};
+ if($@ =~ /Rmpc_set_ld_ld not implemented/) {$ok .= 'V'}
+ else {warn "V: \$\@: $@\n"}
+
+ eval {Rmpc_set_ld_d($mpc, $ld, $d, $round);};
+ if($@ =~ /Rmpc_set_ld_ld not implemented/) {$ok .= 'W'}
+ else {warn "W: \$\@: $@\n"}
+
+ eval {Rmpc_set_ld($mpc, $ld, $round);};
+ if($@ =~ /Rmpc_set_ld not implemented/) {$ok .= 'X'}
+ else {warn "X: \$\@: $@\n"}
+}
+
+if($ok eq 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWX') {print "ok 1\n"}
+else {print "not ok 1\n$ok\n"}
+
+$ok = '';
+
+$ret = Rmpc_set_ui($mpc, $ui, $round);
+Rmpc_real($mpfr_re, $mpc, $round);
+Rmpc_imag($mpfr_im, $mpc, $round);
+if($ret == 0 && $mpfr_re == $ui && $mpfr_im == 0) {$ok .= 'a'}
+else {warn "2a: $ret $mpfr_re $mpfr_im\n$mpc\n"}
+
+$ret = Rmpc_set_si($mpc, $si, $round);
+Rmpc_real($mpfr_re, $mpc, $round);
+Rmpc_imag($mpfr_im, $mpc, $round);
+if($ret == 0 && $mpfr_re == $si && $mpfr_im == 0) {$ok .= 'b'}
+else {warn "2b: $ret $mpfr_re $mpfr_im\n$mpc\n"}
+
+$ret = Rmpc_set_d($mpc, $d, $round);
+Rmpc_real($mpfr_re, $mpc, $round);
+Rmpc_imag($mpfr_im, $mpc, $round);
+if($ret == 0 && $mpfr_re == $d && $mpfr_im == 0) {$ok .= 'c'}
+else {warn "2c: $ret $mpfr_re $mpfr_im\n$mpc\n"}
+
+if(Math::MPC::_has_longlong()) {
+ $ret = Rmpc_set_uj($mpc, $uj, $round);
+ Rmpc_real($mpfr_re, $mpc, $round);
+ Rmpc_imag($mpfr_im, $mpc, $round);
+ if($ret == 0 && $mpfr_re == $uj && $mpfr_im == 0) {$ok .= 'd'}
+ else {warn "2d: $ret $mpfr_re $mpfr_im\n$mpc\n"}
+
+ $ret = Rmpc_set_sj($mpc, $sj, $round);
+ Rmpc_real($mpfr_re, $mpc, $round);
+ Rmpc_imag($mpfr_im, $mpc, $round);
+ if($ret == 0 && $mpfr_re == $sj && $mpfr_im == 0) {$ok .= 'e'}
+ else {warn "2e: $ret $mpfr_re $mpfr_im\n$mpc\n"}
+}
+else {
+ eval {Rmpc_set_uj($mpc, $uj, $round);};
+ if($@ =~ /Rmpc_set_uj not implemented/) {$ok .= 'd'}
+ else {warn "2d: \$\@: $@\n"}
+
+ eval {Rmpc_set_sj($mpc, $sj, $round);};
+ if($@ =~ /Rmpc_set_sj not implemented/) {$ok .= 'e'}
+ else {warn "2e: \$\@: $@\n"}
+}
+
+# Rmpc_set_ld is already checked above
+
+$ret = Rmpc_set_fr($mpc, $mpfr, $round);
+Rmpc_real($mpfr_re, $mpc, $round);
+Rmpc_imag($mpfr_im, $mpc, $round);
+if($ret == 0 && $mpfr_re == $mpfr && $mpfr_im == 0) {$ok .= 'f'}
+else {warn "2d: $ret $mpfr_re $mpfr_im\n$mpc\n"}
+
+if($ok eq 'abcdef') {print "ok 2\n"}
+else {print "not ok 2\n$ok\n"}
+
+my ($have_GMP, $have_GMPz, $have_GMPq, $have_GMPf) = (0, 0, 0, 0);
+
+eval{require Math::GMP;};
+$have_GMP = 1 if !$@;
+
+eval{require Math::GMPz;};
+$have_GMPz = 1 if !$@;
+
+eval{require Math::GMPq;};
+$have_GMPq = 1 if !$@;
+
+eval{require Math::GMPf;};
+$have_GMPf = 1 if !$@;
+
+if($have_GMP) {
+ $ok = '';
+ my $gmp = Math::GMP->new(1234567);
+ $ret = Rmpc_set_z($mpc, $gmp, $round);
+ Rmpc_real($mpfr_re, $mpc, $round);
+ Rmpc_imag($mpfr_im, $mpc, $round);
+ if($ret == 0 && $mpfr_re == 1234567 && $mpfr_im == 0) {$ok .= 'a'}
+ else {warn "3a: $ret $mpfr_re $mpfr_im\n$mpc\n"}
+
+ my $gmp2 = Math::GMP->new(890);
+ $ret = Rmpc_set_z_z($mpc, $gmp, $gmp2, $round);
+ Rmpc_real($mpfr_re, $mpc, $round);
+ Rmpc_imag($mpfr_im, $mpc, $round);
+ if($ret == 0 && $mpfr_re == 1234567 && $mpfr_im == 890) {$ok .= 'b'}
+ else {warn "3b: $ret $mpfr_re $mpfr_im\n$mpc\n"}
+
+
+ $ret = Rmpc_set_z_ui($mpc, $gmp, $ui, $round);
+ Rmpc_real($mpfr_re, $mpc, $round);
+ Rmpc_imag($mpfr_im, $mpc, $round);
+ if($ret == 0 && $mpfr_re == 1234567 && $mpfr_im == $ui) {$ok .= 'c'}
+ else {warn "3c: $ret $mpfr_re $mpfr_im\n$mpc\n"}
+
+ $ret = Rmpc_set_ui_z($mpc, $ui, $gmp, $round);
+ Rmpc_real($mpfr_re, $mpc, $round);
+ Rmpc_imag($mpfr_im, $mpc, $round);
+ if($ret == 0 && $mpfr_re == $ui && $mpfr_im == 1234567) {$ok .= 'd'}
+ else {warn "3d: $ret $mpfr_re $mpfr_im\n$mpc\n"}
+
+ $ret = Rmpc_set_z_si($mpc, $gmp, $si, $round);
+ Rmpc_real($mpfr_re, $mpc, $round);
+ Rmpc_imag($mpfr_im, $mpc, $round);
+ if($ret == 0 && $mpfr_re == 1234567 && $mpfr_im == $si) {$ok .= 'e'}
+ else {warn "4e: $ret $mpfr_re $mpfr_im\n$mpc\n"}
+
+ $ret = Rmpc_set_si_z($mpc, $si, $gmp, $round);
+ Rmpc_real($mpfr_re, $mpc, $round);
+ Rmpc_imag($mpfr_im, $mpc, $round);
+ if($ret == 0 && $mpfr_re == $si && $mpfr_im == 1234567) {$ok .= 'f'}
+ else {warn "3f: $ret $mpfr_re $mpfr_im\n$mpc\n"}
+
+ $ret = Rmpc_set_z_d($mpc, $gmp, $d, $round);
+ Rmpc_real($mpfr_re, $mpc, $round);
+ Rmpc_imag($mpfr_im, $mpc, $round);
+ if($ret == 0 && $mpfr_re == 1234567 && $mpfr_im == $d) {$ok .= 'g'}
+ else {warn "3g: $ret $mpfr_re $mpfr_im\n$mpc\n"}
+
+ $ret = Rmpc_set_d_z($mpc, $d, $gmp, $round);
+ Rmpc_real($mpfr_re, $mpc, $round);
+ Rmpc_imag($mpfr_im, $mpc, $round);
+ if($ret == 0 && $mpfr_re == $d && $mpfr_im == 1234567) {$ok .= 'h'}
+ else {warn "3h: $ret $mpfr_re $mpfr_im\n$mpc\n"}
+
+ if(Math::MPC::_has_longlong()) {
+ $ret = Rmpc_set_z_uj($mpc, $gmp, $uj, $round);
+ Rmpc_real($mpfr_re, $mpc, $round);
+ Rmpc_imag($mpfr_im, $mpc, $round);
+ if($ret == 0 && $mpfr_re == 1234567 && $mpfr_im == $uj) {$ok .= 'i'}
+ else {warn "3i: $ret $mpfr_re $mpfr_im\n$mpc\n"}
+
+ $ret = Rmpc_set_uj_z($mpc, $uj, $gmp, $round);
+ Rmpc_real($mpfr_re, $mpc, $round);
+ Rmpc_imag($mpfr_im, $mpc, $round);
+ if($ret == 0 && $mpfr_re == $uj && $mpfr_im == 1234567) {$ok .= 'j'}
+ else {warn "3j: $ret $mpfr_re $mpfr_im\n$mpc\n"}
+
+ $ret = Rmpc_set_z_sj($mpc, $gmp, $sj, $round);
+ Rmpc_real($mpfr_re, $mpc, $round);
+ Rmpc_imag($mpfr_im, $mpc, $round);
+ if($ret == 0 && $mpfr_re == 1234567 && $mpfr_im == $sj) {$ok .= 'k'}
+ else {warn "3k: $ret $mpfr_re $mpfr_im\n$mpc\n"}
+
+ $ret = Rmpc_set_sj_z($mpc, $sj, $gmp, $round);
+ Rmpc_real($mpfr_re, $mpc, $round);
+ Rmpc_imag($mpfr_im, $mpc, $round);
+ if($ret == 0 && $mpfr_re == $sj && $mpfr_im == 1234567) {$ok .= 'l'}
+ else {warn "3l: $ret $mpfr_re $mpfr_im\n$mpc\n"}
+ }
+ else {
+ eval {Rmpc_set_z_uj($mpc, $gmp, $uj, $round);};
+ if($@ =~ /Rmpc_set_z_uj not implemented/) {$ok .= 'i'}
+ else {warn "3i: \$\@: $@\n"}
+
+ eval {Rmpc_set_uj_z($mpc, $uj, $gmp, $round);};
+ if($@ =~ /Rmpc_set_uj_z not implemented/) {$ok .= 'j'}
+ else {warn "3j: \$\@: $@\n"}
+
+ eval {Rmpc_set_z_sj($mpc, $gmp, $sj, $round);};
+ if($@ =~ /Rmpc_set_z_sj not implemented/) {$ok .= 'k'}
+ else {warn "3k: \$\@: $@\n"}
+
+ eval {Rmpc_set_sj_z($mpc, $sj, $gmp, $round);};
+ if($@ =~ /Rmpc_set_sj_z not implemented/) {$ok .= 'l'}
+ else {warn "3l: \$\@: $@\n"}
+ }
+
+ if(Math::MPC::_has_longdouble()) {
+ $ret = Rmpc_set_z_ld($mpc, $gmp, $ld, $round);
+ Rmpc_real($mpfr_re, $mpc, $round);
+ Rmpc_imag($mpfr_im, $mpc, $round);
+ if($ret == 0 && $mpfr_re == 1234567 && $mpfr_im == $ld) {$ok .= 'm'}
+ else {warn "3m: $ret $mpfr_re $mpfr_im\n$mpc\n"}
+
+ $ret = Rmpc_set_ld_z($mpc, $ld, $gmp, $round);
+ Rmpc_real($mpfr_re, $mpc, $round);
+ Rmpc_imag($mpfr_im, $mpc, $round);
+ if($ret == 0 && $mpfr_re == $ld && $mpfr_im == 1234567) {$ok .= 'n'}
+ else {warn "3n: $ret $mpfr_re $mpfr_im\n$mpc\n"}
+ }
+ else {
+ eval {Rmpc_set_z_ld($mpc, $gmp, $ld, $round);};
+ if($@ =~ /Rmpc_set_z_ld not implemented/) {$ok .= 'm'}
+ else {warn "3m: \$\@: $@\n"}
+
+ eval {Rmpc_set_ld_z($mpc, $ld, $gmp, $round);};
+ if($@ =~ /Rmpc_set_ld_z not implemented/) {$ok .= 'n'}
+ else {warn "3n: \$\@: $@\n"}
+ }
+
+ $ret = Rmpc_set_z_fr($mpc, $gmp, $mpfr, $round);
+ Rmpc_real($mpfr_re, $mpc, $round);
+ Rmpc_imag($mpfr_im, $mpc, $round);
+ if($ret == 0 && $mpfr_re == 1234567 && $mpfr_im == $mpfr) {$ok .= 'o'}
+ else {warn "3o: $ret $mpfr_re $mpfr_im\n$mpc\n"}
+
+ $ret = Rmpc_set_fr_z($mpc, $mpfr, $gmp, $round);
+ Rmpc_real($mpfr_re, $mpc, $round);
+ Rmpc_imag($mpfr_im, $mpc, $round);
+ if($ret == 0 && $mpfr_re == $mpfr && $mpfr_im == 1234567) {$ok .= 'p'}
+ else {warn "3p: $ret $mpfr_re $mpfr_im\n$mpc\n"}
+
+ if($have_GMPq) {
+ my $gmpq = Math::GMPq->new(89083);
+ $ret = Rmpc_set_z_q($mpc, $gmp, $gmpq, $round);
+ Rmpc_real($mpfr_re, $mpc, $round);
+ Rmpc_imag($mpfr_im, $mpc, $round);
+ if($ret == 0 && $mpfr_re == 1234567 && $mpfr_im == 89083) {$ok .= 'q'}
+ else {warn "3q: $ret $mpfr_re $mpfr_im\n$mpc\n"}
+
+ $ret = Rmpc_set_q_z($mpc, $gmpq, $gmp, $round);
+ Rmpc_real($mpfr_re, $mpc, $round);
+ Rmpc_imag($mpfr_im, $mpc, $round);
+ if($ret == 0 && $mpfr_re == 89083 && $mpfr_im == 1234567) {$ok .= 'r'}
+ else {warn "3r: $ret $mpfr_re $mpfr_im\n$mpc\n"}
+ }
+ else {
+ warn " skipping 3q and 3r - no Math::GMPq\n";
+ $ok .= 'qr';
+ }
+
+ if($have_GMPf) {
+ my $gmpf = Math::GMPf->new(890213.5);
+ $ret = Rmpc_set_z_f($mpc, $gmp, $gmpf, $round);
+ Rmpc_real($mpfr_re, $mpc, $round);
+ Rmpc_imag($mpfr_im, $mpc, $round);
+ if($ret == 0 && $mpfr_re == 1234567 && $mpfr_im == 890213.5) {$ok .= 's'}
+ else {warn "3s: $ret $mpfr_re $mpfr_im\n$mpc\n"}
+
+ $ret = Rmpc_set_f_z($mpc, $gmpf, $gmp, $round);
+ Rmpc_real($mpfr_re, $mpc, $round);
+ Rmpc_imag($mpfr_im, $mpc, $round);
+ if($ret == 0 && $mpfr_re == 890213.5 && $mpfr_im == 1234567) {$ok .= 't'}
+ else {warn "3t: $ret $mpfr_re $mpfr_im\n$mpc\n"}
+ }
+ else {
+ warn " skipping 3s and 3t - no Math::GMPf\n";
+ $ok .= 'st';
+ }
+
+ if($ok eq 'abcdefghijklmnopqrst') {print "ok 3\n"}
+ else {print "not ok 3\n$ok\n"}
+}
+else {
+ print "ok 3 - skipped, no Math::GMP\n";
+}
+
+if($have_GMPz) {
+ $ok = '';
+ my $gmp = Math::GMPz->new(1234566);
+ $ret = Rmpc_set_z($mpc, $gmp, $round);
+ Rmpc_real($mpfr_re, $mpc, $round);
+ Rmpc_imag($mpfr_im, $mpc, $round);
+ if($ret == 0 && $mpfr_re == 1234566 && $mpfr_im == 0) {$ok .= 'a'}
+ else {warn "4a: $ret $mpfr_re $mpfr_im\n$mpc\n"}
+
+ my $gmp2 = Math::GMPz->new(891);
+ $ret = Rmpc_set_z_z($mpc, $gmp, $gmp2, $round);
+ Rmpc_real($mpfr_re, $mpc, $round);
+ Rmpc_imag($mpfr_im, $mpc, $round);
+ if($ret == 0 && $mpfr_re == 1234566 && $mpfr_im == 891) {$ok .= 'b'}
+ else {warn "4b: $ret $mpfr_re $mpfr_im\n$mpc\n"}
+
+ $ret = Rmpc_set_z_ui($mpc, $gmp, $ui, $round);
+ Rmpc_real($mpfr_re, $mpc, $round);
+ Rmpc_imag($mpfr_im, $mpc, $round);
+ if($ret == 0 && $mpfr_re == 1234566 && $mpfr_im == $ui) {$ok .= 'c'}
+ else {warn "4c: $ret $mpfr_re $mpfr_im\n$mpc\n"}
+
+ $ret = Rmpc_set_ui_z($mpc, $ui, $gmp, $round);
+ Rmpc_real($mpfr_re, $mpc, $round);
+ Rmpc_imag($mpfr_im, $mpc, $round);
+ if($ret == 0 && $mpfr_re == $ui && $mpfr_im == 1234566) {$ok .= 'd'}
+ else {warn "4d: $ret $mpfr_re $mpfr_im\n$mpc\n"}
+
+ $ret = Rmpc_set_z_si($mpc, $gmp, $si, $round);
+ Rmpc_real($mpfr_re, $mpc, $round);
+ Rmpc_imag($mpfr_im, $mpc, $round);
+ if($ret == 0 && $mpfr_re == 1234566 && $mpfr_im == $si) {$ok .= 'e'}
+ else {warn "4e: $ret $mpfr_re $mpfr_im\n$mpc\n"}
+
+ $ret = Rmpc_set_si_z($mpc, $si, $gmp, $round);
+ Rmpc_real($mpfr_re, $mpc, $round);
+ Rmpc_imag($mpfr_im, $mpc, $round);
+ if($ret == 0 && $mpfr_re == $si && $mpfr_im == 1234566) {$ok .= 'f'}
+ else {warn "4f: $ret $mpfr_re $mpfr_im\n$mpc\n"}
+
+ $ret = Rmpc_set_z_d($mpc, $gmp, $d, $round);
+ Rmpc_real($mpfr_re, $mpc, $round);
+ Rmpc_imag($mpfr_im, $mpc, $round);
+ if($ret == 0 && $mpfr_re == 1234566 && $mpfr_im == $d) {$ok .= 'g'}
+ else {warn "4g: $ret $mpfr_re $mpfr_im\n$mpc\n"}
+
+ $ret = Rmpc_set_d_z($mpc, $d, $gmp, $round);
+ Rmpc_real($mpfr_re, $mpc, $round);
+ Rmpc_imag($mpfr_im, $mpc, $round);
+ if($ret == 0 && $mpfr_re == $d && $mpfr_im == 1234566) {$ok .= 'h'}
+ else {warn "4h: $ret $mpfr_re $mpfr_im\n$mpc\n"}
+
+ if(Math::MPC::_has_longlong()) {
+ $ret = Rmpc_set_z_uj($mpc, $gmp, $uj, $round);
+ Rmpc_real($mpfr_re, $mpc, $round);
+ Rmpc_imag($mpfr_im, $mpc, $round);
+ if($ret == 0 && $mpfr_re == 1234566 && $mpfr_im == $uj) {$ok .= 'i'}
+ else {warn "4i: $ret $mpfr_re $mpfr_im\n$mpc\n"}
+
+ $ret = Rmpc_set_uj_z($mpc, $uj, $gmp, $round);
+ Rmpc_real($mpfr_re, $mpc, $round);
+ Rmpc_imag($mpfr_im, $mpc, $round);
+ if($ret == 0 && $mpfr_re == $uj && $mpfr_im == 1234566) {$ok .= 'j'}
+ else {warn "4j: $ret $mpfr_re $mpfr_im\n$mpc\n"}
+
+ $ret = Rmpc_set_z_sj($mpc, $gmp, $sj, $round);
+ Rmpc_real($mpfr_re, $mpc, $round);
+ Rmpc_imag($mpfr_im, $mpc, $round);
+ if($ret == 0 && $mpfr_re == 1234566 && $mpfr_im == $sj) {$ok .= 'k'}
+ else {warn "4k: $ret $mpfr_re $mpfr_im\n$mpc\n"}
+
+ $ret = Rmpc_set_sj_z($mpc, $sj, $gmp, $round);
+ Rmpc_real($mpfr_re, $mpc, $round);
+ Rmpc_imag($mpfr_im, $mpc, $round);
+ if($ret == 0 && $mpfr_re == $sj && $mpfr_im == 1234566) {$ok .= 'l'}
+ else {warn "4l: $ret $mpfr_re $mpfr_im\n$mpc\n"}
+ }
+ else {
+ eval {Rmpc_set_z_uj($mpc, $gmp, $uj, $round);};
+ if($@ =~ /Rmpc_set_z_uj not implemented/) {$ok .= 'i'}
+ else {warn "4i: \$\@: $@\n"}
+
+ eval {Rmpc_set_uj_z($mpc, $uj, $gmp, $round);};
+ if($@ =~ /Rmpc_set_uj_z not implemented/) {$ok .= 'j'}
+ else {warn "4j: \$\@: $@\n"}
+
+ eval {Rmpc_set_z_sj($mpc, $gmp, $sj, $round);};
+ if($@ =~ /Rmpc_set_z_sj not implemented/) {$ok .= 'k'}
+ else {warn "4k: \$\@: $@\n"}
+
+ eval {Rmpc_set_sj_z($mpc, $sj, $gmp, $round);};
+ if($@ =~ /Rmpc_set_sj_z not implemented/) {$ok .= 'l'}
+ else {warn "4l: \$\@: $@\n"}
+ }
+
+ if(Math::MPC::_has_longdouble()) {
+ $ret = Rmpc_set_z_ld($mpc, $gmp, $ld, $round);
+ Rmpc_real($mpfr_re, $mpc, $round);
+ Rmpc_imag($mpfr_im, $mpc, $round);
+ if($ret == 0 && $mpfr_re == 1234566 && $mpfr_im == $ld) {$ok .= 'm'}
+ else {warn "4m: $ret $mpfr_re $mpfr_im\n$mpc\n"}
+
+ $ret = Rmpc_set_ld_z($mpc, $ld, $gmp, $round);
+ Rmpc_real($mpfr_re, $mpc, $round);
+ Rmpc_imag($mpfr_im, $mpc, $round);
+ if($ret == 0 && $mpfr_re == $ld && $mpfr_im == 1234566) {$ok .= 'n'}
+ else {warn "4n: $ret $mpfr_re $mpfr_im\n$mpc\n"}
+ }
+ else {
+ eval {Rmpc_set_z_ld($mpc, $gmp, $ld, $round);};
+ if($@ =~ /Rmpc_set_z_ld not implemented/) {$ok .= 'm'}
+ else {warn "4m: \$\@: $@\n"}
+
+ eval {Rmpc_set_ld_z($mpc, $ld, $gmp, $round);};
+ if($@ =~ /Rmpc_set_ld_z not implemented/) {$ok .= 'n'}
+ else {warn "4n: \$\@: $@\n"}
+ }
+
+ $ret = Rmpc_set_z_fr($mpc, $gmp, $mpfr, $round);
+ Rmpc_real($mpfr_re, $mpc, $round);
+ Rmpc_imag($mpfr_im, $mpc, $round);
+ if($ret == 0 && $mpfr_re == 1234566 && $mpfr_im == $mpfr) {$ok .= 'o'}
+ else {warn "4o: $ret $mpfr_re $mpfr_im\n$mpc\n"}
+
+ $ret = Rmpc_set_fr_z($mpc, $mpfr, $gmp, $round);
+ Rmpc_real($mpfr_re, $mpc, $round);
+ Rmpc_imag($mpfr_im, $mpc, $round);
+ if($ret == 0 && $mpfr_re == $mpfr && $mpfr_im == 1234566) {$ok .= 'p'}
+ else {warn "4p: $ret $mpfr_re $mpfr_im\n$mpc\n"}
+
+ if($have_GMPq) {
+ my $gmpq = Math::GMPq->new(8903);
+ $ret = Rmpc_set_z_q($mpc, $gmp, $gmpq, $round);
+ Rmpc_real($mpfr_re, $mpc, $round);
+ Rmpc_imag($mpfr_im, $mpc, $round);
+ if($ret == 0 && $mpfr_re == 1234566 && $mpfr_im == 8903) {$ok .= 'q'}
+ else {warn "4q: $ret $mpfr_re $mpfr_im\n$mpc\n"}
+
+ $ret = Rmpc_set_q_z($mpc, $gmpq, $gmp, $round);
+ Rmpc_real($mpfr_re, $mpc, $round);
+ Rmpc_imag($mpfr_im, $mpc, $round);
+ if($ret == 0 && $mpfr_re == 8903 && $mpfr_im == 1234566) {$ok .= 'r'}
+ else {warn "4r: $ret $mpfr_re $mpfr_im\n$mpc\n"}
+ }
+ else {
+ warn " skipping 4q and 4r - no Math::GMPq\n";
+ $ok .= 'qr';
+ }
+
+ if($have_GMPf) {
+ my $gmpf = Math::GMPf->new(89023.5);
+ $ret = Rmpc_set_z_f($mpc, $gmp, $gmpf, $round);
+ Rmpc_real($mpfr_re, $mpc, $round);
+ Rmpc_imag($mpfr_im, $mpc, $round);
+ if($ret == 0 && $mpfr_re == 1234566 && $mpfr_im == 89023.5) {$ok .= 's'}
+ else {warn "4s: $ret $mpfr_re $mpfr_im\n$mpc\n"}
+
+ $ret = Rmpc_set_f_z($mpc, $gmpf, $gmp, $round);
+ Rmpc_real($mpfr_re, $mpc, $round);
+ Rmpc_imag($mpfr_im, $mpc, $round);
+ if($ret == 0 && $mpfr_re == 89023.5 && $mpfr_im == 1234566) {$ok .= 't'}
+ else {warn "4t: $ret $mpfr_re $mpfr_im\n$mpc\n"}
+ }
+ else {
+ warn " skipping 4s and 4t - no Math::GMPf\n";
+ $ok .= 'st';
+ }
+
+ if($ok eq 'abcdefghijklmnopqrst') {print "ok 4\n"}
+ else {print "not ok 4\n$ok\n"}
+}
+else {
+ print "ok 4 - skipped, no Math::GMPz\n";
+}
+
+if($have_GMPq) {
+ $ok = '';
+ my $gmp = Math::GMPq->new(1234565);
+ $ret = Rmpc_set_q($mpc, $gmp, $round);
+ Rmpc_real($mpfr_re, $mpc, $round);
+ Rmpc_imag($mpfr_im, $mpc, $round);
+ if($ret == 0 && $mpfr_re == 1234565 && $mpfr_im == 0) {$ok .= 'a'}
+ else {warn "5a: $ret $mpfr_re $mpfr_im\n$mpc\n"}
+
+ my $gmp2 = Math::GMPq->new(8921);
+ $ret = Rmpc_set_q_q($mpc, $gmp, $gmp2, $round);
+ Rmpc_real($mpfr_re, $mpc, $round);
+ Rmpc_imag($mpfr_im, $mpc, $round);
+ if($ret == 0 && $mpfr_re == 1234565 && $mpfr_im == 8921) {$ok .= 'b'}
+ else {warn "5b: $ret $mpfr_re $mpfr_im\n$mpc\n"}
+
+ $ret = Rmpc_set_q_ui($mpc, $gmp, $ui, $round);
+ Rmpc_real($mpfr_re, $mpc, $round);
+ Rmpc_imag($mpfr_im, $mpc, $round);
+ if($ret == 0 && $mpfr_re == 1234565 && $mpfr_im == $ui) {$ok .= 'c'}
+ else {warn "5c: $ret $mpfr_re $mpfr_im\n$mpc\n"}
+
+ $ret = Rmpc_set_ui_q($mpc, $ui, $gmp, $round);
+ Rmpc_real($mpfr_re, $mpc, $round);
+ Rmpc_imag($mpfr_im, $mpc, $round);
+ if($ret == 0 && $mpfr_re == $ui && $mpfr_im == 1234565) {$ok .= 'd'}
+ else {warn "5d: $ret $mpfr_re $mpfr_im\n$mpc\n"}
+
+ $ret = Rmpc_set_q_si($mpc, $gmp, $si, $round);
+ Rmpc_real($mpfr_re, $mpc, $round);
+ Rmpc_imag($mpfr_im, $mpc, $round);
+ if($ret == 0 && $mpfr_re == 1234565 && $mpfr_im == $si) {$ok .= 'e'}
+ else {warn "5e: $ret $mpfr_re $mpfr_im\n$mpc\n"}
+
+ $ret = Rmpc_set_si_q($mpc, $si, $gmp, $round);
+ Rmpc_real($mpfr_re, $mpc, $round);
+ Rmpc_imag($mpfr_im, $mpc, $round);
+ if($ret == 0 && $mpfr_re == $si && $mpfr_im == 1234565) {$ok .= 'f'}
+ else {warn "5f: $ret $mpfr_re $mpfr_im\n$mpc\n"}
+
+ $ret = Rmpc_set_q_d($mpc, $gmp, $d, $round);
+ Rmpc_real($mpfr_re, $mpc, $round);
+ Rmpc_imag($mpfr_im, $mpc, $round);
+ if($ret == 0 && $mpfr_re == 1234565 && $mpfr_im == $d) {$ok .= 'g'}
+ else {warn "5g: $ret $mpfr_re $mpfr_im\n$mpc\n"}
+
+ $ret = Rmpc_set_d_q($mpc, $d, $gmp, $round);
+ Rmpc_real($mpfr_re, $mpc, $round);
+ Rmpc_imag($mpfr_im, $mpc, $round);
+ if($ret == 0 && $mpfr_re == $d && $mpfr_im == 1234565) {$ok .= 'h'}
+ else {warn "5h: $ret $mpfr_re $mpfr_im\n$mpc\n"}
+
+ if(Math::MPC::_has_longlong()) {
+ $ret = Rmpc_set_q_uj($mpc, $gmp, $uj, $round);
+ Rmpc_real($mpfr_re, $mpc, $round);
+ Rmpc_imag($mpfr_im, $mpc, $round);
+ if($ret == 0 && $mpfr_re == 1234565 && $mpfr_im == $uj) {$ok .= 'i'}
+ else {warn "5i: $ret $mpfr_re $mpfr_im\n$mpc\n"}
+
+ $ret = Rmpc_set_uj_q($mpc, $uj, $gmp, $round);
+ Rmpc_real($mpfr_re, $mpc, $round);
+ Rmpc_imag($mpfr_im, $mpc, $round);
+ if($ret == 0 && $mpfr_re == $uj && $mpfr_im == 1234565) {$ok .= 'j'}
+ else {warn "5j: $ret $mpfr_re $mpfr_im\n$mpc\n"}
+
+ $ret = Rmpc_set_q_sj($mpc, $gmp, $sj, $round);
+ Rmpc_real($mpfr_re, $mpc, $round);
+ Rmpc_imag($mpfr_im, $mpc, $round);
+ if($ret == 0 && $mpfr_re == 1234565 && $mpfr_im == $sj) {$ok .= 'k'}
+ else {warn "4k: $ret $mpfr_re $mpfr_im\n$mpc\n"}
+
+ $ret = Rmpc_set_sj_q($mpc, $sj, $gmp, $round);
+ Rmpc_real($mpfr_re, $mpc, $round);
+ Rmpc_imag($mpfr_im, $mpc, $round);
+ if($ret == 0 && $mpfr_re == $sj && $mpfr_im == 1234565) {$ok .= 'l'}
+ else {warn "5l: $ret $mpfr_re $mpfr_im\n$mpc\n"}
+ }
+ else {
+ eval {Rmpc_set_q_uj($mpc, $gmp, $uj, $round);};
+ if($@ =~ /Rmpc_set_q_uj not implemented/) {$ok .= 'i'}
+ else {warn "5i: \$\@: $@\n"}
+
+ eval {Rmpc_set_uj_q($mpc, $uj, $gmp, $round);};
+ if($@ =~ /Rmpc_set_uj_q not implemented/) {$ok .= 'j'}
+ else {warn "5j: \$\@: $@\n"}
+
+ eval {Rmpc_set_q_sj($mpc, $gmp, $sj, $round);};
+ if($@ =~ /Rmpc_set_q_sj not implemented/) {$ok .= 'k'}
+ else {warn "5k: \$\@: $@\n"}
+
+ eval {Rmpc_set_sj_q($mpc, $sj, $gmp, $round);};
+ if($@ =~ /Rmpc_set_sj_q not implemented/) {$ok .= 'l'}
+ else {warn "5l: \$\@: $@\n"}
+ }
+
+ if(Math::MPC::_has_longdouble()) {
+ $ret = Rmpc_set_q_ld($mpc, $gmp, $ld, $round);
+ Rmpc_real($mpfr_re, $mpc, $round);
+ Rmpc_imag($mpfr_im, $mpc, $round);
+ if($ret == 0 && $mpfr_re == 1234565 && $mpfr_im == $ld) {$ok .= 'm'}
+ else {warn "5m: $ret $mpfr_re $mpfr_im\n$mpc\n"}
+
+ $ret = Rmpc_set_ld_q($mpc, $ld, $gmp, $round);
+ Rmpc_real($mpfr_re, $mpc, $round);
+ Rmpc_imag($mpfr_im, $mpc, $round);
+ if($ret == 0 && $mpfr_re == $ld && $mpfr_im == 1234565) {$ok .= 'n'}
+ else {warn "5n: $ret $mpfr_re $mpfr_im\n$mpc\n"}
+ }
+ else {
+ eval {Rmpc_set_q_ld($mpc, $gmp, $ld, $round);};
+ if($@ =~ /Rmpc_set_q_ld not implemented/) {$ok .= 'm'}
+ else {warn "5m: \$\@: $@\n"}
+
+ eval {Rmpc_set_ld_q($mpc, $ld, $gmp, $round);};
+ if($@ =~ /Rmpc_set_ld_q not implemented/) {$ok .= 'n'}
+ else {warn "5n: \$\@: $@\n"}
+ }
+
+ $ret = Rmpc_set_q_fr($mpc, $gmp, $mpfr, $round);
+ Rmpc_real($mpfr_re, $mpc, $round);
+ Rmpc_imag($mpfr_im, $mpc, $round);
+ if($ret == 0 && $mpfr_re == 1234565 && $mpfr_im == $mpfr) {$ok .= 'o'}
+ else {warn "5o: $ret $mpfr_re $mpfr_im\n$mpc\n"}
+
+ $ret = Rmpc_set_fr_q($mpc, $mpfr, $gmp, $round);
+ Rmpc_real($mpfr_re, $mpc, $round);
+ Rmpc_imag($mpfr_im, $mpc, $round);
+ if($ret == 0 && $mpfr_re == $mpfr && $mpfr_im == 1234565) {$ok .= 'p'}
+ else {warn "5p: $ret $mpfr_re $mpfr_im\n$mpc\n"}
+
+
+ if($have_GMPf) {
+ my $gmpf = Math::GMPf->new(89024.5);
+ $ret = Rmpc_set_q_f($mpc, $gmp, $gmpf, $round);
+ Rmpc_real($mpfr_re, $mpc, $round);
+ Rmpc_imag($mpfr_im, $mpc, $round);
+ if($ret == 0 && $mpfr_re == 1234565 && $mpfr_im == 89024.5) {$ok .= 'q'}
+ else {warn "5q: $ret $mpfr_re $mpfr_im\n$mpc\n"}
+
+ $ret = Rmpc_set_f_q($mpc, $gmpf, $gmp, $round);
+ Rmpc_real($mpfr_re, $mpc, $round);
+ Rmpc_imag($mpfr_im, $mpc, $round);
+ if($ret == 0 && $mpfr_re == 89024.5 && $mpfr_im == 1234565) {$ok .= 'r'}
+ else {warn "5r: $ret $mpfr_re $mpfr_im\n$mpc\n"}
+ }
+ else {
+ warn " skipping 5q and 5r - no Math::GMPf\n";
+ $ok .= 'qr';
+ }
+
+ if($ok eq 'abcdefghijklmnopqr') {print "ok 5\n"}
+ else {print "not ok 5\n$ok\n"}
+}
+else {
+ print "ok 5 - skipped, no Math::GMPq\n";
+}
+
+if($have_GMPf) {
+ $ok = '';
+ my $gmp = Math::GMPf->new(1234564.5);
+ $ret = Rmpc_set_f($mpc, $gmp, $round);
+ Rmpc_real($mpfr_re, $mpc, $round);
+ Rmpc_imag($mpfr_im, $mpc, $round);
+ if($ret == 0 && $mpfr_re == 1234564.5 && $mpfr_im == 0) {$ok .= 'a'}
+ else {warn "6a: $ret $mpfr_re $mpfr_im\n$mpc\n"}
+
+ my $gmp2 = Math::GMPf->new(8921.5);
+ $ret = Rmpc_set_f_f($mpc, $gmp, $gmp2, $round);
+ Rmpc_real($mpfr_re, $mpc, $round);
+ Rmpc_imag($mpfr_im, $mpc, $round);
+ if($ret == 0 && $mpfr_re == 1234564.5 && $mpfr_im == 8921.5) {$ok .= 'b'}
+ else {warn "6b: $ret $mpfr_re $mpfr_im\n$mpc\n"}
+
+ $ret = Rmpc_set_f_ui($mpc, $gmp, $ui, $round);
+ Rmpc_real($mpfr_re, $mpc, $round);
+ Rmpc_imag($mpfr_im, $mpc, $round);
+ if($ret == 0 && $mpfr_re == 1234564.5 && $mpfr_im == $ui) {$ok .= 'c'}
+ else {warn "6c: $ret $mpfr_re $mpfr_im\n$mpc\n"}
+
+ $ret = Rmpc_set_ui_f($mpc, $ui, $gmp, $round);
+ Rmpc_real($mpfr_re, $mpc, $round);
+ Rmpc_imag($mpfr_im, $mpc, $round);
+ if($ret == 0 && $mpfr_re == $ui && $mpfr_im == 1234564.5) {$ok .= 'd'}
+ else {warn "6d: $ret $mpfr_re $mpfr_im\n$mpc\n"}
+
+ $ret = Rmpc_set_f_si($mpc, $gmp, $si, $round);
+ Rmpc_real($mpfr_re, $mpc, $round);
+ Rmpc_imag($mpfr_im, $mpc, $round);
+ if($ret == 0 && $mpfr_re == 1234564.5 && $mpfr_im == $si) {$ok .= 'e'}
+ else {warn "6e: $ret $mpfr_re $mpfr_im\n$mpc\n"}
+
+ $ret = Rmpc_set_si_f($mpc, $si, $gmp, $round);
+ Rmpc_real($mpfr_re, $mpc, $round);
+ Rmpc_imag($mpfr_im, $mpc, $round);
+ if($ret == 0 && $mpfr_re == $si && $mpfr_im == 1234564.5) {$ok .= 'f'}
+ else {warn "6f: $ret $mpfr_re $mpfr_im\n$mpc\n"}
+
+ $ret = Rmpc_set_f_d($mpc, $gmp, $d, $round);
+ Rmpc_real($mpfr_re, $mpc, $round);
+ Rmpc_imag($mpfr_im, $mpc, $round);
+ if($ret == 0 && $mpfr_re == 1234564.5 && $mpfr_im == $d) {$ok .= 'g'}
+ else {warn "6g: $ret $mpfr_re $mpfr_im\n$mpc\n"}
+
+ $ret = Rmpc_set_d_f($mpc, $d, $gmp, $round);
+ Rmpc_real($mpfr_re, $mpc, $round);
+ Rmpc_imag($mpfr_im, $mpc, $round);
+ if($ret == 0 && $mpfr_re == $d && $mpfr_im == 1234564.5) {$ok .= 'h'}
+ else {warn "6h: $ret $mpfr_re $mpfr_im\n$mpc\n"}
+
+ if(Math::MPC::_has_longlong()) {
+ $ret = Rmpc_set_f_uj($mpc, $gmp, $uj, $round);
+ Rmpc_real($mpfr_re, $mpc, $round);
+ Rmpc_imag($mpfr_im, $mpc, $round);
+ if($ret == 0 && $mpfr_re == 1234564.5 && $mpfr_im == $uj) {$ok .= 'i'}
+ else {warn "6i: $ret $mpfr_re $mpfr_im\n$mpc\n"}
+
+ $ret = Rmpc_set_uj_f($mpc, $uj, $gmp, $round);
+ Rmpc_real($mpfr_re, $mpc, $round);
+ Rmpc_imag($mpfr_im, $mpc, $round);
+ if($ret == 0 && $mpfr_re == $uj && $mpfr_im == 1234564.5) {$ok .= 'j'}
+ else {warn "6j: $ret $mpfr_re $mpfr_im\n$mpc\n"}
+
+ $ret = Rmpc_set_f_sj($mpc, $gmp, $sj, $round);
+ Rmpc_real($mpfr_re, $mpc, $round);
+ Rmpc_imag($mpfr_im, $mpc, $round);
+ if($ret == 0 && $mpfr_re == 1234564.5 && $mpfr_im == $sj) {$ok .= 'k'}
+ else {warn "6k: $ret $mpfr_re $mpfr_im\n$mpc\n"}
+
+ $ret = Rmpc_set_sj_f($mpc, $sj, $gmp, $round);
+ Rmpc_real($mpfr_re, $mpc, $round);
+ Rmpc_imag($mpfr_im, $mpc, $round);
+ if($ret == 0 && $mpfr_re == $sj && $mpfr_im == 1234564.5) {$ok .= 'l'}
+ else {warn "6l: $ret $mpfr_re $mpfr_im\n$mpc\n"}
+ }
+ else {
+ eval {Rmpc_set_f_uj($mpc, $gmp, $uj, $round);};
+ if($@ =~ /Rmpc_set_f_uj not implemented/) {$ok .= 'i'}
+ else {warn "6i: \$\@: $@\n"}
+
+ eval {Rmpc_set_uj_f($mpc, $uj, $gmp, $round);};
+ if($@ =~ /Rmpc_set_uj_f not implemented/) {$ok .= 'j'}
+ else {warn "6j: \$\@: $@\n"}
+
+ eval {Rmpc_set_f_sj($mpc, $gmp, $sj, $round);};
+ if($@ =~ /Rmpc_set_f_sj not implemented/) {$ok .= 'k'}
+ else {warn "6k: \$\@: $@\n"}
+
+ eval {Rmpc_set_sj_f($mpc, $sj, $gmp, $round);};
+ if($@ =~ /Rmpc_set_sj_f not implemented/) {$ok .= 'l'}
+ else {warn "6l: \$\@: $@\n"}
+ }
+
+ if(Math::MPC::_has_longdouble()) {
+ $ret = Rmpc_set_f_ld($mpc, $gmp, $ld, $round);
+ Rmpc_real($mpfr_re, $mpc, $round);
+ Rmpc_imag($mpfr_im, $mpc, $round);
+ if($ret == 0 && $mpfr_re == 1234564.5 && $mpfr_im == $ld) {$ok .= 'm'}
+ else {warn "6m: $ret $mpfr_re $mpfr_im\n$mpc\n"}
+
+ $ret = Rmpc_set_ld_f($mpc, $ld, $gmp, $round);
+ Rmpc_real($mpfr_re, $mpc, $round);
+ Rmpc_imag($mpfr_im, $mpc, $round);
+ if($ret == 0 && $mpfr_re == $ld && $mpfr_im == 1234564.5) {$ok .= 'n'}
+ else {warn "6n: $ret $mpfr_re $mpfr_im\n$mpc\n"}
+ }
+ else {
+ eval {Rmpc_set_f_ld($mpc, $gmp, $ld, $round);};
+ if($@ =~ /Rmpc_set_f_ld not implemented/) {$ok .= 'm'}
+ else {warn "6m: \$\@: $@\n"}
+
+ eval {Rmpc_set_ld_f($mpc, $ld, $gmp, $round);};
+ if($@ =~ /Rmpc_set_ld_f not implemented/) {$ok .= 'n'}
+ else {warn "6n: \$\@: $@\n"}
+ }
+
+ $ret = Rmpc_set_f_fr($mpc, $gmp, $mpfr, $round);
+ Rmpc_real($mpfr_re, $mpc, $round);
+ Rmpc_imag($mpfr_im, $mpc, $round);
+ if($ret == 0 && $mpfr_re == 1234564.5 && $mpfr_im == $mpfr) {$ok .= 'o'}
+ else {warn "6o: $ret $mpfr_re $mpfr_im\n$mpc\n"}
+
+ $ret = Rmpc_set_fr_f($mpc, $mpfr, $gmp, $round);
+ Rmpc_real($mpfr_re, $mpc, $round);
+ Rmpc_imag($mpfr_im, $mpc, $round);
+ if($ret == 0 && $mpfr_re == $mpfr && $mpfr_im == 1234564.5) {$ok .= 'p'}
+ else {warn "6p: $ret $mpfr_re $mpfr_im\n$mpc\n"}
+
+ if($ok eq 'abcdefghijklmnop') {print "ok 6\n"}
+ else {print "not ok 6\n$ok\n"}
+}
+else {
+ print "ok 6 - skipped, no Math::GMPf\n";
+}
+
+$ok = '';
+
+unless(Math::MPC::_have_Complex_h()) {
+ eval{Rmpc_set_dc($mpc, $round, $round);};
+ if($@){
+ $ok .= 'a';
+ if($@ =~ /not implemented/){$ok .= 'b'}
+ else {warn "a: \$\@: $@\n"}
+ }
+
+ eval{Rmpc_set_ldc($mpc, $round, $round);};
+ if($@){
+ $ok .= 'c';
+ if($@ =~ /not implemented/){$ok .= 'd'}
+ else {warn "a: \$\@: $@\n"}
+ }
+}
+else {
+ warn "Skipping test 7 - Math::MPC::_have_complex_h returns true\n";
+ $ok = 'abcd';
+}
+
+if($ok eq 'abcd') {print "ok 7\n"}
+else {
+ warn "7: \$ok: $ok\n";
+ print "not ok 7\n";
+}
+
+$ok = '';
+
+unless(Math::MPC::_have_Complex_h()) {
+ eval{Rmpc_get_dc($round, $mpc, $round);};
+ if($@){
+ $ok .= 'a';
+ if($@ =~ /not implemented/){$ok .= 'b'}
+ else {warn "a: \$\@: $@\n"}
+ }
+
+ eval{Rmpc_get_ldc($round, $mpc, $round);};
+ if($@){
+ $ok .= 'c';
+ if($@ =~ /not implemented/){$ok .= 'd'}
+ else {warn "a: \$\@: $@\n"}
+ }
+}
+else {
+ warn "Skipping test 8 - Math::MPC::_have_complex_h returns true\n";
+ $ok = 'abcd';
+}
+
+if($ok eq 'abcd') {print "ok 8\n"}
+else {
+ warn "8: \$ok: $ok\n";
+ print "not ok 8\n";
+}
@@ -1,30 +1,30 @@
-use warnings;
-use strict;
-use Math::MPFR qw(:mpfr);
-use Math::MPC qw(:mpc);
-
-print "1..2\n";
-
-my $mpc1 = Rmpc_init3(100, 150);
-my $mpc1_copy = Rmpc_init3(100, 150);
-my $mpc2 = Rmpc_init3(90, 70);
-my $mpc2_copy = Rmpc_init3(90, 70);
-
-Rmpc_set_d_d($mpc1, 1.31, 1.173, MPC_RNDNN);
-Rmpc_set_d_d($mpc2, 2.59, 2.871, MPC_RNDNN);
-Rmpc_set_d_d($mpc1_copy, 1.31, 1.173, MPC_RNDNN);
-Rmpc_set_d_d($mpc2_copy, 2.59, 2.871, MPC_RNDNN);
-
-Rmpc_swap($mpc1, $mpc2);
-
-if($mpc1 == $mpc2_copy) {print "ok 1\n"}
-else {
- warn "\nmpc1: $mpc1\nmpc2_copy: $mpc2_copy\n";
- print "not ok 1\n";
-}
-
-if($mpc2 == $mpc1_copy) {print "ok 2\n"}
-else {
- warn "\nmpc2: $mpc2\nmpc1_copy: $mpc1_copy\n";
- print "not ok 2\n";
-}
\ No newline at end of file
+use warnings;
+use strict;
+use Math::MPFR qw(:mpfr);
+use Math::MPC qw(:mpc);
+
+print "1..2\n";
+
+my $mpc1 = Rmpc_init3(100, 150);
+my $mpc1_copy = Rmpc_init3(100, 150);
+my $mpc2 = Rmpc_init3(90, 70);
+my $mpc2_copy = Rmpc_init3(90, 70);
+
+Rmpc_set_d_d($mpc1, 1.31, 1.173, MPC_RNDNN);
+Rmpc_set_d_d($mpc2, 2.59, 2.871, MPC_RNDNN);
+Rmpc_set_d_d($mpc1_copy, 1.31, 1.173, MPC_RNDNN);
+Rmpc_set_d_d($mpc2_copy, 2.59, 2.871, MPC_RNDNN);
+
+Rmpc_swap($mpc1, $mpc2);
+
+if($mpc1 == $mpc2_copy) {print "ok 1\n"}
+else {
+ warn "\nmpc1: $mpc1\nmpc2_copy: $mpc2_copy\n";
+ print "not ok 1\n";
+}
+
+if($mpc2 == $mpc1_copy) {print "ok 2\n"}
+else {
+ warn "\nmpc2: $mpc2\nmpc1_copy: $mpc1_copy\n";
+ print "not ok 2\n";
+}
@@ -1,153 +1,153 @@
-use warnings;
-use strict;
-use Math::MPFR qw(:mpfr);
-use Math::MPC qw(:mpc);
-
-print "1..4\n";
-
-Rmpc_set_default_prec2(359, 359);
-
-my $z = Math::MPC->new(2, 2);
-my $zz = Math::MPC->new(1,1);
-my $mpc1 = Math::MPC->new();
-my $mpfr1 = Math::MPFR->new();
-my $tan = Math::MPC->new();
-my $zero = Math::MPC->new(0,0);
-my $ok = '';
-
-Rmpc_sin($mpc1, $z, MPC_RNDNN);
-
-RMPC_RE($mpfr1, $mpc1);
-$ok .= 'a' if $mpfr1 < 3.420954862 && $mpfr1 > 3.42095486;
-RMPC_IM($mpfr1, $mpc1);
-$ok .= 'b' if $mpfr1 > -1.50930648533 && $mpfr1 < -1.5093064853;
-
-my $mpc2 = sin($zz);
-
-RMPC_RE($mpfr1, $mpc2);
-$ok .= 'c' if $mpfr1 < 1.29845758142 && $mpfr1 > 1.2984575814;
-RMPC_IM($mpfr1, $mpc2);
-$ok .= 'd' if $mpfr1 > 0.634963914784 && $mpfr1 < 0.634963914785;
-
-if($ok eq 'abcd') {print "ok 1\n"}
-else {print "not ok 1 $ok\n"}
-
-$ok = '';
-
-my $sin = sin($z);
-my $cos = cos($z);
-Rmpc_tan($tan, $z, MPC_RNDNN);
-
-my $diff1 = $tan - ($sin / $cos);
-
-RMPC_RE($mpfr1, $diff1);
-$ok .= 'a' if $mpfr1 < 0.000001 && $mpfr1 > -0.000001;
-RMPC_IM($mpfr1, $diff1);
-$ok .= 'b' if $mpfr1 < 0.000001 && $mpfr1 > -0.000001;
-
-RMPC_RE($mpfr1, ($sin * $sin) + ($cos * $cos));
-$ok .= 'c' if $mpfr1 < 1.000001 && $mpfr1 > 0.999999;
-RMPC_IM($mpfr1, ($sin * $sin) + ($cos * $cos));
-$ok .= 'd' if $mpfr1 < 0.000001 && $mpfr1 > -0.000001;
-
-if($ok eq 'abcd') {print "ok 2\n"}
-else {print "not ok 2 $ok\n"}
-
-$ok = '';
-
-Rmpc_sin($mpc1, $zero, MPC_RNDNN);
-$ok .= 'a' if $mpc1 == 0;
-
-Rmpc_cos($mpc1, $zero, MPC_RNDNN);
-$ok .= 'b' if $mpc1 == 1;
-
-Rmpc_tan($mpc1, $zero, MPC_RNDNN);
-$ok .= 'c' if $mpc1 == 0;
-
-Rmpc_sinh($mpc1, $zero, MPC_RNDNN);
-$ok .= 'd' if $mpc1 == 0;
-
-Rmpc_cosh($mpc1, $zero, MPC_RNDNN);
-$ok .= 'e' if $mpc1 == 1;
-
-Rmpc_tanh($mpc1, $zero, MPC_RNDNN);
-$ok .= 'f' if $mpc1 == 0;
-
-if(MPC_VERSION_MAJOR > 0 || MPC_VERSION_MINOR > 8) {
- Rmpc_sin_cos($mpc1, $mpc2, $zero, MPC_RNDNN, MPC_RNDNN);
- $ok .= 'g' if $mpc1 == 0 && $mpc2 == 1;
-}
-else {
- eval{Rmpc_sin_cos($mpc1, $mpc2, $zero, MPC_RNDNN, MPC_RNDNN);};
- if($@) {
- if($@ =~ /not supported by your version/){$ok .= 'g'}
- else {warn "3g: \$\@: $@\n"}
- }
- else {warn "\$\@ not set\n"}
-}
-
-if($ok eq 'abcdefg') {print "ok 3\n"}
-else {
- warn "3: $ok\n";
- print "not ok 3 $ok\n";
-}
-
-$ok = '';
-
-Rmpc_sinh($mpc1, $z, MPC_RNDNN);
-RMPC_RE($mpfr1, $mpc1);
-$ok .= 'a' if $mpfr1 < -1.509306485 && $mpfr1 > -1.50930649;
-RMPC_IM($mpfr1, $mpc1);
-$ok .= 'b' if $mpfr1 > 3.42095486 && $mpfr1 < 3.420954862;
-
-Rmpc_cosh($mpc1, $z, MPC_RNDNN);
-RMPC_RE($mpfr1, $mpc1);
-$ok .= 'c' if $mpfr1 < -1.565625835 && $mpfr1 > -1.5656258354;
-RMPC_IM($mpfr1, $mpc1);
-$ok .= 'd' if $mpfr1 > 3.297894836 && $mpfr1 < 3.2978948364;
-
-Rmpc_tanh($mpc1, $z, MPC_RNDNN);
-RMPC_RE($mpfr1, $mpc1);
-$ok .= 'e' if $mpfr1 < 1.0238355946 && $mpfr1 > 1.023835594;
-RMPC_IM($mpfr1, $mpc1);
-$ok .= 'f' if $mpfr1 > -0.028392953 && $mpfr1 < -0.02839295;
-
-Rmpc_asin($mpc1, $z, MPC_RNDNN);
-RMPC_RE($mpfr1, $mpc1);
-$ok .= 'g' if $mpfr1 < 0.7542492 && $mpfr1 > 0.754249;
-RMPC_IM($mpfr1, $mpc1);
-$ok .= 'h' if $mpfr1 > 1.734324521 && $mpfr1 < 1.7343245215;
-
-Rmpc_acos($mpc1, $z, MPC_RNDNN);
-RMPC_RE($mpfr1, $mpc1);
-$ok .= 'i' if $mpfr1 < 0.8165471821 && $mpfr1 > 0.816547182;
-RMPC_IM($mpfr1, $mpc1);
-$ok .= 'j' if $mpfr1 > -1.7343245215 && $mpfr1 < -1.734324521;
-
-Rmpc_atan($mpc1, $z, MPC_RNDNN);
-RMPC_RE($mpfr1, $mpc1);
-$ok .= 'k' if $mpfr1 < 1.3112232697 && $mpfr1 > 1.311223269;
-RMPC_IM($mpfr1, $mpc1);
-$ok .= 'l' if $mpfr1 > 0.23887786 && $mpfr1 < 0.238877862;
-
-Rmpc_asinh($mpc1, $z, MPC_RNDNN);
-RMPC_RE($mpfr1, $mpc1);
-$ok .= 'm' if $mpfr1 < 1.734324522 && $mpfr1 > 1.734324521;
-RMPC_IM($mpfr1, $mpc1);
-$ok .= 'n' if $mpfr1 > 0.754249144698 && $mpfr1 < 0.7542491446981;
-
-Rmpc_acosh($mpc1, $z, MPC_RNDNN);
-RMPC_RE($mpfr1, $mpc1);
-$ok .= 'o' if $mpfr1 < 1.734324522 && $mpfr1 > 1.734324521;
-RMPC_IM($mpfr1, $mpc1);
-$ok .= 'p' if $mpfr1 > 0.816547182 && $mpfr1 < 0.8165471821;
-
-Rmpc_atanh($mpc1, $z, MPC_RNDNN);
-RMPC_RE($mpfr1, $mpc1);
-$ok .= 'q' if $mpfr1 < 0.2388778613 && $mpfr1 > 0.2388778612;
-RMPC_IM($mpfr1, $mpc1);
-$ok .= 'r' if $mpfr1 > 1.3112232 && $mpfr1 < 1.31122327;
-
-if($ok eq 'abcdefghijklmnopqr') { print "ok 4\n" }
-else { print "not ok 4 $ok\n" }
-
+use warnings;
+use strict;
+use Math::MPFR qw(:mpfr);
+use Math::MPC qw(:mpc);
+
+print "1..4\n";
+
+Rmpc_set_default_prec2(359, 359);
+
+my $z = Math::MPC->new(2, 2);
+my $zz = Math::MPC->new(1,1);
+my $mpc1 = Math::MPC->new();
+my $mpfr1 = Math::MPFR->new();
+my $tan = Math::MPC->new();
+my $zero = Math::MPC->new(0,0);
+my $ok = '';
+
+Rmpc_sin($mpc1, $z, MPC_RNDNN);
+
+RMPC_RE($mpfr1, $mpc1);
+$ok .= 'a' if $mpfr1 < 3.420954862 && $mpfr1 > 3.42095486;
+RMPC_IM($mpfr1, $mpc1);
+$ok .= 'b' if $mpfr1 > -1.50930648533 && $mpfr1 < -1.5093064853;
+
+my $mpc2 = sin($zz);
+
+RMPC_RE($mpfr1, $mpc2);
+$ok .= 'c' if $mpfr1 < 1.29845758142 && $mpfr1 > 1.2984575814;
+RMPC_IM($mpfr1, $mpc2);
+$ok .= 'd' if $mpfr1 > 0.634963914784 && $mpfr1 < 0.634963914785;
+
+if($ok eq 'abcd') {print "ok 1\n"}
+else {print "not ok 1 $ok\n"}
+
+$ok = '';
+
+my $sin = sin($z);
+my $cos = cos($z);
+Rmpc_tan($tan, $z, MPC_RNDNN);
+
+my $diff1 = $tan - ($sin / $cos);
+
+RMPC_RE($mpfr1, $diff1);
+$ok .= 'a' if $mpfr1 < 0.000001 && $mpfr1 > -0.000001;
+RMPC_IM($mpfr1, $diff1);
+$ok .= 'b' if $mpfr1 < 0.000001 && $mpfr1 > -0.000001;
+
+RMPC_RE($mpfr1, ($sin * $sin) + ($cos * $cos));
+$ok .= 'c' if $mpfr1 < 1.000001 && $mpfr1 > 0.999999;
+RMPC_IM($mpfr1, ($sin * $sin) + ($cos * $cos));
+$ok .= 'd' if $mpfr1 < 0.000001 && $mpfr1 > -0.000001;
+
+if($ok eq 'abcd') {print "ok 2\n"}
+else {print "not ok 2 $ok\n"}
+
+$ok = '';
+
+Rmpc_sin($mpc1, $zero, MPC_RNDNN);
+$ok .= 'a' if $mpc1 == 0;
+
+Rmpc_cos($mpc1, $zero, MPC_RNDNN);
+$ok .= 'b' if $mpc1 == 1;
+
+Rmpc_tan($mpc1, $zero, MPC_RNDNN);
+$ok .= 'c' if $mpc1 == 0;
+
+Rmpc_sinh($mpc1, $zero, MPC_RNDNN);
+$ok .= 'd' if $mpc1 == 0;
+
+Rmpc_cosh($mpc1, $zero, MPC_RNDNN);
+$ok .= 'e' if $mpc1 == 1;
+
+Rmpc_tanh($mpc1, $zero, MPC_RNDNN);
+$ok .= 'f' if $mpc1 == 0;
+
+if(MPC_VERSION_MAJOR > 0 || MPC_VERSION_MINOR > 8) {
+ Rmpc_sin_cos($mpc1, $mpc2, $zero, MPC_RNDNN, MPC_RNDNN);
+ $ok .= 'g' if $mpc1 == 0 && $mpc2 == 1;
+}
+else {
+ eval{Rmpc_sin_cos($mpc1, $mpc2, $zero, MPC_RNDNN, MPC_RNDNN);};
+ if($@) {
+ if($@ =~ /not supported by your version/){$ok .= 'g'}
+ else {warn "3g: \$\@: $@\n"}
+ }
+ else {warn "\$\@ not set\n"}
+}
+
+if($ok eq 'abcdefg') {print "ok 3\n"}
+else {
+ warn "3: $ok\n";
+ print "not ok 3 $ok\n";
+}
+
+$ok = '';
+
+Rmpc_sinh($mpc1, $z, MPC_RNDNN);
+RMPC_RE($mpfr1, $mpc1);
+$ok .= 'a' if $mpfr1 < -1.509306485 && $mpfr1 > -1.50930649;
+RMPC_IM($mpfr1, $mpc1);
+$ok .= 'b' if $mpfr1 > 3.42095486 && $mpfr1 < 3.420954862;
+
+Rmpc_cosh($mpc1, $z, MPC_RNDNN);
+RMPC_RE($mpfr1, $mpc1);
+$ok .= 'c' if $mpfr1 < -1.565625835 && $mpfr1 > -1.5656258354;
+RMPC_IM($mpfr1, $mpc1);
+$ok .= 'd' if $mpfr1 > 3.297894836 && $mpfr1 < 3.2978948364;
+
+Rmpc_tanh($mpc1, $z, MPC_RNDNN);
+RMPC_RE($mpfr1, $mpc1);
+$ok .= 'e' if $mpfr1 < 1.0238355946 && $mpfr1 > 1.023835594;
+RMPC_IM($mpfr1, $mpc1);
+$ok .= 'f' if $mpfr1 > -0.028392953 && $mpfr1 < -0.02839295;
+
+Rmpc_asin($mpc1, $z, MPC_RNDNN);
+RMPC_RE($mpfr1, $mpc1);
+$ok .= 'g' if $mpfr1 < 0.7542492 && $mpfr1 > 0.754249;
+RMPC_IM($mpfr1, $mpc1);
+$ok .= 'h' if $mpfr1 > 1.734324521 && $mpfr1 < 1.7343245215;
+
+Rmpc_acos($mpc1, $z, MPC_RNDNN);
+RMPC_RE($mpfr1, $mpc1);
+$ok .= 'i' if $mpfr1 < 0.8165471821 && $mpfr1 > 0.816547182;
+RMPC_IM($mpfr1, $mpc1);
+$ok .= 'j' if $mpfr1 > -1.7343245215 && $mpfr1 < -1.734324521;
+
+Rmpc_atan($mpc1, $z, MPC_RNDNN);
+RMPC_RE($mpfr1, $mpc1);
+$ok .= 'k' if $mpfr1 < 1.3112232697 && $mpfr1 > 1.311223269;
+RMPC_IM($mpfr1, $mpc1);
+$ok .= 'l' if $mpfr1 > 0.23887786 && $mpfr1 < 0.238877862;
+
+Rmpc_asinh($mpc1, $z, MPC_RNDNN);
+RMPC_RE($mpfr1, $mpc1);
+$ok .= 'm' if $mpfr1 < 1.734324522 && $mpfr1 > 1.734324521;
+RMPC_IM($mpfr1, $mpc1);
+$ok .= 'n' if $mpfr1 > 0.754249144698 && $mpfr1 < 0.7542491446981;
+
+Rmpc_acosh($mpc1, $z, MPC_RNDNN);
+RMPC_RE($mpfr1, $mpc1);
+$ok .= 'o' if $mpfr1 < 1.734324522 && $mpfr1 > 1.734324521;
+RMPC_IM($mpfr1, $mpc1);
+$ok .= 'p' if $mpfr1 > 0.816547182 && $mpfr1 < 0.8165471821;
+
+Rmpc_atanh($mpc1, $z, MPC_RNDNN);
+RMPC_RE($mpfr1, $mpc1);
+$ok .= 'q' if $mpfr1 < 0.2388778613 && $mpfr1 > 0.2388778612;
+RMPC_IM($mpfr1, $mpc1);
+$ok .= 'r' if $mpfr1 > 1.3112232 && $mpfr1 < 1.31122327;
+
+if($ok eq 'abcdefghijklmnopqr') { print "ok 4\n" }
+else { print "not ok 4 $ok\n" }
+
@@ -1,55 +1,55 @@
-use warnings;
-use strict;
-use Math::MPC qw(:mpc);
-
-# mpc_out_str() segfaults on some architectures -
-# better to use c_string() - or r_string() and i_string()
-
-print "1..2\n";
-
-Rmpc_set_default_prec2(100, 100);
-
-my $string = Math::MPC->new('246' x 7, '3579' x 6);
-my $ok = '';
-
-my $ret = TRmpc_out_str(*STDOUT, 16, 0, $string, MPC_RNDNN);
-# prints "(d.595a684adcdfe766000000000@16 4.bcbbcfdfb50863475ab000000@19)".
-
-if($ret == 63) {$ok .= 'a'}
-else {print "\nReturned: ", $ret, "\n"}
-
-print "\n";
-
-$ret = TRmpc_out_str(*STDOUT, 16, 0, $string, MPC_RNDNN, " \n");
-
-if($ret == 63) {$ok .= 'b'}
-else {print "Returned: ", $ret, "\n"}
-
-$ret = TRmpc_out_str("hello world ", *STDOUT, 16, 0, $string, MPC_RNDNN);
-
-if($ret == 63) {$ok .= 'c'}
-else {print "Returned: ", $ret, "\n"}
-
-print "\n";
-
-$ret = TRmpc_out_str("hello world ", *STDOUT, 16, 0, $string, MPC_RNDNN, " \n");
-
-if($ret == 63) {$ok .= 'd'}
-else {print "Returned: ", $ret, "\n"}
-
-if($ok eq 'abcd') {print "ok 1 \n"}
-else {print "not ok 1 $ok\n"}
-
-$ok = '';
-
-eval{$ret = TRmpc_out_str($string, 16, 0, 1);};
-$ok .= 'a' if $@ =~ /Wrong number of arguments/;
-
-eval{$ret = TRmpc_out_str($string, 16, 0, MPC_RNDNN, 7, 5, 9, 10);};
-$ok .= 'b' if $@ =~ /Wrong number of arguments/;
-
-if($ok eq 'ab') {print "ok 2 \n"}
-else {print "not ok 2 $ok\n"}
-
-
-
+use warnings;
+use strict;
+use Math::MPC qw(:mpc);
+
+# mpc_out_str() segfaults on some architectures -
+# better to use c_string() - or r_string() and i_string()
+
+print "1..2\n";
+
+Rmpc_set_default_prec2(100, 100);
+
+my $string = Math::MPC->new('246' x 7, '3579' x 6);
+my $ok = '';
+
+my $ret = TRmpc_out_str(*STDOUT, 16, 0, $string, MPC_RNDNN);
+# prints "(d.595a684adcdfe766000000000@16 4.bcbbcfdfb50863475ab000000@19)".
+
+if($ret == 63) {$ok .= 'a'}
+else {print "\nReturned: ", $ret, "\n"}
+
+print "\n";
+
+$ret = TRmpc_out_str(*STDOUT, 16, 0, $string, MPC_RNDNN, " \n");
+
+if($ret == 63) {$ok .= 'b'}
+else {print "Returned: ", $ret, "\n"}
+
+$ret = TRmpc_out_str("hello world ", *STDOUT, 16, 0, $string, MPC_RNDNN);
+
+if($ret == 63) {$ok .= 'c'}
+else {print "Returned: ", $ret, "\n"}
+
+print "\n";
+
+$ret = TRmpc_out_str("hello world ", *STDOUT, 16, 0, $string, MPC_RNDNN, " \n");
+
+if($ret == 63) {$ok .= 'd'}
+else {print "Returned: ", $ret, "\n"}
+
+if($ok eq 'abcd') {print "ok 1 \n"}
+else {print "not ok 1 $ok\n"}
+
+$ok = '';
+
+eval{$ret = TRmpc_out_str($string, 16, 0, 1);};
+$ok .= 'a' if $@ =~ /Wrong number of arguments/;
+
+eval{$ret = TRmpc_out_str($string, 16, 0, MPC_RNDNN, 7, 5, 9, 10);};
+$ok .= 'b' if $@ =~ /Wrong number of arguments/;
+
+if($ok eq 'ab') {print "ok 2 \n"}
+else {print "not ok 2 $ok\n"}
+
+
+
@@ -1,224 +1,224 @@
-use warnings;
-use strict;
-use Math::MPC qw(:mpc);
-use Math::MPFR qw(:mpfr);
-
-print "1..8\n";
-
-
-Rmpc_set_default_prec2(64, 64);
-
-my $mpc = Math::MPC->new(6.5, 8.25); # 6.5000000000000000+I*8.2500000000000000 (39 characters)
-my $ret;
-open(WR1, '>', 'out1.txt') or die "Can't open WR1: $!";
-open(WR2, '>', 'out2.txt') or die "Can't open WR2: $!";
-open(WR3, '>', 'out3.txt') or die "Can't open WR3: $!";
-open(WR4, '>', 'out4.txt') or die "Can't open WR4: $!";
-open(WR5, '>', 'out5.txt') or die "Can't open WR5: $!";
-open(WR6, '>', 'out6.txt') or die "Can't open WR6: $!";
-open(WR7, '>', 'out7.txt') or die "Can't open WR7: $!";
-
-my $prefix = "This is the prefix ";
-my $suffix = " and this is the suffix\n";
-
-# No prefix, no suffix - the five numbers will all be
-# strung together on the one line.
-for(1..5) {
- $ret = TRmpc_out_str(\*WR1, 10, 0, $mpc, MPC_RNDNN);
- print WR7 "From the first loop\n";
-}
-
-# Prefix, but no suffix - again, the output will be
-# strung together on the one line.
-for(1..5) {
- $ret = TRmpc_out_str($prefix, \*WR2, 10, 0, $mpc, MPC_RNDNN);
- print WR7 "From the second loop";
-}
-
-# Suffix, but no prefix - this file will contain 5 lines.
-for(1..5) {
- $ret = TRmpc_out_str(\*WR3, 10, 0, $mpc, MPC_RNDNN, $suffix);
- print WR7 "\nFrom the third loop";
-}
-
-print WR7 "\n";
-
-# Both prefix and suffix - this file will contain 5 lines.
-for(1..5) {
- $ret = TRmpc_out_str($prefix, \*WR4, 10, 0, $mpc, MPC_RNDNN, $suffix);
- print WR7 "From the fourth loop\n";
-}
-
-$prefix .= "\n";
-
-# Prefix, but no suffix - this file will contain 6 lines.
-for(1..5) {
- $ret = TRmpc_out_str($prefix, \*WR5, 10, 0, $mpc, MPC_RNDNN);
- print WR7 "From the fifth loop";
-}
-
-# Both prefix and suffix - this file will contain 10 lines -
-# the prefix appearing on one line, the number and the suffix
-# appearing on the next.
-for(1..5) {
- $ret = TRmpc_out_str($prefix, \*WR6, 10, 0, $mpc, MPC_RNDNN, $suffix);
- print WR7 "From the sixth loop";
-}
-
-close WR1 or die "Can't close WR1: $!";
-close WR2 or die "Can't close WR2: $!";
-close WR3 or die "Can't close WR3: $!";
-close WR4 or die "Can't close WR4: $!";
-close WR5 or die "Can't close WR5: $!";
-close WR6 or die "Can't close WR6: $!";
-close WR7 or die "Can't close WR7: $!";
-
-open(RD1, '<', 'out1.txt') or die "Can't open RD1: $!";
-open(RD2, '<', 'out2.txt') or die "Can't open RD2: $!";
-open(RD3, '<', 'out3.txt') or die "Can't open RD3: $!";
-open(RD4, '<', 'out4.txt') or die "Can't open RD4: $!";
-open(RD5, '<', 'out5.txt') or die "Can't open RD5: $!";
-open(RD6, '<', 'out6.txt') or die "Can't open RD6: $!";
-open(RD7, '<', 'out7.txt') or die "Can't open RD7: $!";
-
-my $ok = 1;
-my $count = 0;
-
-while(<RD1>) {
- $count = $.;
- chomp;
- unless($_ eq '(6.50000000000000000000 8.25000000000000000000)'x5) {$ok = 0}
-}
-
-if($ok && $count == 1) {print "ok 1\n"}
-else {print "not ok 1 $ok $count\n"}
-
-
-$ok = 1;
-$count = 0;
-
-while(<RD2>) {
- $count = $.;
- chomp;
- unless($_ eq 'This is the prefix (6.50000000000000000000 8.25000000000000000000)'x5) {$ok = 0}
-}
-
-if($ok && $count == 1) {print "ok 2\n"}
-else {print "not ok 2 $ok $count\n"}
-
-$ok = 1;
-$count = 0;
-
-while(<RD3>) {
- $count = $.;
- chomp;
- unless($_ eq '(6.50000000000000000000 8.25000000000000000000) and this is the suffix') {$ok = 0}
-}
-
-if($ok && $count == 5) {print "ok 3\n"}
-else {print "not ok 3 $ok $count\n"}
-
-$ok = 1;
-$count = 0;
-
-while(<RD4>) {
- $count = $.;
- chomp;
- unless($_ eq 'This is the prefix (6.50000000000000000000 8.25000000000000000000) and this is the suffix') {$ok = 0}
-}
-
-if($ok && $count == 5) {print "ok 4\n"}
-else {print "not ok 4 $ok $count\n"}
-
-$ok = 1;
-$count = 0;
-
-while(<RD5>) {
- $count = $.;
- chomp;
- if($. == 1) {
- unless($_ eq 'This is the prefix ') {$ok = 0}
- }
- elsif($. == 6) {
- unless($_ eq '(6.50000000000000000000 8.25000000000000000000)') {$ok = 0}
- }
- else {
- unless($_ eq '(6.50000000000000000000 8.25000000000000000000)This is the prefix ') {$ok = 0}
- }
-}
-
-if($ok && $count == 6) {print "ok 5\n"}
-else {print "not ok 5 $ok $count\n"}
-
-$ok = 1;
-$count = 0;
-
-while(<RD6>) {
- $count = $.;
- chomp;
- if($. & 1) {
- unless($_ eq 'This is the prefix ') {$ok = 0}
- }
- else {
- unless($_ eq '(6.50000000000000000000 8.25000000000000000000) and this is the suffix') {$ok = 0}
- }
-}
-
-if($ok && $count == 10) {print "ok 6\n"}
-else {print "not ok 6 $ok $count\n"}
-
-$ok = 1;
-$count = 0;
-
-while(<RD7>) {
- $count = $.;
- chomp;
- if($. <= 5 && $. >= 1) {
- unless($_ eq 'From the first loop') {$ok = 0}
- }
- if($. == 6) {
- unless($_ eq 'From the second loop' x 5) {$ok = 0}
- }
- if($. <= 11 && $. >= 7) {
- unless($_ eq 'From the third loop') {$ok = 0}
- }
- if($. <= 16 && $. >= 12) {
- unless($_ eq 'From the fourth loop') {$ok = 0}
- }
- if($. == 17) {
- unless($_ eq 'From the fifth loop' x 5 . 'From the sixth loop' x 5) {$ok = 0}
- }
-}
-
-if($ok && $count == 17) {print "ok 7\n"}
-else {print "not ok 7 $ok $count\n"}
-
-close RD1 or die "Can't close RD1: $!";
-close RD2 or die "Can't close RD2: $!";
-close RD3 or die "Can't close RD3: $!";
-close RD4 or die "Can't close RD4: $!";
-close RD5 or die "Can't close RD5: $!";
-close RD6 or die "Can't close RD6: $!";
-close RD7 or die "Can't close RD7: $!";
-
-open(WR8, '>', 'out1.txt') or die "Can't open WR8: $!";
-#print WR8 "6.5000000000000000\n";
-#print WR8 "+I*\n";
-#print WR8 "8.2500000000000000\n";
-print WR8 "(6.5000000000000000 8.2500000000000000)\n";
-close WR8 or die "Can't close WR8: $!";
-
-open(RD8, '<', 'out1.txt') or die "Can't open RD8: $!";
-$ret = TRmpc_inp_str($mpc, \*RD8, 10, MPC_RNDNN);
-close RD8 or die "Can't close RD8: $!";
-
-my $real = Math::MPFR->new();
-my $im = Math::MPFR->new();
-
-RMPC_RE($real, $mpc);
-RMPC_IM($im, $mpc);
-
-if($ret == 0 && $real == 6.5 && $im == 8.25) {print "ok 8\n"}
-else {print "not ok 8 $ret $real $im $mpc\n"}
-
-
+use warnings;
+use strict;
+use Math::MPC qw(:mpc);
+use Math::MPFR qw(:mpfr);
+
+print "1..8\n";
+
+
+Rmpc_set_default_prec2(64, 64);
+
+my $mpc = Math::MPC->new(6.5, 8.25); # 6.5000000000000000+I*8.2500000000000000 (39 characters)
+my $ret;
+open(WR1, '>', 'out1.txt') or die "Can't open WR1: $!";
+open(WR2, '>', 'out2.txt') or die "Can't open WR2: $!";
+open(WR3, '>', 'out3.txt') or die "Can't open WR3: $!";
+open(WR4, '>', 'out4.txt') or die "Can't open WR4: $!";
+open(WR5, '>', 'out5.txt') or die "Can't open WR5: $!";
+open(WR6, '>', 'out6.txt') or die "Can't open WR6: $!";
+open(WR7, '>', 'out7.txt') or die "Can't open WR7: $!";
+
+my $prefix = "This is the prefix ";
+my $suffix = " and this is the suffix\n";
+
+# No prefix, no suffix - the five numbers will all be
+# strung together on the one line.
+for(1..5) {
+ $ret = TRmpc_out_str(\*WR1, 10, 0, $mpc, MPC_RNDNN);
+ print WR7 "From the first loop\n";
+}
+
+# Prefix, but no suffix - again, the output will be
+# strung together on the one line.
+for(1..5) {
+ $ret = TRmpc_out_str($prefix, \*WR2, 10, 0, $mpc, MPC_RNDNN);
+ print WR7 "From the second loop";
+}
+
+# Suffix, but no prefix - this file will contain 5 lines.
+for(1..5) {
+ $ret = TRmpc_out_str(\*WR3, 10, 0, $mpc, MPC_RNDNN, $suffix);
+ print WR7 "\nFrom the third loop";
+}
+
+print WR7 "\n";
+
+# Both prefix and suffix - this file will contain 5 lines.
+for(1..5) {
+ $ret = TRmpc_out_str($prefix, \*WR4, 10, 0, $mpc, MPC_RNDNN, $suffix);
+ print WR7 "From the fourth loop\n";
+}
+
+$prefix .= "\n";
+
+# Prefix, but no suffix - this file will contain 6 lines.
+for(1..5) {
+ $ret = TRmpc_out_str($prefix, \*WR5, 10, 0, $mpc, MPC_RNDNN);
+ print WR7 "From the fifth loop";
+}
+
+# Both prefix and suffix - this file will contain 10 lines -
+# the prefix appearing on one line, the number and the suffix
+# appearing on the next.
+for(1..5) {
+ $ret = TRmpc_out_str($prefix, \*WR6, 10, 0, $mpc, MPC_RNDNN, $suffix);
+ print WR7 "From the sixth loop";
+}
+
+close WR1 or die "Can't close WR1: $!";
+close WR2 or die "Can't close WR2: $!";
+close WR3 or die "Can't close WR3: $!";
+close WR4 or die "Can't close WR4: $!";
+close WR5 or die "Can't close WR5: $!";
+close WR6 or die "Can't close WR6: $!";
+close WR7 or die "Can't close WR7: $!";
+
+open(RD1, '<', 'out1.txt') or die "Can't open RD1: $!";
+open(RD2, '<', 'out2.txt') or die "Can't open RD2: $!";
+open(RD3, '<', 'out3.txt') or die "Can't open RD3: $!";
+open(RD4, '<', 'out4.txt') or die "Can't open RD4: $!";
+open(RD5, '<', 'out5.txt') or die "Can't open RD5: $!";
+open(RD6, '<', 'out6.txt') or die "Can't open RD6: $!";
+open(RD7, '<', 'out7.txt') or die "Can't open RD7: $!";
+
+my $ok = 1;
+my $count = 0;
+
+while(<RD1>) {
+ $count = $.;
+ chomp;
+ unless($_ eq '(6.50000000000000000000 8.25000000000000000000)'x5) {$ok = 0}
+}
+
+if($ok && $count == 1) {print "ok 1\n"}
+else {print "not ok 1 $ok $count\n"}
+
+
+$ok = 1;
+$count = 0;
+
+while(<RD2>) {
+ $count = $.;
+ chomp;
+ unless($_ eq 'This is the prefix (6.50000000000000000000 8.25000000000000000000)'x5) {$ok = 0}
+}
+
+if($ok && $count == 1) {print "ok 2\n"}
+else {print "not ok 2 $ok $count\n"}
+
+$ok = 1;
+$count = 0;
+
+while(<RD3>) {
+ $count = $.;
+ chomp;
+ unless($_ eq '(6.50000000000000000000 8.25000000000000000000) and this is the suffix') {$ok = 0}
+}
+
+if($ok && $count == 5) {print "ok 3\n"}
+else {print "not ok 3 $ok $count\n"}
+
+$ok = 1;
+$count = 0;
+
+while(<RD4>) {
+ $count = $.;
+ chomp;
+ unless($_ eq 'This is the prefix (6.50000000000000000000 8.25000000000000000000) and this is the suffix') {$ok = 0}
+}
+
+if($ok && $count == 5) {print "ok 4\n"}
+else {print "not ok 4 $ok $count\n"}
+
+$ok = 1;
+$count = 0;
+
+while(<RD5>) {
+ $count = $.;
+ chomp;
+ if($. == 1) {
+ unless($_ eq 'This is the prefix ') {$ok = 0}
+ }
+ elsif($. == 6) {
+ unless($_ eq '(6.50000000000000000000 8.25000000000000000000)') {$ok = 0}
+ }
+ else {
+ unless($_ eq '(6.50000000000000000000 8.25000000000000000000)This is the prefix ') {$ok = 0}
+ }
+}
+
+if($ok && $count == 6) {print "ok 5\n"}
+else {print "not ok 5 $ok $count\n"}
+
+$ok = 1;
+$count = 0;
+
+while(<RD6>) {
+ $count = $.;
+ chomp;
+ if($. & 1) {
+ unless($_ eq 'This is the prefix ') {$ok = 0}
+ }
+ else {
+ unless($_ eq '(6.50000000000000000000 8.25000000000000000000) and this is the suffix') {$ok = 0}
+ }
+}
+
+if($ok && $count == 10) {print "ok 6\n"}
+else {print "not ok 6 $ok $count\n"}
+
+$ok = 1;
+$count = 0;
+
+while(<RD7>) {
+ $count = $.;
+ chomp;
+ if($. <= 5 && $. >= 1) {
+ unless($_ eq 'From the first loop') {$ok = 0}
+ }
+ if($. == 6) {
+ unless($_ eq 'From the second loop' x 5) {$ok = 0}
+ }
+ if($. <= 11 && $. >= 7) {
+ unless($_ eq 'From the third loop') {$ok = 0}
+ }
+ if($. <= 16 && $. >= 12) {
+ unless($_ eq 'From the fourth loop') {$ok = 0}
+ }
+ if($. == 17) {
+ unless($_ eq 'From the fifth loop' x 5 . 'From the sixth loop' x 5) {$ok = 0}
+ }
+}
+
+if($ok && $count == 17) {print "ok 7\n"}
+else {print "not ok 7 $ok $count\n"}
+
+close RD1 or die "Can't close RD1: $!";
+close RD2 or die "Can't close RD2: $!";
+close RD3 or die "Can't close RD3: $!";
+close RD4 or die "Can't close RD4: $!";
+close RD5 or die "Can't close RD5: $!";
+close RD6 or die "Can't close RD6: $!";
+close RD7 or die "Can't close RD7: $!";
+
+open(WR8, '>', 'out1.txt') or die "Can't open WR8: $!";
+#print WR8 "6.5000000000000000\n";
+#print WR8 "+I*\n";
+#print WR8 "8.2500000000000000\n";
+print WR8 "(6.5000000000000000 8.2500000000000000)\n";
+close WR8 or die "Can't close WR8: $!";
+
+open(RD8, '<', 'out1.txt') or die "Can't open RD8: $!";
+$ret = TRmpc_inp_str($mpc, \*RD8, 10, MPC_RNDNN);
+close RD8 or die "Can't close RD8: $!";
+
+my $real = Math::MPFR->new();
+my $im = Math::MPFR->new();
+
+RMPC_RE($real, $mpc);
+RMPC_IM($im, $mpc);
+
+if($ret == 0 && $real == 6.5 && $im == 8.25) {print "ok 8\n"}
+else {print "not ok 8 $ret $real $im $mpc\n"}
+
+
@@ -1,13 +1,13 @@
-eval "use Test::Pod 1.00";
-
-if($@) {
- print "1..1\n";
- warn "Skipping test 1 - no recent version of Test::Pod installed\n";
- print "ok 1\n";
-}
-
-else {
- warn "\nTest::Pod version: $Test::Pod::VERSION\n";
- warn "\nPod::Simple version: $Pod::Simple::VERSION\n";
- Test::Pod::all_pod_files_ok();
-}
\ No newline at end of file
+eval "use Test::Pod 1.00";
+
+if($@) {
+ print "1..1\n";
+ warn "Skipping test 1 - no recent version of Test::Pod installed\n";
+ print "ok 1\n";
+}
+
+else {
+ warn "\nTest::Pod version: $Test::Pod::VERSION\n";
+ warn "\nPod::Simple version: $Pod::Simple::VERSION\n";
+ Test::Pod::all_pod_files_ok();
+}
@@ -1,64 +1,64 @@
-use warnings;
-use strict;
-use Math::MPC qw(:mpc);
-use Math::MPFR qw(:mpfr);
-
-print "1..1\n";
-
-Rmpc_set_default_prec(64);
-Rmpfr_set_default_prec(64);
-my $ok = '';
-
-my $mpc = Math::MPC->new();
-my $re = Math::MPFR->new();
-my $im = Math::MPFR->new();
-
-my $ret = Rmpc_strtoc($mpc, '(@nan@ @inf@)', 10, MPC_RNDNN);
-
-RMPC_RE($re, $mpc);
-RMPC_IM($im, $mpc);
-
-$ok .= 'a' if $ret == 0;
-$ok .= 'b' if Rmpfr_nan_p($re);
-$ok .= 'c' if Rmpfr_inf_p($im);
-
-$ret = Rmpc_strtoc($mpc, '( -@inf@ @nan@)', 16, MPC_RNDNN);
-
-RMPC_RE($re, $mpc);
-RMPC_IM($im, $mpc);
-
-$ok .= 'd' if $ret == 0;
-$ok .= 'e' if Rmpfr_nan_p($im);
-$ok .= 'f' if Rmpfr_inf_p($re);
-$ok .= 'g' if $re < 0;
-
-$ret = Rmpc_strtoc($mpc, '(0b1p+5 +0x802)', 0, MPC_RNDNN);
-
-RMPC_RE($re, $mpc);
-RMPC_IM($im, $mpc);
-
-$ok .= 'h' if $ret == 0;
-$ok .= 'i' if $re == 32;
-$ok .= 'j' if $im == 2050;
-
-$ret = Rmpc_set_str($mpc, '(0b1p+5 +0x802)', 0, MPC_RNDNN);
-
-RMPC_RE($re, $mpc);
-RMPC_IM($im, $mpc);
-
-$ok .= 'k' if $ret == 0;
-$ok .= 'l' if $re == 32;
-$ok .= 'm' if $im == 2050;
-
-$ret = Rmpc_set_str($mpc, '(0b1p+5 +0x802z)', 0, MPC_RNDNN);
-
-RMPC_RE($re, $mpc);
-RMPC_IM($im, $mpc);
-
-$ok .= 'n' if $ret == -1;
-$ok .= 'o' if Rmpfr_nan_p($re);
-$ok .= 'p' if Rmpfr_nan_p($im);
-$ok .= 'q' if lc(Rmpc_get_str(10, 0, $mpc, MPC_RNDNN)) eq '(@nan@ @nan@)';
-
-if($ok eq 'abcdefghijklmnopq') {print "ok 1\n"}
-else {print "not ok 1 $ok\n"}
+use warnings;
+use strict;
+use Math::MPC qw(:mpc);
+use Math::MPFR qw(:mpfr);
+
+print "1..1\n";
+
+Rmpc_set_default_prec(64);
+Rmpfr_set_default_prec(64);
+my $ok = '';
+
+my $mpc = Math::MPC->new();
+my $re = Math::MPFR->new();
+my $im = Math::MPFR->new();
+
+my $ret = Rmpc_strtoc($mpc, '(@nan@ @inf@)', 10, MPC_RNDNN);
+
+RMPC_RE($re, $mpc);
+RMPC_IM($im, $mpc);
+
+$ok .= 'a' if $ret == 0;
+$ok .= 'b' if Rmpfr_nan_p($re);
+$ok .= 'c' if Rmpfr_inf_p($im);
+
+$ret = Rmpc_strtoc($mpc, '( -@inf@ @nan@)', 16, MPC_RNDNN);
+
+RMPC_RE($re, $mpc);
+RMPC_IM($im, $mpc);
+
+$ok .= 'd' if $ret == 0;
+$ok .= 'e' if Rmpfr_nan_p($im);
+$ok .= 'f' if Rmpfr_inf_p($re);
+$ok .= 'g' if $re < 0;
+
+$ret = Rmpc_strtoc($mpc, '(0b1p+5 +0x802)', 0, MPC_RNDNN);
+
+RMPC_RE($re, $mpc);
+RMPC_IM($im, $mpc);
+
+$ok .= 'h' if $ret == 0;
+$ok .= 'i' if $re == 32;
+$ok .= 'j' if $im == 2050;
+
+$ret = Rmpc_set_str($mpc, '(0b1p+5 +0x802)', 0, MPC_RNDNN);
+
+RMPC_RE($re, $mpc);
+RMPC_IM($im, $mpc);
+
+$ok .= 'k' if $ret == 0;
+$ok .= 'l' if $re == 32;
+$ok .= 'm' if $im == 2050;
+
+$ret = Rmpc_set_str($mpc, '(0b1p+5 +0x802z)', 0, MPC_RNDNN);
+
+RMPC_RE($re, $mpc);
+RMPC_IM($im, $mpc);
+
+$ok .= 'n' if $ret == -1;
+$ok .= 'o' if Rmpfr_nan_p($re);
+$ok .= 'p' if Rmpfr_nan_p($im);
+$ok .= 'q' if lc(Rmpc_get_str(10, 0, $mpc, MPC_RNDNN)) eq '(@nan@ @nan@)';
+
+if($ok eq 'abcdefghijklmnopq') {print "ok 1\n"}
+else {print "not ok 1 $ok\n"}
@@ -1,169 +1,169 @@
-# Some adhoc tests to check that signed zeroes are being dealt with correctly.
-# By no means exhaustive tests - they just deal with a known issue with
-# 64-bit builds and overloaded mul and div operations (which should now be fixed).
-
-use warnings;
-use strict;
-use Math::MPC qw(:mpc);
-use Math::MPFR qw(:mpfr);
-
-print "1..5\n";
-
-my $ok;
-my $z = Math::MPC->new(0, 0);
-my $mul = -1;
-
-my $x = $z * $mul;
-if(Math::MPC::overload_string($x) eq '(-0 -0)') {$ok .= 'a'}
-else {warn "\n1a: got '",Math::MPC::overload_string($x), "'\nexpected '(-0 -0)'\n"}
-
-my $y = $z / $mul;
-if(Math::MPC::overload_string($y) eq '(-0 -0)') {$ok .= 'b'}
-else {warn "\n1b: got '",Math::MPC::overload_string($y), "'\nexpected '(-0 -0)'\n"}
-
-$z *= $mul;
-if(Math::MPC::overload_string($z) eq '(-0 -0)') {$ok .= 'c'}
-else {warn "\n1c: got '",Math::MPC::overload_string($z), "'\nexpected '(-0 -0)'\n"}
-
-$z *= $mul;
-if(Math::MPC::overload_string($z) eq '(0 0)') {$ok .= 'd'}
-else {warn "\n1d: got '",Math::MPC::overload_string($z), "'\nexpected '(0 0)'\n"}
-
-$z /= $mul;
-if(Math::MPC::overload_string($z) eq '(-0 -0)') {$ok .= 'e'}
-else {warn "\n1e: got '",Math::MPC::overload_string($z), "'\nexpected '(-0 -0)'\n"}
-
-if($ok eq 'abcde') {print "ok 1\n"}
-else {
- warn "\$ok: $ok\n";
- print "not ok 1\n";
-}
-
-$ok = '';
-Rmpc_set_ui_ui($z, 0, 0, MPC_RNDNN);
-$mul = -10.625;
-
-$x = $z * $mul;
-if(Math::MPC::overload_string($x) eq '(-0 -0)') {$ok .= 'a'}
-else {warn "\n2a: got '",Math::MPC::overload_string($x), "'\nexpected '(-0 -0)'\n"}
-
-$y = $z / $mul;
-if(Math::MPC::overload_string($y) eq '(-0 -0)') {$ok .= 'b'}
-else {warn "\n2b: got '",Math::MPC::overload_string($y), "'\nexpected '(-0 -0)'\n"}
-
-$z *= $mul;
-if(Math::MPC::overload_string($z) eq '(-0 -0)') {$ok .= 'c'}
-else {warn "\n2c: got '",Math::MPC::overload_string($z), "'\nexpected '(-0 -0)'\n"}
-
-$z *= $mul;
-if(Math::MPC::overload_string($z) eq '(0 0)') {$ok .= 'd'}
-else {warn "\n2d: got '",Math::MPC::overload_string($z), "'\nexpected '(0 0)'\n"}
-
-$z /= $mul;
-if(Math::MPC::overload_string($z) eq '(-0 -0)') {$ok .= 'e'}
-else {warn "\n2e: got '",Math::MPC::overload_string($z), "'\nexpected '(-0 -0)'\n"}
-
-if($ok eq 'abcde') {print "ok 2\n"}
-else {
- warn "\$ok: $ok\n";
- print "not ok 2\n";
-}
-
-$ok = '';
-my $_64i = Math::MPC::_has_longlong();
-my $_64d = Math::MPC::_has_longdouble();
-
-my $long = -15;
-my $double = -2.5;
-Rmpc_set_ui_ui($z, 10, 8, MPC_RNDNN);
-my $rop = Math::MPC->new();
-my $check = Math::MPFR->new();
-
-Rmpc_mul_d($rop, $z, $double, MPC_RNDNN);
-RMPC_RE($check, $rop);
-$ok .= 'a' if $check == -25;
-RMPC_IM($check, $rop);
-$ok .= 'b' if $check == -20;
-
-Rmpc_div_d($rop, $rop, $double, MPC_RNDNN);
-RMPC_RE($check, $rop);
-$ok .= 'c' if $check == 10;
-RMPC_IM($check, $rop);
-$ok .= 'd' if $check == 8;
-
-Rmpc_d_div($rop, $double, $z, MPC_RNDNN);
-RMPC_RE($check, $rop);
-$ok .= 'e' if ($check > -1.524390244e-1 && $check < -1.5243902439e-1) ;
-RMPC_IM($check, $rop);
-$ok .= 'f' if ($check < 0.12195122 && $check > 0.1219512195);
-
-if($ok eq 'abcdef') {print "ok 3\n"}
-else {
- warn "\$ok: $ok\n";
- print "not ok 3 \n";
-}
-
-$ok = '';
-
-if($_64i) {
-Rmpc_mul_sj($rop, $z, $long, MPC_RNDNN);
-RMPC_RE($check, $rop);
-$ok .= 'a' if $check == -150;
-RMPC_IM($check, $rop);
-$ok .= 'b' if $check == -120;
-
-Rmpc_div_sj($rop, $rop, $long, MPC_RNDNN);
-RMPC_RE($check, $rop);
-$ok .= 'c' if $check == 10;
-RMPC_IM($check, $rop);
-$ok .= 'd' if $check == 8;
-
-Rmpc_sj_div($rop, $long, $z, MPC_RNDNN);
-# (-9.1463414634146345e-1 7.3170731707317072e-1)
-RMPC_RE($check, $rop);
-$ok .= 'e' if ($check < -9.14634e-1 && $check > -9.1463415e-1) ;
-RMPC_IM($check, $rop);
-$ok .= 'f' if ($check < 7.3170732e-1 && $check > 7.3170731e-1);
-
-if($ok eq 'abcdef') {print "ok 4\n"}
-else {
- warn "\$ok: $ok\n";
- print "not ok 4 \n";
-}
-}
-else {
- warn "Skipping test 4 - no 64 bit int support\n";
- print "ok 4\n";
-}
-
-$ok = '';
-
-if($_64d) {
-Rmpc_mul_ld($rop, $z, $double, MPC_RNDNN);
-RMPC_RE($check, $rop);
-$ok .= 'a' if $check == -25;
-RMPC_IM($check, $rop);
-$ok .= 'b' if $check == -20;
-
-Rmpc_div_ld($rop, $rop, $double, MPC_RNDNN);
-RMPC_RE($check, $rop);
-$ok .= 'c' if $check == 10;
-RMPC_IM($check, $rop);
-$ok .= 'd' if $check == 8;
-
-Rmpc_ld_div($rop, $double, $z, MPC_RNDNN);
-RMPC_RE($check, $rop);
-$ok .= 'e' if ($check > -1.524390244e-1 && $check < -1.5243902439e-1) ;
-RMPC_IM($check, $rop);
-$ok .= 'f' if ($check < 0.12195122 && $check > 0.1219512195);
-
-if($ok eq 'abcdef') {print "ok 5\n"}
-else {
- warn "\$ok: $ok\n";
- print "not ok 5 \n";
-}
-}
-else {
- warn "Skipping test 5 - no long double support\n";
- print "ok 5\n";
-}
\ No newline at end of file
+# Some adhoc tests to check that signed zeroes are being dealt with correctly.
+# By no means exhaustive tests - they just deal with a known issue with
+# 64-bit builds and overloaded mul and div operations (which should now be fixed).
+
+use warnings;
+use strict;
+use Math::MPC qw(:mpc);
+use Math::MPFR qw(:mpfr);
+
+print "1..5\n";
+
+my $ok;
+my $z = Math::MPC->new(0, 0);
+my $mul = -1;
+
+my $x = $z * $mul;
+if(Math::MPC::overload_string($x) eq '(-0 -0)') {$ok .= 'a'}
+else {warn "\n1a: got '",Math::MPC::overload_string($x), "'\nexpected '(-0 -0)'\n"}
+
+my $y = $z / $mul;
+if(Math::MPC::overload_string($y) eq '(-0 -0)') {$ok .= 'b'}
+else {warn "\n1b: got '",Math::MPC::overload_string($y), "'\nexpected '(-0 -0)'\n"}
+
+$z *= $mul;
+if(Math::MPC::overload_string($z) eq '(-0 -0)') {$ok .= 'c'}
+else {warn "\n1c: got '",Math::MPC::overload_string($z), "'\nexpected '(-0 -0)'\n"}
+
+$z *= $mul;
+if(Math::MPC::overload_string($z) eq '(0 0)') {$ok .= 'd'}
+else {warn "\n1d: got '",Math::MPC::overload_string($z), "'\nexpected '(0 0)'\n"}
+
+$z /= $mul;
+if(Math::MPC::overload_string($z) eq '(-0 -0)') {$ok .= 'e'}
+else {warn "\n1e: got '",Math::MPC::overload_string($z), "'\nexpected '(-0 -0)'\n"}
+
+if($ok eq 'abcde') {print "ok 1\n"}
+else {
+ warn "\$ok: $ok\n";
+ print "not ok 1\n";
+}
+
+$ok = '';
+Rmpc_set_ui_ui($z, 0, 0, MPC_RNDNN);
+$mul = -10.625;
+
+$x = $z * $mul;
+if(Math::MPC::overload_string($x) eq '(-0 -0)') {$ok .= 'a'}
+else {warn "\n2a: got '",Math::MPC::overload_string($x), "'\nexpected '(-0 -0)'\n"}
+
+$y = $z / $mul;
+if(Math::MPC::overload_string($y) eq '(-0 -0)') {$ok .= 'b'}
+else {warn "\n2b: got '",Math::MPC::overload_string($y), "'\nexpected '(-0 -0)'\n"}
+
+$z *= $mul;
+if(Math::MPC::overload_string($z) eq '(-0 -0)') {$ok .= 'c'}
+else {warn "\n2c: got '",Math::MPC::overload_string($z), "'\nexpected '(-0 -0)'\n"}
+
+$z *= $mul;
+if(Math::MPC::overload_string($z) eq '(0 0)') {$ok .= 'd'}
+else {warn "\n2d: got '",Math::MPC::overload_string($z), "'\nexpected '(0 0)'\n"}
+
+$z /= $mul;
+if(Math::MPC::overload_string($z) eq '(-0 -0)') {$ok .= 'e'}
+else {warn "\n2e: got '",Math::MPC::overload_string($z), "'\nexpected '(-0 -0)'\n"}
+
+if($ok eq 'abcde') {print "ok 2\n"}
+else {
+ warn "\$ok: $ok\n";
+ print "not ok 2\n";
+}
+
+$ok = '';
+my $_64i = Math::MPC::_has_longlong();
+my $_64d = Math::MPC::_has_longdouble();
+
+my $long = -15;
+my $double = -2.5;
+Rmpc_set_ui_ui($z, 10, 8, MPC_RNDNN);
+my $rop = Math::MPC->new();
+my $check = Math::MPFR->new();
+
+Rmpc_mul_d($rop, $z, $double, MPC_RNDNN);
+RMPC_RE($check, $rop);
+$ok .= 'a' if $check == -25;
+RMPC_IM($check, $rop);
+$ok .= 'b' if $check == -20;
+
+Rmpc_div_d($rop, $rop, $double, MPC_RNDNN);
+RMPC_RE($check, $rop);
+$ok .= 'c' if $check == 10;
+RMPC_IM($check, $rop);
+$ok .= 'd' if $check == 8;
+
+Rmpc_d_div($rop, $double, $z, MPC_RNDNN);
+RMPC_RE($check, $rop);
+$ok .= 'e' if ($check > -1.524390244e-1 && $check < -1.5243902439e-1) ;
+RMPC_IM($check, $rop);
+$ok .= 'f' if ($check < 0.12195122 && $check > 0.1219512195);
+
+if($ok eq 'abcdef') {print "ok 3\n"}
+else {
+ warn "\$ok: $ok\n";
+ print "not ok 3 \n";
+}
+
+$ok = '';
+
+if($_64i) {
+Rmpc_mul_sj($rop, $z, $long, MPC_RNDNN);
+RMPC_RE($check, $rop);
+$ok .= 'a' if $check == -150;
+RMPC_IM($check, $rop);
+$ok .= 'b' if $check == -120;
+
+Rmpc_div_sj($rop, $rop, $long, MPC_RNDNN);
+RMPC_RE($check, $rop);
+$ok .= 'c' if $check == 10;
+RMPC_IM($check, $rop);
+$ok .= 'd' if $check == 8;
+
+Rmpc_sj_div($rop, $long, $z, MPC_RNDNN);
+# (-9.1463414634146345e-1 7.3170731707317072e-1)
+RMPC_RE($check, $rop);
+$ok .= 'e' if ($check < -9.14634e-1 && $check > -9.1463415e-1) ;
+RMPC_IM($check, $rop);
+$ok .= 'f' if ($check < 7.3170732e-1 && $check > 7.3170731e-1);
+
+if($ok eq 'abcdef') {print "ok 4\n"}
+else {
+ warn "\$ok: $ok\n";
+ print "not ok 4 \n";
+}
+}
+else {
+ warn "Skipping test 4 - no 64 bit int support\n";
+ print "ok 4\n";
+}
+
+$ok = '';
+
+if($_64d) {
+Rmpc_mul_ld($rop, $z, $double, MPC_RNDNN);
+RMPC_RE($check, $rop);
+$ok .= 'a' if $check == -25;
+RMPC_IM($check, $rop);
+$ok .= 'b' if $check == -20;
+
+Rmpc_div_ld($rop, $rop, $double, MPC_RNDNN);
+RMPC_RE($check, $rop);
+$ok .= 'c' if $check == 10;
+RMPC_IM($check, $rop);
+$ok .= 'd' if $check == 8;
+
+Rmpc_ld_div($rop, $double, $z, MPC_RNDNN);
+RMPC_RE($check, $rop);
+$ok .= 'e' if ($check > -1.524390244e-1 && $check < -1.5243902439e-1) ;
+RMPC_IM($check, $rop);
+$ok .= 'f' if ($check < 0.12195122 && $check > 0.1219512195);
+
+if($ok eq 'abcdef') {print "ok 5\n"}
+else {
+ warn "\$ok: $ok\n";
+ print "not ok 5 \n";
+}
+}
+else {
+ warn "Skipping test 5 - no long double support\n";
+ print "ok 5\n";
+}
@@ -1,68 +1,68 @@
-use warnings;
-use strict;
-use Math::MPFR qw(:mpfr);
-use Math::MPC qw(:mpc);
-
-print "1..3\n";
-
-my $ok = '';
-
-Rmpc_set_default_prec2(100, 100);
-Rmpfr_set_default_prec(81);
-
-my $mpc1 = Math::MPC->new(1.23456, 654321);
-my $mpfr1 = Math::MPFR->new();
-
-Rmpc_arg($mpfr1, $mpc1, GMP_RNDN);
-
-if(!Rmpfr_nan_p($mpfr1)) {$ok .= 'a'}
-if(Rmpfr_get_prec($mpfr1) == 81) {$ok .= 'b'}
-
-if($ok eq 'ab') {print "ok 1\n"}
-else {print "not ok 1 $ok\n"}
-
-$ok = '';
-
-$mpfr1 *= -1;
-$mpfr1 /= 0; # -inf
-my $minus_zero = $mpfr1;
-
-my $mpfr2 = Math::MPFR->new();
-
-my $mpc2 = Math::MPC->new($mpfr2, $mpfr1);
-
-Rmpc_proj($mpc1, $mpc2, MPC_RNDNN);
-
-my $ret = Rmpc_real($mpfr1, $mpc1, GMP_RNDN);
-
-if($ret == 0) {$ok .= 'a'}
-if($mpfr1 > 0) {$ok .= 'b'}
-if(Rmpfr_inf_p($mpfr1)) {$ok .= 'c'}
-if(Rmpfr_get_prec($mpfr1) == 81) {$ok .= 'd'}
-
-$ret = Rmpc_imag($mpfr1, $mpc1, GMP_RNDN);
-
-if($ret == 0) {$ok .= 'e'}
-if($mpfr1 == 0 && $mpfr1 == $minus_zero) {$ok .= 'f'}
-if(Rmpfr_get_prec($mpfr1) == 81) {$ok .= 'g'}
-
-if($ok eq 'abcdefg') {print "ok 2\n"}
-else {print "not ok 2 $ok \n"}
-
-Rmpc_set_ui($mpc1, 10, MPC_RNDNN);
-eval {Rmpc_log10($mpc1, $mpc1, MPC_RNDNN);};
-
-if(65536 > MPC_VERSION) {
- if($@ =~ /mpc_log10 not implemented until mpc\-1\.0/) {print "ok 3\n"}
- else {
- warn "\$\@: $@\n";
- print "not ok 3\n";
- }
-}
-else {
- if($mpc1 == 1) {print "ok 3\n"}
- else {
- warn "\$mpc1: $mpc1\n";
- print "not ok 3\n";
- }
-}
\ No newline at end of file
+use warnings;
+use strict;
+use Math::MPFR qw(:mpfr);
+use Math::MPC qw(:mpc);
+
+print "1..3\n";
+
+my $ok = '';
+
+Rmpc_set_default_prec2(100, 100);
+Rmpfr_set_default_prec(81);
+
+my $mpc1 = Math::MPC->new(1.23456, 654321);
+my $mpfr1 = Math::MPFR->new();
+
+Rmpc_arg($mpfr1, $mpc1, GMP_RNDN);
+
+if(!Rmpfr_nan_p($mpfr1)) {$ok .= 'a'}
+if(Rmpfr_get_prec($mpfr1) == 81) {$ok .= 'b'}
+
+if($ok eq 'ab') {print "ok 1\n"}
+else {print "not ok 1 $ok\n"}
+
+$ok = '';
+
+$mpfr1 *= -1;
+$mpfr1 /= 0; # -inf
+my $minus_zero = $mpfr1;
+
+my $mpfr2 = Math::MPFR->new();
+
+my $mpc2 = Math::MPC->new($mpfr2, $mpfr1);
+
+Rmpc_proj($mpc1, $mpc2, MPC_RNDNN);
+
+my $ret = Rmpc_real($mpfr1, $mpc1, GMP_RNDN);
+
+if($ret == 0) {$ok .= 'a'}
+if($mpfr1 > 0) {$ok .= 'b'}
+if(Rmpfr_inf_p($mpfr1)) {$ok .= 'c'}
+if(Rmpfr_get_prec($mpfr1) == 81) {$ok .= 'd'}
+
+$ret = Rmpc_imag($mpfr1, $mpc1, GMP_RNDN);
+
+if($ret == 0) {$ok .= 'e'}
+if($mpfr1 == 0 && $mpfr1 == $minus_zero) {$ok .= 'f'}
+if(Rmpfr_get_prec($mpfr1) == 81) {$ok .= 'g'}
+
+if($ok eq 'abcdefg') {print "ok 2\n"}
+else {print "not ok 2 $ok \n"}
+
+Rmpc_set_ui($mpc1, 10, MPC_RNDNN);
+eval {Rmpc_log10($mpc1, $mpc1, MPC_RNDNN);};
+
+if(65536 > MPC_VERSION) {
+ if($@ =~ /mpc_log10 not implemented until mpc\-1\.0/) {print "ok 3\n"}
+ else {
+ warn "\$\@: $@\n";
+ print "not ok 3\n";
+ }
+}
+else {
+ if($mpc1 == 1) {print "ok 3\n"}
+ else {
+ warn "\$mpc1: $mpc1\n";
+ print "not ok 3\n";
+ }
+}
@@ -1,329 +1,329 @@
-use warnings;
-use strict;
-use Math::MPFR qw(:mpfr);
-use Math::MPC qw(:mpc);
-
-my $cut = eval 'use threads; 1';
-my $cut_mess = '';
-
-if($cut) {
- if($threads::VERSION < 1.71) {
- $cut = 0;
- $cut_mess = "threads version 1.71 needed - we have only $threads::VERSION. Please update from CPAN.\n";
- }
-}
-
-print "1..5\n";
-
-print "# Using Math::MPFR version ", $Math::MPFR::VERSION, "\n";
-print "# Using mpfr library version ", MPFR_VERSION_STRING, "\n";
-print "# Using gmp library version ", Math::MPFR::gmp_v(), "\n";
-
-my ($ok, $pid);
-
-if(!$cut && !$cut_mess) {$cut_mess = "ithreads not available with this build of perl\n"}
-
-if($cut) { # perform tests
-
- Rmpc_set_default_prec(101);
- my $thr1 = threads->create(
- sub {
- Rmpc_set_default_prec(201);
- return Rmpc_get_default_prec();
- } );
- my $res = $thr1->join();
-
- if($res == 201 && Rmpc_get_default_prec() == 101) {$ok .= 'a'}
- else {warn "\n1a: \$res: $res\n prec: ", Rmpc_get_default_prec(), "\n"}
-
- if($pid = fork()) {
- Rmpc_set_default_prec(102);
- waitpid($pid,0);
- } else {
- sleep 1;
- Rmpc_set_default_prec(202);
- _save(Rmpc_get_default_prec());
- exit(0);
- }
-
- sleep 2;
-
- if(Rmpc_get_default_prec() == 102) {$ok .= 'b'}
- else {warn "\n1b: prec: ", Rmpc_get_default_prec(), "\n"}
-
- my $f = _retrieve();
-
- if($f == 999999) {
- warn "Skipping test 1c - couldn't open 'save_child_setting.txt'";
- $ok .= 'c';
- }
- elsif($f == 202) {
- $ok .= 'c';
- }
- else {
- warn "\n1c: prec: $f\n";
- }
-
- if($ok eq 'abc') {print "ok 1\n"}
- else {
- warn "\$ok: $ok\n";
- print "not ok 1\n";
- }
-
- #######################
-
- $ok = '';
-
- Rmpc_set_default_rounding_mode(GMP_RNDZ);
- my $thr2 = threads->create(
- sub {
- Rmpc_set_default_rounding_mode(GMP_RNDU);
- return Rmpc_get_default_rounding_mode();
- } );
- $res = $thr2->join();
-
- if($res == GMP_RNDU && Rmpc_get_default_rounding_mode() == GMP_RNDZ) {$ok .= 'a'}
- else {warn "\n2a: \$res: $res\n rounding: ", Rmpc_get_default_rounding_mode(), "\n"}
-
- if($pid = fork()) {
- Rmpc_set_default_rounding_mode(GMP_RNDU);
- waitpid($pid,0);
- } else {
- sleep 1;
- Rmpc_set_default_rounding_mode(GMP_RNDD);
- _save(Rmpc_get_default_rounding_mode());
- exit(0);
- }
-
- sleep 2;
-
- if(Rmpc_get_default_rounding_mode() == GMP_RNDU) {$ok .= 'b'}
- else {warn "\n2b: rounding: ", Rmpc_get_default_rounding_mode(), "\n"}
-
- $f = _retrieve();
-
- if($f == 999999) {
- warn "Skipping test 2c - couldn't open 'save_child_setting.txt'";
- $ok .= 'c';
- }
- elsif($f == GMP_RNDD) {
- $ok .= 'c';
- }
- else {
- warn "\n2c: rounding: $f\n";
- }
-
- if($ok eq 'abc') {print "ok 2\n"}
- else {
- warn "\$ok: $ok\n";
- print "not ok 2\n";
- }
-
- #######################
-
- $ok = '';
-
- Rmpc_set_default_rounding_mode(GMP_RNDN);
- Rmpc_set_default_prec(103);
- my $thr3 = threads->create(
- {'context' => 'list'},
- sub {
- Rmpc_set_default_prec(203);
- Rmpc_set_default_rounding_mode(GMP_RNDU);
- return (Rmpc_get_default_prec(), Rmpc_get_default_rounding_mode());
- } );
- my @res = $thr3->join();
-
- if($res[0] == 203 && $res[1] == GMP_RNDU && Rmpc_get_default_prec() == 103 && Rmpc_get_default_rounding_mode() == GMP_RNDN) {$ok .= 'a'}
- else {warn "\n3a: \$res[0]: $res[0]\n \$res[1]: $res[1]\n prec: ", Rmpc_get_default_prec(), "\n rounding: ", Rmpc_get_default_rounding_mode(), "\n"}
-
- if($pid = fork()) {
- Rmpc_set_default_prec(104);
- Rmpc_set_default_rounding_mode(GMP_RNDU);
- waitpid($pid,0);
- } else {
- sleep 1;
- Rmpc_set_default_prec(204);
- Rmpc_set_default_rounding_mode(GMP_RNDD);
- my $p = Rmpc_get_default_prec();
- my $r = Rmpc_get_default_rounding_mode();
- _save("$p $r");
- exit(0);
- }
-
- sleep 2;
-
- if(Rmpc_get_default_rounding_mode() == GMP_RNDU && Rmpc_get_default_prec() == 104) {$ok .= 'b'}
- else {warn "\n3b: prec: ", Rmpc_get_default_prec(), "\n rounding: ", Rmpc_get_default_rounding_mode(), "\n"}
-
- my @f = _retrieve();
-
- if($f[0] == 999999) {
- warn "Skipping test 3c - couldn't open 'save_child_setting.txt'";
- $ok .= 'c';
- }
- elsif($f[0] == 204 && $f[1] == GMP_RNDD) {
- $ok .= 'c';
- }
- else {
- warn "\n3c: prec: $f[0] rounding: $f[1]\n";
- }
-
- if($ok eq 'abc') {print "ok 3\n"}
- else {
- warn "\$ok: $ok\n";
- print "not ok 3\n";
- }
-
- #######################
-
- $ok = '';
-
- Rmpc_set_default_prec2(301, 302);
- my $thr4 = threads->create(
- {'context' => 'list'},
- sub {
- Rmpc_set_default_prec2(310, 320);
- my @ret = Rmpc_get_default_prec2();
- return @ret;
- } );
- @res = $thr4->join();
- my @p2 = Rmpc_get_default_prec2();
-
- if($res[0] == 310 && $res[1] == 320 && $p2[0] == 301 && $p2[1] == 302) {$ok .= 'a'}
- else {warn "\n4a: \$res[0]: $res[0]\n \$res[1]: $res[1]\n \$p2[0]: $p2[0]\n \$p2[1]: $p2[1]\n" }
-
- if($pid = fork()) {
- Rmpc_set_default_prec2(303, 304);
- waitpid($pid,0);
- } else {
- sleep 1;
- Rmpc_set_default_prec2(330, 340);
- my @args = Rmpc_get_default_prec2();
- _save("$args[0] $args[1]");
- exit(0);
- }
-
- sleep 2;
-
- @p2 = Rmpc_get_default_prec2();
-
- if($p2[0] == 303 && $p2[1] == 304) {$ok .= 'b'}
- else {warn "\n4b: \$p2[0]: $p2[0]\n \$p2[1]: $p2[1]\n"}
-
- @f = _retrieve();
-
- if($f[0] == 999999) {
- warn "Skipping test 4c - couldn't open 'save_child_setting.txt'";
- $ok .= 'c';
- }
- elsif($f[0] == 330 && $f[1] == 340) {
- $ok .= 'c';
- }
- else {
- warn "\n4c: prec: @f\n";
- }
-
- if($ok eq 'abc') {print "ok 4\n"}
- else {
- warn "\$ok: $ok\n";
- print "not ok 4\n";
- }
-
- #######################
- #######################
-
- $ok = '';
-
- Rmpc_set_default_prec2(311, 311);
- my $thr5 = threads->create(
- {'context' => 'list'},
- sub {
- Rmpc_set_default_prec2(320, 330);
- my @ret = Rmpc_get_default_prec2();
- push @ret, Rmpc_get_default_prec();
- return @ret;
- } );
- @res = $thr5->join();
- @p2 = Rmpc_get_default_prec2();
-
- if($res[0] == 320 && $res[1] == 330 && $res[2] == 0 && $p2[0] == 311 && $p2[1] == 311 && Rmpc_get_default_prec() == 311) {$ok .= 'a'}
- else {warn "\n5a: \$res[0]: $res[0]\n \$res[1]: $res[1]\n \$p2[0]: $p2[0]\n \$p2[1]: $p2[1]\n Default Prec: ",
- Rmpc_get_default_prec(), "\n" }
-
- if($pid = fork()) {
- Rmpc_set_default_prec2(303, 303);
- waitpid($pid,0);
- } else {
- sleep 1;
- Rmpc_set_default_prec2(330, 340);
- my @args = Rmpc_get_default_prec2();
- push @args, Rmpc_get_default_prec();
- _save("$args[0] $args[1] $args[2]");
- exit(0);
- }
-
- sleep 2;
-
- @p2 = Rmpc_get_default_prec2();
- push @p2, Rmpc_get_default_prec();
-
- if($p2[0] == 303 && $p2[1] == 303 && $p2[2] == 303) {$ok .= 'b'}
- else {warn "\n5b: \$p2[0]: $p2[0]\n \$p2[1]: $p2[1]\n \$p2[2]: $p2[2]\n"}
-
- @f = _retrieve();
-
- if($f[0] == 999999) {
- warn "Skipping test 5c - couldn't open 'save_child_setting.txt'";
- $ok .= 'c';
- }
- elsif($f[0] == 330 && $f[1] == 340 && $f[2] == 0) {
- $ok .= 'c';
- }
- else {
- warn "\n5c: prec: @f\n";
- }
-
- if($ok eq 'abc') {print "ok 5\n"}
- else {
- warn "\$ok: $ok\n";
- print "not ok 5\n";
- }
-
- #######################
-
-}
-else {
- warn "Skipping all tests: ${cut_mess}";
- print "ok 1\n";
- print "ok 2\n";
- print "ok 3\n";
- print "ok 4\n";
- print "ok 5\n";
-}
-
-
-sub _save {
- unless (open(WR, '>', 'save_child_setting.txt')) {
- warn "Can't open file 'save_child_setting.txt' for writing : $!";
- return 0;
- }
- print WR $_[0];
- return 1;
-}
-
-sub _retrieve {
- unless (open (RD, '<', 'save_child_setting.txt')) {
- warn "Can't open file 'save_child_setting.txt' for reading: $!";
- return 999999;
- }
- my @ret;
- my $ret = <RD>;
- chomp $ret;
- if($ret =~ / /) {
- @ret = split / /, $ret;
- return @ret;
- }
- return $ret;
-}
-
+use warnings;
+use strict;
+use Math::MPFR qw(:mpfr);
+use Math::MPC qw(:mpc);
+
+my $cut = eval 'use threads; 1';
+my $cut_mess = '';
+
+if($cut) {
+ if($threads::VERSION < 1.71) {
+ $cut = 0;
+ $cut_mess = "threads version 1.71 needed - we have only $threads::VERSION. Please update from CPAN.\n";
+ }
+}
+
+print "1..5\n";
+
+print "# Using Math::MPFR version ", $Math::MPFR::VERSION, "\n";
+print "# Using mpfr library version ", MPFR_VERSION_STRING, "\n";
+print "# Using gmp library version ", Math::MPFR::gmp_v(), "\n";
+
+my ($ok, $pid);
+
+if(!$cut && !$cut_mess) {$cut_mess = "ithreads not available with this build of perl\n"}
+
+if($cut) { # perform tests
+
+ Rmpc_set_default_prec(101);
+ my $thr1 = threads->create(
+ sub {
+ Rmpc_set_default_prec(201);
+ return Rmpc_get_default_prec();
+ } );
+ my $res = $thr1->join();
+
+ if($res == 201 && Rmpc_get_default_prec() == 101) {$ok .= 'a'}
+ else {warn "\n1a: \$res: $res\n prec: ", Rmpc_get_default_prec(), "\n"}
+
+ if($pid = fork()) {
+ Rmpc_set_default_prec(102);
+ waitpid($pid,0);
+ } else {
+ sleep 1;
+ Rmpc_set_default_prec(202);
+ _save(Rmpc_get_default_prec());
+ exit(0);
+ }
+
+ sleep 2;
+
+ if(Rmpc_get_default_prec() == 102) {$ok .= 'b'}
+ else {warn "\n1b: prec: ", Rmpc_get_default_prec(), "\n"}
+
+ my $f = _retrieve();
+
+ if($f == 999999) {
+ warn "Skipping test 1c - couldn't open 'save_child_setting.txt'";
+ $ok .= 'c';
+ }
+ elsif($f == 202) {
+ $ok .= 'c';
+ }
+ else {
+ warn "\n1c: prec: $f\n";
+ }
+
+ if($ok eq 'abc') {print "ok 1\n"}
+ else {
+ warn "\$ok: $ok\n";
+ print "not ok 1\n";
+ }
+
+ #######################
+
+ $ok = '';
+
+ Rmpc_set_default_rounding_mode(GMP_RNDZ);
+ my $thr2 = threads->create(
+ sub {
+ Rmpc_set_default_rounding_mode(GMP_RNDU);
+ return Rmpc_get_default_rounding_mode();
+ } );
+ $res = $thr2->join();
+
+ if($res == GMP_RNDU && Rmpc_get_default_rounding_mode() == GMP_RNDZ) {$ok .= 'a'}
+ else {warn "\n2a: \$res: $res\n rounding: ", Rmpc_get_default_rounding_mode(), "\n"}
+
+ if($pid = fork()) {
+ Rmpc_set_default_rounding_mode(GMP_RNDU);
+ waitpid($pid,0);
+ } else {
+ sleep 1;
+ Rmpc_set_default_rounding_mode(GMP_RNDD);
+ _save(Rmpc_get_default_rounding_mode());
+ exit(0);
+ }
+
+ sleep 2;
+
+ if(Rmpc_get_default_rounding_mode() == GMP_RNDU) {$ok .= 'b'}
+ else {warn "\n2b: rounding: ", Rmpc_get_default_rounding_mode(), "\n"}
+
+ $f = _retrieve();
+
+ if($f == 999999) {
+ warn "Skipping test 2c - couldn't open 'save_child_setting.txt'";
+ $ok .= 'c';
+ }
+ elsif($f == GMP_RNDD) {
+ $ok .= 'c';
+ }
+ else {
+ warn "\n2c: rounding: $f\n";
+ }
+
+ if($ok eq 'abc') {print "ok 2\n"}
+ else {
+ warn "\$ok: $ok\n";
+ print "not ok 2\n";
+ }
+
+ #######################
+
+ $ok = '';
+
+ Rmpc_set_default_rounding_mode(GMP_RNDN);
+ Rmpc_set_default_prec(103);
+ my $thr3 = threads->create(
+ {'context' => 'list'},
+ sub {
+ Rmpc_set_default_prec(203);
+ Rmpc_set_default_rounding_mode(GMP_RNDU);
+ return (Rmpc_get_default_prec(), Rmpc_get_default_rounding_mode());
+ } );
+ my @res = $thr3->join();
+
+ if($res[0] == 203 && $res[1] == GMP_RNDU && Rmpc_get_default_prec() == 103 && Rmpc_get_default_rounding_mode() == GMP_RNDN) {$ok .= 'a'}
+ else {warn "\n3a: \$res[0]: $res[0]\n \$res[1]: $res[1]\n prec: ", Rmpc_get_default_prec(), "\n rounding: ", Rmpc_get_default_rounding_mode(), "\n"}
+
+ if($pid = fork()) {
+ Rmpc_set_default_prec(104);
+ Rmpc_set_default_rounding_mode(GMP_RNDU);
+ waitpid($pid,0);
+ } else {
+ sleep 1;
+ Rmpc_set_default_prec(204);
+ Rmpc_set_default_rounding_mode(GMP_RNDD);
+ my $p = Rmpc_get_default_prec();
+ my $r = Rmpc_get_default_rounding_mode();
+ _save("$p $r");
+ exit(0);
+ }
+
+ sleep 2;
+
+ if(Rmpc_get_default_rounding_mode() == GMP_RNDU && Rmpc_get_default_prec() == 104) {$ok .= 'b'}
+ else {warn "\n3b: prec: ", Rmpc_get_default_prec(), "\n rounding: ", Rmpc_get_default_rounding_mode(), "\n"}
+
+ my @f = _retrieve();
+
+ if($f[0] == 999999) {
+ warn "Skipping test 3c - couldn't open 'save_child_setting.txt'";
+ $ok .= 'c';
+ }
+ elsif($f[0] == 204 && $f[1] == GMP_RNDD) {
+ $ok .= 'c';
+ }
+ else {
+ warn "\n3c: prec: $f[0] rounding: $f[1]\n";
+ }
+
+ if($ok eq 'abc') {print "ok 3\n"}
+ else {
+ warn "\$ok: $ok\n";
+ print "not ok 3\n";
+ }
+
+ #######################
+
+ $ok = '';
+
+ Rmpc_set_default_prec2(301, 302);
+ my $thr4 = threads->create(
+ {'context' => 'list'},
+ sub {
+ Rmpc_set_default_prec2(310, 320);
+ my @ret = Rmpc_get_default_prec2();
+ return @ret;
+ } );
+ @res = $thr4->join();
+ my @p2 = Rmpc_get_default_prec2();
+
+ if($res[0] == 310 && $res[1] == 320 && $p2[0] == 301 && $p2[1] == 302) {$ok .= 'a'}
+ else {warn "\n4a: \$res[0]: $res[0]\n \$res[1]: $res[1]\n \$p2[0]: $p2[0]\n \$p2[1]: $p2[1]\n" }
+
+ if($pid = fork()) {
+ Rmpc_set_default_prec2(303, 304);
+ waitpid($pid,0);
+ } else {
+ sleep 1;
+ Rmpc_set_default_prec2(330, 340);
+ my @args = Rmpc_get_default_prec2();
+ _save("$args[0] $args[1]");
+ exit(0);
+ }
+
+ sleep 2;
+
+ @p2 = Rmpc_get_default_prec2();
+
+ if($p2[0] == 303 && $p2[1] == 304) {$ok .= 'b'}
+ else {warn "\n4b: \$p2[0]: $p2[0]\n \$p2[1]: $p2[1]\n"}
+
+ @f = _retrieve();
+
+ if($f[0] == 999999) {
+ warn "Skipping test 4c - couldn't open 'save_child_setting.txt'";
+ $ok .= 'c';
+ }
+ elsif($f[0] == 330 && $f[1] == 340) {
+ $ok .= 'c';
+ }
+ else {
+ warn "\n4c: prec: @f\n";
+ }
+
+ if($ok eq 'abc') {print "ok 4\n"}
+ else {
+ warn "\$ok: $ok\n";
+ print "not ok 4\n";
+ }
+
+ #######################
+ #######################
+
+ $ok = '';
+
+ Rmpc_set_default_prec2(311, 311);
+ my $thr5 = threads->create(
+ {'context' => 'list'},
+ sub {
+ Rmpc_set_default_prec2(320, 330);
+ my @ret = Rmpc_get_default_prec2();
+ push @ret, Rmpc_get_default_prec();
+ return @ret;
+ } );
+ @res = $thr5->join();
+ @p2 = Rmpc_get_default_prec2();
+
+ if($res[0] == 320 && $res[1] == 330 && $res[2] == 0 && $p2[0] == 311 && $p2[1] == 311 && Rmpc_get_default_prec() == 311) {$ok .= 'a'}
+ else {warn "\n5a: \$res[0]: $res[0]\n \$res[1]: $res[1]\n \$p2[0]: $p2[0]\n \$p2[1]: $p2[1]\n Default Prec: ",
+ Rmpc_get_default_prec(), "\n" }
+
+ if($pid = fork()) {
+ Rmpc_set_default_prec2(303, 303);
+ waitpid($pid,0);
+ } else {
+ sleep 1;
+ Rmpc_set_default_prec2(330, 340);
+ my @args = Rmpc_get_default_prec2();
+ push @args, Rmpc_get_default_prec();
+ _save("$args[0] $args[1] $args[2]");
+ exit(0);
+ }
+
+ sleep 2;
+
+ @p2 = Rmpc_get_default_prec2();
+ push @p2, Rmpc_get_default_prec();
+
+ if($p2[0] == 303 && $p2[1] == 303 && $p2[2] == 303) {$ok .= 'b'}
+ else {warn "\n5b: \$p2[0]: $p2[0]\n \$p2[1]: $p2[1]\n \$p2[2]: $p2[2]\n"}
+
+ @f = _retrieve();
+
+ if($f[0] == 999999) {
+ warn "Skipping test 5c - couldn't open 'save_child_setting.txt'";
+ $ok .= 'c';
+ }
+ elsif($f[0] == 330 && $f[1] == 340 && $f[2] == 0) {
+ $ok .= 'c';
+ }
+ else {
+ warn "\n5c: prec: @f\n";
+ }
+
+ if($ok eq 'abc') {print "ok 5\n"}
+ else {
+ warn "\$ok: $ok\n";
+ print "not ok 5\n";
+ }
+
+ #######################
+
+}
+else {
+ warn "Skipping all tests: ${cut_mess}";
+ print "ok 1\n";
+ print "ok 2\n";
+ print "ok 3\n";
+ print "ok 4\n";
+ print "ok 5\n";
+}
+
+
+sub _save {
+ unless (open(WR, '>', 'save_child_setting.txt')) {
+ warn "Can't open file 'save_child_setting.txt' for writing : $!";
+ return 0;
+ }
+ print WR $_[0];
+ return 1;
+}
+
+sub _retrieve {
+ unless (open (RD, '<', 'save_child_setting.txt')) {
+ warn "Can't open file 'save_child_setting.txt' for reading: $!";
+ return 999999;
+ }
+ my @ret;
+ my $ret = <RD>;
+ chomp $ret;
+ if($ret =~ / /) {
+ @ret = split / /, $ret;
+ return @ret;
+ }
+ return $ret;
+}
+
@@ -1,40 +1,40 @@
-mpq_t * MPQ
-mpz_t * MPZ
-mpf_t * MPF
-mpfr_t * MPFR
-mpc_t * MPC
-mpc_ptr MPC_PTR
-mpc_rnd_t MPC_RND
-intmax_t INTMAX
-uintmax_t UINTMAX
-long double LONG_DOUBLE
-
-INPUT
-MPQ
- $var = INT2PTR($type, SvIV(SvRV($arg)))
-MPZ
- $var = INT2PTR($type, SvIV(SvRV($arg)))
-MPF
- $var = INT2PTR($type, SvIV(SvRV($arg)))
-MPFR
- $var = INT2PTR($type, SvIV(SvRV($arg)))
-MPC
- $var = INT2PTR($type, SvIV(SvRV($arg)))
-MPC_PTR
- $var = INT2PTR($type, SvIV(SvRV($arg)))
-MPC_RND
- $var = ($type)SvUV($arg)
-INTMAX
- $var = ($type)SvIV($arg)
-UINTMAX
- $var = ($type)SvUV($arg)
-LONG_DOUBLE
- $var = ($type)SvNV($arg)
-
-
-
-
-
-
-
-
+mpq_t * MPQ
+mpz_t * MPZ
+mpf_t * MPF
+mpfr_t * MPFR
+mpc_t * MPC
+mpc_ptr MPC_PTR
+mpc_rnd_t MPC_RND
+intmax_t INTMAX
+uintmax_t UINTMAX
+long double LONG_DOUBLE
+
+INPUT
+MPQ
+ $var = INT2PTR($type, SvIV(SvRV($arg)))
+MPZ
+ $var = INT2PTR($type, SvIV(SvRV($arg)))
+MPF
+ $var = INT2PTR($type, SvIV(SvRV($arg)))
+MPFR
+ $var = INT2PTR($type, SvIV(SvRV($arg)))
+MPC
+ $var = INT2PTR($type, SvIV(SvRV($arg)))
+MPC_PTR
+ $var = INT2PTR($type, SvIV(SvRV($arg)))
+MPC_RND
+ $var = ($type)SvUV($arg)
+INTMAX
+ $var = ($type)SvIV($arg)
+UINTMAX
+ $var = ($type)SvUV($arg)
+LONG_DOUBLE
+ $var = ($type)SvNV($arg)
+
+
+
+
+
+
+
+