php8.5
Home/ Manual/ engine / xoshiro256starstar/ Random\Engine\Xoshiro256StarStar::jumpLong

Random\Engine\Xoshiro256StarStar::jumpLong

PHP function Edit on GitHub ✎

(PHP 8 >= 8.2.0)

Efficiently move the engine ahead by 2^192 steps

Description

Random\Engine\Xoshiro256StarStar::jumpLong(): void

Moves the algorithm’s state ahead by 2192 steps, as if Random\Engine\Xoshiro256StarStar::generate() was called 2192 times.

The purpose of a long jump is to facilitate the creation of a new Random\Engine\Xoshiro256StarStar engine from an existing seeded Random\Engine\Xoshiro256StarStar engine. The seeded engine acts as a blueprint, which can be cloned and repeatedly jumped to create 264 non-overlapping sequences with 2192 values each.

Long jumping may be combined with Random\Engine\Xoshiro256StarStar::jump()ing to further split each of the 264 sequences generated by long jumping, into 264 sequences of 2128 values each.

Parameters Parameters

Return Values

Void

Examples

Random\Engine\Xoshiro256StarStar::jumpLong() example

php
<?php
$blueprintRng = new \Random\Engine\Xoshiro256StarStar(0);

// Each parent engine will have its own chunk of 2**192 values.
$parent1 = clone $blueprintRng;
$blueprintRng->jumpLong();

$parent2 = clone $blueprintRng;
$blueprintRng->jumpLong();

// Each of the child engines will have its own chunk of 2**128 values
// taken from their parent engine’s chunk of 2**192 values.
$child1a = clone $parent1;
$parent1->jump();
$child1b = clone $parent1;
$parent1->jump();

$child2a = clone $parent2;
$parent2->jump();
$child2b = clone $parent2;
$parent2->jump();

echo "Child 1A: ", bin2hex($child1a->generate()), "\n";
echo "Child 1B: ", bin2hex($child1b->generate()), "\n";
echo "Child 2A: ", bin2hex($child2a->generate()), "\n";
echo "Child 2B: ", bin2hex($child2b->generate()), "\n";
?>

The above example will output:

output
Child 1A: b4f275cb365fec99
Child 1B: 2cd646c8ed156237
Child 2A: eb3729a722a504e7
Child 2B: d4208dc85bdd6dc3

See Also

Source: reference/random/random/engine/xoshiro256starstar/jumplong.xml · from the official PHP manual (php/doc-en)