LAPACK  3.6.1
LAPACK: Linear Algebra PACKage
real function slarnd ( integer  IDIST,
integer, dimension( 4 )  ISEED 
)

SLARND

Purpose:
 SLARND returns a random real number from a uniform or normal
 distribution.
Parameters
[in]IDIST
          IDIST is INTEGER
          Specifies the distribution of the random numbers:
          = 1:  uniform (0,1)
          = 2:  uniform (-1,1)
          = 3:  normal (0,1)
[in,out]ISEED
          ISEED is INTEGER array, dimension (4)
          On entry, the seed of the random number generator; the array
          elements must be between 0 and 4095, and ISEED(4) must be
          odd.
          On exit, the seed is updated.
Author
Univ. of Tennessee
Univ. of California Berkeley
Univ. of Colorado Denver
NAG Ltd.
Date
November 2011
Further Details:
  This routine calls the auxiliary routine SLARAN to generate a random
  real number from a uniform (0,1) distribution. The Box-Muller method
  is used to transform numbers from a uniform to a normal distribution.

Definition at line 75 of file slarnd.f.

75 *
76 * -- LAPACK auxiliary routine (version 3.4.0) --
77 * -- LAPACK is a software package provided by Univ. of Tennessee, --
78 * -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
79 * November 2011
80 *
81 * .. Scalar Arguments ..
82  INTEGER idist
83 * ..
84 * .. Array Arguments ..
85  INTEGER iseed( 4 )
86 * ..
87 *
88 * =====================================================================
89 *
90 * .. Parameters ..
91  REAL one, two
92  parameter ( one = 1.0e+0, two = 2.0e+0 )
93  REAL twopi
94  parameter ( twopi = 6.2831853071795864769252867663e+0 )
95 * ..
96 * .. Local Scalars ..
97  REAL t1, t2
98 * ..
99 * .. External Functions ..
100  REAL slaran
101  EXTERNAL slaran
102 * ..
103 * .. Intrinsic Functions ..
104  INTRINSIC cos, log, sqrt
105 * ..
106 * .. Executable Statements ..
107 *
108 * Generate a real random number from a uniform (0,1) distribution
109 *
110  t1 = slaran( iseed )
111 *
112  IF( idist.EQ.1 ) THEN
113 *
114 * uniform (0,1)
115 *
116  slarnd = t1
117  ELSE IF( idist.EQ.2 ) THEN
118 *
119 * uniform (-1,1)
120 *
121  slarnd = two*t1 - one
122  ELSE IF( idist.EQ.3 ) THEN
123 *
124 * normal (0,1)
125 *
126  t2 = slaran( iseed )
127  slarnd = sqrt( -two*log( t1 ) )*cos( twopi*t2 )
128  END IF
129  RETURN
130 *
131 * End of SLARND
132 *
real function slarnd(IDIST, ISEED)
SLARND
Definition: slarnd.f:75
real function slaran(ISEED)
SLARAN
Definition: slaran.f:69