package umontreal.iro.lecuyer.hups;
/* *
* Title:
* Description:
* Copyright: Copyright (c)
* Company:
* @author
* @version 1.0
*/
/**
* This class implements Hammersley point sets,
* which are defined as follows.
* Let
* 2 = b1 < b2 < ... denote the sequence of all prime
* numbers by increasing order.
* The Hammersley point set with n points in s dimensions contains
* the points
*
*
*
* ui = (i/n, ψb1(i), ψb2(i),..., ψbs-1(i)),
*
* for
* i = 0,..., n - 1, where ψb is the radical inverse function
* in base b, defined in {@link RadicalInverse}.
* This class is not a subclass of {@link DigitalNet}, because the basis
* is not the same for all coordinates.
* We do obtain a net in a generalized sense if
*
* n = b1k1 = b2k2 = ... = bs-1ks-1
* for some integers
* k1,..., ks-1.
*
*
* The points of a Hammersley point set can be ``scrambled'' by applying a
* permutation to the digits of i before computing each coordinate. If
*
*
*
* i = a0 + a1bj + ... + akj-1bjkj-1,
*
* and πj is a permutation of the digits
* {0,..., bj -1}, then
*
*
*
* ψbj(i) = ∑r=0kj-1arbj-r-1
*
* is replaced by
*
*
*
* ui, j = ∑r=0kj-1πj[ar]bj-r-1.
*
* The permutations πj can be deterministic or random.
* One (deterministic) possibility implemented here is to use
* the Faure permutation of
* {0,..., bj} for πj, for each
* coordinate j > 0.
*
*/
public class HammersleyPointSet extends PointSet {
private int[] base; // Vector of prime bases.
private int[][] permutation; // Digits permutation, for each dimension.
private boolean permuted; // Permute digits?
/**
* Constructs a new Hammersley point set with n points in dim
* dimensions.
*
* @param n number of points
*
* @param dim dimension of the point set
*
*/
public HammersleyPointSet (int n, int dim) {
if (n < 0 || dim < 1)
throw new IllegalArgumentException
("Hammersley point sets must have positive dimension and n >= 0");
numPoints = n;
this.dim = dim;
if (dim > 1)
base = RadicalInverse.getPrimes (dim - 1);
}
/**
* Permutes the digits using Faure permutations for all coordinates.
* After the method is called, the coordinates ui, j are generated via
*
*
*
* ui, j = ∑r=0k-1πj[ar]bj-r-1,
*
* for
* j = 1,..., s - 1 and
* ui, 0 = i/n,
* where πj is the Faure permutation of
* {0,..., bj -1}.
*
*/
public void addFaurePermutations() {
if (dim > 1) {
permutation = new int[dim][];
for (int i = 0; i < dim - 1; i++) {
permutation[i] = new int[base[i]];
RadicalInverse.getFaurePermutation (base[i], permutation[i]);
}
}
permuted = true;
}
/**
* Erases the Faure permutations: from now on, the digits will not be
* Faure permuted.
*
*/
public void ErasePermutations() {
permuted = false;
permutation = null;
}
public double getCoordinate (int i, int j) {
if (j == 0)
return (double) i / (double) numPoints;
if (permuted)
return RadicalInverse.permutedRadicalInverse
(base[j - 1], permutation[j - 1], i);
else
return RadicalInverse.radicalInverse (base[j - 1], i);
}
}
Ads help maintain this website.