LAPACK  3.10.0
LAPACK: Linear Algebra PACKage

◆ slarnd()

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.
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 72 of file slarnd.f.

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