Pseudo-random numbers/Combined recursive generator MRG32k3a: Difference between revisions
Pseudo-random numbers/Combined recursive generator MRG32k3a (view source)
Revision as of 20:00, 20 January 2021
, 3 years ago→{{header|Perl}}: proper use of package/class
SqrtNegInf (talk | contribs) m (→{{header|Perl}}: fixed package syntax, as was done with the others in series) |
SqrtNegInf (talk | contribs) (→{{header|Perl}}: proper use of package/class) |
||
Line 246:
package MRG32k3a {
};
our @a1 = < 0 1403580 -810728>;▼
our @a2 = <527612 0 -1370589>;▼
use Const::Fast;
sub new { @x1 = @x2 = ($_[2], 0, 0) }▼
sub new {
my ($class,undef,$seed) = @_;
bless {x1 => \@x1, x2 => \@x2}, $class;
}
sub next_int {
my ($class,$self) = @_;
unshift @
unshift @{$$self{x2}}, ($
($$self{x1}[0] - $$self{x2}[0]) % (m1 + 1)
}
sub next_float { next_int(@_) / (
}
|