LAPACK 3.12.0
LAPACK: Linear Algebra PACKage
Loading...
Searching...
No Matches

◆ dlarnd()

double precision function dlarnd ( integer  idist,
integer, dimension( 4 )  iseed 
)

DLARND

Purpose:
 DLARND 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 DLARAN 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 dlarnd.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 DOUBLE PRECISION ONE, TWO
89 parameter( one = 1.0d+0, two = 2.0d+0 )
90 DOUBLE PRECISION TWOPI
91 parameter( twopi = 6.28318530717958647692528676655900576839d+0 )
92* ..
93* .. Local Scalars ..
94 DOUBLE PRECISION T1, T2
95* ..
96* .. External Functions ..
97 DOUBLE PRECISION DLARAN
98 EXTERNAL dlaran
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 = dlaran( iseed )
108*
109 IF( idist.EQ.1 ) THEN
110*
111* uniform (0,1)
112*
113 dlarnd = t1
114 ELSE IF( idist.EQ.2 ) THEN
115*
116* uniform (-1,1)
117*
118 dlarnd = two*t1 - one
119 ELSE IF( idist.EQ.3 ) THEN
120*
121* normal (0,1)
122*
123 t2 = dlaran( iseed )
124 dlarnd = sqrt( -two*log( t1 ) )*cos( twopi*t2 )
125 END IF
126 RETURN
127*
128* End of DLARND
129*
double precision function dlaran(iseed)
DLARAN
Definition dlaran.f:67
double precision function dlarnd(idist, iseed)
DLARND
Definition dlarnd.f:73
Here is the call graph for this function:
Here is the caller graph for this function: