1 /* -- translated by f2c (version 19940927).
2 You must link the resulting object file with the libraries:
3 -lf2c -lm (in that order)
4 */
5
6 #include "f2c.h"
7
dlaran_(integer * iseed)8 doublereal dlaran_(integer *iseed)
9 {
10 /* System generated locals */
11 doublereal ret_val;
12
13 /* Local variables */
14 static integer it1, it2, it3, it4;
15
16
17 /* -- LAPACK auxiliary routine (version 2.0) --
18 Univ. of Tennessee, Univ. of California Berkeley, NAG Ltd.,
19 Courant Institute, Argonne National Lab, and Rice University
20 February 29, 1992
21
22
23 Purpose
24 =======
25
26 DLARAN returns a random real number from a uniform (0,1)
27 distribution.
28
29 Arguments
30 =========
31
32 ISEED (input/output) INTEGER array, dimension (4)
33 On entry, the seed of the random number generator; the array
34
35 elements must be between 0 and 4095, and ISEED(4) must be
36 odd.
37 On exit, the seed is updated.
38
39 Further Details
40 ===============
41
42 This routine uses a multiplicative congruential method with modulus
43 2**48 and multiplier 33952834046453 (see G.S.Fishman,
44 'Multiplicative congruential random number generators with modulus
45 2**b: an exhaustive analysis for b = 32 and a partial analysis for
46 b = 48', Math. Comp. 189, pp 331-344, 1990).
47
48 48-bit integers are stored in 4 integer array elements with 12 bits
49 per element. Hence the routine is portable across machines with
50 integers of 32 bits or more.
51
52 =====================================================================
53
54
55
56 multiply the seed by the multiplier modulo 2**48
57
58 Parameter adjustments */
59 --iseed;
60
61 /* Function Body */
62 it4 = iseed[4] * 2549;
63 it3 = it4 / 4096;
64 it4 -= it3 << 12;
65 it3 = it3 + iseed[3] * 2549 + iseed[4] * 2508;
66 it2 = it3 / 4096;
67 it3 -= it2 << 12;
68 it2 = it2 + iseed[2] * 2549 + iseed[3] * 2508 + iseed[4] * 322;
69 it1 = it2 / 4096;
70 it2 -= it1 << 12;
71 it1 = it1 + iseed[1] * 2549 + iseed[2] * 2508 + iseed[3] * 322 + iseed[4]
72 * 494;
73 it1 %= 4096;
74
75 /* return updated seed */
76
77 iseed[1] = it1;
78 iseed[2] = it2;
79 iseed[3] = it3;
80 iseed[4] = it4;
81
82 /* convert 48-bit integer to a real number in the interval (0,1) */
83
84 ret_val = ((doublereal) it1 + ((doublereal) it2 + ((doublereal) it3 + (
85 doublereal) it4 * 2.44140625e-4) * 2.44140625e-4) * 2.44140625e-4)
86 * 2.44140625e-4;
87 return ret_val;
88
89 /* End of DLARAN */
90
91 } /* dlaran_ */
92
93