Skip Menu |

This queue is for tickets about the Math-GMP CPAN distribution.

Report information
The Basics
Id: 92641
Status: resolved
Priority: 0/
Queue: Math-GMP

People
Owner: Nobody in particular
Requestors: greg [...] turnstep.com
Cc: DANAJ [...] cpan.org
AdminCc:

Bug Information
Severity: (no value)
Broken in: (no value)
Fixed in: (no value)



Subject: Tests need to include large numbers
Per astute observation in another ticket, the tests are not using large numbers (e.g. > int), but they really ought to.
Tests should be added for other functions, but here are some gcd, lcm, jacobi, and probab_prime tests to start discussion. I just added these to the end of t/01_gmppm.t. I'm not sure what opinions there are on having all the tests in one file vs. multiple test files (either by function or by size). For gcd, I included some basic small integer tests as well, including negative inputs, then some larger numbers. For lcm, similarly it has some small tests. It also tests negative inputs, which are not otherwise tested. This is important because GMP's lcm semantics follow Mathematica, Pari, Perl6, and Math::Prime::Util, but are different from Math::BigInt. We also test that two large 32-bit native inputs correctly give us a big result. Jacobi is a complicated one. In v4.0 released in 2001, they added kronecker, with legendre and jacobi just #defined to the same function. A separate issue is the documentation for jacobi and legendre -- contrary to the module documentation, these would only return 0 on very old systems. I put in a large subset of my kronecker tests, which all pass for me with GMP 4.1.4 and 5.0.2. If kronecker is added then all the tests could use it, but that would mean there is a dependency on GMP 4.0+. If that's not done, then these tests should be pruned to remove all tests where the second argument is even. probab_prime with bigint args. There are two gotchas: 1) GMP doesn't specify how it will distinguish between a result of 1 and 2. 5.1.3 will return 2 for results below 1000000, 1 above that. A future version might do something more intelligent and return 2 for any result < 2^64, for instance. 2) The probable prime test in GMP isn't ideal, but with 25 tests the chance is pretty small of having misidentified composites. Digression, expanding on #2, if I added: 13247749459499406215491:12:0 10627945015121687221861591:15:0 to the test suite, both cases would fail with GMP 5.0. We need a minimum of 13 and 16 tests respectively to pass. Similarly I have large numbers that trip up Perl6's is-prime.
Subject: 01additions.t
&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:1 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
On Thu Feb 20 18:19:40 2014, DANAJ wrote: Show quoted text
> Tests should be added for other functions, but here are some gcd, lcm, > jacobi, and probab_prime tests to start discussion. I just added > these to the end of t/01_gmppm.t. I'm not sure what opinions there > are on having all the tests in one file vs. multiple test files > (either by function or by size). >
Thanks, DANAJ! I added your tests. More tests can now be added as pull requests to https://github.com/turnstep/Math-GMP . RESOLVEDing this ticket for now. Regards, -- Shlomi Fish .