1 /*
2 * Copyright (C) 1994. James Darrell McCauley. (darrell@mccauley-usa.com)
3 * http://mccauley-usa.com/
4 *
5 * This program is free software under the GPL (>=v2)
6 * Read the file GPL.TXT coming with GRASS for details.
7 */
8
9 #include<stdio.h>
10 #include<math.h>
11 #include"zufall.h"
12
normal00(void)13 int normal00(void)
14 {
15 int i;
16 double twopi, r1, r2, t1, t2;
17 extern struct klotz1 klotz1_1;
18
19 twopi = 6.2831853071795862;
20 zufall(1024, klotz1_1.xbuff);
21
22 /* VOCL LOOP, TEMP(r1,r2,t1,t2), NOVREC(xbuff) */
23
24 for (i = 1; i <= 1024; i += 2) {
25 r1 = twopi * klotz1_1.xbuff[i - 1];
26 t1 = cos(r1);
27 t2 = sin(r1);
28 r2 = sqrt(log((double)1. - klotz1_1.xbuff[i]) * (double)-2.);
29 klotz1_1.xbuff[i - 1] = t1 * r2;
30 klotz1_1.xbuff[i] = t2 * r2;
31 }
32 return 0;
33 } /* normal00 */
34