![]() |
LAPACK
3.4.1
LAPACK: Linear Algebra PACKage
|
00001 *> \brief \b SLARND 00002 * 00003 * =========== DOCUMENTATION =========== 00004 * 00005 * Online html documentation available at 00006 * http://www.netlib.org/lapack/explore-html/ 00007 * 00008 * Definition: 00009 * =========== 00010 * 00011 * REAL FUNCTION SLARND( 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 *> SLARND returns a random real 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: uniform (0,1) 00038 *> = 2: uniform (-1,1) 00039 *> = 3: normal (0,1) 00040 *> \endverbatim 00041 *> 00042 *> \param[in,out] ISEED 00043 *> \verbatim 00044 *> ISEED is INTEGER array, dimension (4) 00045 *> On entry, the seed of the random number generator; the array 00046 *> elements must be between 0 and 4095, and ISEED(4) must be 00047 *> odd. 00048 *> On exit, the seed is updated. 00049 *> \endverbatim 00050 * 00051 * Authors: 00052 * ======== 00053 * 00054 *> \author Univ. of Tennessee 00055 *> \author Univ. of California Berkeley 00056 *> \author Univ. of Colorado Denver 00057 *> \author NAG Ltd. 00058 * 00059 *> \date November 2011 00060 * 00061 *> \ingroup real_matgen 00062 * 00063 *> \par Further Details: 00064 * ===================== 00065 *> 00066 *> \verbatim 00067 *> 00068 *> This routine calls the auxiliary routine SLARAN to generate a random 00069 *> real number from a uniform (0,1) distribution. The Box-Muller method 00070 *> is used to transform numbers from a uniform to a normal distribution. 00071 *> \endverbatim 00072 *> 00073 * ===================================================================== 00074 REAL FUNCTION SLARND( IDIST, ISEED ) 00075 * 00076 * -- LAPACK auxiliary routine (version 3.4.0) -- 00077 * -- LAPACK is a software package provided by Univ. of Tennessee, -- 00078 * -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..-- 00079 * November 2011 00080 * 00081 * .. Scalar Arguments .. 00082 INTEGER IDIST 00083 * .. 00084 * .. Array Arguments .. 00085 INTEGER ISEED( 4 ) 00086 * .. 00087 * 00088 * ===================================================================== 00089 * 00090 * .. Parameters .. 00091 REAL ONE, TWO 00092 PARAMETER ( ONE = 1.0E+0, TWO = 2.0E+0 ) 00093 REAL TWOPI 00094 PARAMETER ( TWOPI = 6.2831853071795864769252867663E+0 ) 00095 * .. 00096 * .. Local Scalars .. 00097 REAL T1, T2 00098 * .. 00099 * .. External Functions .. 00100 REAL SLARAN 00101 EXTERNAL SLARAN 00102 * .. 00103 * .. Intrinsic Functions .. 00104 INTRINSIC COS, LOG, SQRT 00105 * .. 00106 * .. Executable Statements .. 00107 * 00108 * Generate a real random number from a uniform (0,1) distribution 00109 * 00110 T1 = SLARAN( ISEED ) 00111 * 00112 IF( IDIST.EQ.1 ) THEN 00113 * 00114 * uniform (0,1) 00115 * 00116 SLARND = T1 00117 ELSE IF( IDIST.EQ.2 ) THEN 00118 * 00119 * uniform (-1,1) 00120 * 00121 SLARND = TWO*T1 - ONE 00122 ELSE IF( IDIST.EQ.3 ) THEN 00123 * 00124 * normal (0,1) 00125 * 00126 T2 = SLARAN( ISEED ) 00127 SLARND = SQRT( -TWO*LOG( T1 ) )*COS( TWOPI*T2 ) 00128 END IF 00129 RETURN 00130 * 00131 * End of SLARND 00132 * 00133 END