Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Already on GitHub? Sign in to your account

Merge the fix_aks branch #1

Closed
leto opened this Issue Nov 24, 2011 · 16 comments

Comments

Projects
None yet
2 participants
Owner

leto commented Nov 24, 2011

Do it.

@ghost ghost assigned leto Nov 24, 2011

Owner

leto commented Nov 25, 2011

Hey @bubaflub, can you help with this?

Collaborator

bubaflub commented Nov 28, 2011

Just saw this - I'll try and get this done sometime this week or perhaps next weekend. I've got a few other fixes coming in for this module as well.

Collaborator

bubaflub commented Dec 4, 2011

What do you think about splitting functionality into other modules - Math::Primality::AKS and Math::Primality::BPSW. We could still bundle all of it together but then things would be a bit more separated.

Owner

leto commented Dec 4, 2011

+1
On Dec 3, 2011 10:59 PM, "Bob Kuo" <
reply@reply.github.com>
wrote:

What do you think about splitting functionality into other modules -
Math::Primality::AKS and Math::Primality::BPSW. We could still bundle all
of it together but then things would be a bit more separated.


Reply to this email directly or view it on GitHub:
#1 (comment)

Owner

leto commented Sep 23, 2012

Current status:

 prove -lrv t/is_aks_prime.t 
t/is_aks_prime.t .. 
1..232
ok 1 - use Math::Primality::AKS;
# Testing Math::Primality::AKS 0.01, Perl 5.012004, /usr/bin/perl
Can't call method "degree" without a package or object reference at /Users/jleto/git/math--primality/lib/Math/Primality/BigPolynomial.pm line 116
    Math::Primality::BigPolynomial::mpz_poly_mod_mult('Math::Primality::BigPolynomial=HASH(0x7f8c8882bb80)', 'Math::Primality::BigPolynomial=HASH(0x7f8c8882bb80)', 'Math::Primality::BigPolynomial=HASH(0x7f8c8882bb80)', 2, undef) called at /Users/jleto/git/math--primality/lib/Math/Primality/BigPolynomial.pm line 156
    Math::Primality::BigPolynomial::mpz_poly_mod_power('Math::Primality::BigPolynomial=HASH(0x7f8c88830318)', 'Math::Primality::BigPolynomial=HASH(0x7f8c8882bb80)', 'Math::GMPz=SCALAR(0x7f8c8882bc58)', 'Math::GMPz=SCALAR(0x7f8c8882bc58)', 2) called at /Users/jleto/git/math--primality/lib/Math/Primality/AKS.pm line 122
    Math::Primality::AKS::is_aks_prime('Math::GMPz=SCALAR(0x7f8c888073b8)') called at t/is_aks_prime.t line 20
# Looks like you planned 232 tests but ran 1.
# Looks like your test exited with 255 just after 1.
Owner

leto commented Sep 23, 2012

Now:

$ prove -lrv t/is_aks_prime.t 
t/is_aks_prime.t .. 
1..232
ok 1 - use Math::Primality::AKS;
# Testing Math::Primality::AKS 0.01, Perl 5.012004, /usr/bin/perl
Use of uninitialized value $polymod in numeric lt (<) at /Users/jleto/git/math--primality/lib/Math/Primality/BigPolynomial.pm line 119
    Math::Primality::BigPolynomial::mpz_poly_mod_mult('Math::Primality::BigPolynomial=HASH(0x7fed2882bb80)', 'Math::Primality::BigPolynomial=HASH(0x7fed2882bb80)', 'Math::Primality::BigPolynomial=HASH(0x7fed2882bb80)', 2, undef) called at /Users/jleto/git/math--primality/lib/Math/Primality/BigPolynomial.pm line 156
    Math::Primality::BigPolynomial::mpz_poly_mod_power('Math::Primality::BigPolynomial=HASH(0x7fed28830318)', 'Math::Primality::BigPolynomial=HASH(0x7fed2882bb80)', 'Math::GMPz=SCALAR(0x7fed2882bc58)', 'Math::GMPz=SCALAR(0x7fed2882bc58)', 2) called at /Users/jleto/git/math--primality/lib/Math/Primality/AKS.pm line 122
    Math::Primality::AKS::is_aks_prime('Math::GMPz=SCALAR(0x7fed288073b8)') called at t/is_aks_prime.t line 20
