LAPACK 3.3.0
|
00001 DOUBLE COMPLEX FUNCTION ZLARND( IDIST, ISEED ) 00002 * 00003 * -- LAPACK auxiliary routine (version 3.1) -- 00004 * Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd.. 00005 * November 2006 00006 * 00007 * .. Scalar Arguments .. 00008 INTEGER IDIST 00009 * .. 00010 * .. Array Arguments .. 00011 INTEGER ISEED( 4 ) 00012 * .. 00013 * 00014 * Purpose 00015 * ======= 00016 * 00017 * ZLARND returns a random complex number from a uniform or normal 00018 * distribution. 00019 * 00020 * Arguments 00021 * ========= 00022 * 00023 * IDIST (input) INTEGER 00024 * Specifies the distribution of the random numbers: 00025 * = 1: real and imaginary parts each uniform (0,1) 00026 * = 2: real and imaginary parts each uniform (-1,1) 00027 * = 3: real and imaginary parts each normal (0,1) 00028 * = 4: uniformly distributed on the disc abs(z) <= 1 00029 * = 5: uniformly distributed on the circle abs(z) = 1 00030 * 00031 * ISEED (input/output) INTEGER array, dimension (4) 00032 * On entry, the seed of the random number generator; the array 00033 * elements must be between 0 and 4095, and ISEED(4) must be 00034 * odd. 00035 * On exit, the seed is updated. 00036 * 00037 * Further Details 00038 * =============== 00039 * 00040 * This routine calls the auxiliary routine DLARAN to generate a random 00041 * real number from a uniform (0,1) distribution. The Box-Muller method 00042 * is used to transform numbers from a uniform to a normal distribution. 00043 * 00044 * ===================================================================== 00045 * 00046 * .. Parameters .. 00047 DOUBLE PRECISION ZERO, ONE, TWO 00048 PARAMETER ( ZERO = 0.0D+0, ONE = 1.0D+0, TWO = 2.0D+0 ) 00049 DOUBLE PRECISION TWOPI 00050 PARAMETER ( TWOPI = 6.2831853071795864769252867663D+0 ) 00051 * .. 00052 * .. Local Scalars .. 00053 DOUBLE PRECISION T1, T2 00054 * .. 00055 * .. External Functions .. 00056 DOUBLE PRECISION DLARAN 00057 EXTERNAL DLARAN 00058 * .. 00059 * .. Intrinsic Functions .. 00060 INTRINSIC DCMPLX, EXP, LOG, SQRT 00061 * .. 00062 * .. Executable Statements .. 00063 * 00064 * Generate a pair of real random numbers from a uniform (0,1) 00065 * distribution 00066 * 00067 T1 = DLARAN( ISEED ) 00068 T2 = DLARAN( ISEED ) 00069 * 00070 IF( IDIST.EQ.1 ) THEN 00071 * 00072 * real and imaginary parts each uniform (0,1) 00073 * 00074 ZLARND = DCMPLX( T1, T2 ) 00075 ELSE IF( IDIST.EQ.2 ) THEN 00076 * 00077 * real and imaginary parts each uniform (-1,1) 00078 * 00079 ZLARND = DCMPLX( TWO*T1-ONE, TWO*T2-ONE ) 00080 ELSE IF( IDIST.EQ.3 ) THEN 00081 * 00082 * real and imaginary parts each normal (0,1) 00083 * 00084 ZLARND = SQRT( -TWO*LOG( T1 ) )*EXP( DCMPLX( ZERO, TWOPI*T2 ) ) 00085 ELSE IF( IDIST.EQ.4 ) THEN 00086 * 00087 * uniform distribution on the unit disc abs(z) <= 1 00088 * 00089 ZLARND = SQRT( T1 )*EXP( DCMPLX( ZERO, TWOPI*T2 ) ) 00090 ELSE IF( IDIST.EQ.5 ) THEN 00091 * 00092 * uniform distribution on the unit circle abs(z) = 1 00093 * 00094 ZLARND = EXP( DCMPLX( ZERO, TWOPI*T2 ) ) 00095 END IF 00096 RETURN 00097 * 00098 * End of ZLARND 00099 * 00100 END