Class LinearCongruentialGenerator

Linear congruential generator for random number generating that can be seeded.

Follows the implementation of include/tvm/support/random_engine.h, which follows the sepcification in https://en.cppreference.com/w/cpp/numeric/random/linear_congruential_engine.

Note Number.MAX_SAFE_INTEGER = 2^53 - 1, and our intermediates are strictly less than 2^48.

Hierarchy

  • LinearCongruentialGenerator

Constructors

Properties

increment: number
modulus: number
multiplier: number

Methods

  • Generate the next integer in the range (0, this.modulus) non-inclusive, updating rand_state.

    Postcondition: pass checkRandState(), i.e. rand_state > 0 and is an integer.

    Returns number

  • Generates random float between (0, 1) non-inclusive, updating rand_state.

    Postcondition: pass checkRandState(), i.e. rand_state > 0 and is an integer.

    Returns number

  • Sets rand_state after normalized with modulus to ensure that it is within range.

    Parameters

    • seed: number

      Any integer. Used to set rand_state after normalized with modulus.

      Postcondition: pass checkRandState(), i.e. rand_state > 0 and is an integer.

    Returns void

Generated using TypeDoc