LAPACK 3.12.0
LAPACK: Linear Algebra PACKage
Loading...
Searching...
No Matches

◆ clarnd()

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.
Author
Univ. of Tennessee
Univ. of California Berkeley
Univ. of Colorado Denver
NAG Ltd.
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 74 of file clarnd.f.

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*
complex function clarnd(idist, iseed)
CLARND
Definition clarnd.f:75
real function slaran(iseed)
SLARAN
Definition slaran.f:67
Here is the call graph for this function:
Here is the caller graph for this function: