SSJ API Documentation
Stochastic Simulation in Java
Loading...
Searching...
No Matches
SplitStream.java
1package umontreal.ssj.mcqmctools.anova;
2
3import umontreal.ssj.rng.*;
4
10public class SplitStream extends RandomStreamBase {
11
12 protected int curCoordIndex;
13 protected CoordinateSet coords;
14 protected double[] vals;
15
24 public SplitStream(RandomStream stream, int nCache) {
25 this.vals = new double[2 * nCache];
26 this.curCoordIndex = 0;
27 this.coords = null;
28 stream.nextArrayOfDouble(vals, 0, 2 * nCache);
29 }
30
31 public SplitStream(double[] vals) {
32 this.curCoordIndex = 0;
33 this.coords = null;
34 this.vals = vals;
35 }
36
37 public SplitStream clone() {
38 SplitStream s = new SplitStream(vals.clone());
39 s.curCoordIndex = curCoordIndex;
40 s.coords = coords;
41 return s;
42 }
43
44 public void setCoordinates(CoordinateSet coords) {
45 this.coords = coords;
46 }
47
48 public CoordinateSet getCoordinates() {
49 return coords;
50 }
51
52 @Override
53 protected double nextValue() {
54 int a = (coords != null && coords.contains(curCoordIndex)) ? 0 : 1;
55 return vals[2 * (curCoordIndex++) + a];
56 // return vals[a*vals.length/2 + (curCoordIndex++)];
57 }
58
59 @Override
60 public void resetNextSubstream() {
61 throw new UnsupportedOperationException();
62 }
63
64 @Override
65 public void resetStartStream() {
66 throw new UnsupportedOperationException();
67 }
68
69 @Override
70 public void resetStartSubstream() {
71 curCoordIndex = 0;
72 }
73
74 @Override
75 public String toString() {
76 return getClass().getSimpleName() + " [nCache=" + (vals.length / 2) + "]";
77 }
78}
void resetStartSubstream()
Reinitializes the stream to the beginning of its current substream:
SplitStream clone()
Clones the current generator and return its copy.
SplitStream(RandomStream stream, int nCache)
Reads 2 * nCache values from a a stream and stores them for future use.
void resetStartStream()
Reinitializes the stream to its initial state : and are set to .
String toString()
Returns a string containing the current state of this stream.
double nextValue()
This method should return the next random number (between 0 and 1) from the current stream.
void resetNextSubstream()
Reinitializes the stream to the beginning of its next substream:
This class provides a convenient foundation on which RNGs can be built.
This interface defines the basic structures to handle multiple streams of uniform (pseudo)random numb...
void nextArrayOfDouble(double[] u, int start, int n)
Generates n (pseudo)random numbers from the uniform distribution and stores them into the array u sta...