ScaLAPACK 2.1  2.1
ScaLAPACK: Scalable Linear Algebra PACKage
zlarnd.f
Go to the documentation of this file.
1  DOUBLE COMPLEX FUNCTION zlarnd( 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 * ZLARND returns a random complex 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: real and imaginary parts each uniform (0,1)
26 * = 2: real and imaginary parts each uniform (-1,1)
27 * = 3: real and imaginary parts each normal (0,1)
28 * = 4: uniformly distributed on the disc abs(z) <= 1
29 * = 5: uniformly distributed on the circle abs(z) = 1
30 *
31 * ISEED (input/output) INTEGER array, dimension (4)
32 * On entry, the seed of the random number generator; the array
33 * elements must be between 0 and 4095, and ISEED(4) must be
34 * odd.
35 * On exit, the seed is updated.
36 *
37 * Further Details
38 * ===============
39 *
40 * This routine calls the auxiliary routine DLARAN to generate a random
41 * real number from a uniform (0,1) distribution. The Box-Muller method
42 * is used to transform numbers from a uniform to a normal distribution.
43 *
44 * =====================================================================
45 *
46 * .. Parameters ..
47  DOUBLE PRECISION zero, one, two
48  parameter( zero = 0.0d+0, one = 1.0d+0, two = 2.0d+0 )
49  DOUBLE PRECISION twopi
50  parameter( twopi = 6.2831853071795864769252867663d+0 )
51 * ..
52 * .. Local Scalars ..
53  DOUBLE PRECISION t1, t2
54 * ..
55 * .. External Functions ..
56  DOUBLE PRECISION dlaran
57  EXTERNAL dlaran
58 * ..
59 * .. Intrinsic Functions ..
60  INTRINSIC dcmplx, exp, log, sqrt
61 * ..
62 * .. Executable Statements ..
63 *
64 * Generate a pair of real random numbers from a uniform (0,1)
65 * distribution
66 *
67  t1 = dlaran( iseed )
68  t2 = dlaran( iseed )
69 *
70  IF( idist.EQ.1 ) THEN
71 *
72 * real and imaginary parts each uniform (0,1)
73 *
74  zlarnd = dcmplx( t1, t2 )
75  ELSE IF( idist.EQ.2 ) THEN
76 *
77 * real and imaginary parts each uniform (-1,1)
78 *
79  zlarnd = dcmplx( two*t1-one, two*t2-one )
80  ELSE IF( idist.EQ.3 ) THEN
81 *
82 * real and imaginary parts each normal (0,1)
83 *
84  zlarnd = sqrt( -two*log( t1 ) )*exp( dcmplx( zero, twopi*t2 ) )
85  ELSE IF( idist.EQ.4 ) THEN
86 *
87 * uniform distribution on the unit disc abs(z) <= 1
88 *
89  zlarnd = sqrt( t1 )*exp( dcmplx( zero, twopi*t2 ) )
90  ELSE IF( idist.EQ.5 ) THEN
91 *
92 * uniform distribution on the unit circle abs(z) = 1
93 *
94  zlarnd = exp( dcmplx( zero, twopi*t2 ) )
95  ELSE
96  zlarnd = dcmplx(zero,zero)
97  END IF
98  RETURN
99 *
100 * End of ZLARND
101 *
102  END
zlarnd
double complex function zlarnd(IDIST, ISEED)
Definition: tools.f:1899
dlaran
double precision function dlaran(ISEED)
Definition: tools.f:2000