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

◆ clarnv()

subroutine clarnv ( integer idist,
integer, dimension( 4 ) iseed,
integer n,
complex, dimension( * ) x )

CLARNV returns a vector of random numbers from a uniform or normal distribution.

Download CLARNV + dependencies [TGZ] [ZIP] [TXT]

Purpose:
!>
!> CLARNV returns a vector of n random complex numbers 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.
!> 
[in]N
!>          N is INTEGER
!>          The number of random numbers to be generated.
!> 
[out]X
!>          X is COMPLEX array, dimension (N)
!>          The generated random numbers.
!> 
Author
Univ. of Tennessee
Univ. of California Berkeley
Univ. of Colorado Denver
NAG Ltd.
Further Details:
!>
!>  This routine calls the auxiliary routine SLARUV to generate random
!>  real numbers from a uniform (0,1) distribution, in batches of up to
!>  128 using vectorisable code. The Box-Muller method is used to
!>  transform numbers from a uniform to a normal distribution.
!> 

Definition at line 96 of file clarnv.f.

97*
98* -- LAPACK auxiliary routine --
99* -- LAPACK is a software package provided by Univ. of Tennessee, --
100* -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
101*
102* .. Scalar Arguments ..
103 INTEGER IDIST, N
104* ..
105* .. Array Arguments ..
106 INTEGER ISEED( 4 )
107 COMPLEX X( * )
108* ..
109*
110* =====================================================================
111*
112* .. Parameters ..
113 REAL ZERO, ONE, TWO
114 parameter( zero = 0.0e+0, one = 1.0e+0, two = 2.0e+0 )
115 INTEGER LV
116 parameter( lv = 128 )
117 REAL TWOPI
118 parameter( twopi = 6.28318530717958647692528676655900576839e+0 )
119* ..
120* .. Local Scalars ..
121 INTEGER I, IL, IV
122* ..
123* .. Local Arrays ..
124 REAL U( LV )
125* ..
126* .. Intrinsic Functions ..
127 INTRINSIC cmplx, exp, log, min, sqrt
128* ..
129* .. External Subroutines ..
130 EXTERNAL slaruv
131* ..
132* .. Executable Statements ..
133*
134 DO 60 iv = 1, n, lv / 2
135 il = min( lv / 2, n-iv+1 )
136*
137* Call SLARUV to generate 2*IL real numbers from a uniform (0,1)
138* distribution (2*IL <= LV)
139*
140 CALL slaruv( iseed, 2*il, u )
141*
142 IF( idist.EQ.1 ) THEN
143*
144* Copy generated numbers
145*
146 DO 10 i = 1, il
147 x( iv+i-1 ) = cmplx( u( 2*i-1 ), u( 2*i ) )
148 10 CONTINUE
149 ELSE IF( idist.EQ.2 ) THEN
150*
151* Convert generated numbers to uniform (-1,1) distribution
152*
153 DO 20 i = 1, il
154 x( iv+i-1 ) = cmplx( two*u( 2*i-1 )-one,
155 $ two*u( 2*i )-one )
156 20 CONTINUE
157 ELSE IF( idist.EQ.3 ) THEN
158*
159* Convert generated numbers to normal (0,1) distribution
160*
161 DO 30 i = 1, il
162 x( iv+i-1 ) = sqrt( -two*log( u( 2*i-1 ) ) )*
163 $ exp( cmplx( zero, twopi*u( 2*i ) ) )
164 30 CONTINUE
165 ELSE IF( idist.EQ.4 ) THEN
166*
167* Convert generated numbers to complex numbers uniformly
168* distributed on the unit disk
169*
170 DO 40 i = 1, il
171 x( iv+i-1 ) = sqrt( u( 2*i-1 ) )*
172 $ exp( cmplx( zero, twopi*u( 2*i ) ) )
173 40 CONTINUE
174 ELSE IF( idist.EQ.5 ) THEN
175*
176* Convert generated numbers to complex numbers uniformly
177* distributed on the unit circle
178*
179 DO 50 i = 1, il
180 x( iv+i-1 ) = exp( cmplx( zero, twopi*u( 2*i ) ) )
181 50 CONTINUE
182 END IF
183 60 CONTINUE
184 RETURN
185*
186* End of CLARNV
187*
subroutine slaruv(iseed, n, x)
SLARUV returns a vector of n random real numbers from a uniform distribution.
Definition slaruv.f:93
Here is the call graph for this function:
Here is the caller graph for this function: