Commit eba1e3bd authored by gregor herrmann's avatar gregor herrmann

New upstream version 1.999816

parent b1298f89
1.999816 2018-10-26
* bnok() for Math::BigInt and Math::BigFloat now support the full Kronenburg
extension. The behaviour is identical to the behaviour of the Maple and
Mathematica function for negative integers n, k. Add tests. This closes CPAN
RT #95628.
* Fix POD errors. This closes CPAN RT #125141.
1.999815 2018-10-19
* Move bitwise operators signed and, signed or, and signed xor from
......
......@@ -156,6 +156,8 @@ t/bigints.t
t/biglog.t
t/bigroot.t
t/blucas-mbi.t
t/bnok-mbf.t
t/bnok-mbi.t
t/bnstr-mbf.t
t/bnstr-mbi.t
t/bsstr-mbf.t
......
......@@ -41,6 +41,6 @@
}
},
"release_status" : "stable",
"version" : "1.999815",
"version" : "1.999816",
"x_serialization_backend" : "JSON::PP version 2.97001"
}
......@@ -20,5 +20,5 @@ no_index:
requires:
Math::Complex: '1.39'
perl: '5.006001'
version: '1.999815'
version: '1.999816'
x_serialization_backend: 'CPAN::Meta::YAML version 0.018'
......@@ -15,15 +15,15 @@ not run its Makefile.PL or Build.PL.
Hash: SHA1
SHA256 961f8c23b6fc94cb9766265257dd548b190087df0c71dfd7d994bc649af5f002 BUGS
SHA256 df17bd7189f124c8d1670af929b6acf5e9933aefc640edebab4001185b33fcde CHANGES
SHA256 fe244a635f607ea79c558c3a13d37b544e685eaf3415edc94260cea51e6cbf4f CHANGES
SHA256 7d84c6e69ee6c3ab6301314d2fa4bc233f24bd36a4a546b2cfd05a078bda98b7 CREDITS
SHA256 fd8f78318c23adef95971cc01ee0e79d68f52f60b761ba28129c8509fff46954 GOALS
SHA256 28e80ee628ff111dd34a2a26af921693c9c823caadab30c848e4c4f4fc00830f HISTORY
SHA256 b857edab549ac6893e2df5e1ec768ee46b62bcf1607a55e876f4d23f079eacce LICENSE
SHA256 6d73cd7ad314a791923e670599e2f9a3df5ed0623b6bb1ec7c5fbae1489cb95f MANIFEST
SHA256 9967e6c84df5fb6079ae0263d4363d95cb3b42669c6bf2d74eee9b20575745aa MANIFEST
SHA256 7ed7c42f0ac867d31943d9dd69c5eeac4014ac676bb2e160adf7cee5ab33f2c4 MANIFEST.SKIP
SHA256 d5ab0befdcd8983662dc54bab21918dbd1ffdec317065290561c209ad115dc1c META.json
SHA256 d8a94d92e80a8d7d75ab935313a9903238d248d66f0f8987303bf95c90346e06 META.yml
SHA256 13f0b7a32e8970d03431066454f5077cb49accdb3f8bb0d4d2f1d52068a8a022 META.json
SHA256 d02351b2a1b37de67fd83370a6c98894748b7468091e26f1a13543653bb6f573 META.yml
SHA256 826e110bea2fd63eec15cae2115a1365f9cbef0c5fa4554e70fe9a153f2bf2a3 Makefile.PL
SHA256 99f7f7df45a00c9f19ad38edec8c5dad5f5977c2b1a14ac3bb491ac193db1f7d NEW
SHA256 9672f35169c70213ef469a42d2e1c36ae1889492be9d0a010458cecfb32b30fb README
......@@ -31,15 +31,15 @@ SHA256 267a279d88f5e3e555a6788cf5cf6f4085c24f0575e810ec7dbc3ea450704c86 TODO
SHA256 77a80748e329a042faaa91eb0b44a493dfdfd726fec854a1a376c8404324b485 examples/1000.txt
SHA256 702e323f59be58db758a3fa70ffe5fb80d392043bb855b0f172dd748809435df examples/bigprimes.pl
SHA256 81a3ff3476038ec839c12a2b3548898055112bebc81fbf3513ee5efd6adfd0bd examples/prime.pl
SHA256 b049e3948abdd366f0dce144ada26e3d85c9759418d49ccb3ddef7aa9582d03e lib/Math/BigFloat.pm
SHA256 c0e98bccfac7c73c4d6b6834f75287198205d1bb53bb981cdb68a0ee34cd5bd2 lib/Math/BigInt.pm
SHA256 73f0996f70f302bb17d70913a1feebebae364d11938a9bde3347c791db0ef9b3 lib/Math/BigInt/Calc.pm
SHA256 ac5effb1a821c3e9acf9cdc55a71c3ae4b0fd772e00cfe759a54478a73d3885f lib/Math/BigInt/Lib.pm
SHA256 5f40084f9a971786ecf6584678140a703966b03edef83ea0a8db8a539a3eb4c5 lib/Math/BigFloat.pm
SHA256 aa86573816540ef9a00a76697b456d1b410b40aa62df1d8adb4595344ffa1be3 lib/Math/BigInt.pm
SHA256 0a596afee81b522cc24a6cf403dbfb99aa5548338e8977562352ddcd40fc6806 lib/Math/BigInt/Calc.pm
SHA256 e0081553829e20557f63a3805a85290cddc8fd145b573669d9300cf7af6ff87c lib/Math/BigInt/Lib.pm
SHA256 e887b97b1d39e2e8ff68cf06009bc5ee55f16bfdeaf53a1c18712a510f67568c t/00sig.t
SHA256 1a11bbacf4b402399c82c831ab717e672a8a0144794e5359bdbb5376a2dadb79 t/01load.t
SHA256 4e5136c0d8fb9e26fb6e1bd67e7584129fe5b22963e6c093f80b3025ab91fd8c t/Math/BigFloat/Subclass.pm
SHA256 cc82c425ffbc4a9d36c6a875b47a0501d6d2eab2a6bc395b1e90e9d5b33b0067 t/Math/BigInt/BareCalc.pm
SHA256 83bcd118064216ddc1563914af8c09d15b848865c1909b60108e92ebdd97d222 t/Math/BigInt/Lib/Minimal.pm
SHA256 6d65b414f524c3ce6616357af20f91d0082a060e61299a84bebc3e091c050405 t/Math/BigInt/Lib/Minimal.pm
SHA256 400f4b0e486d7b9dad8eb9b2d5dc771dd862aac9dddf986588876ab38d93ca2d t/Math/BigInt/Lib/TestUtil.pm
SHA256 1110d81ea57001952f81a7a93c81b6fd1ca397a4ef146d06c239dcbf37835318 t/Math/BigInt/Scalar.pm
SHA256 1b52aeafb492d426a2cf19f20221589e5036dad75c30aa6376938f2f80049aa0 t/Math/BigInt/Subclass.pm
......@@ -181,13 +181,15 @@ SHA256 78d9aab67b41dba36184056f58b8a3e9164bc403d76d9ab42f221456408634c8 t/bigint
SHA256 4c4a4aab0fb5683443854ac590de2a7a6f4e1747e382ac3d36cdecd87f652ddc t/biglog.t
SHA256 075d59b713187cd780c7dcf82f409cc1ac4ec3599fda69fffac7fa625dac6961 t/bigroot.t
SHA256 66022ed6c1c42f9f0790f2f1088f32403b4b44ed05a339de59578a9a877e2347 t/blucas-mbi.t
SHA256 547f4a405f05243e84a91334d3a07b0494cc7fc37eb793fa0cf81515d1950eea t/bnok-mbf.t
SHA256 cc567087fb8fb651cd92ff380ad6af89db928533e52f126950fdaa3c2e77ede6 t/bnok-mbi.t
SHA256 91311eb8d25e5e42ffd09283dca9e18e9576aebbfac262a47393bc1a34932124 t/bnstr-mbf.t
SHA256 0e116f7293a0660ffb100b107132abadbeaacb7aa5097b8564bcb37c4a2dd011 t/bnstr-mbi.t
SHA256 5be670a9a13b7d6fe6894829312285c907bcc93b253ecb28568e1e79eb33cd75 t/bsstr-mbf.t
SHA256 8d64ff3e496cdd8dcd78b894723524d0891ab608eeb20b41a1ebb8a9585cab1d t/bsstr-mbi.t
SHA256 1e1607a451727e7d4f94d405990a489ba16f9312069ed79cb2aaa782fe9fff55 t/calling-class-methods.t
SHA256 a6a0ff863549987dd53acbf7eb5ee3e1333816f2f79fea585c2af960ae81c658 t/calling-instance-methods.t
SHA256 3a44876d359a055cc64eb05c78cdf544ead1d1ae173e0429815d5f8bae6093fc t/calling.t
SHA256 7d5eb629c1d827d3d1ef2ff51be98de38b8b5974ec82950afadf8bf273f09b61 t/calling.t
SHA256 483d91ee8d0d81d5d709e4c342e87255b8052dd094d8d16aae3294d4ef90847a t/config.t
SHA256 29cc3af8923a486253b05425e1c98c49efbf9f6713a4e405ed72a4186884d661 t/const_mbf.t
SHA256 defccbdddf2b3fc71916a9bc96e6ebef145a691ef42753c18250a65d4f32ef27 t/constant.t
......@@ -253,11 +255,11 @@ SHA256 ae800b388554283ad632a3e6169e4181b0a20b10b6653147d1803e652c99809e t/use_mb
SHA256 302dc439220aaae4285bef252ead16b79f8545f37ac896a473ec154dcbaf11bf t/with_sub.t
-----BEGIN PGP SIGNATURE-----
iQEcBAEBAgAGBQJbygLbAAoJEGcmPl2fr166iRQH/jD/2FBp0jirVjJ+UkJne+bk
Pwr9MQamCU54uQXy0DobzO0SYjjKBIGSBZex58af7LJpvPKMYchr9lSbIrDrCIzE
gcz2fnfPNPOk9TRdfNTrBTEI8pWv7gVtCVaNJjGMxo85U/G7rQFPy0+8IW5M1i4P
9+y2wniUkq2jDnCIeTtleG/CwzYW4GT8EsT6ZzjJabGROECxOxaC9Czip8E45gFR
9lYBwB+/NP7DC0UYOszgMnLLvNlkBcDRBfoF9h0dXkvepYBlBx4PcKME0hpzDKuU
7BbvLaz4Rk+ApoYHWeSOl76zkawGp+uiwV2CGxlG//apffO0GasuFJZ2YP2LFAY=
=vZEk
iQEcBAEBAgAGBQJb003OAAoJEGcmPl2fr1664iAH/2hJeB5kygJb2e+KNxWFSACq
80tao5QsnRQY+hYmKX9zeyOotwEjJyPZSJk9a5oJjmeLr37KMEiVP3y1rwiAghA/
/eVgKU8Kpa4l7IRnRANOAMZMTPD2ivk6AmCDyO8IvJOaqRFjGqxaae7O2PG4xsCA
MwSJaAI3FmTYRqu/+NVX3nsXuBo83HUD7Hri9ztcIoapM4mIeC68rNxj3Q8ZOQzm
bQh11lRULh7ld6zzcva1ytwx4jI6cilCGfp9SOsHClJC0Qk8nfyVMYWPpnC3rgjG
MLV77Abgzxi/5CTOR2YslFFtr9DgBXNhK7WP0U/ihDB6mnwNEP5oTY2v1sSlQM0=
=i6CZ
-----END PGP SIGNATURE-----
......@@ -19,7 +19,7 @@ use warnings;
use Carp qw< carp croak >;
use Math::BigInt ();
our $VERSION = '1.999815';
our $VERSION = '1.999816';
our @ISA = qw/Math::BigInt/;
our @EXPORT_OK = qw/bpi/;
......@@ -2569,16 +2569,20 @@ sub bnok {
return $x if $x->modify('bnok');
return $x->bnan() if $x->is_nan() || $y->is_nan();
return $x->binf() if $x->is_inf();
return $x->bnan() if (($x->is_finite() && !$x->is_int()) ||
($y->is_finite() && !$y->is_int()));
my $u = $x->as_int();
$u->bnok($y->as_int());
my $xint = Math::BigInt -> new($x -> bsstr());
my $yint = Math::BigInt -> new($y -> bsstr());
$xint -> bnok($yint);
my $xflt = Math::BigFloat -> new($xint);
$x->{_m} = $u->{value};
$x->{_e} = $LIB->_zero();
$x->{_es} = '+';
$x->{sign} = '+';
$x->bnorm(@r);
$x->{_m} = $xflt->{_m};
$x->{_e} = $xflt->{_e};
$x->{_es} = $xflt->{_es};
$x->{sign} = $xflt->{sign};
return $x;
}
sub bsin {
......@@ -5133,7 +5137,7 @@ This method was added in v1.87 of Math::BigInt (June 2007).
In scalar context, divides $x by $y and returns the result to the given or
default accuracy/precision. In list context, does floored division
(F-division), returning an integer $q and a remainder $r so that $x = $q * $y +
$r. The remainer (modulo) is equal to what is returned by C<$x->bmod($y)>.
$r. The remainer (modulo) is equal to what is returned by C<< $x->bmod($y) >>.
=item bmod()
......
......@@ -20,7 +20,7 @@ use warnings;
use Carp qw< carp croak >;
our $VERSION = '1.999815';
our $VERSION = '1.999816';
require Exporter;
our @ISA = qw(Exporter);
......@@ -2521,74 +2521,85 @@ sub bexp {
}
sub bnok {
# Calculate n over k (binomial coefficient or "choose" function) as integer.
# set up parameters
my ($class, $x, $y, @r) = (ref($_[0]), @_);
# Calculate n over k (binomial coefficient or "choose" function) as
# integer.
# objectify is costly, so avoid it
# Set up parameters.
my ($self, $n, $k, @r) = (ref($_[0]), @_);
# Objectify is costly, so avoid it.
if ((!ref($_[0])) || (ref($_[0]) ne ref($_[1]))) {
($class, $x, $y, @r) = objectify(2, @_);
($self, $n, $k, @r) = objectify(2, @_);
}
return $x if $x->modify('bnok');
return $x->bnan() if $x->{sign} eq 'NaN' || $y->{sign} eq 'NaN';
return $x->binf() if $x->{sign} eq '+inf';
return $n if $n->modify('bnok');
# k > n or k < 0 => 0
my $cmp = $x->bacmp($y);
return $x->bzero() if $cmp < 0 || substr($y->{sign}, 0, 1) eq "-";
# All cases where at least one argument is NaN.
if ($LIB->can('_nok')) {
$x->{value} = $LIB->_nok($x->{value}, $y->{value});
} else {
# ( 7 ) 7! 1*2*3*4 * 5*6*7 5 * 6 * 7 6 7
# ( - ) = --------- = --------------- = --------- = 5 * - * -
# ( 3 ) (7-3)! 3! 1*2*3*4 * 1*2*3 1 * 2 * 3 2 3
return $n->bnan() if $n->{sign} eq 'NaN' || $k->{sign} eq 'NaN';
my $n = $x -> {value};
my $k = $y -> {value};
# All cases where at least one argument is +/-inf.
# If k > n/2, or, equivalently, 2*k > n, compute nok(n, k) as
# nok(n, n-k) to minimize the number if iterations in the loop.
{
my $twok = $LIB->_mul($LIB->_two(), $LIB->_copy($k));
if ($LIB->_acmp($twok, $n) > 0) {
$k = $LIB->_sub($LIB->_copy($n), $k);
if ($n -> is_inf()) {
if ($k -> is_inf()) { # bnok(+/-inf,+/-inf)
return $n -> bnan();
} elsif ($k -> is_neg()) { # bnok(+/-inf,k), k < 0
return $n -> bzero();
} elsif ($k -> is_zero()) { # bnok(+/-inf,k), k = 0
return $n -> bone();
} else {
if ($n -> is_inf("+")) { # bnok(+inf,k), 0 < k < +inf
return $n -> binf("+");
} else { # bnok(-inf,k), k > 0
my $sign = $k -> is_even() ? "+" : "-";
return $n -> binf($sign);
}
}
}
if ($LIB->_is_zero($k)) {
$n = $LIB->_one();
} else {
elsif ($k -> is_inf()) { # bnok(n,+/-inf), -inf <= n <= inf
return $n -> bnan();
}
# Make a copy of the original n, since we'll be modifying n
# in-place.
# At this point, both n and k are real numbers.
my $n_orig = $LIB->_copy($n);
my $sign = 1;
$LIB->_sub($n, $k);
$LIB->_inc($n);
if ($n >= 0) {
if ($k < 0 || $k > $n) {
return $n -> bzero();
}
} else {
my $f = $LIB->_copy($n);
$LIB->_inc($f);
if ($k >= 0) {
my $d = $LIB->_two();
# n < 0 and k >= 0: bnok(n,k) = (-1)^k * bnok(-n+k-1,k)
# while f <= n (the original n, that is) ...
$sign = (-1) ** $k;
$n -> bneg() -> badd($k) -> bdec();
while ($LIB->_acmp($f, $n_orig) <= 0) {
$LIB->_mul($n, $f);
$LIB->_div($n, $d);
$LIB->_inc($f);
$LIB->_inc($d);
}
}
} elsif ($k <= $n) {
# n < 0 and k <= n: bnok(n,k) = (-1)^(n-k) * bnok(-k-1,n-k)
$sign = (-1) ** ($n - $k);
my $x0 = $n -> copy();
$n -> bone() -> badd($k) -> bneg();
$k = $k -> copy();
$k -> bneg() -> badd($x0);
$x -> {value} = $n;
} else {
# n < 0 and n < k < 0:
return $n -> bzero();
}
}
$x->round(@r);
$n->{value} = $LIB->_nok($n->{value}, $k->{value});
$n -> bneg() if $sign == -1;
$n->round(@r);
}
sub bsin {
......@@ -5258,13 +5269,28 @@ See also L</blog()>.
$x->bnok($y); # x over y (binomial coefficient n over k)
Calculates the binomial coefficient n over k, also called the "choose"
function. The result is equivalent to:
function, which is
( n ) n!
| - | = -------
( n ) n!
| | = --------
( k ) k!(n-k)!
This method was added in v1.84 of Math::BigInt (April 2007).
when n and k are non-negative. This method implements the full Kronenburg
extension (Kronenburg, M.J. "The Binomial Coefficient for Negative Arguments."
18 May 2011. http://arxiv.org/abs/1105.3689/) illustrated by the following
pseudo-code:
if n >= 0 and k >= 0:
return binomial(n, k)
if k >= 0:
return (-1)^k*binomial(-n+k-1, k)
if k <= n:
return (-1)^(n-k)*binomial(-k-1, n-k)
else
return 0
The behaviour is identical to the behaviour of the Maple and Mathematica
function for negative integers n, k.
=item bsin()
......
......@@ -7,7 +7,7 @@ use warnings;
use Carp qw< carp croak >;
use Math::BigInt::Lib;
our $VERSION = '1.999815';
our $VERSION = '1.999816';
our @ISA = ('Math::BigInt::Lib');
......
......@@ -4,7 +4,7 @@ use 5.006001;
use strict;
use warnings;
our $VERSION = '1.999815';
our $VERSION = '1.999816';
use Carp;
......
......@@ -692,8 +692,8 @@ except that it might be much faster, depending on how the number is represented
internally.
For instance, if the object $obj represents the hexadecimal number 0xabcde,
then C<$obj->_rsft(2, 16)> returns an object representing the number 0xabc. The
"remainer", 0xde, is discarded and not returned.
then C<< $obj->_rsft(2, 16) >> returns an object representing the number 0xabc.
The "remainer", 0xde, is discarded and not returned.
=item I<_lsft(OBJ, N, B)>
......
This diff is collapsed.
This diff is collapsed.
......@@ -6,7 +6,7 @@ use strict;
use warnings;
use lib 't';
my $VERSION = '1.999815'; # adjust manually to match latest release
my $VERSION = '1.999816'; # adjust manually to match latest release
use Test::More tests => 5;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment