IJumpable Interface

Represents an RNG that supports jumping by large, fixed strides.

Definition

Namespace: Numerics.NET.Random
Assembly: Numerics.NET (in Numerics.NET.dll) Version: 10.3.0
C#
public interface IJumpable : IAdvanceable
Implements
IAdvanceable

Remarks

A jumpable RNG can efficiently advance its state by large, algorithm-defined strides. This is particularly useful for:

  • Creating independent parallel streams with guaranteed non-overlap
  • Spawning subsequences for distributed computing
  • Partitioning a single sequence across multiple processors

Jump Operations:

This interface exposes two canonical jump operations: Jump(UInt64) and LongJump(UInt64). Each advances the RNG by a fixed, algorithm-specific distance described by JumpSize and LongJumpSize respectively.

If an RNG only supports a single jump distance, both JumpSize and LongJumpSize will report the same value, and LongJump() will delegate to Jump().

Jump Sizes:

The JumpSize and LongJumpSize properties provide metadata about the jump distances. These are informational and fixed per algorithm.

  Important

Jump operations are designed for block splitting, not for creating independent streams. Each jump advances along the same sequence. For true independent streams, use RNGs with native stream support (e.g., counter-based RNGs with stream IDs).

  Caution

Jump operations on Xoshiro/Xoroshiro generators have O(1) time complexity and are very fast. However, jumping on some RNGs (e.g., PCG with advancement) may have O(log n) complexity. Check the specific RNG documentation for performance characteristics.

Example

C#
// Create a base RNG and inspect its jump capabilities
var rng = new Xoshiro256Plus(42);
var jumpable = (IJumpable)rng;

Console.WriteLine($"Jump size: {jumpable.JumpSize}");
Console.WriteLine($"Long jump size: {jumpable.LongJumpSize}");

// Spawn independent streams by jumping
var streams = new Xoshiro256Plus[4];
streams[0] = new Xoshiro256Plus(42);
for (int i = 1; i < 4; i++)
{
    streams[i] = new Xoshiro256Plus(42);
    ((IJumpable)streams[i]).Jump((ulong)i);
}

// Use long jump for even greater separation
var distantStream = new Xoshiro256Plus(42);
((IJumpable)distantStream).LongJump();

Properties

JumpSize Gets the size category of the primary jump operation.
LongJumpSize Gets the size category of the long jump operation.

Methods

Advance Advances the RNG state by the specified number of outputs.
(Inherited from IAdvanceable)
Jump Jumps the RNG forward by the specified number of primary jump strides.
LongJump Jumps the RNG forward by the specified number of long jump strides.

See Also