LAPACK  3.4.1
LAPACK: Linear Algebra PACKage
zlarnv.f
Go to the documentation of this file.
00001 *> \brief \b ZLARNV
00002 *
00003 *  =========== DOCUMENTATION ===========
00004 *
00005 * Online html documentation available at 
00006 *            http://www.netlib.org/lapack/explore-html/ 
00007 *
00008 *> \htmlonly
00009 *> Download ZLARNV + dependencies 
00010 *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/zlarnv.f"> 
00011 *> [TGZ]</a> 
00012 *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/zlarnv.f"> 
00013 *> [ZIP]</a> 
00014 *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/zlarnv.f"> 
00015 *> [TXT]</a>
00016 *> \endhtmlonly 
00017 *
00018 *  Definition:
00019 *  ===========
00020 *
00021 *       SUBROUTINE ZLARNV( IDIST, ISEED, N, X )
00022 * 
00023 *       .. Scalar Arguments ..
00024 *       INTEGER            IDIST, N
00025 *       ..
00026 *       .. Array Arguments ..
00027 *       INTEGER            ISEED( 4 )
00028 *       COMPLEX*16         X( * )
00029 *       ..
00030 *  
00031 *
00032 *> \par Purpose:
00033 *  =============
00034 *>
00035 *> \verbatim
00036 *>
00037 *> ZLARNV returns a vector of n random complex numbers from a uniform or
00038 *> normal distribution.
00039 *> \endverbatim
00040 *
00041 *  Arguments:
00042 *  ==========
00043 *
00044 *> \param[in] IDIST
00045 *> \verbatim
00046 *>          IDIST is INTEGER
00047 *>          Specifies the distribution of the random numbers:
00048 *>          = 1:  real and imaginary parts each uniform (0,1)
00049 *>          = 2:  real and imaginary parts each uniform (-1,1)
00050 *>          = 3:  real and imaginary parts each normal (0,1)
00051 *>          = 4:  uniformly distributed on the disc abs(z) < 1
00052 *>          = 5:  uniformly distributed on the circle abs(z) = 1
00053 *> \endverbatim
00054 *>
00055 *> \param[in,out] ISEED
00056 *> \verbatim
00057 *>          ISEED is INTEGER array, dimension (4)
00058 *>          On entry, the seed of the random number generator; the array
00059 *>          elements must be between 0 and 4095, and ISEED(4) must be
00060 *>          odd.
00061 *>          On exit, the seed is updated.
00062 *> \endverbatim
00063 *>
00064 *> \param[in] N
00065 *> \verbatim
00066 *>          N is INTEGER
00067 *>          The number of random numbers to be generated.
00068 *> \endverbatim
00069 *>
00070 *> \param[out] X
00071 *> \verbatim
00072 *>          X is COMPLEX*16 array, dimension (N)
00073 *>          The generated random numbers.
00074 *> \endverbatim
00075 *
00076 *  Authors:
00077 *  ========
00078 *
00079 *> \author Univ. of Tennessee 
00080 *> \author Univ. of California Berkeley 
00081 *> \author Univ. of Colorado Denver 
00082 *> \author NAG Ltd. 
00083 *
00084 *> \date November 2011
00085 *
00086 *> \ingroup complex16OTHERauxiliary
00087 *
00088 *> \par Further Details:
00089 *  =====================
00090 *>
00091 *> \verbatim
00092 *>
00093 *>  This routine calls the auxiliary routine DLARUV to generate random
00094 *>  real numbers from a uniform (0,1) distribution, in batches of up to
00095 *>  128 using vectorisable code. The Box-Muller method is used to
00096 *>  transform numbers from a uniform to a normal distribution.
00097 *> \endverbatim
00098 *>
00099 *  =====================================================================
00100       SUBROUTINE ZLARNV( IDIST, ISEED, N, X )
00101 *
00102 *  -- LAPACK auxiliary routine (version 3.4.0) --
00103 *  -- LAPACK is a software package provided by Univ. of Tennessee,    --
00104 *  -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
00105 *     November 2011
00106 *
00107 *     .. Scalar Arguments ..
00108       INTEGER            IDIST, N
00109 *     ..
00110 *     .. Array Arguments ..
00111       INTEGER            ISEED( 4 )
00112       COMPLEX*16         X( * )
00113 *     ..
00114 *
00115 *  =====================================================================
00116 *
00117 *     .. Parameters ..
00118       DOUBLE PRECISION   ZERO, ONE, TWO
00119       PARAMETER          ( ZERO = 0.0D+0, ONE = 1.0D+0, TWO = 2.0D+0 )
00120       INTEGER            LV
00121       PARAMETER          ( LV = 128 )
00122       DOUBLE PRECISION   TWOPI
00123       PARAMETER          ( TWOPI = 6.2831853071795864769252867663D+0 )
00124 *     ..
00125 *     .. Local Scalars ..
00126       INTEGER            I, IL, IV
00127 *     ..
00128 *     .. Local Arrays ..
00129       DOUBLE PRECISION   U( LV )
00130 *     ..
00131 *     .. Intrinsic Functions ..
00132       INTRINSIC          DCMPLX, EXP, LOG, MIN, SQRT
00133 *     ..
00134 *     .. External Subroutines ..
00135       EXTERNAL           DLARUV
00136 *     ..
00137 *     .. Executable Statements ..
00138 *
00139       DO 60 IV = 1, N, LV / 2
00140          IL = MIN( LV / 2, N-IV+1 )
00141 *
00142 *        Call DLARUV to generate 2*IL real numbers from a uniform (0,1)
00143 *        distribution (2*IL <= LV)
00144 *
00145          CALL DLARUV( ISEED, 2*IL, U )
00146 *
00147          IF( IDIST.EQ.1 ) THEN
00148 *
00149 *           Copy generated numbers
00150 *
00151             DO 10 I = 1, IL
00152                X( IV+I-1 ) = DCMPLX( U( 2*I-1 ), U( 2*I ) )
00153    10       CONTINUE
00154          ELSE IF( IDIST.EQ.2 ) THEN
00155 *
00156 *           Convert generated numbers to uniform (-1,1) distribution
00157 *
00158             DO 20 I = 1, IL
00159                X( IV+I-1 ) = DCMPLX( TWO*U( 2*I-1 )-ONE,
00160      $                       TWO*U( 2*I )-ONE )
00161    20       CONTINUE
00162          ELSE IF( IDIST.EQ.3 ) THEN
00163 *
00164 *           Convert generated numbers to normal (0,1) distribution
00165 *
00166             DO 30 I = 1, IL
00167                X( IV+I-1 ) = SQRT( -TWO*LOG( U( 2*I-1 ) ) )*
00168      $                       EXP( DCMPLX( ZERO, TWOPI*U( 2*I ) ) )
00169    30       CONTINUE
00170          ELSE IF( IDIST.EQ.4 ) THEN
00171 *
00172 *           Convert generated numbers to complex numbers uniformly
00173 *           distributed on the unit disk
00174 *
00175             DO 40 I = 1, IL
00176                X( IV+I-1 ) = SQRT( U( 2*I-1 ) )*
00177      $                       EXP( DCMPLX( ZERO, TWOPI*U( 2*I ) ) )
00178    40       CONTINUE
00179          ELSE IF( IDIST.EQ.5 ) THEN
00180 *
00181 *           Convert generated numbers to complex numbers uniformly
00182 *           distributed on the unit circle
00183 *
00184             DO 50 I = 1, IL
00185                X( IV+I-1 ) = EXP( DCMPLX( ZERO, TWOPI*U( 2*I ) ) )
00186    50       CONTINUE
00187          END IF
00188    60 CONTINUE
00189       RETURN
00190 *
00191 *     End of ZLARNV
00192 *
00193       END
 All Files Functions