1       DOUBLE COMPLEX   FUNCTION ZLARND( 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 *  ZLARND 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 DLARAN 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       DOUBLE PRECISION   ZERO, ONE, TWO
 48       PARAMETER          ( ZERO = 0.0D+0, ONE = 1.0D+0, TWO = 2.0D+0 )
 49       DOUBLE PRECISION   TWOPI
 50       PARAMETER          ( TWOPI = 6.2831853071795864769252867663D+0 )
 51 *     ..
 52 *     .. Local Scalars ..
 53       DOUBLE PRECISION   T1, T2
 54 *     ..
 55 *     .. External Functions ..
 56       DOUBLE PRECISION   DLARAN
 57       EXTERNAL           DLARAN
 58 *     ..
 59 *     .. Intrinsic Functions ..
 60       INTRINSIC          DCMPLXEXPLOGSQRT
 61 *     ..
 62 *     .. Executable Statements ..
 63 *
 64 *     Generate a pair of real random numbers from a uniform (0,1)
 65 *     distribution
 66 *
 67       T1 = DLARAN( ISEED )
 68       T2 = DLARAN( ISEED )
 69 *
 70       IF( IDIST.EQ.1 ) THEN
 71 *
 72 *        real and imaginary parts each uniform (0,1)
 73 *
 74          ZLARND = DCMPLX( T1, T2 )
 75       ELSE IF( IDIST.EQ.2 ) THEN
 76 *
 77 *        real and imaginary parts each uniform (-1,1)
 78 *
 79          ZLARND = DCMPLX( 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          ZLARND = SQRT-TWO*LOG( T1 ) )*EXPDCMPLX( ZERO, TWOPI*T2 ) )
 85       ELSE IF( IDIST.EQ.4 ) THEN
 86 *
 87 *        uniform distribution on the unit disc abs(z) <= 1
 88 *
 89          ZLARND = SQRT( T1 )*EXPDCMPLX( ZERO, TWOPI*T2 ) )
 90       ELSE IF( IDIST.EQ.5 ) THEN
 91 *
 92 *        uniform distribution on the unit circle abs(z) = 1
 93 *
 94          ZLARND = EXPDCMPLX( ZERO, TWOPI*T2 ) )
 95       END IF
 96       RETURN
 97 *
 98 *     End of ZLARND
 99 *
100       END