Logo Search packages:      
Sourcecode: csound version File versions  Download package

PUBLIC uint32_t csoundRandMT ( CsoundRandMTState *  p  ) 

Returns next random number from MT19937 generator. The PRNG must be initialised first by calling csoundSeedRandMT().

Definition at line 90 of file random.c.

References csoundRandMT().

Referenced by csoundRandMT().

{
    int       i = p->mti;
    uint32_t  y;

    if (i >= N) {                   /* generate N words at one time */
      MT_update_state(&(p->mt[0]));
      i = 0;
    }
    y = p->mt[i];
    p->mti = i + 1;
    /* Tempering */
    y ^= (y >> 11);
    y ^= (y << 7) & (uint32_t) 0x9D2C5680U;
    y ^= (y << 15) & (uint32_t) 0xEFC60000U;
    y ^= (y >> 18);

    return y;
}


Generated by  Doxygen 1.6.0   Back to index