SSJ API Documentation
Stochastic Simulation in Java
Loading...
Searching...
No Matches
KorobovLatticeSequence.java
1/*
2 * Class: KorobovLatticeSequence
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
54 int base; // Base for radical inversion
55 int inverse; // global variables for radical inverssion,
56 int n; // since bloody JAVA cannot pass references
57
58 // Method modPower is inherited from Rank1Lattice.
59
66 public KorobovLatticeSequence(int b, int a) {
67// Pas termine: ne fonctionne pas
68 super(2, 3, 1);
69 if (a < 1)
70 throw new IllegalArgumentException("KorobovLatticeSequence: Multiplier a must be >= 1");
71// dim = Integer.MAX_VALUE;
72// numPoints = Integer.MAX_VALUE;
73 base = b;
74 throw new UnsupportedOperationException("NOT FINISHED");
75 }
76
77 // A very inefficient way of generating the points!
78 public double getCoordinate(int i, int j) {
79 int n;
80 int inverse;
81 if (i == 0)
82 return 0.0;
83 else if (j == 0)
84 return radicalInverse(base, i);
85 else {
86 // integerRadicalInverse (i);
87 n = 1;
88 for (inverse = 0; i > 0; i /= base) {
89 inverse = inverse * base + (i % base);
90 n *= base;
91 }
92 return (double) ((inverse * modPower(genA, j, n)) % n) / (double) n;
93 }
94 }
95
96 // ... has been unrolled in getCoordinate.
97 private void integerRadicalInverse(int i) {
98 // Attention: returns results in variables n and inverse.
99 n = 1;
100 for (inverse = 0; i > 0; i /= base) {
101 inverse = inverse * base + (i % base);
102 n *= base;
103 }
104 }
105
106}
double getCoordinate(int i, int j)
Returns , the coordinate of the point .
KorobovLatticeSequence(int b, int a)
Constructs a new lattice sequence with base b and generator .
KorobovLattice(int n, int a, int s)
Instantiates a Korobov lattice point set with modulus and multiplier in dimension .