SSJ API Documentation
Stochastic Simulation in Java
Loading...
Searching...
No Matches
HammersleyPointSet.java
1/*
2 * Class: HammersleyPointSet
3 * Description:
4 * Environment: Java
5 * Software: SSJ
6 * Copyright (C) 2001 Pierre L'Ecuyer and Universite de Montreal
7 * Organization: DIRO, Universite de Montreal
8 * @author
9 * @since
10 *
11 *
12 * Licensed under the Apache License, Version 2.0 (the "License");
13 * you may not use this file except in compliance with the License.
14 * You may obtain a copy of the License at
15 *
16 * http://www.apache.org/licenses/LICENSE-2.0
17 *
18 * Unless required by applicable law or agreed to in writing, software
19 * distributed under the License is distributed on an "AS IS" BASIS,
20 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
21 * See the License for the specific language governing permissions and
22 * limitations under the License.
23 *
24 */
25package umontreal.ssj.hups;
26
64public class HammersleyPointSet extends PointSet {
65 private int[] base; // Vector of prime bases.
66 private int[][] permutation; // Digits permutation, for each dimension.
67 private boolean permuted; // Permute digits?
68
75 public HammersleyPointSet(int n, int dim) {
76 if (n < 0 || dim < 1)
77 throw new IllegalArgumentException("Hammersley point sets must have positive dimension and n >= 0");
78 numPoints = n;
79 this.dim = dim;
80 if (dim > 1)
81 base = RadicalInverse.getPrimes(dim - 1);
82 }
83
91 public void addFaurePermutations() {
92 if (dim > 1) {
93 permutation = new int[dim][];
94 for (int i = 0; i < dim - 1; i++) {
95 permutation[i] = new int[base[i]];
96 RadicalInverse.getFaurePermutation(base[i], permutation[i]);
97 }
98 }
99 permuted = true;
100 }
101
106 public void ErasePermutations() {
107 permuted = false;
108 permutation = null;
109 }
110
111 public double getCoordinate(int i, int j) {
112 if (j == 0)
113 return (double) i / (double) numPoints;
114 if (permuted)
115 return RadicalInverse.permutedRadicalInverse(base[j - 1], permutation[j - 1], i);
116 else
117 return RadicalInverse.radicalInverse(base[j - 1], i);
118 }
119}
void addFaurePermutations()
Permutes the digits using Faure permutations for all coordinates.
void ErasePermutations()
Erases the Faure permutations: from now on, the digits will not be Faure permuted.
HammersleyPointSet(int n, int dim)
Constructs a new Hammersley point set with n points in dim dimensions.
double getCoordinate(int i, int j)
Returns , the coordinate of the point .
This abstract class represents a general point set.
Definition PointSet.java:99
int numPoints
Number of points.
int dim
Dimension of the points.
This class implements basic methods for working with radical inverses of integers in an arbitrary bas...
static double permutedRadicalInverse(int b, int[] pi, long i)
Computes the radical inverse of in base , where the digits are permuted using the permutation .
static double radicalInverse(int b, long i)
Computes the radical inverse of in base .
static void getFaurePermutation(int b, int[] pi)
Computes the Faure permutation rfau92a  of the set and puts it in array pi.
static int[] getPrimes(int n)
Provides an elementary method for obtaining the first prime numbers larger than 1.