-
Notifications
You must be signed in to change notification settings - Fork 1
/
ranstream.hoc
43 lines (40 loc) · 933 Bytes
/
ranstream.hoc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
random_stream_offset_ = 250000
begintemplate RandomStream ///
public r, repick, start, stream
external random_stream_offset_
objref r
proc init() {
stream = $1
r = new Random()
start()
}
// to get same results on each run
// call rs.start() just before run()
func start() {
return r.MCellRan4(stream*random_stream_offset_ + 1)
}
func repick() {
return r.repick()
}
endtemplate RandomStream //// End
begintemplate RandomStream123 //// Unify RandomStream for all random generator
public r, repick, start, ID1, ID2, ID3, getID
external random_stream_offset_
objref r
proc init() {
{ID1 = $1 ID2 = $2 ID3 = $3 }
r = new Random()
start()
}
// to get same results on each run
// call rs.start() just before run()
func start() {
return r.Random123(ID1,ID2,ID3)
}
func repick() {
return r.repick()
}
proc getID() {
print "Random123 : Seed ID #1 = ", ID1, " , #2 = ", ID2, " , #3 = ", ID3, "\n"
}
endtemplate RandomStream123