package umontreal.iro.lecuyer.hups;

/* *
 * Title:        

* Description:

* Copyright: Copyright (c)

* Company:

* @author * @version 1.0 */ import umontreal.iro.lecuyer.util.PrintfFormat; /** * This class implements Korobov lattices, which are the same point sets * as in class {@link LCGPointSet}, but implemented differently. * The parameters are the modulus n and the multiplier a, for arbitrary * integers * 1 <= a < n. The number of points is n, their dimension is * s, and they are defined by *

*

*
* ui = (i/n)(1, a, a2,…, as-1) mod 1 *

* for * i = 0,..., n - 1. * *

* It is also possible to build a ``shifted'' Korobov lattice with the first * t coordinates rejected. The s-dimensionnal points are then defined as *

*

*
* ui = (i/n)(at, at+1, at+2,…, at+s-1) mod 1 *

* for * i = 0,..., n - 1 and fixed t. * */ public class KorobovLattice extends Rank1Lattice { protected int genA; // Multiplier a. // Method modPower is inherited from Rank1Lattice. /** * Instantiates a Korobov lattice point set with modulus n and * multiplier a in dimension s. * */ public KorobovLattice (int n, int a, int s) { super (n, null, 0); if (a < 1 || a >= n) throw new IllegalArgumentException ("KorobovLattice must have 1 <= a < n"); genA = a; dim = s; v = new double[s]; long[] B = new long[dim]; B[0] = 1; v[0] = normFactor; for (int j = 1; j < dim; j++) { B[j] = (a * B[j - 1]) % n; v[j] = normFactor * B[j]; } } /** * Instantiates a shifted Korobov lattice point set with modulus n and * multiplier a in dimension s. The first t coordinates of a * standard Korobov lattice are dropped as described above. * The case t = 0 corresponds to the standard Korobov lattice. * */ public KorobovLattice (int n, int a, int s, int t) { super (n, null, 0); if (a < 1 || a >= n) throw new IllegalArgumentException ("KorobovLattice must have 1 <= a < n"); if (t < 1) throw new IllegalArgumentException ("KorobovLattice: must have 0 < t"); dim = s; genA = a; v = new double[s]; long[] B = new long[dim]; int j; B[0] = a; for (j = 1; j < t; j++) B[0] *= a; v[0] = B[0] * normFactor; for (j = 1; j < dim; j++) { B[j] = (a * B[j - 1]) % n; v[j] = normFactor * B[j]; } } /** * Returns the multiplier a of the lattice. * */ public int getA() { return genA; } public String toString() { StringBuffer sb = new StringBuffer ("KorobovLattice:" + PrintfFormat.NEWLINE); sb.append ("Multiplier a: " + genA + PrintfFormat.NEWLINE); sb.append (super.toString()); return sb.toString(); } }

Ads help maintain this website.