LAPACK  3.6.1
LAPACK: Linear Algebra PACKage
zlarnd.f
Go to the documentation of this file.
1 *> \brief \b ZLARND
2 *
3 * =========== DOCUMENTATION ===========
4 *
5 * Online html documentation available at
6 * http://www.netlib.org/lapack/explore-html/
7 *
8 * Definition:
9 * ===========
10 *
11 * COMPLEX*16 FUNCTION ZLARND( IDIST, ISEED )
12 *
13 * .. Scalar Arguments ..
14 * INTEGER IDIST
15 * ..
16 * .. Array Arguments ..
17 * INTEGER ISEED( 4 )
18 * ..
19 *
20 *
21 *> \par Purpose:
22 * =============
23 *>
24 *> \verbatim
25 *>
26 *> ZLARND returns a random complex number from a uniform or normal
27 *> distribution.
28 *> \endverbatim
29 *
30 * Arguments:
31 * ==========
32 *
33 *> \param[in] IDIST
34 *> \verbatim
35 *> IDIST is INTEGER
36 *> Specifies the distribution of the random numbers:
37 *> = 1: real and imaginary parts each uniform (0,1)
38 *> = 2: real and imaginary parts each uniform (-1,1)
39 *> = 3: real and imaginary parts each normal (0,1)
40 *> = 4: uniformly distributed on the disc abs(z) <= 1
41 *> = 5: uniformly distributed on the circle abs(z) = 1
42 *> \endverbatim
43 *>
44 *> \param[in,out] ISEED
45 *> \verbatim
46 *> ISEED is INTEGER array, dimension (4)
47 *> On entry, the seed of the random number generator; the array
48 *> elements must be between 0 and 4095, and ISEED(4) must be
49 *> odd.
50 *> On exit, the seed is updated.
51 *> \endverbatim
52 *
53 * Authors:
54 * ========
55 *
56 *> \author Univ. of Tennessee
57 *> \author Univ. of California Berkeley
58 *> \author Univ. of Colorado Denver
59 *> \author NAG Ltd.
60 *
61 *> \date November 2011
62 *
63 *> \ingroup complex16_matgen
64 *
65 *> \par Further Details:
66 * =====================
67 *>
68 *> \verbatim
69 *>
70 *> This routine calls the auxiliary routine DLARAN to generate a random
71 *> real number from a uniform (0,1) distribution. The Box-Muller method
72 *> is used to transform numbers from a uniform to a normal distribution.
73 *> \endverbatim
74 *>
75 * =====================================================================
76  COMPLEX*16 FUNCTION zlarnd( IDIST, ISEED )
77 *
78 * -- LAPACK auxiliary routine (version 3.4.0) --
79 * -- LAPACK is a software package provided by Univ. of Tennessee, --
80 * -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
81 * November 2011
82 *
83 * .. Scalar Arguments ..
84  INTEGER IDIST
85 * ..
86 * .. Array Arguments ..
87  INTEGER ISEED( 4 )
88 * ..
89 *
90 * =====================================================================
91 *
92 * .. Parameters ..
93  DOUBLE PRECISION ZERO, ONE, TWO
94  parameter ( zero = 0.0d+0, one = 1.0d+0, two = 2.0d+0 )
95  DOUBLE PRECISION TWOPI
96  parameter ( twopi = 6.2831853071795864769252867663d+0 )
97 * ..
98 * .. Local Scalars ..
99  DOUBLE PRECISION T1, T2
100 * ..
101 * .. External Functions ..
102  DOUBLE PRECISION DLARAN
103  EXTERNAL dlaran
104 * ..
105 * .. Intrinsic Functions ..
106  INTRINSIC dcmplx, exp, log, sqrt
107 * ..
108 * .. Executable Statements ..
109 *
110 * Generate a pair of real random numbers from a uniform (0,1)
111 * distribution
112 *
113  t1 = dlaran( iseed )
114  t2 = dlaran( iseed )
115 *
116  IF( idist.EQ.1 ) THEN
117 *
118 * real and imaginary parts each uniform (0,1)
119 *
120  zlarnd = dcmplx( t1, t2 )
121  ELSE IF( idist.EQ.2 ) THEN
122 *
123 * real and imaginary parts each uniform (-1,1)
124 *
125  zlarnd = dcmplx( two*t1-one, two*t2-one )
126  ELSE IF( idist.EQ.3 ) THEN
127 *
128 * real and imaginary parts each normal (0,1)
129 *
130  zlarnd = sqrt( -two*log( t1 ) )*exp( dcmplx( zero, twopi*t2 ) )
131  ELSE IF( idist.EQ.4 ) THEN
132 *
133 * uniform distribution on the unit disc abs(z) <= 1
134 *
135  zlarnd = sqrt( t1 )*exp( dcmplx( zero, twopi*t2 ) )
136  ELSE IF( idist.EQ.5 ) THEN
137 *
138 * uniform distribution on the unit circle abs(z) = 1
139 *
140  zlarnd = exp( dcmplx( zero, twopi*t2 ) )
141  END IF
142  RETURN
143 *
144 * End of ZLARND
145 *
146  END
complex *16 function zlarnd(IDIST, ISEED)
ZLARND
Definition: zlarnd.f:77