Math-GMP-2.24000755000764000764 014145117655 13261 5ustar00shlomifshlomif000000000000GMP.xs100644000764000764 2747414145117655 14377 0ustar00shlomifshlomif000000000000Math-GMP-2.24#include "EXTERN.h" #include "perl.h" #include "XSUB.h" #include "gmp.h" /* Math::GMP, a Perl module for high-speed arbitrary size integer calculations Copyright (C) 2000 James H. Turner This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more details. You should have received a copy of the GNU Library General Public License along with this library; if not, write to the Free Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA You can contact the author at chip@redhat.com, chipt@cpan.org, or by mail: Chip Turner Red Hat Inc. 2600 Meridian Park Blvd Durham, NC 27713 */ #define SWAP_GMP if (swap) { mpz_t* t = m; m = n; n = t; } /* * mpz_rootrem() has bug with negative first argument before 5.1.0 */ static int need_rootrem_workaround(mpz_t* m, unsigned long n) { /* workaround only valid for n odd (n even should be an error) */ if ((n & 1) == 0) return 0; /* workaround only relevant for m negative */ if (mpz_sgn(*m) >= 0) return 0; /* workaround only needed for gmp_version < 5.1.0 */ if ((gmp_version[0] && gmp_version[1] != '.') /* >= 10.0.0 */ || (gmp_version[0] > '5') /* >= 6.0.0 */ || (gmp_version[0] == '5' && gmp_version[2] != '0') /* >= 5.1.0 */ ) return 0; return 1; } #if 0 static double constant(char *name, int arg) { errno = 0; switch (*name) { } errno = EINVAL; return 0; not_there: errno = ENOENT; return 0; } #endif mpz_t * pv2gmp(char* pv) { mpz_t* z; SV* sv; z = malloc (sizeof(mpz_t)); mpz_init_set_str(*z, pv, 0); sv = sv_newmortal(); sv_setref_pv(sv, "Math::GMP", (void*)z); return z; } mpz_t * sv2gmp(SV* sv) { char* pv; /* MAYCHANGE in perlguts.pod - bug in perl */ if (SvGMAGICAL(sv)) mg_get(sv); if (SvROK(sv) && sv_derived_from(sv, "Math::GMP")) { IV tmp = SvIV((SV*)SvRV(sv)); return (mpz_t *)tmp; } pv = SvPV_nolen(sv); return pv2gmp(pv); } MODULE = Math::GMP PACKAGE = Math::GMP PROTOTYPES: ENABLE mpz_t * new_from_scalar(s) char * s CODE: RETVAL = malloc (sizeof(mpz_t)); mpz_init_set_str(*RETVAL, s, 0); OUTPUT: RETVAL mpz_t * new_from_scalar_with_base(s, b) char * s int b CODE: RETVAL = malloc (sizeof(mpz_t)); mpz_init_set_str(*RETVAL, s, b); OUTPUT: RETVAL void destroy(n) mpz_t *n CODE: mpz_clear(*n); free(n); SV * _gmp_build_version() CODE: char buf[] = STRINGIFY(__GNU_MP_VERSION) "." STRINGIFY(__GNU_MP_VERSION_MINOR) "." STRINGIFY(__GNU_MP_VERSION_PATCHLEVEL); RETVAL = newSV(6); scan_vstring(buf, buf + sizeof(buf), RETVAL); OUTPUT: RETVAL SV * _gmp_lib_version() CODE: const char* v = gmp_version; RETVAL = newSV(6); scan_vstring(v, v + strlen(v), RETVAL); OUTPUT: RETVAL SV * stringify(n) mpz_t * n PREINIT: int len; CODE: len = mpz_sizeinbase(*n, 10); { char *buf; buf = malloc(len + 2); mpz_get_str(buf, 10, *n); RETVAL = newSVpv(buf, strlen(buf)); free(buf); } OUTPUT: RETVAL SV * get_str_gmp(n, b) mpz_t * n int b PREINIT: int len; CODE: len = mpz_sizeinbase(*n, b); { char *buf; buf = malloc(len + 2); mpz_get_str(buf, b, *n); RETVAL = newSVpv(buf, strlen(buf)); free(buf); } OUTPUT: RETVAL int sizeinbase_gmp(n, b) mpz_t * n int b CODE: RETVAL = mpz_sizeinbase(*n, b); OUTPUT: RETVAL unsigned long uintify(n) mpz_t * n CODE: RETVAL = mpz_get_ui(*n); OUTPUT: RETVAL void add_ui_gmp(n, v) mpz_t * n unsigned long v CODE: mpz_add_ui(*n, *n, v); long intify(n) mpz_t * n CODE: RETVAL = mpz_get_si(*n); OUTPUT: RETVAL mpz_t * mul_2exp_gmp(n, e) mpz_t * n unsigned long e CODE: RETVAL = malloc (sizeof(mpz_t)); mpz_init(*RETVAL); mpz_mul_2exp(*RETVAL, *n, e); OUTPUT: RETVAL mpz_t * div_2exp_gmp(n, e) mpz_t * n unsigned long e CODE: RETVAL = malloc (sizeof(mpz_t)); mpz_init(*RETVAL); mpz_div_2exp(*RETVAL, *n, e); OUTPUT: RETVAL mpz_t * powm_gmp(n, exp, mod) mpz_t * n mpz_t * exp mpz_t * mod CODE: RETVAL = malloc (sizeof(mpz_t)); mpz_init(*RETVAL); mpz_powm(*RETVAL, *n, *exp, *mod); OUTPUT: RETVAL mpz_t * mmod_gmp(a, b) mpz_t * a mpz_t * b CODE: RETVAL = malloc (sizeof(mpz_t)); mpz_init(*RETVAL); mpz_mmod(*RETVAL, *a, *b); OUTPUT: RETVAL mpz_t * mod_2exp_gmp(in, cnt) mpz_t * in unsigned long cnt CODE: RETVAL = malloc (sizeof(mpz_t)); mpz_init(*RETVAL); mpz_mod_2exp(*RETVAL, *in, cnt); OUTPUT: RETVAL mpz_t * op_add(m,n,swap) mpz_t * m mpz_t * n bool swap CODE: RETVAL = malloc (sizeof(mpz_t)); mpz_init(*RETVAL); mpz_add(*RETVAL, *m, *n); OUTPUT: RETVAL mpz_t * op_sub(m,n,swap) mpz_t * m mpz_t * n bool swap CODE: SWAP_GMP RETVAL = malloc (sizeof(mpz_t)); mpz_init(*RETVAL); mpz_sub(*RETVAL, *m, *n); OUTPUT: RETVAL mpz_t * op_mul(m,n,swap) mpz_t * m mpz_t * n bool swap CODE: RETVAL = malloc (sizeof(mpz_t)); mpz_init(*RETVAL); mpz_mul(*RETVAL, *m, *n); OUTPUT: RETVAL mpz_t * bmulf(n,d) mpz_t * n double d PREINIT: mpf_t nf, df; mp_bitcnt_t prec; CODE: /* Multiply (mpz_t) n by (double) d returning an (mpz_t) result. Uses GMP floats with maximum needed precision. */ prec = mpf_get_default_prec(); mpf_set_default_prec(mpz_sizeinbase(*n, 2) + 8 * sizeof(double)); RETVAL = malloc (sizeof(mpz_t)); mpz_init(*RETVAL); mpf_init(nf); mpf_init(df); mpf_set_z(nf, *n); mpf_set_d(df, d); mpf_mul(nf, nf, df); mpz_set_f(*RETVAL, nf); mpf_clear(nf); mpf_clear(df); /* restore default */ mpf_set_default_prec(prec); OUTPUT: RETVAL mpz_t * op_div(m,n,swap) mpz_t * m mpz_t * n bool swap CODE: SWAP_GMP RETVAL = malloc (sizeof(mpz_t)); mpz_init(*RETVAL); mpz_div(*RETVAL, *m, *n); OUTPUT: RETVAL void bdiv(m,n) mpz_t * m mpz_t * n PREINIT: mpz_t * quo; mpz_t * rem; PPCODE: quo = malloc (sizeof(mpz_t)); rem = malloc (sizeof(mpz_t)); mpz_init(*quo); mpz_init(*rem); mpz_tdiv_qr(*quo, *rem, *m, *n); EXTEND(SP, 2); PUSHs(sv_setref_pv(sv_newmortal(), "Math::GMP", (void*)quo)); PUSHs(sv_setref_pv(sv_newmortal(), "Math::GMP", (void*)rem)); mpz_t * op_mod(m,n,swap) mpz_t * m mpz_t * n bool swap CODE: SWAP_GMP RETVAL = malloc (sizeof(mpz_t)); mpz_init(*RETVAL); mpz_mod(*RETVAL, *m, *n); OUTPUT: RETVAL mpz_t * bmodinv(m,n) mpz_t * m mpz_t * n CODE: RETVAL = malloc (sizeof(mpz_t)); mpz_init(*RETVAL); mpz_invert(*RETVAL, *m, *n); OUTPUT: RETVAL int op_spaceship(m,n,swap) mpz_t * m mpz_t * n bool swap PREINIT: int i; CODE: i = mpz_cmp(*m, *n); if (swap) { i = -i; } RETVAL = (i < 0) ? -1 : (i > 0) ? 1 : 0; OUTPUT: RETVAL int op_eq(m,n,swap) mpz_t* m mpz_t* n bool swap PREINIT: int i; CODE: i = mpz_cmp(*m, *n); RETVAL = (i == 0) ? 1 : 0; OUTPUT: RETVAL int legendre(m, n) mpz_t * m mpz_t * n CODE: RETVAL = mpz_legendre(*m, *n); OUTPUT: RETVAL int jacobi(m, n) mpz_t * m mpz_t * n CODE: RETVAL = mpz_jacobi(*m, *n); OUTPUT: RETVAL int probab_prime(m, reps) mpz_t * m int reps CODE: RETVAL = mpz_probab_prime_p(*m, reps); OUTPUT: RETVAL mpz_t * op_pow(m,n) mpz_t * m long n CODE: RETVAL = malloc (sizeof(mpz_t)); mpz_init(*RETVAL); /* fprintf(stderr, "n is %ld\n", n);*/ mpz_pow_ui(*RETVAL, *m, n); OUTPUT: RETVAL mpz_t * bgcd(m,n) mpz_t * m mpz_t * n CODE: RETVAL = malloc (sizeof(mpz_t)); mpz_init(*RETVAL); mpz_gcd(*RETVAL, *m, *n); OUTPUT: RETVAL mpz_t * blcm(m,n) mpz_t * m mpz_t * n CODE: RETVAL = malloc (sizeof(mpz_t)); mpz_init(*RETVAL); mpz_lcm(*RETVAL, *m, *n); OUTPUT: RETVAL mpz_t * fibonacci(n) long n CODE: RETVAL = malloc (sizeof(mpz_t)); mpz_init(*RETVAL); mpz_fib_ui(*RETVAL, n); OUTPUT: RETVAL mpz_t * band(m,n, ...) mpz_t * m mpz_t * n CODE: RETVAL = malloc (sizeof(mpz_t)); mpz_init(*RETVAL); mpz_and(*RETVAL, *m, *n); OUTPUT: RETVAL mpz_t * bxor(m,n, ...) mpz_t * m mpz_t * n CODE: RETVAL = malloc (sizeof(mpz_t)); mpz_init(*RETVAL); mpz_xor(*RETVAL, *m, *n); OUTPUT: RETVAL mpz_t * bior(m,n, ...) mpz_t * m mpz_t * n CODE: RETVAL = malloc (sizeof(mpz_t)); mpz_init(*RETVAL); mpz_ior(*RETVAL, *m, *n); OUTPUT: RETVAL mpz_t * blshift(m,n,swap) mpz_t * m mpz_t * n bool swap CODE: SWAP_GMP RETVAL = malloc (sizeof(mpz_t)); mpz_init(*RETVAL); mpz_mul_2exp(*RETVAL, *m, mpz_get_ui(*n)); OUTPUT: RETVAL mpz_t * brshift(m,n,swap) mpz_t * m mpz_t * n bool swap CODE: SWAP_GMP RETVAL = malloc (sizeof(mpz_t)); mpz_init(*RETVAL); mpz_div_2exp(*RETVAL, *m, mpz_get_ui(*n)); OUTPUT: RETVAL mpz_t * bfac(n) long n CODE: RETVAL = malloc (sizeof(mpz_t)); mpz_init(*RETVAL); mpz_fac_ui(*RETVAL, n); OUTPUT: RETVAL mpz_t * bnok(n, k) long n long k CODE: RETVAL = malloc (sizeof(mpz_t)); mpz_init(*RETVAL); mpz_bin_uiui(*RETVAL, n, k); OUTPUT: RETVAL mpz_t * gmp_copy(m) mpz_t * m CODE: RETVAL = malloc (sizeof(mpz_t)); mpz_init_set(*RETVAL, *m); OUTPUT: RETVAL int gmp_tstbit(m,n) mpz_t * m long n CODE: RETVAL = mpz_tstbit(*m,n); OUTPUT: RETVAL mpz_t * broot(m,n) mpz_t * m unsigned long n CODE: RETVAL = malloc (sizeof(mpz_t)); mpz_init(*RETVAL); mpz_root(*RETVAL, *m, n); OUTPUT: RETVAL void brootrem(m,n) mpz_t * m unsigned long n PREINIT: mpz_t * root; mpz_t * remainder; PPCODE: root = malloc (sizeof(mpz_t)); remainder = malloc (sizeof(mpz_t)); mpz_init(*root); mpz_init(*remainder); if (need_rootrem_workaround(m, n)) { /* Older libgmp have bugs for negative m, but if we need to we can * work on abs(m) then negate the results. */ mpz_neg(*root, *m); mpz_rootrem(*root, *remainder, *root, n); mpz_neg(*root, *root); mpz_neg(*remainder, *remainder); } else { mpz_rootrem(*root, *remainder, *m, n); } EXTEND(SP, 2); PUSHs(sv_setref_pv(sv_newmortal(), "Math::GMP", (void*)root)); PUSHs(sv_setref_pv(sv_newmortal(), "Math::GMP", (void*)remainder)); mpz_t * bsqrt(m) mpz_t * m CODE: RETVAL = malloc (sizeof(mpz_t)); mpz_init(*RETVAL); mpz_sqrt(*RETVAL, *m); OUTPUT: RETVAL void bsqrtrem(m) mpz_t * m PREINIT: mpz_t * sqrt; mpz_t * remainder; PPCODE: sqrt = malloc (sizeof(mpz_t)); remainder = malloc (sizeof(mpz_t)); mpz_init(*sqrt); mpz_init(*remainder); mpz_sqrtrem(*sqrt, *remainder, *m); EXTEND(SP, 2); PUSHs(sv_setref_pv(sv_newmortal(), "Math::GMP", (void*)sqrt)); PUSHs(sv_setref_pv(sv_newmortal(), "Math::GMP", (void*)remainder)); int is_perfect_power(m) mpz_t * m CODE: RETVAL = mpz_perfect_power_p(*m) ? 1 : 0; OUTPUT: RETVAL int is_perfect_square(m) mpz_t * m CODE: RETVAL = mpz_perfect_square_p(*m) ? 1 : 0; OUTPUT: RETVAL Changes100644000764000764 1353314145117655 14662 0ustar00shlomifshlomif000000000000Math-GMP-2.24Revision history for Perl extension Math::GMP. 2.24 2021-11-17 Shlomif - tests+better docs for bnok() (Binomial) - Eliminate warning about not_here() in GMP.xs. 2.23 2021-11-05 Shlomif - add support for bmulf() to multiply by a floating point number - Hugo - add support for bnok() (Binomial) 2.22 2021-09-20 Shlomif - Signature files are generated unreliably and are an ongoing source of bug reports. As a result, we decided to axe them altogether. - https://github.com/turnstep/Math-GMP/issues/6 - Thanks to @lemrouch . 2.21 2021-09-11 Shlomif - Apply doc patch from @hvds documenting the pitfalls of division by zero. - https://github.com/turnstep/Math-GMP/issues/5 2.20 2020-02-09 Shlomif - Try to fix tests when using libgmp version 6.2.0 - https://rt.cpan.org/Public/Bug/Display.html?id=131718 - Thanks to GREGOA and HVDS and Debian. - The tests should still pass on earlier libgmps. 2.19 2018-04-08 Shlomif - Fix int() on large unsigned integers. - https://github.com/turnstep/Math-GMP/issues/2 - Thanks to @trizen . 2.18 2018-04-07 Shlomif - Depend on Alien::GMP to automatically install GMP when missing - See https://rt.cpan.org/Ticket/Display.html?id=125018 - See https://github.com/turnstep/Math-GMP/pull/1 2.17 2018-04-05 Shlomif - Correct the link to the GitHub repository. - See https://rt.cpan.org/Ticket/Display.html?id=125018 2.16 2017-12-18 Shlomif - Fix behaviour under "use feature 'bitwise'" - See https://rt.cpan.org/Public/Bug/Display.html?id=123907 - Thanks to Sisphus for the report and perlxs for some insights. 2.15 2017-06-25 Shlomif - Bump required perl version to 5.10.x. - There were test failures with 5.8.x and even 5.10.x is old enough. - http://www.cpantesters.org/cpan/report/256184b2-58bf-11e7-a074-e1beba07c9dd 2.14 2017-02-01 Shlomif - Hopefully fix the GPG signature. - https://rt.cpan.org/Ticket/Display.html?id=120062 - Thanks to Pavel Mateja for the report. 2.13 2016-11-18 Shlomif - Fix the tests on older libgmps. - See https://rt.cpan.org/Ticket/Display.html?id=118816 - Thanks to Hugo van der Sanden for the patches. - Refactoring of the test suite. 2.12 2016-11-09 Shlomif - Add support for testing methods that return lists. - Add broot, brootrem, bsqrtrem, is_perfect_power, is_perfect_square - Thanks to Hugo van der Sanden for the patches - https://rt.cpan.org/Ticket/Display.html?id=118677 2.11 2015-08-16 Shlomif - Got the distribution to have full POD coverage and check all functions for usage. - t/check-funcs-ret-value--rt92593.t - https://rt.cpan.org/Public/Bug/Display.html?id=92593 - CPAN Day! 2.10 2015-08-12 Shlomif - Throw an exception on invalid input to Math::GMP->new; - https://rt.cpan.org/Ticket/Display.html?id=27521 - Thanks to SISYPHUS for the report. - Put RELEASE_TESTING tests under xt instead of t. - https://rt.cpan.org/Ticket/Display.html?id=106365 - Thanks to ilmari for the report and suggested fix. - Document and test some functions that were improperly documented or not tested. - t/check-funcs-ret-value--rt92593.t - https://rt.cpan.org/Public/Bug/Display.html?id=92593 - Still aiming for full POD Coverage. 2.09 2015-07-29 Shlomif - Add the binary-left-shift / << operator. - Add the binary-right-shift / >> operator. - Convert the build system to Dist-Zilla to ease future maintenance. - Add a call to Devel::CheckLib for finding the "gmp.h" header. 2.08 2015-07-28 Shlomif - Add a link to the version control repository at various places. - Get rid of indirect object notation in the code and the examples. - It’s a sign of Ancient Perl. - Overload bool to avoid fallback to intify (Hugo) - Fixes RT #101443 - https://rt.cpan.org/Ticket/Display.html?id=101443 - Modified patch applied by Shlomif. - Add tests from DANAJ for large numbers in some functions. - RT #92641 - https://rt.cpan.org/Ticket/Display.html?id=92641 2.07 2014-01-26 Hugo - Go direct to XS for more speed - add lcm/blcm, bsqrt, bmodinv 2.06 2009-09-17 Greg - Make Makefile.PL more forgiving of gmp library locations. (CPAN bug #46323) - Update link to libgmp.org in INSTALL file (CPAN bug #46324) 2.05 2008-10-06 Greg - New maintainer: Greg Sabino Mullane - Allow tests to work on 64-bit platforms. Patch from Flo. (CPAN bugs #5960, #30327, #27641, #12751, #15459) - Add support for probab_prime function. Patch by shlomif@iglu.org.il. (CPAN bug #6184) - Get smarter about detecting lack of GMP libraries. (CPAN bug #18709) - Add META.yml and some more tests. 2.04 2004-09-28 cturner - added patch from Nicholas Oxhøj for constructing with different bases (nicholas@oxhoej.dk) (CPAN bug #4472) 2.03 2002-02-16 Tels - added internal functions gmp_copy, gmp_tstbit, gmp_sqrt - moved test.pl to t/gmppmt, made it use Test and use strict - moved GMP.pm to lib/Math/GMP.pm - documented some of the public methods - fixed README - added INSTALL file 2.02 2002-02-15 Tels - added internal functions gmp_fac, gmp_fib, and_two, or_two, xor_two - added band, bior, bxor, bfac - added overload for &, ^ and | - tests for new functions 2.00 2002-02-08 cturner - remove gmp inside of package, performance improvements, some new ops 1.07 2001-04-22 cturner 1.06 2001-04-10 cturner 1.05 2001-02-23 cturner 1.04 2001-02-13 cturner 1.03 2001-01-25 cturner 1.02 2001-01-20 cturner 1.01 2000-03-21 cturner 1.00 2000-02-25 cturner 0.9 1999-09-19 cturner 0.01 1999-09-17 cturner - original version; created by h2xs 1.19 LICENSE100644000764000764 166314145117655 14355 0ustar00shlomifshlomif000000000000Math-GMP-2.24Math::GMP, a Perl module for high-speed arbitrary size integer calculations Copyright (C) 2000 James H. Turner This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more details. You should have received a copy of the GNU Library General Public License along with this library; if not, write to the Free Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA You can contact the author at chip@redhat.com, chipt@cpan.org, or by mail: Chip Turner Red Hat Inc. 2600 Meridian Park Blvd Durham, NC 27713 INSTALL100644000764000764 250314145117655 14373 0ustar00shlomifshlomif000000000000Math-GMP-2.24Math::GMP - High speed arbitrary size integer math To install this package, you will need a version of the GMP library. You have different alternatives: - get it at the homepage of GMP: http://www.gmplib.org/ - install a pre-compiled package provided by your distribution - let Math::GMP download and install GMP for you (thanks to Alien::GMP) After installing GMP (if you want to do it yourself), do the following: perl Makefile.PL make make test When all tests pass, install it (as root) with the following command: make install Enjoy! If you have problems, please check the platform-specific notes below. ** Notes for AIX ** tswd13@yahoo.com notes on bug #11736 about installing on AIX 5.2: First, I had to modify the Makefile.PL so that it could see the gmp libraries by adding "-L/usr/local/lib" as below: 'LIBS' => ['-L/usr/local/lib -lgmp'], # e.g., '-lm' Then, I had to change the following line in GMP.c and GMP.xs from: #include "gmp.h" to: #include Reinstalled gmp-4.1.4 with: ./configure ABI=32 --disable-static ** Notes for Mac OS X ** Rob writes on bug #19262: Error: /usr/bin/ld: /usr/local/lib/libgmp.a(mode1o.o) has local relocation entries in non-writable section (__TEXT,__text) Solution: Edit the Makefile, adding the following to LDDLFLAGS: -read_only_relocs suppress typemap100644000764000764 21514145117655 14722 0ustar00shlomifshlomif000000000000Math-GMP-2.24mpz_t * MPZ INPUT MPZ $var = sv2gmp($arg); bool $var = (bool)SvTRUE($arg); OUTPUT MPZ sv_setref_pv($arg, \"Math::GMP\", (void*)$var); dist.ini100644000764000764 237014145117655 15010 0ustar00shlomifshlomif000000000000Math-GMP-2.24; See [dzil / Dist-Zilla](http://dzil.org/) (also ; https://metacpan.org/pod/Dist::Zilla ) for how to build from the ; `dist.ini`-based repository sources. name = Math-GMP author = Shlomi Fish license = LGPL_2_1 copyright_holder = James H. Turner copyright_year = 2000 [@Filter] -bundle = @Basic -remove = MakeMaker -remove = ExtraTests -remove = License -remove = Readme [AutoPrereqs] [Prereqs / ConfigureRequires] Alien::GMP = 1.08 [MakeMaker::Awesome] header = use Alien::Base::Wrapper qw( Alien::GMP !export ); WriteMakefile_arg = Alien::Base::Wrapper->mm_args [MetaJSON] [MetaProvides::Package] [MetaResources] bugtracker.web = https://rt.cpan.org/Public/Dist/Display.html?Name=Math-GMP bugtracker.mailto = bug-math-gmp@rt.cpan.org repository.url = https://github.com/turnstep/Math-GMP.git repository.web = https://github.com/turnstep/Math-GMP repository.type = git [PodSyntaxTests] [PodCoverageTests] [PodWeaver] [PruneCruft] [PruneFiles] match = ^Rejects/ match = ^scripts/ [RewriteVersion] [RunExtraTests] [Test::CPAN::Changes] [Test::Compile] skip = scripts fake_home = 1 [Test::TrailingSpace] ; Signature files are generated unreliably and are an ongoing source of ; bug reports. As a result, we decided to axe them altogether. ; [Signature] META.yml100644000764000764 174214145117655 14617 0ustar00shlomifshlomif000000000000Math-GMP-2.24--- abstract: 'High speed arbitrary size integer math' author: - 'Shlomi Fish ' build_requires: Data::Dumper: '0' File::Spec: '0' File::Temp: '0' IO::Handle: '0' IPC::Open3: '0' Test::More: '0' configure_requires: Alien::GMP: '1.08' ExtUtils::MakeMaker: '0' dynamic_config: 0 generated_by: 'Dist::Zilla version 6.024, CPAN::Meta::Converter version 2.150010' license: lgpl meta-spec: url: http://module-build.sourceforge.net/META-spec-v1.4.html version: '1.4' name: Math-GMP provides: Math::GMP: file: lib/Math/GMP.pm version: '2.24' requires: AutoLoader: '0' Carp: '0' DynaLoader: '0' Exporter: '0' overload: '0' perl: '5.010' strict: '0' vars: '0' warnings: '0' resources: bugtracker: https://rt.cpan.org/Public/Dist/Display.html?Name=Math-GMP repository: https://github.com/turnstep/Math-GMP.git version: '2.24' x_generated_by_perl: v5.32.1 x_serialization_backend: 'YAML::Tiny version 1.73' x_spdx_expression: LGPL-2.1 MANIFEST100644000764000764 71414145117655 14455 0ustar00shlomifshlomif000000000000Math-GMP-2.24# This file was automatically generated by Dist::Zilla::Plugin::Manifest v6.024. COPYING.LIB Changes GMP.xs INSTALL LICENSE MANIFEST META.json META.yml Makefile.PL README.md dist.ini lib/Math/GMP.pm t/00-compile.t t/01_gmppm.t t/02_init_from_float.t t/check-funcs-ret-value--rt92593.t t/test-use-constant.t typemap weaver.ini xt/99_spellcheck.t xt/99_yaml.t xt/author/pod-coverage.t xt/author/pod-syntax.t xt/release/cpan-changes.t xt/release/trailing-space.t README.md100644000764000764 156114145117655 14624 0ustar00shlomifshlomif000000000000Math-GMP-2.24# NAME Math::GMP - High speed arbitrary size integer math # SYNOPSIS ```perl use Math::GMP; my $n = Math::GMP->new('2'); $n = $n ** (256*1024); $n = $n - 1; print "n is now $n\n"; ``` # DESCRIPTION Math::GMP gives you access to the fast GMP library for fast big integer math. # AUTHOR Chip Turner , based on Math::BigInt by Mark Biggar and Ilya Zakharevich. Further extensive work provided by Tels . Later non-extensive work by Greg Sabino Mullane. Later work by [Shlomi Fish](https://www.shlomifish.org/) while putting his changes under CC0. # DEVELOPMENT * [GitHub Repository](https://github.com/turnstep/Math-GMP) * [rt.cpan](https://rt.cpan.org/Dist/Display.html?Name=Math-GMP) See [dzil / Dist-Zilla](http://dzil.org/) (also https://metacpan.org/pod/Dist::Zilla ) for how to build from the `dist.ini`-based repository sources. META.json100644000764000764 435114145117655 14766 0ustar00shlomifshlomif000000000000Math-GMP-2.24{ "abstract" : "High speed arbitrary size integer math", "author" : [ "Shlomi Fish " ], "dynamic_config" : 0, "generated_by" : "Dist::Zilla version 6.024, CPAN::Meta::Converter version 2.150010", "license" : [ "lgpl_2_1" ], "meta-spec" : { "url" : "http://search.cpan.org/perldoc?CPAN::Meta::Spec", "version" : 2 }, "name" : "Math-GMP", "prereqs" : { "configure" : { "requires" : { "Alien::GMP" : "1.08", "ExtUtils::MakeMaker" : "0" } }, "develop" : { "requires" : { "File::Comments" : "0", "Pod::Coverage::TrustPod" : "0", "Pod::Spell" : "0", "Test::CPAN::Changes" : "0.19", "Test::More" : "0.96", "Test::Pod" : "1.41", "Test::Pod::Coverage" : "1.08", "Test::TrailingSpace" : "0.0203", "Test::YAML::Meta" : "0", "Text::SpellChecker" : "0" } }, "runtime" : { "requires" : { "AutoLoader" : "0", "Carp" : "0", "DynaLoader" : "0", "Exporter" : "0", "overload" : "0", "perl" : "5.010", "strict" : "0", "vars" : "0", "warnings" : "0" } }, "test" : { "requires" : { "Data::Dumper" : "0", "File::Spec" : "0", "File::Temp" : "0", "IO::Handle" : "0", "IPC::Open3" : "0", "Test::More" : "0" } } }, "provides" : { "Math::GMP" : { "file" : "lib/Math/GMP.pm", "version" : "2.24" } }, "release_status" : "stable", "resources" : { "bugtracker" : { "mailto" : "bug-math-gmp@rt.cpan.org", "web" : "https://rt.cpan.org/Public/Dist/Display.html?Name=Math-GMP" }, "repository" : { "type" : "git", "url" : "https://github.com/turnstep/Math-GMP.git", "web" : "https://github.com/turnstep/Math-GMP" } }, "version" : "2.24", "x_generated_by_perl" : "v5.32.1", "x_serialization_backend" : "Cpanel::JSON::XS version 4.25", "x_spdx_expression" : "LGPL-2.1" } weaver.ini100644000764000764 66514145117655 15323 0ustar00shlomifshlomif000000000000Math-GMP-2.24[@CorePrep] [-SingleEncoding] [Generic / NAME] [Version] [Region / prelude] [Generic / SYNOPSIS] [Generic / DESCRIPTION] [Generic / OVERVIEW] [Collect / ATTRIBUTES] command = attr [Collect / METHODS] command = method [Leftovers] [Region / postlude] [Authors] [Legal] ; [Generic / DESCRIPTION] ; required = 1 ; [Generic / BUGS] ; [Generic / Section::Bugs] ; [Generic / Section::License] ; [Bugs] [Support] all_modules = 1 COPYING.LIB100644000764000764 6127114145117655 15031 0ustar00shlomifshlomif000000000000Math-GMP-2.24 GNU LIBRARY GENERAL PUBLIC LICENSE Version 2, June 1991 Copyright (C) 1991 Free Software Foundation, Inc. 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. [This is the first released version of the library GPL. It is numbered 2 because it goes with version 2 of the ordinary GPL.] Preamble The licenses for most software are designed to take away your freedom to share and change it. By contrast, the GNU General Public Licenses are intended to guarantee your freedom to share and change free software--to make sure the software is free for all its users. This license, the Library General Public License, applies to some specially designated Free Software Foundation software, and to any other libraries whose authors decide to use it. You can use it for your libraries, too. When we speak of free software, we are referring to freedom, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for this service if you wish), that you receive source code or can get it if you want it, that you can change the software or use pieces of it in new free programs; and that you know you can do these things. To protect your rights, we need to make restrictions that forbid anyone to deny you these rights or to ask you to surrender the rights. These restrictions translate to certain responsibilities for you if you distribute copies of the library, or if you modify it. For example, if you distribute copies of the library, whether gratis or for a fee, you must give the recipients all the rights that we gave you. You must make sure that they, too, receive or can get the source code. If you link a program with the library, you must provide complete object files to the recipients so that they can relink them with the library, after making changes to the library and recompiling it. And you must show them these terms so they know their rights. Our method of protecting your rights has two steps: (1) copyright the library, and (2) offer you this license which gives you legal permission to copy, distribute and/or modify the library. Also, for each distributor's protection, we want to make certain that everyone understands that there is no warranty for this free library. If the library is modified by someone else and passed on, we want its recipients to know that what they have is not the original version, so that any problems introduced by others will not reflect on the original authors' reputations. Finally, any free program is threatened constantly by software patents. We wish to avoid the danger that companies distributing free software will individually obtain patent licenses, thus in effect transforming the program into proprietary software. To prevent this, we have made it clear that any patent must be licensed for everyone's free use or not licensed at all. Most GNU software, including some libraries, is covered by the ordinary GNU General Public License, which was designed for utility programs. This license, the GNU Library General Public License, applies to certain designated libraries. This license is quite different from the ordinary one; be sure to read it in full, and don't assume that anything in it is the same as in the ordinary license. The reason we have a separate public license for some libraries is that they blur the distinction we usually make between modifying or adding to a program and simply using it. Linking a program with a library, without changing the library, is in some sense simply using the library, and is analogous to running a utility program or application program. However, in a textual and legal sense, the linked executable is a combined work, a derivative of the original library, and the ordinary General Public License treats it as such. Because of this blurred distinction, using the ordinary General Public License for libraries did not effectively promote software sharing, because most developers did not use the libraries. We concluded that weaker conditions might promote sharing better. However, unrestricted linking of non-free programs would deprive the users of those programs of all benefit from the free status of the libraries themselves. This Library General Public License is intended to permit developers of non-free programs to use free libraries, while preserving your freedom as a user of such programs to change the free libraries that are incorporated in them. (We have not seen how to achieve this as regards changes in header files, but we have achieved it as regards changes in the actual functions of the Library.) The hope is that this will lead to faster development of free libraries. The precise terms and conditions for copying, distribution and modification follow. Pay close attention to the difference between a "work based on the library" and a "work that uses the library". The former contains code derived from the library, while the latter only works together with the library. Note that it is possible for a library to be covered by the ordinary General Public License rather than by this special one. GNU LIBRARY GENERAL PUBLIC LICENSE TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 0. This License Agreement applies to any software library which contains a notice placed by the copyright holder or other authorized party saying it may be distributed under the terms of this Library General Public License (also called "this License"). Each licensee is addressed as "you". A "library" means a collection of software functions and/or data prepared so as to be conveniently linked with application programs (which use some of those functions and data) to form executables. The "Library", below, refers to any such software library or work which has been distributed under these terms. A "work based on the Library" means either the Library or any derivative work under copyright law: that is to say, a work containing the Library or a portion of it, either verbatim or with modifications and/or translated straightforwardly into another language. (Hereinafter, translation is included without limitation in the term "modification".) "Source code" for a work means the preferred form of the work for making modifications to it. For a library, complete source code means all the source code for all modules it contains, plus any associated interface definition files, plus the scripts used to control compilation and installation of the library. Activities other than copying, distribution and modification are not covered by this License; they are outside its scope. The act of running a program using the Library is not restricted, and output from such a program is covered only if its contents constitute a work based on the Library (independent of the use of the Library in a tool for writing it). Whether that is true depends on what the Library does and what the program that uses the Library does. 1. You may copy and distribute verbatim copies of the Library's complete source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice and disclaimer of warranty; keep intact all the notices that refer to this License and to the absence of any warranty; and distribute a copy of this License along with the Library. You may charge a fee for the physical act of transferring a copy, and you may at your option offer warranty protection in exchange for a fee. 2. You may modify your copy or copies of the Library or any portion of it, thus forming a work based on the Library, and copy and distribute such modifications or work under the terms of Section 1 above, provided that you also meet all of these conditions: a) The modified work must itself be a software library. b) You must cause the files modified to carry prominent notices stating that you changed the files and the date of any change. c) You must cause the whole of the work to be licensed at no charge to all third parties under the terms of this License. d) If a facility in the modified Library refers to a function or a table of data to be supplied by an application program that uses the facility, other than as an argument passed when the facility is invoked, then you must make a good faith effort to ensure that, in the event an application does not supply such function or table, the facility still operates, and performs whatever part of its purpose remains meaningful. (For example, a function in a library to compute square roots has a purpose that is entirely well-defined independent of the application. Therefore, Subsection 2d requires that any application-supplied function or table used by this function must be optional: if the application does not supply it, the square root function must still compute square roots.) These requirements apply to the modified work as a whole. If identifiable sections of that work are not derived from the Library, and can be reasonably considered independent and separate works in themselves, then this License, and its terms, do not apply to those sections when you distribute them as separate works. But when you distribute the same sections as part of a whole which is a work based on the Library, the distribution of the whole must be on the terms of this License, whose permissions for other licensees extend to the entire whole, and thus to each and every part regardless of who wrote it. Thus, it is not the intent of this section to claim rights or contest your rights to work written entirely by you; rather, the intent is to exercise the right to control the distribution of derivative or collective works based on the Library. In addition, mere aggregation of another work not based on the Library with the Library (or with a work based on the Library) on a volume of a storage or distribution medium does not bring the other work under the scope of this License. 3. You may opt to apply the terms of the ordinary GNU General Public License instead of this License to a given copy of the Library. To do this, you must alter all the notices that refer to this License, so that they refer to the ordinary GNU General Public License, version 2, instead of to this License. (If a newer version than version 2 of the ordinary GNU General Public License has appeared, then you can specify that version instead if you wish.) Do not make any other change in these notices. Once this change is made in a given copy, it is irreversible for that copy, so the ordinary GNU General Public License applies to all subsequent copies and derivative works made from that copy. This option is useful when you wish to copy part of the code of the Library into a program that is not a library. 4. You may copy and distribute the Library (or a portion or derivative of it, under Section 2) in object code or executable form under the terms of Sections 1 and 2 above provided that you accompany it with the complete corresponding machine-readable source code, which must be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange. If distribution of object code is made by offering access to copy from a designated place, then offering equivalent access to copy the source code from the same place satisfies the requirement to distribute the source code, even though third parties are not compelled to copy the source along with the object code. 5. A program that contains no derivative of any portion of the Library, but is designed to work with the Library by being compiled or linked with it, is called a "work that uses the Library". Such a work, in isolation, is not a derivative work of the Library, and therefore falls outside the scope of this License. However, linking a "work that uses the Library" with the Library creates an executable that is a derivative of the Library (because it contains portions of the Library), rather than a "work that uses the library". The executable is therefore covered by this License. Section 6 states terms for distribution of such executables. When a "work that uses the Library" uses material from a header file that is part of the Library, the object code for the work may be a derivative work of the Library even though the source code is not. Whether this is true is especially significant if the work can be linked without the Library, or if the work is itself a library. The threshold for this to be true is not precisely defined by law. If such an object file uses only numerical parameters, data structure layouts and accessors, and small macros and small inline functions (ten lines or less in length), then the use of the object file is unrestricted, regardless of whether it is legally a derivative work. (Executables containing this object code plus portions of the Library will still fall under Section 6.) Otherwise, if the work is a derivative of the Library, you may distribute the object code for the work under the terms of Section 6. Any executables containing that work also fall under Section 6, whether or not they are linked directly with the Library itself. 6. As an exception to the Sections above, you may also compile or link a "work that uses the Library" with the Library to produce a work containing portions of the Library, and distribute that work under terms of your choice, provided that the terms permit modification of the work for the customer's own use and reverse engineering for debugging such modifications. You must give prominent notice with each copy of the work that the Library is used in it and that the Library and its use are covered by this License. You must supply a copy of this License. If the work during execution displays copyright notices, you must include the copyright notice for the Library among them, as well as a reference directing the user to the copy of this License. Also, you must do one of these things: a) Accompany the work with the complete corresponding machine-readable source code for the Library including whatever changes were used in the work (which must be distributed under Sections 1 and 2 above); and, if the work is an executable linked with the Library, with the complete machine-readable "work that uses the Library", as object code and/or source code, so that the user can modify the Library and then relink to produce a modified executable containing the modified Library. (It is understood that the user who changes the contents of definitions files in the Library will not necessarily be able to recompile the application to use the modified definitions.) b) Accompany the work with a written offer, valid for at least three years, to give the same user the materials specified in Subsection 6a, above, for a charge no more than the cost of performing this distribution. c) If distribution of the work is made by offering access to copy from a designated place, offer equivalent access to copy the above specified materials from the same place. d) Verify that the user has already received a copy of these materials or that you have already sent this user a copy. For an executable, the required form of the "work that uses the Library" must include any data and utility programs needed for reproducing the executable from it. However, as a special exception, the source code distributed need not include anything that is normally distributed (in either source or binary form) with the major components (compiler, kernel, and so on) of the operating system on which the executable runs, unless that component itself accompanies the executable. It may happen that this requirement contradicts the license restrictions of other proprietary libraries that do not normally accompany the operating system. Such a contradiction means you cannot use both them and the Library together in an executable that you distribute. 7. You may place library facilities that are a work based on the Library side-by-side in a single library together with other library facilities not covered by this License, and distribute such a combined library, provided that the separate distribution of the work based on the Library and of the other library facilities is otherwise permitted, and provided that you do these two things: a) Accompany the combined library with a copy of the same work based on the Library, uncombined with any other library facilities. This must be distributed under the terms of the Sections above. b) Give prominent notice with the combined library of the fact that part of it is a work based on the Library, and explaining where to find the accompanying uncombined form of the same work. 8. You may not copy, modify, sublicense, link with, or distribute the Library except as expressly provided under this License. Any attempt otherwise to copy, modify, sublicense, link with, or distribute the Library is void, and will automatically terminate your rights under this License. However, parties who have received copies, or rights, from you under this License will not have their licenses terminated so long as such parties remain in full compliance. 9. You are not required to accept this License, since you have not signed it. However, nothing else grants you permission to modify or distribute the Library or its derivative works. These actions are prohibited by law if you do not accept this License. Therefore, by modifying or distributing the Library (or any work based on the Library), you indicate your acceptance of this License to do so, and all its terms and conditions for copying, distributing or modifying the Library or works based on it. 10. Each time you redistribute the Library (or any work based on the Library), the recipient automatically receives a license from the original licensor to copy, distribute, link with or modify the Library subject to these terms and conditions. You may not impose any further restrictions on the recipients' exercise of the rights granted herein. You are not responsible for enforcing compliance by third parties to this License. 11. If, as a consequence of a court judgment or allegation of patent infringement or for any other reason (not limited to patent issues), conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot distribute so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not distribute the Library at all. For example, if a patent license would not permit royalty-free redistribution of the Library by all those who receive copies directly or indirectly through you, then the only way you could satisfy both it and this License would be to refrain entirely from distribution of the Library. If any portion of this section is held invalid or unenforceable under any particular circumstance, the balance of the section is intended to apply, and the section as a whole is intended to apply in other circumstances. It is not the purpose of this section to induce you to infringe any patents or other property right claims or to contest validity of any such claims; this section has the sole purpose of protecting the integrity of the free software distribution system which is implemented by public license practices. Many people have made generous contributions to the wide range of software distributed through that system in reliance on consistent application of that system; it is up to the author/donor to decide if he or she is willing to distribute software through any other system and a licensee cannot impose that choice. This section is intended to make thoroughly clear what is believed to be a consequence of the rest of this License. 12. If the distribution and/or use of the Library is restricted in certain countries either by patents or by copyrighted interfaces, the original copyright holder who places the Library under this License may add an explicit geographical distribution limitation excluding those countries, so that distribution is permitted only in or among countries not thus excluded. In such case, this License incorporates the limitation as if written in the body of this License. 13. The Free Software Foundation may publish revised and/or new versions of the Library General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. Each version is given a distinguishing version number. If the Library specifies a version number of this License which applies to it and "any later version", you have the option of following the terms and conditions either of that version or of any later version published by the Free Software Foundation. If the Library does not specify a license version number, you may choose any version ever published by the Free Software Foundation. 14. If you wish to incorporate parts of the Library into other free programs whose distribution conditions are incompatible with these, write to the author to ask for permission. For software which is copyrighted by the Free Software Foundation, write to the Free Software Foundation; we sometimes make exceptions for this. Our decision will be guided by the two goals of preserving the free status of all derivatives of our free software and of promoting the sharing and reuse of software generally. NO WARRANTY 15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. END OF TERMS AND CONDITIONS How to Apply These Terms to Your New Libraries If you develop a new library, and you want it to be of the greatest possible use to the public, we recommend making it free software that everyone can redistribute and change. You can do so by permitting redistribution under these terms (or, alternatively, under the terms of the ordinary General Public License). To apply these terms, attach the following notices to the library. It is safest to attach them to the start of each source file to most effectively convey the exclusion of warranty; and each file should have at least the "copyright" line and a pointer to where the full notice is found. Copyright (C) This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more details. You should have received a copy of the GNU Library General Public License along with this library; if not, write to the Free Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA Also add information on how to contact you by electronic and paper mail. You should also get your employer (if you work as a programmer) or your school, if any, to sign a "copyright disclaimer" for the library, if necessary. Here is a sample; alter the names: Yoyodyne, Inc., hereby disclaims all copyright interest in the library `Frob' (a library for tweaking knobs) written by James Random Hacker. , 1 April 1990 Ty Coon, President of Vice That's all there is to it! Makefile.PL100644000764000764 334514145117655 15321 0ustar00shlomifshlomif000000000000Math-GMP-2.24# This Makefile.PL for Math-GMP was generated by # Dist::Zilla::Plugin::MakeMaker::Awesome 0.49. # Don't edit it but the dist.ini and plugins used to construct it. use strict; use warnings; use 5.010; use ExtUtils::MakeMaker; use Alien::Base::Wrapper qw( Alien::GMP !export ); my %WriteMakefileArgs = ( "ABSTRACT" => "High speed arbitrary size integer math", "AUTHOR" => "Shlomi Fish ", "CONFIGURE_REQUIRES" => { "Alien::GMP" => "1.08", "ExtUtils::MakeMaker" => 0 }, "DISTNAME" => "Math-GMP", "LICENSE" => "lgpl", "MIN_PERL_VERSION" => "5.010", "NAME" => "Math::GMP", "PREREQ_PM" => { "AutoLoader" => 0, "Carp" => 0, "DynaLoader" => 0, "Exporter" => 0, "overload" => 0, "strict" => 0, "vars" => 0, "warnings" => 0 }, "TEST_REQUIRES" => { "Data::Dumper" => 0, "File::Spec" => 0, "File::Temp" => 0, "IO::Handle" => 0, "IPC::Open3" => 0, "Test::More" => 0 }, "VERSION" => "2.24", "test" => { "TESTS" => "t/*.t" } ); %WriteMakefileArgs = ( %WriteMakefileArgs, Alien::Base::Wrapper->mm_args, ); my %FallbackPrereqs = ( "AutoLoader" => 0, "Carp" => 0, "Data::Dumper" => 0, "DynaLoader" => 0, "Exporter" => 0, "File::Spec" => 0, "File::Temp" => 0, "IO::Handle" => 0, "IPC::Open3" => 0, "Test::More" => 0, "overload" => 0, "strict" => 0, "vars" => 0, "warnings" => 0 ); unless ( eval { ExtUtils::MakeMaker->VERSION('6.63_03') } ) { delete $WriteMakefileArgs{TEST_REQUIRES}; delete $WriteMakefileArgs{BUILD_REQUIRES}; $WriteMakefileArgs{PREREQ_PM} = \%FallbackPrereqs; } delete $WriteMakefileArgs{CONFIGURE_REQUIRES} unless eval { ExtUtils::MakeMaker->VERSION(6.52) }; WriteMakefile(%WriteMakefileArgs); xt000755000764000764 014145117655 13635 5ustar00shlomifshlomif000000000000Math-GMP-2.2499_yaml.t100644000764000764 124314145117655 15445 0ustar00shlomifshlomif000000000000Math-GMP-2.24/xt#!perl ## Test META.yml for YAMLiciousness, requires Test::YAML::Meta use 5.006; use strict; use warnings; use Test::More; select(($|=1,select(STDERR),$|=1)[1]); if (! $ENV{RELEASE_TESTING}) { plan (skip_all => 'Test skipped unless environment variable RELEASE_TESTING is set'); } plan tests => 2; my $V = 0.03; eval { require Test::YAML::Meta; Test::YAML::Meta->import; }; if ($@) { SKIP: { skip ('Skipping Test::YAML::Meta tests: module not found', 2); } } elsif ($Test::YAML::Meta::VERSION < $V) { SKIP: { skip ("Skipping Test::YAML::Meta tests: need version $V, but only have $Test::YAML::Meta::VERSION", 2); } } else { meta_spec_ok ('META.yml', 1.4); } t000755000764000764 014145117655 13445 5ustar00shlomifshlomif000000000000Math-GMP-2.2401_gmppm.t100644000764000764 3724214145117655 15442 0ustar00shlomifshlomif000000000000Math-GMP-2.24/t#!perl use strict; use warnings; use Data::Dumper; use Math::GMP; use Test::More; use Config; my ($f); my @data = ; my @tests = grep { ! /\A&/ } @data; plan tests => (2 * @tests + 10); my $WITH_FEATURE = ("$]" >= 5.022); LINES: foreach my $line (@data) { chomp $line; if ($line =~ s/\A&//) { $f = $line; next LINES; } my @args = split(/:/,$line,99); my $ans = pop(@args); my $expect_list = 0; my $ans_any = ($ans =~ s/\AANY//); if ($ans_any) { $ans = [ split /,/, $ans ]; } elsif ($ans =~ s/\AL//) { $ans = [ split /,/, $ans ]; $expect_list = 1; } my $first_arg = $args[0]; my $try = ( ( $first_arg =~ /\Ai([-+]?[0-9]+)\z/ ) ? "\$x = $1;" : ( $first_arg =~ /\Ab([-+]?.+),([0-9]+)\z/ ) ? qq#\$x = Math::GMP->new("$1", $2);# : qq#\$x = Math::GMP->new("$first_arg");# ); if ($f eq 'bnorm') { $try .= '$x+0;'; } elsif ($f eq 'fibonacci') { $try .= 'Math::GMP::fibonacci($x);'; } elsif ($f eq 'bfac') { $try .= '$x->bfac();'; } elsif ($f eq 'bneg') { $try .= '-$x;'; } elsif ($f eq 'babs') { $try .= 'abs $x;'; } elsif ($f eq 'square_root') { $try .= 'Math::GMP::bsqrt($x);'; } elsif ($f eq 'square_rootrem') { $try .= '[ Math::GMP::bsqrtrem($x) ];'; } elsif ($f eq 'perfect_power') { $try .= '$x->is_perfect_power'; } elsif ($f eq 'perfect_square') { $try .= '$x->is_perfect_square'; } elsif ($f eq 'uintify') { $try .= 'Math::GMP::uintify($x);'; $ans = pop(@args) if ($Config{longsize} == 4 && scalar @args > 1); } elsif ($f eq 'intify') { $try .= 'Math::GMP::intify($x);'; $ans = pop(@args) if ($Config{longsize} == 4 && scalar @args > 1); } elsif ($f eq 'probab_prime') { my $rets = $args[1]; $try .= "Math::GMP::probab_prime(\$x,$rets);"; } elsif ($f eq 'new_from_base') { $try .= '$x;'; } else { if ( $args[1] =~ /\Ai([-+]?[0-9]+)\z/ ) { $try .= "\$y = $1;"; } elsif ( $args[1] =~ /\Af([-+]?[0-9.]+)\z/ ) { $try .= "\$y = $1;"; } else { $try .= qq#\$y = Math::GMP->new("$args[1]");#; } if ($f eq 'bcmp') { $try .= '$x <=> $y;'; } elsif ($f eq 'band') { $try .= '$x & $y;'; } elsif ($f eq 'bxor') { $try .= '$x ^ $y;'; } elsif ($f eq 'bior') { $try .= '$x | $y;'; } elsif ($f eq 'blshift') { $try .= '$x << $y;'; } elsif ($f eq 'brshift') { $try .= '$x >> $y;'; } elsif ($f eq 'badd') { $try .= '$x + $y;'; } elsif ($f eq 'bsub') { $try .= '$x - $y;'; } elsif ($f eq 'bmul') { $try .= '$x * $y;'; } elsif ($f eq 'bmulf') { $try .= 'Math::GMP::bmulf($x,$y)'; } elsif ($f eq 'bdiv') { $try .= '$x / $y;'; } elsif ($f eq 'bmod') { $try .= '$x % $y;'; } elsif ($f eq 'bdiv2a') { $try .= '((Math::GMP::bdiv($x, $y))[0]);'; } elsif ($f eq 'bdiv2b') { $try .= '((Math::GMP::bdiv($x, $y))[1]);'; } elsif ($f eq 'bgcd') { $try .= 'Math::GMP::bgcd($x, $y);'; } elsif ($f eq 'gcd') { $try .= 'Math::GMP::gcd($x, $y);'; } elsif ($f eq 'blcm') { $try .= 'Math::GMP::blcm($x, $y);'; } elsif ($f eq 'bmodinv') { $try .= 'Math::GMP::bmodinv($x, $y);'; } elsif ($f eq 'bnok') { $try .= 'Math::GMP::bnok($x, $y);'; } elsif ($f eq 'sizeinbase') { $try .= 'Math::GMP::sizeinbase_gmp($x, $y);'; } elsif ($f eq 'add_ui') { $try .= 'Math::GMP::add_ui_gmp($x, $y); $x'; } elsif ($f eq 'mul_2exp') { $try .= 'Math::GMP::mul_2exp_gmp($x, $y);'; } elsif ($f eq 'div_2exp') { $try .= 'Math::GMP::div_2exp_gmp($x, $y);'; } elsif ($f eq 'mmod') { $try .= 'Math::GMP::mmod_gmp($x, $y);'; } elsif ($f eq 'mod_2exp') { $try .= 'Math::GMP::mod_2exp_gmp($x, $y);'; } elsif ($f eq 'legendre') { $try .= 'Math::GMP::legendre($x, $y);'; } elsif ($f eq 'jacobi') { $try .= 'Math::GMP::jacobi($x, $y);'; } elsif ($f eq 'test_bit') { $try .= 'Math::GMP::gmp_tstbit($x, $y);'; } elsif ($f eq 'root') { $try .= '$x->broot($y)'; } elsif ($f eq 'rootrem') { $try .= '[ $x->brootrem($y) ]'; } else { if ( $args[2] =~ /\Ai([-+]?[0-9]+)\z/ ) { $try .= "\$z = $1;"; } else { $try .= qq#\$z = Math::GMP->new("$args[2]");#; } if ($f eq 'powm') { $try .= 'Math::GMP::powm_gmp($x, $y, $z);'; } else { warn 'Unknown op'; } } } my ($x,$y,$z); my $got = eval $try; my $test_sub = sub { my $desc = shift; my $blurb = "Test worked ${desc}: $try"; if ($ans_any) { ok(scalar(1 == scalar(grep { $_ eq $got } @$ans)), $blurb); } elsif ($expect_list) { is_deeply($got, $ans, $blurb); } else { is("$got", $ans, $blurb); } }; $test_sub->(""); if ($WITH_FEATURE) { $got = eval "use feature 'bitwise'; no warnings 'experimental::bitwise'; $try"; $test_sub->("[feature bitwise]"); } else { pass("skipped due to feature"); } } # Test of bfac as described in the pod { my $x = Math::GMP->new(5); my $val = $x->bfac(); is(int $val, 120, 'gfac gives expected result'); } # some assorted tests for internal functions { my $x = Math::GMP->new('123'); my $y = Math::GMP::gmp_copy($x); is (ref($y),ref($x), 'refs are the same'); is ("$y",'123', 'gmp_copy gives correct value'); } { # boolean check should not fall back to truncating intify my $s = '1' . ('0' x 70); my $i1 = Math::GMP->new($s); is ($s, "$i1", 'new 1e70 from string is preserved'); my $bool = $i1 ? 1 : 0; is ($bool, 1, '1e70 is boolean TRUE'); my $i2 = Math::GMP->new($i1); # has internal boolean check is ($s, "$i2", 'new 1e70 from object is preserved'); } { # Test of blshift as described in the POD. my $x = Math::GMP->new('2'); my $result = $x->blshift(4, 0); is ("$x", '2', 'x stays the same.'); is ("$result", '32', 'Result is 2 << 4'); } { # Test of brshift as described in the POD. my $x = Math::GMP->new('5'); my $result = $x->brshift(1, 0); is ("$x", '5', 'x stays the same.'); is ("$result", '2', 'Result is 2 << 4'); } # all done __END__ &bcmp +0:0:0 -1:0:-1 +0:-1:1 +1:0:1 +0:1:-1 -1:1:-1 +1:-1:1 -1:-1:0 +1:1:0 +123:123:0 +123:12:1 +12:123:-1 -123:-123:0 -123:-12:-1 -12:-123:1 +123:124:-1 +124:123:1 -123:-124:1 -124:-123:-1 +100:5:1 i+100:5:1 +100:i5:1 i-10:-10:0 &badd +0:0:0 +1:0:1 +0:1:1 +1:1:2 -1:0:-1 +0:-1:-1 -1:-1:-2 -1:1:0 +1:-1:0 +9:1:10 +99:1:100 +999:1:1000 +9999:1:10000 +99999:1:100000 +999999:1:1000000 +9999999:1:10000000 i+9999999:1:10000000 +99999999:1:100000000 +999999999:1:1000000000 +9999999999:1:10000000000 +99999999999:1:100000000000 +99999999999:i1:100000000000 +10:-1:9 +100:-1:99 +1000:-1:999 +10000:-1:9999 +100000:-1:99999 +1000000:-1:999999 +10000000:-1:9999999 +100000000:-1:99999999 +1000000000:-1:999999999 +10000000000:-1:9999999999 +123456789:987654321:1111111110 -123456789:987654321:864197532 -123456789:-987654321:-1111111110 +123456789:-987654321:-864197532 &bsub +0:0:0 +1:0:1 +0:1:-1 +1:1:0 -1:0:-1 +0:-1:1 -1:-1:0 -1:1:-2 +1:-1:2 +9:1:8 +99:1:98 +999:1:998 +9999:1:9998 +99999:1:99998 +999999:1:999998 +9999999:1:9999998 +99999999:1:99999998 +999999999:1:999999998 +9999999999:1:9999999998 +99999999999:1:99999999998 +99999999999:i1:99999999998 +10:-1:11 +100:-1:101 +1000:-1:1001 +10000:-1:10001 +100000:-1:100001 +1000000:-1:1000001 +10000000:-1:10000001 +100000000:-1:100000001 +1000000000:-1:1000000001 +10000000000:-1:10000000001 +123456789:987654321:-864197532 -123456789:987654321:-1111111110 -123456789:-987654321:864197532 +123456789:-987654321:1111111110 i4:12345678987:-12345678983 &bmul +0:0:0 +0:1:0 +1:0:0 +0:-1:0 -1:0:0 +123456789123456789:0:0 +0:123456789123456789:0 -1:-1:1 -1:1:-1 +1:-1:-1 +1:1:1 +2:3:6 -2:3:-6 +2:-3:-6 -2:-3:6 +111:111:12321 +10101:10101:102030201 +1001001:1001001:1002003002001 +100010001:100010001:10002000300020001 +10000100001:10000100001:100002000030000200001 +11111111111:9:99999999999 +11111111111:i9:99999999999 i9:+11111111111:99999999999 +22222222222:9:199999999998 +33333333333:9:299999999997 +44444444444:9:399999999996 +55555555555:9:499999999995 +66666666666:9:599999999994 +77777777777:9:699999999993 +88888888888:9:799999999992 +99999999999:9:899999999991 &bmulf +0:f0.0:0 +0:f1.0:0 +1:f0.0:0 +0:f-1.0:0 -1:f0.0:0 +123456789123456789:f0.0:0 +0:f123456789123456789.0:0 -1:f-1.0:1 -1:f1.0:-1 +1:f-1.0:-1 +1:f1.0:1 +2:f3.0:6 -2:f3.0:-6 +2:f-3.0:-6 -2:f-3.0:6 +1:f+1.5:1 -1:f+1.5:-1 +1:f-1.5:-1 -1:f-1.0:1 +100000000000000000001:f+1.5:150000000000000000001 -100000000000000000001:f+1.5:-150000000000000000001 +100000000000000000001:f-1.5:-150000000000000000001 -100000000000000000001:f-1.5:150000000000000000001 &bdiv2a +0:1:0 +0:-1:0 +1:1:1 -1:-1:1 +1:-1:-1 -1:1:-1 +1:2:0 +2:1:2 +1000000000:9:111111111 +1000000000:i9:111111111 +2000000000:9:222222222 +3000000000:9:333333333 +4000000000:9:444444444 +5000000000:9:555555555 +6000000000:9:666666666 +7000000000:9:777777777 +8000000000:9:888888888 +9000000000:9:1000000000 +35500000:113:314159 +71000000:226:314159 +106500000:339:314159 +1000000000:3:333333333 +10:5:2 +100:4:25 +1000:8:125 +10000:16:625 i+10000:16:625 +999999999999:9:111111111111 +999999999999:99:10101010101 +999999999999:999:1001001001 +999999999999:9999:100010001 +999999999999999:99999:10000100001 &bdiv +0:1:0 +0:-1:0 +1:1:1 -1:-1:1 +1:-1:-1 -1:1:-1 +1:2:0 +2:1:2 +1000000000:9:111111111 +1000000000:i9:111111111 +2000000000:9:222222222 +3000000000:9:333333333 +4000000000:9:444444444 +5000000000:9:555555555 +6000000000:9:666666666 +7000000000:9:777777777 +8000000000:9:888888888 +9000000000:9:1000000000 +35500000:113:314159 +71000000:226:314159 +106500000:339:314159 +1000000000:3:333333333 +10:5:2 +100:4:25 +1000:8:125 +10000:16:625 i+10000:16:625 +999999999999:9:111111111111 +999999999999:99:10101010101 +999999999999:999:1001001001 +999999999999:9999:100010001 +999999999999999:99999:10000100001 &bdiv2b +0:1:0 +0:-1:0 +1:1:0 -1:-1:0 +1:-1:0 -1:1:0 +1:2:1 +2:1:0 +1000000000:9:1 +1000000000:i9:1 +2000000000:9:2 +3000000000:9:3 +4000000000:9:4 +5000000000:9:5 +6000000000:9:6 +7000000000:9:7 +8000000000:9:8 +9000000000:9:0 +35500000:113:33 i+35500000:113:33 +71000000:226:66 +106500000:339:99 +1000000000:3:1 +10:5:0 +100:4:0 +1000:8:0 +10000:16:0 +999999999999:9:0 +999999999999:99:0 +999999999999:999:0 +999999999999:9999:0 +999999999999999:99999:0 &bmod +0:1:0 +0:-1:0 +1:1:0 -1:-1:0 +1:-1:0 -1:1:0 +1:2:1 +2:1:0 +1000000000:9:1 +1000000000:i9:1 +2000000000:9:2 +3000000000:9:3 +4000000000:9:4 +5000000000:9:5 +6000000000:9:6 +7000000000:9:7 +8000000000:9:8 +9000000000:9:0 +35500000:113:33 i+35500000:113:33 +71000000:226:66 +106500000:339:99 +1000000000:3:1 +10:5:0 +100:4:0 +1000:8:0 +10000:16:0 +999999999999:9:0 +999999999999:99:0 +999999999999:999:0 +999999999999:9999:0 +999999999999999:99999:0 &bgcd +0:0:0 +0:1:1 +1:0:1 +1:1:1 +2:3:1 +3:2:1 +100:625:25 +4096:81:1 &gcd +0:0:0 +0:1:1 +1:0:1 +1:1:1 +2:3:1 +3:2:1 +100:625:25 +4096:81:1 &blcm +0:0:0 +0:1:0 +1:0:0 +1:1:1 +2:3:6 +3:2:6 +100:625:2500 +75600:5402250:129654000 &bmodinv +0:1:0 +1:1:0 +2:3:2 +5:7:3 +999:1000:999 &new_from_base 0xff:255 0x2395fa:2332154 babcdefgh,36:808334348993 &sizeinbase +5:i10:1 +9999999999:i16:9 -5000:i2:13 &uintify +15:15 +9999999999:1410065407:9999999999 +99999999999:1215752191:99999999999 +999999999999:3567587327:999999999999 &add_ui +999999:i1:1000000 +9999999:i1:10000000 +99999999:i1:100000000 &intify +999999999:999999999 +9999999999:1410065407:9999999999 &mul_2exp +9999:i9:5119488 +99999:i9:51199488 +0:i1:0 +1:i0:1 &div_2exp +999999:i1111:0 +0:i1:0 &powm +99999:999999:99:27 +1:1:1:0 +1:0:1:0 &mmod +99999:100002:99999 +1:1:0 &mod_2exp +99999999:11111:99999999 +0:1:0 &jacobi +1:15:1 +1:15:1 +2:15:1 +3:15:0 +4:15:1 +5:15:0 +6:15:0 +7:15:-1 +8:15:1 +9:15:0 +10:15:0 +11:15:-1 +12:15:0 +13:15:-1 +14:15:-1 +15:15:0 &band 7:3:3 2:3:2 4:1:0 &bxor 7:3:4 2:3:1 4:1:5 &bior 7:3:7 2:3:3 4:1:5 &bfac 1:1 2:2 3:6 4:24 5:120 6:720 &fibonacci 2:1 3:2 4:3 5:5 6:8 7:13 8:21 9:34 10:55 &test_bit 10:0:0 1:0:1 3:1:1 3:2:0 &root 16:i2:4 16:i4:2 999:i3:9 -1:i3:-1 -2:i3:-1 &rootrem 16:i2:L4,0 999:i3:L9,270 -2:i3:L-1,-1 &square_root 16:4 1:1 0:0 100:10 101:10 99:9 &square_rootrem 16:L4,0 100:L10,0 101:L10,1 99:L9,18 0:L0,0 &perfect_power 99:0 100:1 101:0 0:1 -27:1 -9:0 &perfect_square 99:0 100:1 101:0 0:1 -27:0 -9:0 &probab_prime 5:10:2 6:10:0 &gcd 0:0:0 1:0:1 9:9:9 17:19:1 54:24:6 42:56:14 9:28:1 48:180:12 i48:i180:12 -30:-90:30 -3:-9:3 i-3:i-9:3 2705353758:2540073744:18 i2705353758:i2540073744:18 12848174105599691600:15386870946739346600:1400 9785375481451202685:17905669244643674637:117 921166566073002915606255698642:1168315374100658224561074758384:14 1214969109355385138343690512057521757303400673155500334102084:1112036111724848964580068879654799564977409491290450115714228:42996 745845206184162095041321:61540282492897317017092677682588744425929751009997907259657808323805386381007:1 &blcm i1:i0:0 i0:i1:0 i17:i19:323 i54:i24:216 i36:i45:180 i-36:i-45:180 i-36:i-45:180 i36:i-45:180 i-36:i45:180 i3219664501:i2880273383:9273513964420276883 9999999998987:10000000001011:99999999999979999998975857 892478777297173184633:892478777297173184633:892478777297173184633 &jacobi i109981:i737777:1 i737779:i121080:-1 i-737779:i121080:1 i737779:i-121080:-1 i-737779:i-121080:-1 i12345:i331:-1 i1001:i9907:-1 i19:i45:1 i8:i21:-1 i5:i21:1 i5:i1237:-1 i10:i49:1 i123:i4567:-1 i3:i18:0 i3:i-18:0 i-2:i0:0 i-1:i0:1 i0:i0:0 i1:i0:1 i2:i0:0 i-2:i1:1 i-1:i1:1 i0:i1:1 i1:i1:1 i2:i1:1 i-2:i-1:-1 i-1:i-1:-1 i0:i-1:1 i1:i-1:1 i2:i-1:1 i3686556869:i428192857:1 i-1453096827:i364435739:-1 i3527710253:i-306243569:1 i-1843526669:i-332265377:1 i321781679:i4095783323:-1 i454249403:i-79475159:-1 17483840153492293897:455592493:1 -1402663995299718225:391125073:1 16715440823750591903:-534621209:-1 13106964391619451641:16744199040925208803:1 11172354269896048081:10442187294190042188:-1 -5694706465843977004:9365273357682496999:-1 878944444444444447324234:216539985579699669610468715172511426009:-1 &probab_prime 3878888047:25:ANY1,2 14811094489161957443:25:1 232959001450513754379792189108873634181:25:1 91824020991616815553147615676933454480045241423098328989602116468298297311309:25:1 8285396061339403252920302070391390891474883409843237347887428315444504156793935159055430946705757466964822392797379161103939327123077267166338215317904079:25:1 777777777777777777777777:25:0 890745785790123461234805903467891234681234:25:0 8041390271962017234692123621666121818392263837471332893549490730885083462618835990190315107479962729421426370683173686420981834217178353304525610906493143:25:0 1498370845232252488162599227507794675135574818583361091623468615853723670176324198216325177:25:0 2887148238050771212671429597130393991977609459279722700926516024197432303799152733116328983144639225941977803110929349655578418949441740933805615113979999421542416933972905423711002751042080134966731755152859226962916775325475044445856101949404200039904432116776619949629539250452698719329070373564032273701278453899126120309244841494728976885406024976768122077071687938121709811322297802059565867:25:0 &blshift 0:0:0 1:0:1 2:640:9124881235244390437282343211400582649786457014497119861158385035798550334417354773011825622634742799557284619147188814621377409442750875996505322639444428376503989348720529900165748384493207552 100:524:5491838128104487771985520639265114573815548240114644327515570767348434546718124841698047712529163643981837049113184686429697590399773315050059222632892045721600 &brshift 0:0:0 1:0:1 9124881235244390437282343211400582649786457014497119861158385035798550334417354773011825622634742799557284619147188814621377409442750875996505322639444428376503989348720529900165748384493207552:640:2 5491838128104487771985520639265114573815548240114644327515570767348434546718124841698047712529163643981837049113184686429697590399773315050059222632892045721600:524:100 50:1:25 3:1:1 &bnok 5:2:10 500:250:116744315788277682920934734762176619659230081180311446124100284957811112673608473715666417775521605376810865902709989580160037468226393900042796872256 67:23:530707489338171600 00-compile.t100644000764000764 274614145117655 15650 0ustar00shlomifshlomif000000000000Math-GMP-2.24/tuse 5.006; use strict; use warnings; # this test was generated with Dist::Zilla::Plugin::Test::Compile 2.058 use Test::More; plan tests => 1 + ($ENV{AUTHOR_TESTING} ? 1 : 0); my @module_files = ( 'Math/GMP.pm' ); # fake home for cpan-testers use File::Temp; local $ENV{HOME} = File::Temp::tempdir( CLEANUP => 1 ); my @switches = ( -d 'blib' ? '-Mblib' : '-Ilib', ); use File::Spec; use IPC::Open3; use IO::Handle; open my $stdin, '<', File::Spec->devnull or die "can't open devnull: $!"; my @warnings; for my $lib (@module_files) { # see L my $stderr = IO::Handle->new; diag('Running: ', join(', ', map { my $str = $_; $str =~ s/'/\\'/g; q{'} . $str . q{'} } $^X, @switches, '-e', "require q[$lib]")) if $ENV{PERL_COMPILE_TEST_DEBUG}; my $pid = open3($stdin, '>&STDERR', $stderr, $^X, @switches, '-e', "require q[$lib]"); binmode $stderr, ':crlf' if $^O eq 'MSWin32'; my @_warnings = <$stderr>; waitpid($pid, 0); is($?, 0, "$lib loaded ok"); shift @_warnings if @_warnings and $_warnings[0] =~ /^Using .*\bblib/ and not eval { +require blib; blib->VERSION('1.01') }; if (@_warnings) { warn @_warnings; push @warnings, @_warnings; } } is(scalar(@warnings), 0, 'no warnings found') or diag 'got warnings: ', ( Test::More->can('explain') ? Test::More::explain(\@warnings) : join("\n", '', @warnings) ) if $ENV{AUTHOR_TESTING}; Math000755000764000764 014145117655 14641 5ustar00shlomifshlomif000000000000Math-GMP-2.24/libGMP.pm100644000764000764 4475414145117655 16020 0ustar00shlomifshlomif000000000000Math-GMP-2.24/lib/Mathpackage Math::GMP; # Math::GMP, a Perl module for high-speed arbitrary size integer # calculations # Copyright (C) 2000-2008 James H. Turner # Copyright (C) 2008-2009 Greg Sabino Mullane # This library is free software; you can redistribute it and/or # modify it under the terms of the GNU Library General Public # License as published by the Free Software Foundation; either # version 2 of the License, or (at your option) any later version. # This library is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU # Library General Public License for more details. # You should have received a copy of the GNU Library General Public # License along with this library; if not, write to the Free # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA # You can contact the author at chip@redhat.com, chipt@cpan.org, or by mail: # Chip Turner # Red Hat Inc. # 2600 Meridian Park Blvd # Durham, NC 27713 use strict; use warnings; use 5.010; use Carp; use vars qw(@ISA @EXPORT @EXPORT_OK $AUTOLOAD); use overload ( '""' => sub { stringify($_[0]) }, '0+' => sub { $_[0] >= 0 ? uintify($_[0]) : intify($_[0]) }, 'bool' => sub { $_[0] != 0 }, '<=>' => \&op_spaceship, '==' => \&op_eq, '+' => \&op_add, '-' => \&op_sub, '&' => \&band, '^' => \&bxor, '|' => \&bior, '<<' => \&blshift, '>>' => \&brshift, '%' => \&op_mod, '**' => sub { $_[2] ? op_pow($_[1], $_[0]) : op_pow($_[0], $_[1]) }, '*' => \&op_mul, '/' => \&op_div, ); require Exporter; require DynaLoader; require AutoLoader; @ISA = qw(Exporter DynaLoader); # Items to export into callers namespace by default. Note: do not export # names by default without a very good reason. Use EXPORT_OK instead. # Do not simply export all your public functions/methods/constants. our $VERSION = '2.24'; bootstrap Math::GMP $VERSION; use strict; sub import { shift; return unless @_; die "unknown import: @_" unless @_ == 1 and $_[0] eq ':constant'; overload::constant integer => sub { Math::GMP->new(shift) }; return; } sub new { my $class = shift; my $ival = shift || 0; my $base = shift; $ival =~ s/\A\+//; $ival =~ tr/ _//d; if ($base) { return Math::GMP::new_from_scalar_with_base($ival, $base); } else { if ($ival =~ /[^\d\-xA-Fa-f]/) { die "Argument to Math::GMP->new is not a string representing an integer"; } return Math::GMP::new_from_scalar($ival); } } BEGIN { *DESTROY = \&Math::GMP::destroy; *gcd = \&bgcd; *lcm = \&blcm; } __END__ =pod =encoding UTF-8 =head1 NAME Math::GMP - High speed arbitrary size integer math =head1 VERSION version 2.24 =head1 SYNOPSIS use Math::GMP; my $n = Math::GMP->new('2'); $n = $n ** (256*1024); $n = $n - 1; print "n is now $n\n"; =head1 DESCRIPTION Math::GMP was designed to be a drop-in replacement both for Math::BigInt and for regular integer arithmetic. Unlike BigInt, though, Math::GMP uses the GNU gmp library for all of its calculations, as opposed to straight Perl functions. This can result in speed improvements. The downside is that this module requires a C compiler to install -- a small tradeoff in most cases. Also, this module is not 100% compatible with Math::BigInt. A Math::GMP object can be used just as a normal numeric scalar would be -- the module overloads most of the normal arithmetic operators to provide as seamless an interface as possible. However, if you need a perfect interface, you can do the following: use Math::GMP qw(:constant); $n = 2 ** (256 * 1024); print "n is $n\n"; This would fail without the ':constant' since Perl would use normal doubles to compute the 250,000 bit number, and thereby overflow it into meaninglessness (smaller exponents yield less accurate data due to floating point rounding). =begin Removed sub AUTOLOAD { # This AUTOLOAD is used to 'autoload' constants from the constant() # XS function. If a constant is not found then control is passed # to the AUTOLOAD in AutoLoader. my $constname; ($constname = $AUTOLOAD) =~ s/.*:://; croak '& not defined' if $constname eq 'constant'; my $val = constant($constname, @_ ? $_[0] : 0); if ($! != 0) { if ($! =~ /Invalid/) { $AutoLoader::AUTOLOAD = $AUTOLOAD; goto &AutoLoader::AUTOLOAD; } else { croak "Your vendor has not defined Math::GMP macro $constname"; } } no strict 'refs'; ## no critic *$AUTOLOAD = sub () { $val }; goto &$AUTOLOAD; } =end Removed =head1 METHODS Although the non-overload interface is not complete, the following functions do exist: =head2 new $x = Math::GMP->new(123); Creates a new Math::GMP object from the passed string or scalar. $x = Math::GMP->new('abcd', 36); Creates a new Math::GMP object from the first parameter which should be represented in the base specified by the second parameter. =head2 bfac $x = Math::GMP->new(5); my $val = $x->bfac(); # 1*2*3*4*5 = 120 print $val; Calculates the factorial of $x and returns the result. =head2 $n->bnok($k) $x = Math::GMP->new(5); my $val = $x->bnok(2); # 1*2*3*4*5/(1*2)/(1*2*3) = 10 print $val; Calculates the binomial coefficient of $n over $k and returns the result. Equals to $n!/($k!*($n-$k)!). ( Added in version 2.23 .) =head2 my $val = $x->band($y, $swap) $x = Math::GMP->new(6); my $val = $x->band(3, 0); # 0b110 & 0b11 = 1 print $val; Calculates the bit-wise AND of its two arguments and returns the result. $swap should be provided but is ignored. =head2 my $ret = $x->bxor($y, $swap); $x = Math::GMP->new(6); my $val = $x->bxor(3, 0); # 0b110 ^ 0b11 = 0b101 print $val; Calculates the bit-wise XOR of its two arguments and returns the result. =head2 my $ret = $x->bior($y, $swap); $x = Math::GMP->new(6); my $val = $x->bior(3); # 0b110 | 0b11 = 0b111 print $val; Calculates the bit-wise OR of its two arguments and returns the result. =head2 blshift $x = Math::GMP->new(0b11); my $result = $x->blshift(4, 0); # $result = 0b11 << 4 = 0b110000 Calculates the bit-wise left-shift of its two arguments and returns the result. Second argument is swap. =head2 brshift $x = Math::GMP->new(0b11001); my $result = $x->brshift(3, 0); # $result = 0b11001 << 3 = 0b11 Calculates the bit-wise right-shift of its two arguments and returns the result. Second argument is swap. =head2 bgcd my $x = Math::GMP->new(6); my $gcd = $x->bgcd(4); # 6 / 2 = 3, 4 / 2 = 2 => 2 print $gcd Returns the Greatest Common Divisor of the two arguments. =head2 blcm my $x = Math::GMP->new(6); my $lcm = $x->blcm(4); # 6 * 2 = 12, 4 * 3 = 12 => 12 print $lcm; Returns the Least Common Multiple of the two arguments. =head2 bmodinv my $x = Math::GMP->new(5); my $modinv = $x->bmodinv(7); # 5 * 3 == 1 (mod 7) => 3 print $modinv; Returns the modular inverse of $x (mod $y), if defined. This currently returns 0 if there is no inverse (but that may change in the future). Behaviour is undefined when $y is 0. =head2 broot my $x = Math::GMP->new(100); my $root = $x->root(3); # int(100 ** (1/3)) => 4 print $root; Returns the integer n'th root of its argument, given a positive integer n. =head2 brootrem my $x = Math::GMP->new(100); my($root, $rem) = $x->rootrem(3); # 4 ** 3 + 36 = 100 print "$x is $rem more than the cube of $root"; Returns the integer n'th root of its argument, and the difference such that C< $root ** $n + $rem == $x >. =head2 bsqrt my $x = Math::GMP->new(6); my $root = $x->bsqrt(); # int(sqrt(6)) => 2 print $root; Returns the integer square root of its argument. =head2 bsqrtrem my $x = Math::GMP->new(7); my($root, $rem) = $x->sqrtrem(); # 2 ** 2 + 3 = 7 print "$x is $rem more than the square of $root"; Returns the integer square root of its argument, and the difference such that C< $root ** 2 + $rem == $x >. =head2 is_perfect_power my $x = Math::GMP->new(100); my $is_power = $x->is_perfect_power(); print "$x is " . ($is_power ? "" : "not ") . "a perfect power"; Returns C if its argument is a power, ie if there exist integers a and b with b > 1 such that C< $x == $a ** $b >. =head2 is_perfect_square my $x = Math::GMP->new(100); my $is_square = $x->is_perfect_square(); print "$x is " . ($is_square ? "" : "not ") . "a perfect square"; Returns C if its argument is the square of an integer. =head2 legendre $x = Math::GMP->new(6); my $ret = $x->legendre(3); Returns the value of the Legendre symbol ($x/$y). The value is defined only when $y is an odd prime; when the value is not defined, this currently returns 0 (but that may change in the future). =head2 jacobi my $x = Math::GMP->new(6); my $jacobi_verdict = $x->jacobi(3); Returns the value of the Jacobi symbol ($x/$y). The value is defined only when $y is odd; when the value is not defined, this currently returns 0 (but that may change in the future). =head2 fibonacci my $fib = Math::GMP::fibonacci(16); Calculates the n'th number in the Fibonacci sequence. =head2 probab_prime my $x = Math::GMP->new(7); my $is_prime_verdict = $x->probab_prime(10); Probabilistically determines if the number is a prime. Argument is the number of checks to perform. Returns 0 if the number is definitely not a prime, 1 if it may be, and 2 if it definitely is a prime. =head2 $x->add_ui_gmp($n) Adds to $x and mutates it in-place. $n must be a regular non-GMP, positive, integer. =head2 ($quotient, $remainder) = $x->bdiv($y); my $x = Math::GMP->new(7); my ($quo, $rem) = $x->bdiv(3); Returns both the division and the modulo of an integer division operation. =head2 my $ret = $x->div_2exp_gmp($n); my $x = Math::GMP->new(200); my $ret = $x->div_2exp_gmp(2); Returns a right-shift of the Math::GMP object by an unsigned regular integer. Also look at blshift() . =head2 my $str = $x->get_str_gmp($base) my $init_n = 3 * 7 + 2 * 7 * 7 + 6 * 7 * 7 * 7; my $x = Math::GMP->new($init_n); my $ret = $x->get_str_gmp(7); print $ret; # Prints "6230". Returns a string representation of the number in base $base. =head2 my $clone = $x->gmp_copy() Returns a copy of $x that can be modified without affecting the original. =head2 my $verdict = $x->gmp_tstbit($bit_index); Returns whether or not bit No. $bit_index is 1 in $x. =head2 my $remainder = $dividend->mmod_gmp($divisor) my $x = Math::GMP->new(2 . ('0' x 200) . 4); my $y = Math::GMP->new(5); my $ret = $x->mmod_gmp($y); # $ret is now Math::GMP of 4. From the GMP documentation: Divide dividend and divisor and put the remainder in remainder. The remainder is always positive, and its value is less than the value of the divisor. =head2 my $result = $x->mod_2exp_gmp($shift); my $x = Math::GMP->new(0b10001011); my $ret = $x->mod_2exp_gmp(4); # $ret is now Math::GMP of 0b1011 Returns a Math::GMP object containing the lower $shift bits of $x (while not modifying $x). =head2 my $left_shifted = $x->mul_2exp_gmp($shift); my $x = Math::GMP->new(0b10001011); my $ret = $x->mul_2exp_gmp(4); # $ret is now Math::GMP of 0b1000_1011_0000 Returns a Math::GMP object containing $x shifted by $shift bits (where $shift is a plain integer). =head2 my $multiplied = $x->bmulf($float) my $x = Math::GMP->new(3)->bpow(100); my $ret = $x->bmulf(1.5); # $ret is now Math::GMP of floor(3^101 / 2) Returns a Math::GMP object representing $x multiplied by the floating point value $float (with the result truncated towards zero). ( Added in version 2.23 .) =head2 my $ret = $base->powm_gmp($exp, $mod); my $base = Math::GMP->new(157); my $exp = Math::GMP->new(100); my $mod = Math::GMP->new(5013); my $ret = $base->powm_gmp($exp, $mod); # $ret is now (($base ** $exp) % $mod) Returns $base raised to the power of $exp modulo $mod. =head2 my $plain_int_ret = $x->sizeinbase_gmp($plain_int_base); Returns the size of $x in base $plain_int_base . =head2 my $int = $x->intify(); Returns the value of the object as an unblessed (and limited-in-precision) integer. =head2 _gmp_build_version() my $gmp_version = Math::GMP::_gmp_build_version; if ($gmp_version ge 6.0.0) { print "Math::GMP was built against libgmp-6.0.0 or later"; } Class method that returns as a vstring the version of libgmp against which this module was built. =head2 _gmp_lib_version() my $gmp_version = Math::GMP::_gmp_lib_version; if ($gmp_version ge 6.0.0) { print "Math::GMP is now running with libgmp-6.0.0 or later"; } Class method that returns as a vstring the version of libgmp it is currently running. =head2 gcd() An alias to bgcd() . =head2 lcm() An alias to blcm() . =head2 constant For internal use. B. =head2 destroy For internal use. B. =head2 new_from_scalar For internal use. B. =head2 new_from_scalar_with_base For internal use. B. =head2 op_add For internal use. B. =head2 op_div For internal use. B. =head2 op_eq For internal use. B. =head2 op_mod For internal use. B. =head2 op_mul For internal use. B. =head2 op_pow For internal use. B. =head2 op_spaceship For internal use. B. =head2 op_sub For internal use. B. =head2 stringify For internal use. B. =head2 uintify For internal use. B. =head1 DIVISION BY ZERO Whereas perl normally catches division by zero to provide a standard perl-level error message, C does not; the result is usually a SIGFPE (floating point exception) giving a core dump if you ever attempt to divide a C object by anything that evaluates to zero. This can make it hard to diagnose where the error has occurred in your perl code. As of perl-5.36.0, SIGFPE is delivered in a way that can be caught by a C<%SIG> handler. So you can get a stack trace with code like: use Carp; # load it up front local $SIG{FPE} = sub { confess(@_) }; Before perl-5.36.0 this approach won't work: you'll need to use L instead: use Carp; use POSIX qw{ sigaction SIGFPE }; sigaction(SIGFPE, POSIX::SigAction->new(sub { confess(@_) })); In either case, you should not attempt to return from the signal handler, since the signal will just be thrown again. =head1 BUGS As of version 1.0, Math::GMP is mostly compatible with the old Math::BigInt version. It is not a full replacement for the rewritten Math::BigInt versions, though. See the L on how to achieve to use Math::GMP and retain full compatibility to Math::BigInt. There are some slight incompatibilities, such as output of positive numbers not being prefixed by a '+' sign. This is intentional. There are also some things missing, and not everything might work as expected. =head1 VERSION CONTROL The version control repository of this module is a git repository hosted on GitHub at: L. Pull requests are welcome. =head1 SEE ALSO Math::BigInt has a new interface to use a different library than the default pure Perl implementation. You can use, for instance, Math::GMP with it: use Math::BigInt lib => 'GMP'; If Math::GMP is not installed, it will fall back to its own Perl implementation. See L and L or L or L. See L, L, and friends ( L ) for bindings of other parts of GMP / MPFR / etc. =head1 AUTHOR Chip Turner , based on the old Math::BigInt by Mark Biggar and Ilya Zakharevich. Further extensive work provided by Tels . Shlomi Fish ( L ) has done some maintenance work while putting his changes under CC0. =head1 AUTHOR Shlomi Fish =head1 COPYRIGHT AND LICENSE This software is Copyright (c) 2000 by James H. Turner. This is free software, licensed under: The GNU Lesser General Public License, Version 2.1, February 1999 =head1 BUGS Please report any bugs or feature requests on the bugtracker website L or by email to L. When submitting a bug or request, please include a test-file or a patch to an existing test-file that illustrates the bug or desired feature. =for :stopwords cpan testmatrix url bugtracker rt cpants kwalitee diff irc mailto metadata placeholders metacpan =head1 SUPPORT =head2 Perldoc You can find documentation for this module with the perldoc command. perldoc Math::GMP =head2 Websites The following websites have more information about this module, and may be of help to you. As always, in addition to those websites please use your favorite search engine to discover more resources. =over 4 =item * MetaCPAN A modern, open-source CPAN search engine, useful to view POD in HTML format. L =item * RT: CPAN's Bug Tracker The RT ( Request Tracker ) website is the default bug/issue tracking system for CPAN. L =item * CPANTS The CPANTS is a website that analyzes the Kwalitee ( code metrics ) of a distribution. L =item * CPAN Testers The CPAN Testers is a network of smoke testers who run automated tests on uploaded CPAN distributions. L =item * CPAN Testers Matrix The CPAN Testers Matrix is a website that provides a visual overview of the test results for a distribution on various Perls/platforms. L =item * CPAN Testers Dependencies The CPAN Testers Dependencies is a website that shows a chart of the test results of all dependencies for a distribution. L =back =head2 Bugs / Feature Requests Please report any bugs or feature requests by email to C, or through the web interface at L. You will be automatically notified of any progress on the request by the system. =head2 Source Code The code is open to the world, and available for you to hack on. Please feel free to browse it and play with it, or whatever. If you want to contribute patches, please send me a diff or prod me to pull from your repository :) L git clone https://github.com/turnstep/Math-GMP.git =cut 99_spellcheck.t100644000764000764 670114145117655 16624 0ustar00shlomifshlomif000000000000Math-GMP-2.24/xt#!perl ## Spellcheck as much as we can use 5.006; use strict; use warnings; use Test::More; select(($|=1,select(STDERR),$|=1)[1]); my (@testfiles, @perlfiles, @textfiles, @commentfiles, $fh); if (! $ENV{RELEASE_TESTING}) { plan (skip_all => 'Test skipped unless environment variable RELEASE_TESTING is set'); } elsif (!eval { require Text::SpellChecker; 1 }) { plan skip_all => 'Could not find Text::SpellChecker'; } else { opendir my $dir, 't' or die qq{Could not open directory 't': $!\n}; @testfiles = map { "t/$_" } grep { /^.+\.(t|pl)$/ } readdir $dir; closedir $dir or die qq{Could not closedir "$dir": $!\n}; open my $fh, '<', 'MANIFEST' or die qq{Could not open the MANIFEST file: $!\n}; while (<$fh>) { next unless /(.*\.pm)/; push @perlfiles, $1; } close $fh or die qq{Could not close the MANIFEST file: $!\n}; @textfiles = qw/README Changes LICENSE/; @commentfiles = (@testfiles, 'Makefile.PL', @perlfiles); plan tests => @textfiles + @perlfiles + @commentfiles; } my %okword; my $file = 'Common'; while () { if (/^## (.+):/) { $file = $1; next; } next if /^#/ or ! /\w/; for (split) { ++$okword{$file}{$_}; } } sub spellcheck { my ($desc, $text, $sfile) = @_; my $check = Text::SpellChecker->new(text => $text); my %badword; my $class = $sfile =~ /\.pm$/ ? 'Perl' : $sfile =~ /\.t$/ ? 'Test' : ''; while (my $word = $check->next_word) { next if $okword{Common}{$word} or $okword{$sfile}{$word} or $okword{$class}{$word}; ++$badword{$word}; } my $count = keys %badword; if (! $count) { pass ("Spell check passed for $desc"); return; } fail ("Spell check failed for $desc. Bad words: $count"); for (sort keys %badword) { diag "$_\n"; } return; } ## General spellchecking for my $file (@textfiles) { if (!open $fh, '<', $file) { fail (qq{Could not find the file "$file"!}); } else { { local $/; $_ = <$fh>; } close $fh or warn qq{Could not close "$file": $!\n}; spellcheck ($file => $_, $file); } } ## Now the embedded POD SKIP: { if (!eval { require Pod::Spell; 1 }) { my $files = @perlfiles; skip ('Need Pod::Spell to test the spelling of embedded POD', $files); } for my $file (@perlfiles) { if (! -e $file) { fail (qq{Could not find the file "$file"!}); } my $string = qx{podspell $file}; spellcheck ("POD from $file" => $string, $file); } } ## Now the comments SKIP: { if (!eval { require File::Comments; 1 }) { my $files = @commentfiles; skip ('Need File::Comments to test the spelling inside comments', $files); } my $fc = File::Comments->new(); for my $file (@commentfiles) { if (! -e $file) { fail (qq{Could not find the file "$file"!}); } my $string = $fc->comments($file); if (! $string) { fail (qq{Could not get comments from file $file}); next; } $string = join "\n" => @$string; $string =~ s/=head1.+//sm; spellcheck ("comments from $file" => $string, $file); } } __DATA__ ## These words are okay ## Common: babcdefgh badd bcmp bdiv bfac bgcd Biggar BigInt bior bloodgate bmod bmul bsub bxor chipt cpan CPAN cturner Divisior dk des DES env fac fibonacci gcd gmp GMP GPL Haydon gmppmt Ilya intify jacobi legendre Makefile MERCHANTABILITY Behaviour Probabilistically mmod mul Mullane namespace nicholas n'th ok Oxh oxhoej perl perl powm README redhat Sabino Sep sizeinbase Spellcheck spellchecking sqrt Tels tels tradeoff tstbit ui Ulrich uintify xff xs YAML YAMLiciousness yml Zakharevich ## Changes iglu il libgmp probab shlomif blcm bmodinv bsqrt lcm test-use-constant.t100644000764000764 31514145117655 17351 0ustar00shlomifshlomif000000000000Math-GMP-2.24/t#!/usr/bin/perl use strict; use warnings; use Test::More tests => 1; use Math::GMP (qw( :constant )); { # TEST is ((2 ** 100 . ''), '1267650600228229401496703205376', "Test for :constant"); } 02_init_from_float.t100644000764000764 54614145117655 17433 0ustar00shlomifshlomif000000000000Math-GMP-2.24/t#!/usr/bin/perl use strict; use warnings; # See: # # https://rt.cpan.org/Ticket/Display.html?id=27521 # # Thanks to Sisyphus for the report. use Test::More tests => 1; use Math::GMP; { my $should_be_1; eval { $should_be_1 = Math::GMP->new(1.5); }; my $E = $@; # TEST like ($E , qr/string representing an integer/); } author000755000764000764 014145117655 15137 5ustar00shlomifshlomif000000000000Math-GMP-2.24/xtpod-syntax.t100644000764000764 25214145117655 17551 0ustar00shlomifshlomif000000000000Math-GMP-2.24/xt/author#!perl # This file was automatically generated by Dist::Zilla::Plugin::PodSyntaxTests. use strict; use warnings; use Test::More; use Test::Pod 1.41; all_pod_files_ok(); pod-coverage.t100644000764000764 33414145117655 20017 0ustar00shlomifshlomif000000000000Math-GMP-2.24/xt/author#!perl # This file was automatically generated by Dist::Zilla::Plugin::PodCoverageTests. use Test::Pod::Coverage 1.08; use Pod::Coverage::TrustPod; all_pod_coverage_ok({ coverage_class => 'Pod::Coverage::TrustPod' }); release000755000764000764 014145117655 15255 5ustar00shlomifshlomif000000000000Math-GMP-2.24/xtcpan-changes.t100644000764000764 34414145117655 20112 0ustar00shlomifshlomif000000000000Math-GMP-2.24/xt/releaseuse strict; use warnings; # this test was generated with Dist::Zilla::Plugin::Test::CPAN::Changes 0.012 use Test::More 0.96 tests => 1; use Test::CPAN::Changes; subtest 'changes_ok' => sub { changes_file_ok('Changes'); }; trailing-space.t100644000764000764 103414145117655 20502 0ustar00shlomifshlomif000000000000Math-GMP-2.24/xt/release#!perl use strict; use warnings; use Test::More; eval "use Test::TrailingSpace"; if ($@) { plan skip_all => "Test::TrailingSpace required for trailing space test."; } else { plan tests => 1; } # TODO: add .pod, .PL, the README/Changes/TODO/etc. documents and possibly # some other stuff. my $finder = Test::TrailingSpace->new( { root => '.', filename_regex => qr#(?:\.(?:t|pm|pl|xs|c|h|txt|pod|PL)|README|Changes|TODO|LICENSE)\z#, }, ); # TEST $finder->no_trailing_space( "No trailing space was found." ); check-funcs-ret-value--rt92593.t100644000764000764 1261014145117655 21221 0ustar00shlomifshlomif000000000000Math-GMP-2.24/t#!/usr/bin/perl use strict; use warnings; # See: # https://rt.cpan.org/Ticket/Display.html?id=92593 use Test::More tests => 47; use Math::GMP; { my $x = Math::GMP->new(5); my $val = $x->bfac(); # 1*2*3*4*5 = 120 # TEST is ($x.'', "5", "x->bfac did not change x"); # TEST is ($val.'', '120', 'val=x->bfac is correct.'); } { my $x = Math::GMP->new(0b1100); my $ret = $x->band(0b1010, 0); # TEST is ($x.'', 0b1100, "x->band did not change"); # TEST is ($ret.'', 0b1000, "ret = x->band is correct."); } { my $x = Math::GMP->new(0b1100); my $ret = $x->bxor(0b1010, 0); # TEST is ($x.'', 0b1100, "x did not change after x->bxor"); # TEST is ($ret.'', 0b110, "ret = x->bxor is correct."); } { my $x = Math::GMP->new(0b1100); my $ret = $x->bior(0b1010, 0); # TEST is ($x.'', 0b1100, "x did not change after x->bior"); # TEST is ($ret.'', 0b1110, "ret = x->bior is correct."); } { my $x = Math::GMP->new(1000 * 3); my $ret = $x->bgcd(1000 * 7); # TEST is ($x.'', 1000 * 3, "x did not change after x->bgcd"); # TEST is ($ret.'', 1000, "ret = x->bgcd(y) is correct."); } { my $x = Math::GMP->new(1000 * 3 * 3); my $ret = $x->blcm(1000 * 3 * 7); # TEST is ($x.'', 1000 * 3 * 3, "x did not change after x->blcm"); # TEST is ($ret.'', 1000 * 3 * 3 * 7, "ret = x->blcm(y) is correct."); } { my $x = Math::GMP->new(5); my $ret = $x->bmodinv(7); # TEST is ($x.'', 5, "x did not change after x->bmodinv"); # TEST is ($ret.'', 3, "ret = x->bmodinv(y) is correct."); } { my $x = Math::GMP->new(6); my $ret = $x->bsqrt(); # TEST is ($x.'', 6, "x did not change after x->bsqrt"); # TEST is ($ret.'', 2, "ret = x->bsqrt() is correct."); } { my $x = Math::GMP->new(200); my $ret = $x->legendre(3); # TEST is ($x.'', 200, "x did not change after x->legendre"); # TEST is ($ret, -1, "ret = x->legendre(y) is correct."); } { my $x = Math::GMP->new(200); my $ret = $x->jacobi(5); # TEST is ($x.'', 200, "x did not change after x->jacobi"); # TEST is ($ret, 0, "ret = x->jacobi(y) is correct."); } { my $x = Math::GMP::fibonacci(200); # TEST is ($x.'', '280571172992510140037611932413038677189525', "Math::GMP::fibonacci() works fine"); } { my $x = Math::GMP->new(7); my $is_prime_verdict = $x->probab_prime(10); # TEST is ($x.'', '7', "x did not change after x->probab_prime"); # TEST is ($is_prime_verdict, '2', 'probab_prime works.'); } { my $x = Math::GMP->new('1'. ('0' x 100)); $x->add_ui_gmp(500); # TEST is ($x.'', '1' . ('0' x (100-3)) . '500', "x was mutated after add_ui_gmp"); } { my $x = Math::GMP->new(7); my ($quo, $rem) = $x->bdiv(3); # TEST is ($x.'', 7, "x did not change after x->bdiv"); # TEST is ($quo.'', 2, "x->bdiv[quo]"); # TEST is ($rem.'', 1, "x->bdiv[rem]"); } { my $x = Math::GMP->new(200); my $ret = $x->div_2exp_gmp(2); # TEST is ($x.'', 200, "x did not change after x->div_2exp_gmp"); # TEST is ($ret.'', 50, "ret = x->div_2exp_gmp(y) is correct."); } { my $init_n = 3 * 7 + 2 * 7 * 7 + 6 * 7 * 7 * 7; my $x = Math::GMP->new($init_n); my $ret = $x->get_str_gmp(7); # TEST is ($x.'', $init_n, "x did not change after x->get_str_gmp"); # TEST is ($ret, "6230", "ret = x->get_str_gmp(base) is correct."); } { my $x = Math::GMP->new('2' . ('123' x 100)); my $y = $x->gmp_copy; # TEST is ($x.'', '2'. ('123' x 100), "x did not change after x->gmp_copy"); # TEST is ($y.'', '2'. ('123' x 100), "->gmp_copy returned a clone."); $y += 1; # TEST is ($x.'', '2'. ('123' x 100), "x did not change after x->gmp_copy+modify"); # TEST is ($y.'', '2'. ('123' x 99) . '124', "y changed."); } { my $x = Math::GMP->new(0b1000100); # TEST is (scalar($x->gmp_tstbit(6)), 1, "gmp_tstbit #1"); # TEST is (scalar($x->gmp_tstbit(4)), 0, "gmp_tstbit #2"); } { my $x = (Math::GMP->new(24) * 5); my $ret = $x->intify; # TEST is ($ret, 120, "test intify"); } { my $x = Math::GMP->new(2 . ('0' x 200) . 4); my $y = Math::GMP->new(5); my $ret = $x->mmod_gmp($y); # TEST is ($ret.'', 4, "mmod_gmp"); # TEST is ($x.'', '2' . ('0' x 200) . '4', "mmod_gmp did not change first arg"); } { my $x = Math::GMP->new(0b10001011); my $ret = $x->mod_2exp_gmp(4); # TEST is ($x.'', 0b10001011, "x did not change after x->mod_2exp_gmp"); # TEST is ($ret.'', 0b1011, "ret = x->mod_2exp_gmp(y) is correct."); } { my $x = Math::GMP->new(0b10001011); my $ret = $x->mul_2exp_gmp(4); # TEST is ($x.'', 0b10001011, "x did not change after x->mul_2exp_gmp"); # TEST is ($ret.'', 0b100010110000, "ret = x->mul_2exp_gmp(y) is correct."); } { my $x = Math::GMP->new(157); my $exp = Math::GMP->new(100); my $mod = Math::GMP->new(5013); my $ret = $x->powm_gmp($exp, $mod); my $brute_force_ret = (($x ** $exp) % $mod); # TEST is ($x.'', 157, "x did not change after x->powm_gmp"); # TEST is ($ret.'', $brute_force_ret.'', "ret = x->powm_gmp(exp, mod) is correct." ); } { my $x = Math::GMP->new('2' . ('123' x 100)); # TEST is ($x->sizeinbase_gmp(10), 1 + 3 * 100, "sizeinbase_gmp works"); }