LAPACK 3.12.0
LAPACK: Linear Algebra PACKage
Loading...
Searching...
No Matches
clarnd.f
Go to the documentation of this file.
1*> \brief \b CLARND
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 FUNCTION CLARND( 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*> CLARND 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 complex_matgen
62*
63*> \par Further Details:
64* =====================
65*>
66*> \verbatim
67*>
68*> This routine calls the auxiliary routine SLARAN 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 FUNCTION clarnd( 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 REAL zero, one, two
91 parameter( zero = 0.0e+0, one = 1.0e+0, two = 2.0e+0 )
92 REAL twopi
93 parameter( twopi = 6.28318530717958647692528676655900576839e+0 )
94* ..
95* .. Local Scalars ..
96 REAL t1, t2
97* ..
98* .. External Functions ..
99 REAL slaran
100 EXTERNAL slaran
101* ..
102* .. Intrinsic Functions ..
103 INTRINSIC cmplx, 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 = slaran( iseed )
111 t2 = slaran( iseed )
112*
113 IF( idist.EQ.1 ) THEN
114*
115* real and imaginary parts each uniform (0,1)
116*
117 clarnd = cmplx( t1, t2 )
118 ELSE IF( idist.EQ.2 ) THEN
119*
120* real and imaginary parts each uniform (-1,1)
121*
122 clarnd = cmplx( 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 clarnd = sqrt( -two*log( t1 ) )*exp( cmplx( zero, twopi*t2 ) )
128 ELSE IF( idist.EQ.4 ) THEN
129*
130* uniform distribution on the unit disc abs(z) <= 1
131*
132 clarnd = sqrt( t1 )*exp( cmplx( zero, twopi*t2 ) )
133 ELSE IF( idist.EQ.5 ) THEN
134*
135* uniform distribution on the unit circle abs(z) = 1
136*
137 clarnd = exp( cmplx( zero, twopi*t2 ) )
138 END IF
139 RETURN
140*
141* End of CLARND
142*
143 END
complex function clarnd(idist, iseed)
CLARND
Definition clarnd.f:75
real function slaran(iseed)
SLARAN
Definition slaran.f:67