LAPACK  3.6.1 LAPACK: Linear Algebra PACKage
 complex function clarnd ( integer IDIST, integer, dimension( 4 ) ISEED )

CLARND

Purpose:
``` CLARND returns a random complex number from a uniform or normal
distribution.```
Parameters
 [in] IDIST ``` IDIST is INTEGER Specifies the distribution of the random numbers: = 1: real and imaginary parts each uniform (0,1) = 2: real and imaginary parts each uniform (-1,1) = 3: real and imaginary parts each normal (0,1) = 4: uniformly distributed on the disc abs(z) <= 1 = 5: uniformly distributed on the circle abs(z) = 1``` [in,out] ISEED ``` ISEED is INTEGER array, dimension (4) On entry, the seed of the random number generator; the array elements must be between 0 and 4095, and ISEED(4) must be odd. On exit, the seed is updated.```
Date
November 2011
Further Details:
```  This routine calls the auxiliary routine SLARAN to generate a random
real number from a uniform (0,1) distribution. The Box-Muller method
is used to transform numbers from a uniform to a normal distribution.```

Definition at line 77 of file clarnd.f.

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  REAL zero, one, two
94  parameter ( zero = 0.0e+0, one = 1.0e+0, two = 2.0e+0 )
95  REAL twopi
96  parameter ( twopi = 6.2831853071795864769252867663e+0 )
97 * ..
98 * .. Local Scalars ..
99  REAL t1, t2
100 * ..
101 * .. External Functions ..
102  REAL slaran
103  EXTERNAL slaran
104 * ..
105 * .. Intrinsic Functions ..
106  INTRINSIC cmplx, 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 = slaran( iseed )
114  t2 = slaran( iseed )
115 *
116  IF( idist.EQ.1 ) THEN
117 *
118 * real and imaginary parts each uniform (0,1)
119 *
120  clarnd = cmplx( t1, t2 )
121  ELSE IF( idist.EQ.2 ) THEN
122 *
123 * real and imaginary parts each uniform (-1,1)
124 *
125  clarnd = cmplx( 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  clarnd = sqrt( -two*log( t1 ) )*exp( cmplx( zero, twopi*t2 ) )
131  ELSE IF( idist.EQ.4 ) THEN
132 *
133 * uniform distribution on the unit disc abs(z) <= 1
134 *
135  clarnd = sqrt( t1 )*exp( cmplx( zero, twopi*t2 ) )
136  ELSE IF( idist.EQ.5 ) THEN
137 *
138 * uniform distribution on the unit circle abs(z) = 1
139 *
140  clarnd = exp( cmplx( zero, twopi*t2 ) )
141  END IF
142  RETURN
143 *
144 * End of CLARND
145 *
complex function clarnd(IDIST, ISEED)
CLARND
Definition: clarnd.f:77
real function slaran(ISEED)
SLARAN
Definition: slaran.f:69