Table of Contents

Struct Mrg32k3aState

Namespace
Mrg32k3a.NET
Assembly
Mrg32k3a.NET.dll

The six values that make up a position of the MRG32k3a generator, used both as a factory seed and as the state of a stream.

public readonly struct Mrg32k3aState : IEquatable<Mrg32k3aState>
Implements
Inherited Members

Remarks

The first three values belong to the first component, in the order x1[n-3], x1[n-2], x1[n-1]; the last three belong to the second component in the same order. Every constructor enforces the seed rules of L'Ecuyer et al. (2002): the first three values below 4294967087 and not all zero, the last three below 4294944443 and not all zero.

The default value is all zeros, which breaks those rules. It is rejected wherever a seed is accepted.

Constructors

Mrg32k3aState(uint, uint, uint, uint, uint, uint)

Creates a state from its six values.

public Mrg32k3aState(uint s10, uint s11, uint s12, uint s20, uint s21, uint s22)

Parameters

s10 uint

x1[n-3], below 4294967087.

s11 uint

x1[n-2], below 4294967087.

s12 uint

x1[n-1], below 4294967087.

s20 uint

x2[n-3], below 4294944443.

s21 uint

x2[n-2], below 4294944443.

s22 uint

x2[n-1], below 4294944443.

Exceptions

ArgumentException

The values break one of the seed rules.

Mrg32k3aState(uint[])

Creates a state from an array of six values in state order.

public Mrg32k3aState(uint[] values)

Parameters

values uint[]

The six values; the array is copied, not held.

Exceptions

ArgumentNullException

values is null.

ArgumentException

The values break one of the seed rules.

Fields

Length

Number of values in a state.

public const int Length = 6

Field Value

int

Properties

DefaultSeed

Gets the default seed of L'Ecuyer et al. (2002), six copies of 12345.

public static Mrg32k3aState DefaultSeed { get; }

Property Value

Mrg32k3aState

this[int]

Gets one of the six values in state order.

public uint this[int index] { get; }

Parameters

index int

A position from zero to five.

Property Value

uint

Exceptions

ArgumentOutOfRangeException

index is outside zero to five.

Methods

Equals(Mrg32k3aState)

Indicates whether the current object is equal to another object of the same type.

public bool Equals(Mrg32k3aState other)

Parameters

other Mrg32k3aState

An object to compare with this object.

Returns

bool

true if the current object is equal to the other parameter; otherwise, false.

Equals(object?)

Indicates whether this instance and a specified object are equal.

public override bool Equals(object? obj)

Parameters

obj object

The object to compare with the current instance.

Returns

bool

true if obj and this instance are the same type and represent the same value; otherwise, false.

GetHashCode()

Returns the hash code for this instance.

public override int GetHashCode()

Returns

int

A 32-bit signed integer that is the hash code for this instance.

ToArray()

Returns the six values in state order.

public uint[] ToArray()

Returns

uint[]

A new array of six unsigned integers.

ToString()

Returns the six values separated by commas.

public override string ToString()

Returns

string

A single line of text.

TryCreate(uint[]?, out Mrg32k3aState, out string?)

Tries to create a state from an array of six values in state order.

public static bool TryCreate(uint[]? values, out Mrg32k3aState state, out string? error)

Parameters

values uint[]

The candidate values.

state Mrg32k3aState

Receives the state when the values are valid, otherwise default.

error string

Receives a description of the first rule broken, or null.

Returns

bool

true when the values form a usable state.

Operators

operator ==(Mrg32k3aState, Mrg32k3aState)

Compares two states for equality.

public static bool operator ==(Mrg32k3aState left, Mrg32k3aState right)

Parameters

left Mrg32k3aState

The first state.

right Mrg32k3aState

The second state.

Returns

bool

true when all six values match.

operator !=(Mrg32k3aState, Mrg32k3aState)

Compares two states for inequality.

public static bool operator !=(Mrg32k3aState left, Mrg32k3aState right)

Parameters

left Mrg32k3aState

The first state.

right Mrg32k3aState

The second state.

Returns

bool

true when any of the six values differ.