Permalink
Browse files

mpz_poly_mod_mult and mpz_poly_mod_power are class methods; fix Rmpz_…

…add call

This gets rid of Perl backtraces but we now get a coredump during a Rmpz_mul
  • Loading branch information...
1 parent 0466429 commit 3ec9032fbe85476095dc2ff1b9132f321614d680 @leto committed Sep 24, 2012
Showing with 5 additions and 3 deletions.
  1. +5 −3 lib/Math/Primality/BigPolynomial.pm
@@ -107,9 +107,10 @@ sub clear {
}
sub mpz_poly_mod_mult {
- my $self = shift;
my ( $rop, $x, $y, $mod, $polymod ) = @_;
+ die "mpz_poly_mod_mult: polymod must be defined!" unless $polymod;
+
$rop->clear();
my $xdeg = ref $x ? $x->degree() : 0;
@@ -120,7 +121,7 @@ sub mpz_poly_mod_mult {
my $sum = Math::GMPz->new(0);
my $temp = Math::GMPz->new(0);
for ( my $j = 0 ; $j <= $i ; $j++ ) {
- Rmpz_add( $temp,
+ Rmpz_add($temp, $temp,
$y->getCoef( $i - $j ) + $y->getCoef( $i + $polymod - $j ) );
Rmpz_mul( $temp, $x->getCoef($j), $temp );
Rmpz_add( $sum, $sum, $temp );
@@ -144,9 +145,10 @@ sub mpz_poly_mod_mult {
}
sub mpz_poly_mod_power {
- my $self = shift;
my ( $rop, $x, $power, $mult_mod, $poly_mod ) = @_;
+ die "mpz_poly_mod_power: polymod must be defined!" unless $poly_mod;
+
$rop->clear();
$rop->setCoef( Math::GMPz->new(1), 0 );

0 comments on commit 3ec9032

Please sign in to comment.