Use of uninitialized value $polymod in numeric lt (<) at /Users/jleto/git/math--primality/lib/Math/Primality/BigPolynomial.pm line 119
    Math::Primality::BigPolynomial::mpz_poly_mod_mult('Math::Primality::BigPolynomial=HASH(0x7fed2882bb80)', 'Math::Primality::BigPolynomial=HASH(0x7fed2882bb80)', 'Math::Primality::BigPolynomial=HASH(0x7fed2882bb80)', 2, undef) called at /Users/jleto/git/math--primality/lib/Math/Primality/BigPolynomial.pm line 156
    Math::Primality::BigPolynomial::mpz_poly_mod_power('Math::Primality::BigPolynomial=HASH(0x7fed28830318)', 'Math::Primality::BigPolynomial=HASH(0x7fed2882bb80)', 'Math::GMPz=SCALAR(0x7fed2882bc58)', 'Math::GMPz=SCALAR(0x7fed2882bc58)', 2) called at /Users/jleto/git/math--primality/lib/Math/Primality/AKS.pm line 122
    Math::Primality::AKS::is_aks_prime('Math::GMPz=SCALAR(0x7fed288073b8)') called at t/is_aks_prime.t line 20
Undefined subroutine &Math::Primality::BigPolynomial::mpz_poly_mod_mul called at /Users/jleto/git/math--primality/lib/Math/Primality/BigPolynomial.pm line 158
    Math::Primality::BigPolynomial::mpz_poly_mod_power('Math::Primality::BigPolynomial=HASH(0x7fed28830318)', 'Math::Primality::BigPolynomial=HASH(0x7fed2882bb80)', 'Math::GMPz=SCALAR(0x7fed2882bc58)', 'Math::GMPz=SCALAR(0x7fed2882bc58)', 2) called at /Users/jleto/git/math--primality/lib/Math/Primality/AKS.pm line 122
    Math::Primality::AKS::is_aks_prime('Math::GMPz=SCALAR(0x7fed288073b8)') called at t/is_aks_prime.t line 20
# Looks like you planned 232 tests but ran 1.
# Looks like your test exited with 255 just after 1.
Owner

leto commented Sep 23, 2012

@bubaflub can you lend any assistance?

Collaborator

bubaflub commented Sep 25, 2012

@leto hey man, long time no see. I've got some branches that are in various states on my fork - one for better test coverage, one for some more cleanup. I've also received two RT tickets - https://rt.cpan.org/Public/Bug/Display.html?id=79674 and https://rt.cpan.org/Public/Bug/Display.html?id=78379. I'll take a look at this stuff and file some issues for these other two tickets. I'd like to get back to hacking on this.

Collaborator

bubaflub commented Sep 25, 2012

I just did a fresh checkout of your copy and the test passed. I'm using perl 5.12.3 and Math::GMPz version 0.31.

Owner

leto commented Sep 25, 2012

I used the patch in one of the RT tickets in 0045721 . The other patch that mentions prime_count/is_prime confuses me. We already do some of the checks and I would want to see some benchmark data before going further.

Owner

leto commented Sep 25, 2012

I get a coredump on Perl 5.10.1 and Math::GMPz as well. Odd.

Owner

leto commented Sep 25, 2012

The line that is causing the coredump is this inside Math::Primality::BigPolynomial::mpz_poly_mod_mult:

            Rmpz_mul( $temp, $x->getCoef($j), $temp );

@bubaflub : Your original code has a line:

 Rmpz_add( $temp,  $y->getCoef( $i - $j ) + $y->getCoef( $i + $polymod - $j ) );

which is an invalid call to Rmpz_add (it needs 3 args), so I converted that to:

 Rmpz_add( $temp, $temp,  $y->getCoef( $i - $j ) + $y->getCoef( $i + $polymod - $j ) );

Is that right?

Owner

leto commented Sep 25, 2012

After more sleuthing, it looks like this is caused by getCoef returning a 0 instead of a Math::GMPz object that has a value of zero. This is because we do getCoef(2) on a 1st degree polynomial.

Owner

leto commented Sep 25, 2012

Looks like getCoef is not quite the issue. Are you sure everything passes for you @bubaflub ? Here is the coredump happening on Travis: http://travis-ci.org/#!/leto/math--primality/jobs/2553084

Did you run the test with prove -lrv ? Without the -l, you will be testing against an installed Math::Primality.

Collaborator

bubaflub commented Sep 26, 2012

Yup, I ran it with -l and I don't have a system or installed Math::Primality anywhere. I'm at a1ea2be right now.

Collaborator

bubaflub commented Sep 26, 2012

Just realized I'm on the wrong branch. My bad. One sec.

@leto leto closed this in 1c6545f Sep 26, 2012

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment