package umontreal.iro.lecuyer.hups;
/* *
* Title:
* Description:
* Copyright: Copyright (c)
* Company:
* @author
* @version 1.0
*/
import umontreal.iro.lecuyer.util.PrintfFormat;
/**
* This class implements a digital net in base 2 starting from a
* linear feedback shift register generator. It is exactly the same
* point set as the one defined in the class
* {@link umontreal.iro.lecuyer.hups.F2wCycleBasedLFSR F2wCycleBasedLFSR}.
* See the description
* of this class for more details on the way the point set is constructed.
*
*
* Constructing a point set using this class, instead of using
* {@link umontreal.iro.lecuyer.hups.F2wCycleBasedLFSR F2wCycleBasedLFSR},
* makes SSJ construct a digital net in base 2. This is useful if one
* wants to randomize using one of the randomizations included in the class
* {@link umontreal.iro.lecuyer.hups.DigitalNet DigitalNet}.
*
*/
public class F2wNetLFSR extends DigitalNetBase2
{
private F2wStructure param;
/* *
* Constructs and stores the set of cycles for an LCG with
* modulus n and multiplier a.
* If pgcd(a, n) = 1, this constructs a full-period LCG which has two
* cycles, one containing 0 and one, the LCG period.
*
* @param n required number of points and modulo of the LCG
*
* @param a generator a of the LCG
*
*
*/
/**
* Constructs a point set with 2rw points. See the description of the class
* {@link umontreal.iro.lecuyer.hups.F2wStructure F2wStructure}
* for the meaning of the parameters.
*
*/
public F2wNetLFSR (int w, int r, int modQ, int step, int nbcoeff,
int coeff[], int nocoeff[], int dim)
{
param = new F2wStructure (w, r, modQ, step, nbcoeff, coeff, nocoeff);
param.initParamLFSR ();
initNet (r, w, dim);
}
/**
* Constructs a point set after reading its parameters from
* file filename; the parameters are located at line numbered no
* of filename. The available files are listed in the description of class
* {@link umontreal.iro.lecuyer.hups.F2wStructure F2wStructure}.
*
*/
public F2wNetLFSR (String filename, int no, int dim)
{
param = new F2wStructure (filename, no);
param.initParamLFSR ();
initNet (param.r, param.w, dim);
}
public String toString ()
{
String s = "F2wNetLFSR:" + PrintfFormat.NEWLINE;
return s + param.toString ();
}
private void initNet (int r, int w, int dim)
{
numCols = r * w;
numRows = 31;
outDigits = 31;
numPoints = (1 << numCols);
this.dim = dim;
normFactor = 1.0 / (1L << 31);
genMat = new int[dim * numCols];
for (int j = 0; j < numCols; j++) {
param.state = 1 << (r * w - 1 - j);
param.initF2wLFSR ();
genMat[j] = param.output;
for (int i = 1; i < dim; i++) {
param.F2wLFSR ();
genMat[i * numCols + j] = param.output;
}
}
}
}
Ads help maintain this website.