add the JGF MolDyn benchmark
[IRC.git] / Robust / src / Benchmarks / Scheduling / JGFMolDyn / MyRandom.java
1 public class MyRandom {
2
3     public int iseed;
4     public float v1,v2;
5
6     public MyRandom(int iseed, float v1, float v2) {
7         this.iseed = iseed;
8         this.v1 = v1;
9         this.v2 = v2;
10     }
11
12     public float update() {
13
14         float rand;
15         float scale= (float)4.656612875e-10;
16
17         int is1,is2,iss2;
18         int imult= 16807;
19         int imod = 2147483647;
20
21         if (iseed<=0) { 
22             iseed = 1; 
23             }
24
25         is2 = iseed % 32768;
26         is1 = (iseed-is2)/32768;
27         iss2 = is2 * imult;
28         is2 = iss2 % 32768;
29         is1 = (is1 * imult+(iss2-is2) / 32768) % (65536);
30
31         iseed = (is1 * 32768 + is2) % imod;
32
33         rand = scale * iseed;
34
35         return rand;
36
37     }
38
39     public float seed() {
40
41         float s,u1,u2,r;
42         s = (float)1.0;
43         //do {
44             //System.printI(0xb1);
45             u1 = update();
46             u2 = update();
47
48         //System.printI(0xb2);
49             v1 = (float)2.0 * u1 - (float)1.0;
50             v2 = (float)2.0 * u2 - (float)1.0;
51             s = v1*v1 + v2*v2;
52         //System.printI(0xb3);
53         //} while (s >= (float)1.0);
54          s = s - (int)s;
55         //System.printI(0xb4);
56         r = Math.sqrtf((float)(-2.0*Math.logf(s))/(float)s);
57         //System.printI(0xb5);
58         return r;
59
60     }
61 }