Next: , Previous: , Up: .Net Interface   [Index]


13.6 MPIR.Net Random Numbers

Class: MpirRandom : IDisposable

The MPIR.Net class that wraps the MPIR random number functions is MpirRandom. It holds an algorithm selection and current state, as per gmp_randstate_t. As the multi-precision classes, MpirRandom allocates unmanaged memory, and should be disposed of via its IDisposable implementation when no longer in use.

Static Method: static MpirRandom Default ()
Static Method: static MpirRandom MersenneTwister ()
Static Method: static MpirRandom LinearCongruential (HugeInt a, ulong/uint c, ulong/uint m)
Static Method: static MpirRandom LinearCongruential (ulong/uint size)

In lieu of constructors, MpirRandom uses more descriptive static factory methods to create new instances of specific random number generator algorithms.

Method: MpirRandom Copy ()

Creates a new random number generator with a copy of the algorithm and state from the source instance.

Method: void Seed (ulong/uint seed)
Method: void Seed (HugeInt seed)

Sets an initial seed value into the random number generator.

Method: ulong/uint GetLimbBits (ulong/uint bitCount)

Generates a uniformly distributed random number of bitCount bits, i.e. in the range 0 to 2^bitCount-1 inclusive.

Method: ulong/uint GetLimb (ulong/uint max)

Generates a uniformly distributed random number in the range 0 to max-1 inclusive.

Method: IntegerExpression GetIntBits (ulong/uint bitCount)
Method: IntegerExpression GetIntBitsChunky (ulong/uint bitCount)

Returns an expression that generates a uniformly distributed random integer in the range 0 to 2^bitCount-1, inclusive.

Method: IntegerExpression GetInt (IntegerExpression max)

Returns an expression that generates a uniformly distributed random number in the range 0 to max-1 inclusive.

Method: FloatExpression GetFloat ()

Returns an expression that generates a uniformly distributed random float in the range 0 <= n < 1. As with all float expressions, precision of the destination is used when available.

Method: FloatExpression GetFloatBits (ulong/uint bitCount)

Returns an expression that generates a uniformly distributed random float in the range 0 <= n < 1, with the specified number of significant mantissa bits.

Method: FloatExpression GetFloatChunky (int maxExponent)

Returns an expression that generates a random float with long strings of zeros and ones in the binary representation, using the precision of the destination. The argument is the maximum absolute value for the exponent of the generated number, expressed in limbs.

Method: FloatExpression GetFloatLimbsChunky (long limbCount, int maxExponent)

Returns an expression that generates a random float with long strings of zeros and ones in the binary representation, and the specified number of significant limbs in the mantissa.


Next: , Previous: , Up: .Net Interface   [Index]