 ScaLAPACK 2.1  2.1 ScaLAPACK: Scalable Linear Algebra PACKage
clarnd.f
Go to the documentation of this file.
1  COMPLEX FUNCTION clarnd( 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 * clarnd 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 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.
43 *
44 * =====================================================================
45 *
46 * .. parameters ..
47  REAL zero, one, two
48  parameter( zero = 0.0e+0, one = 1.0e+0, two = 2.0e+0 )
49  REAL twopi
50  parameter( twopi = 6.2831853071795864769252867663e+0 )
51 * ..
52 * .. local scalars ..
53  REAL t1, t2
54 * ..
55 * .. External functions ..
56  REAL slaran
57  EXTERNAL slaran
58 * ..
59 * .. Intrinsic functions ..
60  INTRINSIC cmplx, 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 = slaran( iseed )
68  t2 = slaran( iseed )
69 *
70  IF( idist.EQ.1 ) THEN
71 *
72 * real and imaginary parts each uniform(0,1)
73 *
74  clarnd = cmplx( t1, t2 )
75  ELSE IF( idist.EQ.2 ) THEN
76 *
77 * real and imaginary parts each uniform(-1,1)
78 *
79  clarnd = cmplx( 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  clarnd = sqrt( -two*log( t1 ) )*exp( cmplx( zero, twopi*t2 ) )
85  ELSE IF( idist.EQ.4 ) THEN
86 *
87 * uniform distribution on the unit disc abs(z) <= 1
88 *
89  clarnd = sqrt( t1 )*exp( cmplx( zero, twopi*t2 ) )
90  ELSE IF( idist.EQ.5 ) THEN
91 *
92 * uniform distribution on the unit circle abs(z) = 1
93 *
94  clarnd = exp( cmplx( zero, twopi*t2 ) )
95  ELSE
96  clarnd = cmplx(zero,zero)
97  END IF
98  RETURN
99 *
100 * End of clarnd
101 *
102  END
cmplx
float cmplx
Definition: pblas.h:132
clarnd
complex function clarnd(IDIST, ISEED)
Definition: clarnd.f:2
slaran
real function slaran(ISEED)
Definition: slaran.f:2