Pcg32.CreateStreamPartition Method

Creates a jump-based stream partition for generating independent RNG streams.

Definition

Namespace: Numerics.NET.Random
Assembly: Numerics.NET (in Numerics.NET.dll) Version: 10.3.0
C#
public static RandomStreamPartition<Pcg32> CreateStreamPartition(
	 in RandomOptions options,
	JumpStride stride,
	ulong startIndex = 0
)

Parameters

options  RandomOptions
The base initialization options for the stream partition.
stride  JumpStride
The jump stride to use for spacing between streams.
startIndex  UInt64  (Optional)
The starting index for stream enumeration (default is 0).

Return Value

RandomStreamPartition<Pcg32>
A new RandomStreamPartition<TRandom> instance.

Remarks

This method creates a jump-based hierarchical stream source (RngStreams-style) that uses jump operations to partition the RNG sequence into disjoint segments.

The startIndex parameter sets the initial enumeration offset, allowing streams to start at a specific jump position in the sequence.

Use NextStream() or NextStreams(Int32) to generate streams. Stream generation is O(N) for N streams.

Example

C#
var options = new RandomOptions(42);
var partition = Pcg32.CreateStreamPartition(in options, JumpStride.Jump, startIndex: 5);
var rng5 = partition.NextStream(); // Stream at jump position 5
var rng6 = partition.NextStream(); // Stream at jump position 6

See Also