Math-Prime-Util icon indicating copy to clipboard operation
Math-Prime-Util copied to clipboard

PP sqrtmod(-a, n) fails

Open hvds opened this issue 3 years ago • 1 comments

% $PERL -MMath::Prime::Util -wle 'print $Math::Prime::Util::VERSION'
0.73
% $PERL -MMath::Prime::Util=sqrtmod -wle 'print sqrtmod(-1, 17) // "undef"'
4
% MPU_NO_XS=1 $PERL -MMath::Prime::Util=sqrtmod -wle 'print sqrtmod(-1, 17) // "undef"'
undef
% 

Found by observation of the code. I didn't check if negative modulus was supposed to be supported, that may also be a problem.

hvds avatar Jun 04 '21 14:06 hvds

Also seems to be fixed in the sqrtmod / rootmod rewrite. Negative inputs are supported, and the documentation indicates we'll use the absolute value (just like Pari/GP). I tried to be more consistent with the *mod functions.

danaj avatar Jun 05 '21 10:06 danaj