1
*> \brief \b DLARUV returns a vector of n random real numbers from a uniform distribution.
3
* =========== DOCUMENTATION ===========
5
* Online html documentation available at
6
* http://www.netlib.org/lapack/explore-html/
9
*> Download DLARUV + dependencies
10
*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/dlaruv.f">
12
*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/dlaruv.f">
14
*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/dlaruv.f">
21
* SUBROUTINE DLARUV( ISEED, N, X )
23
* .. Scalar Arguments ..
26
* .. Array Arguments ..
28
* DOUBLE PRECISION X( N )
37
*> DLARUV returns a vector of n random real numbers from a uniform (0,1)
38
*> distribution (n <= 128).
40
*> This is an auxiliary routine called by DLARNV and ZLARNV.
46
*> \param[in,out] ISEED
48
*> ISEED is INTEGER array, dimension (4)
49
*> On entry, the seed of the random number generator; the array
50
*> elements must be between 0 and 4095, and ISEED(4) must be
52
*> On exit, the seed is updated.
58
*> The number of random numbers to be generated. N <= 128.
63
*> X is DOUBLE PRECISION array, dimension (N)
64
*> The generated random numbers.
70
*> \author Univ. of Tennessee
71
*> \author Univ. of California Berkeley
72
*> \author Univ. of Colorado Denver
75
*> \date September 2012
77
*> \ingroup auxOTHERauxiliary
79
*> \par Further Details:
80
* =====================
84
*> This routine uses a multiplicative congruential method with modulus
85
*> 2**48 and multiplier 33952834046453 (see G.S.Fishman,
86
*> 'Multiplicative congruential random number generators with modulus
87
*> 2**b: an exhaustive analysis for b = 32 and a partial analysis for
88
*> b = 48', Math. Comp. 189, pp 331-344, 1990).
90
*> 48-bit integers are stored in 4 integer array elements with 12 bits
91
*> per element. Hence the routine is portable across machines with
92
*> integers of 32 bits or more.
95
* =====================================================================
1
96
SUBROUTINE DLARUV( ISEED, N, X )
3
* -- LAPACK auxiliary routine (version 2.0) --
4
* Univ. of Tennessee, Univ. of California Berkeley, NAG Ltd.,
5
* Courant Institute, Argonne National Lab, and Rice University
98
* -- LAPACK auxiliary routine (version 3.4.2) --
99
* -- LAPACK is a software package provided by Univ. of Tennessee, --
100
* -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
8
103
* .. Scalar Arguments ..
13
108
DOUBLE PRECISION X( N )
17
* $Id: dlaruv.f 19697 2010-10-29 16:57:34Z d3y133 $
22
* DLARUV returns a vector of n random real numbers from a uniform (0,1)
23
* distribution (n <= 128).
25
* This is an auxiliary routine called by DLARNV and ZLARNV.
30
* ISEED (input/output) INTEGER array, dimension (4)
31
* On entry, the seed of the random number generator; the array
32
* elements must be between 0 and 4095, and ISEED(4) must be
34
* On exit, the seed is updated.
37
* The number of random numbers to be generated. N <= 128.
39
* X (output) DOUBLE PRECISION array, dimension (N)
40
* The generated random numbers.
45
* This routine uses a multiplicative congruential method with modulus
46
* 2**48 and multiplier 33952834046453 (see G.S.Fishman,
47
* 'Multiplicative congruential random number generators with modulus
48
* 2**b: an exhaustive analysis for b = 32 and a partial analysis for
49
* b = 48', Math. Comp. 189, pp 331-344, 1990).
51
* 48-bit integers are stored in 4 integer array elements with 12 bits
52
* per element. Hence the routine is portable across machines with
53
* integers of 32 bits or more.
55
111
* =====================================================================
57
113
* .. Parameters ..
364
415
X( I ) = R*( DBLE( IT1 )+R*( DBLE( IT2 )+R*( DBLE( IT3 )+R*
365
416
$ DBLE( IT4 ) ) ) )
418
IF (X( I ).EQ.1.0D0) THEN
419
* If a real number has n bits of precision, and the first
420
* n bits of the 48-bit integer above happen to be all 1 (which
421
* will occur about once every 2**n calls), then X( I ) will
422
* be rounded to exactly 1.0.
423
* Since X( I ) is not supposed to return exactly 0.0 or 1.0,
424
* the statistically correct thing to do in this situation is
425
* simply to iterate again.
426
* N.B. the case X( I ) = 0.0 should not be possible.
368
436
* Return final value of seed