kusano 7d535a
/*  -- translated by f2c (version 19940927).
kusano 7d535a
   You must link the resulting object file with the libraries:
kusano 7d535a
	-lf2c -lm   (in that order)
kusano 7d535a
*/
kusano 7d535a
kusano 7d535a
#include "f2c.h"
kusano 7d535a
kusano 7d535a
doublereal slaran_(integer *iseed)
kusano 7d535a
{
kusano 7d535a
    /* System generated locals */
kusano 7d535a
    real ret_val;
kusano 7d535a
kusano 7d535a
    /* Local variables */
kusano 7d535a
    static integer it1, it2, it3, it4;
kusano 7d535a
kusano 7d535a
kusano 7d535a
/*  -- LAPACK auxiliary routine (version 2.0) --   
kusano 7d535a
       Univ. of Tennessee, Univ. of California Berkeley, NAG Ltd.,   
kusano 7d535a
       Courant Institute, Argonne National Lab, and Rice University   
kusano 7d535a
       February 29, 1992   
kusano 7d535a
kusano 7d535a
kusano 7d535a
    Purpose   
kusano 7d535a
    =======   
kusano 7d535a
kusano 7d535a
    SLARAN returns a random real number from a uniform (0,1)   
kusano 7d535a
    distribution.   
kusano 7d535a
kusano 7d535a
    Arguments   
kusano 7d535a
    =========   
kusano 7d535a
kusano 7d535a
    ISEED   (input/output) INTEGER array, dimension (4)   
kusano 7d535a
            On entry, the seed of the random number generator; the array 
kusano 7d535a
  
kusano 7d535a
            elements must be between 0 and 4095, and ISEED(4) must be   
kusano 7d535a
            odd.   
kusano 7d535a
            On exit, the seed is updated.   
kusano 7d535a
kusano 7d535a
    Further Details   
kusano 7d535a
    ===============   
kusano 7d535a
kusano 7d535a
    This routine uses a multiplicative congruential method with modulus   
kusano 7d535a
    2**48 and multiplier 33952834046453 (see G.S.Fishman,   
kusano 7d535a
    'Multiplicative congruential random number generators with modulus   
kusano 7d535a
    2**b: an exhaustive analysis for b = 32 and a partial analysis for   
kusano 7d535a
    b = 48', Math. Comp. 189, pp 331-344, 1990).   
kusano 7d535a
kusano 7d535a
    48-bit integers are stored in 4 integer array elements with 12 bits   
kusano 7d535a
    per element. Hence the routine is portable across machines with   
kusano 7d535a
    integers of 32 bits or more.   
kusano 7d535a
kusano 7d535a
    ===================================================================== 
kusano 7d535a
  
kusano 7d535a
kusano 7d535a
kusano 7d535a
       multiply the seed by the multiplier modulo 2**48   
kusano 7d535a
kusano 7d535a
       Parameter adjustments */
kusano 7d535a
    --iseed;
kusano 7d535a
kusano 7d535a
    /* Function Body */
kusano 7d535a
    it4 = iseed[4] * 2549;
kusano 7d535a
    it3 = it4 / 4096;
kusano 7d535a
    it4 -= it3 << 12;
kusano 7d535a
    it3 = it3 + iseed[3] * 2549 + iseed[4] * 2508;
kusano 7d535a
    it2 = it3 / 4096;
kusano 7d535a
    it3 -= it2 << 12;
kusano 7d535a
    it2 = it2 + iseed[2] * 2549 + iseed[3] * 2508 + iseed[4] * 322;
kusano 7d535a
    it1 = it2 / 4096;
kusano 7d535a
    it2 -= it1 << 12;
kusano 7d535a
    it1 = it1 + iseed[1] * 2549 + iseed[2] * 2508 + iseed[3] * 322 + iseed[4] 
kusano 7d535a
	    * 494;
kusano 7d535a
    it1 %= 4096;
kusano 7d535a
kusano 7d535a
/*     return updated seed */
kusano 7d535a
kusano 7d535a
    iseed[1] = it1;
kusano 7d535a
    iseed[2] = it2;
kusano 7d535a
    iseed[3] = it3;
kusano 7d535a
    iseed[4] = it4;
kusano 7d535a
kusano 7d535a
/*     convert 48-bit integer to a real number in the interval (0,1) */
kusano 7d535a
kusano 7d535a
    ret_val = ((real) it1 + ((real) it2 + ((real) it3 + (real) it4 * 
kusano 7d535a
	    2.44140625e-4f) * 2.44140625e-4f) * 2.44140625e-4f) * 
kusano 7d535a
	    2.44140625e-4f;
kusano 7d535a
    return ret_val;
kusano 7d535a
kusano 7d535a
/*     End of SLARAN */
kusano 7d535a
kusano 7d535a
} /* slaran_ */
kusano 7d535a