Example usage for org.apache.commons.math3.random Well1024a setSeed

List of usage examples for org.apache.commons.math3.random Well1024a setSeed

Introduction

In this page you can find the example usage for org.apache.commons.math3.random Well1024a setSeed.

Prototype

@Override
public void setSeed(final int seed) 

Source Link

Document

Reinitialize the generator as if just built with the given int seed.

Usage

From source file:com.ibm.bi.dml.runtime.matrix.data.LibMatrixDatagen.java

/**
 * A matrix of random numbers is generated by using multiple seeds, one for each 
 * block. Such block-level seeds are produced via Well equidistributed long-period linear 
 * generator (Well1024a). For a given seed, this function sets up the block-level seeds.
 * /*from  w ww.  j  ava  2 s  . c  o  m*/
 * This function is invoked from both CP (RandCPInstruction.processInstruction()) 
 * as well as MR (RandMR.java while setting up the Rand job).
 * 
 * @param seed
 * @return
 */
public static Well1024a setupSeedsForRand(long seed) {
    long lSeed = (seed == DataGenOp.UNSPECIFIED_SEED ? DataGenOp.generateRandomSeed() : seed);
    LOG.trace("Setting up RandSeeds with initial seed = " + lSeed + ".");

    Random random = new Random(lSeed);
    Well1024a bigrand = new Well1024a();
    //random.setSeed(lSeed);
    int[] seeds = new int[32];
    for (int s = 0; s < seeds.length; s++)
        seeds[s] = random.nextInt();
    bigrand.setSeed(seeds);

    return bigrand;
}