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
/* Double Complex */ VOID zlarnd_(doublecomplex * ret_val, integer *idist, 
kusano 7d535a
	integer *iseed)
kusano 7d535a
{
kusano 7d535a
    /* System generated locals */
kusano 7d535a
    doublereal d__1, d__2;
kusano 7d535a
    doublecomplex z__1, z__2, z__3;
kusano 7d535a
kusano 7d535a
    /* Builtin functions */
kusano 7d535a
    double log(doublereal), sqrt(doublereal);
kusano 7d535a
    void z_exp(doublecomplex *, doublecomplex *);
kusano 7d535a
kusano 7d535a
    /* Local variables */
kusano 7d535a
    static doublereal t1, t2;
kusano 7d535a
    extern doublereal dlaran_(integer *);
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
       September 30, 1994   
kusano 7d535a
kusano 7d535a
kusano 7d535a
    Purpose   
kusano 7d535a
    =======   
kusano 7d535a
kusano 7d535a
    ZLARND returns a random complex number from a uniform or normal   
kusano 7d535a
    distribution.   
kusano 7d535a
kusano 7d535a
    Arguments   
kusano 7d535a
    =========   
kusano 7d535a
kusano 7d535a
    IDIST   (input) INTEGER   
kusano 7d535a
            Specifies the distribution of the random numbers:   
kusano 7d535a
            = 1:  real and imaginary parts each uniform (0,1)   
kusano 7d535a
            = 2:  real and imaginary parts each uniform (-1,1)   
kusano 7d535a
            = 3:  real and imaginary parts each normal (0,1)   
kusano 7d535a
            = 4:  uniformly distributed on the disc abs(z) <= 1   
kusano 7d535a
            = 5:  uniformly distributed on the circle abs(z) = 1   
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 calls the auxiliary routine DLARAN to generate a random 
kusano 7d535a
  
kusano 7d535a
    real number from a uniform (0,1) distribution. The Box-Muller method 
kusano 7d535a
  
kusano 7d535a
    is used to transform numbers from a uniform to a normal distribution. 
kusano 7d535a
  
kusano 7d535a
kusano 7d535a
    ===================================================================== 
kusano 7d535a
  
kusano 7d535a
kusano 7d535a
kusano 7d535a
       Generate a pair of real random numbers from a uniform (0,1)   
kusano 7d535a
       distribution   
kusano 7d535a
kusano 7d535a
       Parameter adjustments */
kusano 7d535a
    --iseed;
kusano 7d535a
kusano 7d535a
    /* Function Body */
kusano 7d535a
    t1 = dlaran_(&iseed[1]);
kusano 7d535a
    t2 = dlaran_(&iseed[1]);
kusano 7d535a
kusano 7d535a
    if (*idist == 1) {
kusano 7d535a
kusano 7d535a
/*        real and imaginary parts each uniform (0,1) */
kusano 7d535a
kusano 7d535a
	z__1.r = t1, z__1.i = t2;
kusano 7d535a
	 ret_val->r = z__1.r,  ret_val->i = z__1.i;
kusano 7d535a
    } else if (*idist == 2) {
kusano 7d535a
kusano 7d535a
/*        real and imaginary parts each uniform (-1,1) */
kusano 7d535a
kusano 7d535a
	d__1 = t1 * 2. - 1.;
kusano 7d535a
	d__2 = t2 * 2. - 1.;
kusano 7d535a
	z__1.r = d__1, z__1.i = d__2;
kusano 7d535a
	 ret_val->r = z__1.r,  ret_val->i = z__1.i;
kusano 7d535a
    } else if (*idist == 3) {
kusano 7d535a
kusano 7d535a
/*        real and imaginary parts each normal (0,1) */
kusano 7d535a
kusano 7d535a
	d__1 = sqrt(log(t1) * -2.);
kusano 7d535a
	d__2 = t2 * 6.2831853071795864769252867663;
kusano 7d535a
	z__3.r = 0., z__3.i = d__2;
kusano 7d535a
	z_exp(&z__2, &z__3);
kusano 7d535a
	z__1.r = d__1 * z__2.r, z__1.i = d__1 * z__2.i;
kusano 7d535a
	 ret_val->r = z__1.r,  ret_val->i = z__1.i;
kusano 7d535a
    } else if (*idist == 4) {
kusano 7d535a
kusano 7d535a
/*        uniform distribution on the unit disc abs(z) <= 1 */
kusano 7d535a
kusano 7d535a
	d__1 = sqrt(t1);
kusano 7d535a
	d__2 = t2 * 6.2831853071795864769252867663;
kusano 7d535a
	z__3.r = 0., z__3.i = d__2;
kusano 7d535a
	z_exp(&z__2, &z__3);
kusano 7d535a
	z__1.r = d__1 * z__2.r, z__1.i = d__1 * z__2.i;
kusano 7d535a
	 ret_val->r = z__1.r,  ret_val->i = z__1.i;
kusano 7d535a
    } else if (*idist == 5) {
kusano 7d535a
kusano 7d535a
/*        uniform distribution on the unit circle abs(z) = 1 */
kusano 7d535a
kusano 7d535a
	d__1 = t2 * 6.2831853071795864769252867663;
kusano 7d535a
	z__2.r = 0., z__2.i = d__1;
kusano 7d535a
	z_exp(&z__1, &z__2);
kusano 7d535a
	 ret_val->r = z__1.r,  ret_val->i = z__1.i;
kusano 7d535a
    }
kusano 7d535a
    return ;
kusano 7d535a
kusano 7d535a
/*     End of ZLARND */
kusano 7d535a
kusano 7d535a
} /* zlarnd_ */
kusano 7d535a