version 1.1.1.1, 2010/01/26 15:22:45
|
version 1.15, 2017/06/17 10:53:56
|
Line 1
|
Line 1
|
|
*> \brief \b DLARUV returns a vector of n random real numbers from a uniform distribution. |
|
* |
|
* =========== DOCUMENTATION =========== |
|
* |
|
* Online html documentation available at |
|
* http://www.netlib.org/lapack/explore-html/ |
|
* |
|
*> \htmlonly |
|
*> Download DLARUV + dependencies |
|
*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/dlaruv.f"> |
|
*> [TGZ]</a> |
|
*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/dlaruv.f"> |
|
*> [ZIP]</a> |
|
*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/dlaruv.f"> |
|
*> [TXT]</a> |
|
*> \endhtmlonly |
|
* |
|
* Definition: |
|
* =========== |
|
* |
|
* SUBROUTINE DLARUV( ISEED, N, X ) |
|
* |
|
* .. Scalar Arguments .. |
|
* INTEGER N |
|
* .. |
|
* .. Array Arguments .. |
|
* INTEGER ISEED( 4 ) |
|
* DOUBLE PRECISION X( N ) |
|
* .. |
|
* |
|
* |
|
*> \par Purpose: |
|
* ============= |
|
*> |
|
*> \verbatim |
|
*> |
|
*> DLARUV returns a vector of n random real numbers from a uniform (0,1) |
|
*> distribution (n <= 128). |
|
*> |
|
*> This is an auxiliary routine called by DLARNV and ZLARNV. |
|
*> \endverbatim |
|
* |
|
* Arguments: |
|
* ========== |
|
* |
|
*> \param[in,out] ISEED |
|
*> \verbatim |
|
*> 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. |
|
*> \endverbatim |
|
*> |
|
*> \param[in] N |
|
*> \verbatim |
|
*> N is INTEGER |
|
*> The number of random numbers to be generated. N <= 128. |
|
*> \endverbatim |
|
*> |
|
*> \param[out] X |
|
*> \verbatim |
|
*> X is DOUBLE PRECISION array, dimension (N) |
|
*> The generated random numbers. |
|
*> \endverbatim |
|
* |
|
* Authors: |
|
* ======== |
|
* |
|
*> \author Univ. of Tennessee |
|
*> \author Univ. of California Berkeley |
|
*> \author Univ. of Colorado Denver |
|
*> \author NAG Ltd. |
|
* |
|
*> \date December 2016 |
|
* |
|
*> \ingroup OTHERauxiliary |
|
* |
|
*> \par Further Details: |
|
* ===================== |
|
*> |
|
*> \verbatim |
|
*> |
|
*> This routine uses a multiplicative congruential method with modulus |
|
*> 2**48 and multiplier 33952834046453 (see G.S.Fishman, |
|
*> 'Multiplicative congruential random number generators with modulus |
|
*> 2**b: an exhaustive analysis for b = 32 and a partial analysis for |
|
*> b = 48', Math. Comp. 189, pp 331-344, 1990). |
|
*> |
|
*> 48-bit integers are stored in 4 integer array elements with 12 bits |
|
*> per element. Hence the routine is portable across machines with |
|
*> integers of 32 bits or more. |
|
*> \endverbatim |
|
*> |
|
* ===================================================================== |
SUBROUTINE DLARUV( ISEED, N, X ) |
SUBROUTINE DLARUV( ISEED, N, X ) |
* |
* |
* -- LAPACK auxiliary routine (version 3.2) -- |
* -- LAPACK auxiliary routine (version 3.7.0) -- |
* -- LAPACK is a software package provided by Univ. of Tennessee, -- |
* -- LAPACK is a software package provided by Univ. of Tennessee, -- |
* -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..-- |
* -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..-- |
* November 2006 |
* December 2016 |
* |
* |
* .. Scalar Arguments .. |
* .. Scalar Arguments .. |
INTEGER N |
INTEGER N |
Line 13
|
Line 108
|
DOUBLE PRECISION X( N ) |
DOUBLE PRECISION X( N ) |
* .. |
* .. |
* |
* |
* Purpose |
|
* ======= |
|
* |
|
* DLARUV returns a vector of n random real numbers from a uniform (0,1) |
|
* distribution (n <= 128). |
|
* |
|
* This is an auxiliary routine called by DLARNV and ZLARNV. |
|
* |
|
* Arguments |
|
* ========= |
|
* |
|
* ISEED (input/output) 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. |
|
* |
|
* N (input) INTEGER |
|
* The number of random numbers to be generated. N <= 128. |
|
* |
|
* X (output) DOUBLE PRECISION array, dimension (N) |
|
* The generated random numbers. |
|
* |
|
* Further Details |
|
* =============== |
|
* |
|
* This routine uses a multiplicative congruential method with modulus |
|
* 2**48 and multiplier 33952834046453 (see G.S.Fishman, |
|
* 'Multiplicative congruential random number generators with modulus |
|
* 2**b: an exhaustive analysis for b = 32 and a partial analysis for |
|
* b = 48', Math. Comp. 189, pp 331-344, 1990). |
|
* |
|
* 48-bit integers are stored in 4 integer array elements with 12 bits |
|
* per element. Hence the routine is portable across machines with |
|
* integers of 32 bits or more. |
|
* |
|
* ===================================================================== |
* ===================================================================== |
* |
* |
* .. Parameters .. |
* .. Parameters .. |
Line 333
|
Line 392
|
I4 = ISEED( 4 ) |
I4 = ISEED( 4 ) |
* |
* |
DO 10 I = 1, MIN( N, LV ) |
DO 10 I = 1, MIN( N, LV ) |
* |
* |
20 CONTINUE |
20 CONTINUE |
* |
* |
* Multiply the seed by i-th power of the multiplier modulo 2**48 |
* Multiply the seed by i-th power of the multiplier modulo 2**48 |
Line 360
|
Line 419
|
* If a real number has n bits of precision, and the first |
* If a real number has n bits of precision, and the first |
* n bits of the 48-bit integer above happen to be all 1 (which |
* n bits of the 48-bit integer above happen to be all 1 (which |
* will occur about once every 2**n calls), then X( I ) will |
* will occur about once every 2**n calls), then X( I ) will |
* be rounded to exactly 1.0. |
* be rounded to exactly 1.0. |
* Since X( I ) is not supposed to return exactly 0.0 or 1.0, |
* Since X( I ) is not supposed to return exactly 0.0 or 1.0, |
* the statistically correct thing to do in this situation is |
* the statistically correct thing to do in this situation is |
* simply to iterate again. |
* simply to iterate again. |
* N.B. the case X( I ) = 0.0 should not be possible. |
* N.B. the case X( I ) = 0.0 should not be possible. |
I1 = I1 + 2 |
I1 = I1 + 2 |
I2 = I2 + 2 |
I2 = I2 + 2 |
I3 = I3 + 2 |
I3 = I3 + 2 |