LAPACK  3.4.1
LAPACK: Linear Algebra PACKage
zlarnd.f
Go to the documentation of this file.
00001 *> \brief \b ZLARND
00002 *
00003 *  =========== DOCUMENTATION ===========
00004 *
00005 * Online html documentation available at 
00006 *            http://www.netlib.org/lapack/explore-html/ 
00007 *
00008 *  Definition:
00009 *  ===========
00010 *
00011 *       COMPLEX*16   FUNCTION ZLARND( IDIST, ISEED )
00012 * 
00013 *       .. Scalar Arguments ..
00014 *       INTEGER            IDIST
00015 *       ..
00016 *       .. Array Arguments ..
00017 *       INTEGER            ISEED( 4 )
00018 *       ..
00019 *  
00020 *
00021 *> \par Purpose:
00022 *  =============
00023 *>
00024 *> \verbatim
00025 *>
00026 *> ZLARND returns a random complex number from a uniform or normal
00027 *> distribution.
00028 *> \endverbatim
00029 *
00030 *  Arguments:
00031 *  ==========
00032 *
00033 *> \param[in] IDIST
00034 *> \verbatim
00035 *>          IDIST is INTEGER
00036 *>          Specifies the distribution of the random numbers:
00037 *>          = 1:  real and imaginary parts each uniform (0,1)
00038 *>          = 2:  real and imaginary parts each uniform (-1,1)
00039 *>          = 3:  real and imaginary parts each normal (0,1)
00040 *>          = 4:  uniformly distributed on the disc abs(z) <= 1
00041 *>          = 5:  uniformly distributed on the circle abs(z) = 1
00042 *> \endverbatim
00043 *>
00044 *> \param[in,out] ISEED
00045 *> \verbatim
00046 *>          ISEED is INTEGER array, dimension (4)
00047 *>          On entry, the seed of the random number generator; the array
00048 *>          elements must be between 0 and 4095, and ISEED(4) must be
00049 *>          odd.
00050 *>          On exit, the seed is updated.
00051 *> \endverbatim
00052 *
00053 *  Authors:
00054 *  ========
00055 *
00056 *> \author Univ. of Tennessee 
00057 *> \author Univ. of California Berkeley 
00058 *> \author Univ. of Colorado Denver 
00059 *> \author NAG Ltd. 
00060 *
00061 *> \date November 2011
00062 *
00063 *> \ingroup complex16_matgen
00064 *
00065 *> \par Further Details:
00066 *  =====================
00067 *>
00068 *> \verbatim
00069 *>
00070 *>  This routine calls the auxiliary routine DLARAN to generate a random
00071 *>  real number from a uniform (0,1) distribution. The Box-Muller method
00072 *>  is used to transform numbers from a uniform to a normal distribution.
00073 *> \endverbatim
00074 *>
00075 *  =====================================================================
00076       COMPLEX*16   FUNCTION ZLARND( IDIST, ISEED )
00077 *
00078 *  -- LAPACK auxiliary routine (version 3.4.0) --
00079 *  -- LAPACK is a software package provided by Univ. of Tennessee,    --
00080 *  -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
00081 *     November 2011
00082 *
00083 *     .. Scalar Arguments ..
00084       INTEGER            IDIST
00085 *     ..
00086 *     .. Array Arguments ..
00087       INTEGER            ISEED( 4 )
00088 *     ..
00089 *
00090 *  =====================================================================
00091 *
00092 *     .. Parameters ..
00093       DOUBLE PRECISION   ZERO, ONE, TWO
00094       PARAMETER          ( ZERO = 0.0D+0, ONE = 1.0D+0, TWO = 2.0D+0 )
00095       DOUBLE PRECISION   TWOPI
00096       PARAMETER          ( TWOPI = 6.2831853071795864769252867663D+0 )
00097 *     ..
00098 *     .. Local Scalars ..
00099       DOUBLE PRECISION   T1, T2
00100 *     ..
00101 *     .. External Functions ..
00102       DOUBLE PRECISION   DLARAN
00103       EXTERNAL           DLARAN
00104 *     ..
00105 *     .. Intrinsic Functions ..
00106       INTRINSIC          DCMPLX, EXP, LOG, SQRT
00107 *     ..
00108 *     .. Executable Statements ..
00109 *
00110 *     Generate a pair of real random numbers from a uniform (0,1)
00111 *     distribution
00112 *
00113       T1 = DLARAN( ISEED )
00114       T2 = DLARAN( ISEED )
00115 *
00116       IF( IDIST.EQ.1 ) THEN
00117 *
00118 *        real and imaginary parts each uniform (0,1)
00119 *
00120          ZLARND = DCMPLX( T1, T2 )
00121       ELSE IF( IDIST.EQ.2 ) THEN
00122 *
00123 *        real and imaginary parts each uniform (-1,1)
00124 *
00125          ZLARND = DCMPLX( TWO*T1-ONE, TWO*T2-ONE )
00126       ELSE IF( IDIST.EQ.3 ) THEN
00127 *
00128 *        real and imaginary parts each normal (0,1)
00129 *
00130          ZLARND = SQRT( -TWO*LOG( T1 ) )*EXP( DCMPLX( ZERO, TWOPI*T2 ) )
00131       ELSE IF( IDIST.EQ.4 ) THEN
00132 *
00133 *        uniform distribution on the unit disc abs(z) <= 1
00134 *
00135          ZLARND = SQRT( T1 )*EXP( DCMPLX( ZERO, TWOPI*T2 ) )
00136       ELSE IF( IDIST.EQ.5 ) THEN
00137 *
00138 *        uniform distribution on the unit circle abs(z) = 1
00139 *
00140          ZLARND = EXP( DCMPLX( ZERO, TWOPI*T2 ) )
00141       END IF
00142       RETURN
00143 *
00144 *     End of ZLARND
00145 *
00146       END
 All Files Functions