1 COMPLEX FUNCTION clarnd( IDIST, ISEED )
3 * -- lapack auxiliary routine(version 3.1) --
4 * univ. of tennessee, univ. of california berkeley and nag ltd..
7 * .. scalar arguments ..
10 * .. array arguments ..
17 *
clarnd returns a random
complex number from a uniform or normal
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
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
35 * on exit, the seed is updated.
40 * this routine calls the auxiliary routine
slaran 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.
44 * =====================================================================
48 parameter( zero = 0.0e+0, one = 1.0e+0, two = 2.0e+0 )
50 parameter( twopi = 6.2831853071795864769252867663e+0 )
55 * ..
External functions ..
59 * ..
Intrinsic functions ..
60 INTRINSIC cmplx, exp, log, sqrt
62 * .. executable statements ..
64 * generate a pair of
real random numbers from a uniform (0,1)
72 *
real and imaginary parts each uniform (0,1)
75 ELSE IF( idist.EQ.2 )
THEN
77 *
real and imaginary parts each uniform (-1,1)
79 clarnd = cmplx( two*t1-one, two*t2-one )
80 ELSE IF( idist.EQ.3 )
THEN
82 *
real and imaginary parts each normal (0,1)
84 clarnd = sqrt( -two*log( t1 ) )*exp( cmplx( zero, twopi*t2 ) )
85 ELSE IF( idist.EQ.4 )
THEN
87 * uniform distribution on the unit disc abs(z) <= 1
89 clarnd = sqrt( t1 )*exp( cmplx( zero, twopi*t2 ) )
90 ELSE IF( idist.EQ.5 )
THEN
92 * uniform distribution on the unit circle abs(z) = 1
94 clarnd = exp( cmplx( zero, twopi*t2 ) )