LAPACK  3.10.0
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 *> \ingroup complex16_matgen
62 *
63 *> \par Further Details:
64 * =====================
65 *>
66 *> \verbatim
67 *>
68 *> This routine calls the auxiliary routine DLARAN to generate a random
69 *> real number from a uniform (0,1) distribution. The Box-Muller method
70 *> is used to transform numbers from a uniform to a normal distribution.
71 *> \endverbatim
72 *>
73 * =====================================================================
74  COMPLEX*16 FUNCTION zlarnd( IDIST, ISEED )
75 *
76 * -- LAPACK auxiliary routine --
77 * -- LAPACK is a software package provided by Univ. of Tennessee, --
78 * -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
79 *
80 * .. Scalar Arguments ..
81  INTEGER idist
82 * ..
83 * .. Array Arguments ..
84  INTEGER iseed( 4 )
85 * ..
86 *
87 * =====================================================================
88 *
89 * .. Parameters ..
90  DOUBLE PRECISION zero, one, two
91  parameter( zero = 0.0d+0, one = 1.0d+0, two = 2.0d+0 )
92  DOUBLE PRECISION twopi
93  parameter( twopi = 6.28318530717958647692528676655900576839d+0 )
94 * ..
95 * .. Local Scalars ..
96  DOUBLE PRECISION t1, t2
97 * ..
98 * .. External Functions ..
99  DOUBLE PRECISION dlaran
100  EXTERNAL dlaran
101 * ..
102 * .. Intrinsic Functions ..
103  INTRINSIC dcmplx, exp, log, sqrt
104 * ..
105 * .. Executable Statements ..
106 *
107 * Generate a pair of real random numbers from a uniform (0,1)
108 * distribution
109 *
110  t1 = dlaran( iseed )
111  t2 = dlaran( iseed )
112 *
113  IF( idist.EQ.1 ) THEN
114 *
115 * real and imaginary parts each uniform (0,1)
116 *
117  zlarnd = dcmplx( t1, t2 )
118  ELSE IF( idist.EQ.2 ) THEN
119 *
120 * real and imaginary parts each uniform (-1,1)
121 *
122  zlarnd = dcmplx( two*t1-one, two*t2-one )
123  ELSE IF( idist.EQ.3 ) THEN
124 *
125 * real and imaginary parts each normal (0,1)
126 *
127  zlarnd = sqrt( -two*log( t1 ) )*exp( dcmplx( zero, twopi*t2 ) )
128  ELSE IF( idist.EQ.4 ) THEN
129 *
130 * uniform distribution on the unit disc abs(z) <= 1
131 *
132  zlarnd = sqrt( t1 )*exp( dcmplx( zero, twopi*t2 ) )
133  ELSE IF( idist.EQ.5 ) THEN
134 *
135 * uniform distribution on the unit circle abs(z) = 1
136 *
137  zlarnd = exp( dcmplx( zero, twopi*t2 ) )
138  END IF
139  RETURN
140 *
141 * End of ZLARND
142 *
143  END
double precision function dlaran(ISEED)
DLARAN
Definition: dlaran.f:67
complex *16 function zlarnd(IDIST, ISEED)
ZLARND
Definition: zlarnd.f:75