RandomStreams.CreatePartitionedStreams<TRandom> Method

Creates an array of random number generators using jump-based stream partitioning.

Definition

Namespace: Numerics.NET.Random
Assembly: Numerics.NET (in Numerics.NET.dll) Version: 10.3.0
C#
public static TRandom[] CreatePartitionedStreams<TRandom>(
	int count,
	 in RandomOptions options,
	JumpStride stride,
	ulong startIndex = 0
)
where TRandom : Object, IRandomSourceFactory<TRandom>, IJumpable

Parameters

count  Int32
The number of generators to create (must be non-negative).
options  RandomOptions
The initialization options for the base RNG.
stride  JumpStride
The jump stride to use for spacing between streams.
startIndex  UInt64  (Optional)
The starting index for stream enumeration (default is 0).

Type Parameters

TRandom

Return Value

TRandom[]
An array of count RNG instances.

Remarks

This method creates streams using jump-based partitioning (RngStreams-style). Streams are generated by jumping forward along a single sequence.

The startIndex parameter allows starting enumeration at a specific offset. For example, startIndex = 5 produces streams at jump positions 5, 6, 7, etc.

Stream creation is O(N) for N streams, with each stream requiring one jump operation. The stride controls the spacing between streams:

  • Jump: Standard jump distance
  • LongJump: Extended jump distance

Example

C#
var options = new RandomOptions(42);
var streams = RandomStreams.CreatePartitionedStreams<Pcg64>(
    10, in options, JumpStride.Jump, startIndex: 5);
// Produces 10 streams starting at jump position 5

Exceptions

ArgumentOutOfRangeExceptioncount is negative.

See Also