ScaLAPACK 2.1  2.1
ScaLAPACK: Scalable Linear Algebra PACKage
dlarnd.f
Go to the documentation of this file.
1  DOUBLE PRECISION FUNCTION dlarnd( IDIST, ISEED )
2 *
3 * -- LAPACK auxiliary routine (version 3.1) --
4 * Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd..
5 * November 2006
6 *
7 * .. Scalar Arguments ..
8  INTEGER idist
9 * ..
10 * .. Array Arguments ..
11  INTEGER iseed( 4 )
12 * ..
13 *
14 * Purpose
15 * =======
16 *
17 * DLARND returns a random real number from a uniform or normal
18 * distribution.
19 *
20 * Arguments
21 * =========
22 *
23 * IDIST (input) INTEGER
24 * Specifies the distribution of the random numbers:
25 * = 1: uniform (0,1)
26 * = 2: uniform (-1,1)
27 * = 3: normal (0,1)
28 *
29 * ISEED (input/output) INTEGER array, dimension (4)
30 * On entry, the seed of the random number generator; the array
31 * elements must be between 0 and 4095, and ISEED(4) must be
32 * odd.
33 * On exit, the seed is updated.
34 *
35 * Further Details
36 * ===============
37 *
38 * This routine calls the auxiliary routine DLARAN to generate a random
39 * real number from a uniform (0,1) distribution. The Box-Muller method
40 * is used to transform numbers from a uniform to a normal distribution.
41 *
42 * =====================================================================
43 *
44 * .. Parameters ..
45  DOUBLE PRECISION one, two
46  parameter( one = 1.0d+0, two = 2.0d+0 )
47  DOUBLE PRECISION twopi
48  parameter( twopi = 6.2831853071795864769252867663d+0 )
49 * ..
50 * .. Local Scalars ..
51  DOUBLE PRECISION t1, t2
52 * ..
53 * .. External Functions ..
54  DOUBLE PRECISION dlaran
55  EXTERNAL dlaran
56 * ..
57 * .. Intrinsic Functions ..
58  INTRINSIC cos, log, sqrt
59 * ..
60 * .. Executable Statements ..
61 *
62 * Generate a real random number from a uniform (0,1) distribution
63 *
64  t1 = dlaran( iseed )
65 *
66  IF( idist.EQ.1 ) THEN
67 *
68 * uniform (0,1)
69 *
70  dlarnd = t1
71  ELSE IF( idist.EQ.2 ) THEN
72 *
73 * uniform (-1,1)
74 *
75  dlarnd = two*t1 - one
76  ELSE IF( idist.EQ.3 ) THEN
77 *
78 * normal (0,1)
79 *
80  t2 = dlaran( iseed )
81  dlarnd = sqrt( -two*log( t1 ) )*cos( twopi*t2 )
82  ELSE
83  dlarnd = one
84  END IF
85  RETURN
86 *
87 * End of DLARND
88 *
89  END
dlarnd
double precision function dlarnd(IDIST, ISEED)
Definition: tools.f:1811
dlaran
double precision function dlaran(ISEED)
Definition: tools.f:2000