SSJ API Documentation
Stochastic Simulation in Java
Loading...
Searching...
No Matches
KorobovLattice.java
1/*
2 * Class: KorobovLattice
3 * Description: Korobov lattice
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
27import umontreal.ssj.util.PrintfFormat;
28
46public class KorobovLattice extends Rank1Lattice {
47 protected int genA; // multiplier a
48 private int genT; // shift t
49
50 private void initN(int n, int t) {
51 int a = (genA % n) + (genA < 0 ? n : 0);
52 genT = t;
53 long[] B = new long[dim];
54 B[0] = 1;
55 int j;
56 for (j = 0; j < t; j++)
57 B[0] *= a;
58 v[0] = B[0] * normFactor;
59 for (j = 1; j < dim; j++) {
60 B[j] = (a * B[j - 1]) % n;
61 v[j] = normFactor * B[j];
62 }
63 }
64
69 public KorobovLattice(int n, int a, int s) {
70 super(n, null, 0);
71 genA = a;
72 dim = s;
73 v = new double[s];
74 initN(n, 0);
75 }
76
85 public KorobovLattice(int n, int a, int s, int t) {
86 super(n, null, 0);
87 if (t < 0)
88 throw new IllegalArgumentException("KorobovLattice: must have t >= 0");
89 dim = s;
90 genA = a;
91 v = new double[s];
92 initN(n, t);
93 }
94
100 public void setNumPoints(int n) {
101 initN(n, genT);
102 }
103
108 public int getA() {
109 return genA;
110 }
111
112 public String toString() {
113 StringBuffer sb = new StringBuffer("KorobovLattice:" + PrintfFormat.NEWLINE);
114 sb.append("Multiplier a: " + genA + PrintfFormat.NEWLINE);
115 sb.append(super.toString());
116 return sb.toString();
117 }
118}
KorobovLattice(int n, int a, int s)
Instantiates a Korobov lattice point set with modulus and multiplier in dimension .
String toString()
Formats a string that contains information about the point set.
KorobovLattice(int n, int a, int s, int t)
Instantiates a shifted Korobov lattice point set with modulus.
int getA()
Returns the multiplier of the lattice.
void setNumPoints(int n)
Resets the number of points of the lattice to .
int dim
Dimension of the points.
Rank1Lattice(int n, int[] a, int s)
Instantiates a Rank1Lattice with points and lattice vector of dimension .
This class acts like a StringBuffer which defines new types of append methods.
static final String NEWLINE
End-of-line symbol or line separator.