Struct Mrg32k3aState
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
s10uintx1[n-3], below 4294967087.
s11uintx1[n-2], below 4294967087.
s12uintx1[n-1], below 4294967087.
s20uintx2[n-3], below 4294944443.
s21uintx2[n-2], below 4294944443.
s22uintx2[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
valuesuint[]The six values; the array is copied, not held.
Exceptions
- ArgumentNullException
valuesis 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
Properties
DefaultSeed
Gets the default seed of L'Ecuyer et al. (2002), six copies of 12345.
public static Mrg32k3aState DefaultSeed { get; }
Property Value
this[int]
Gets one of the six values in state order.
public uint this[int index] { get; }
Parameters
indexintA position from zero to five.
Property Value
Exceptions
- ArgumentOutOfRangeException
indexis 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
otherMrg32k3aStateAn object to compare with this object.
Returns
Equals(object?)
Indicates whether this instance and a specified object are equal.
public override bool Equals(object? obj)
Parameters
objobjectThe object to compare with the current instance.
Returns
- bool
true if
objand 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
valuesuint[]The candidate values.
stateMrg32k3aStateReceives the state when the values are valid, otherwise default.
errorstringReceives a description of the first rule broken, or null.
Returns
Operators
operator ==(Mrg32k3aState, Mrg32k3aState)
Compares two states for equality.
public static bool operator ==(Mrg32k3aState left, Mrg32k3aState right)
Parameters
leftMrg32k3aStateThe first state.
rightMrg32k3aStateThe second state.
Returns
operator !=(Mrg32k3aState, Mrg32k3aState)
Compares two states for inequality.
public static bool operator !=(Mrg32k3aState left, Mrg32k3aState right)
Parameters
leftMrg32k3aStateThe first state.
rightMrg32k3aStateThe second state.