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