/*Translated by FOR_C, v3.4.2 (-), on 07/09/115 at 08:31:56 */ /*FOR_C Options SET: ftn=u io=c no=p op=aimnv s=dbov str=l x=f - prototypes */ #include #include "fcrt.h" #include "drane.h" #include /* PARAMETER translations */ #define M 97 /* end of PARAMETER translations */ /* COMMON translations */ struct t_rancd2 { double dnums[M]; } rancd2; struct t_rancd1 { long int dptr; LOGICAL32 dgflag; } rancd1; /* end of COMMON translations */ double /*FUNCTION*/ drane( double stddev) { double drane_v; static LOGICAL32 first = TRUE; /* OFFSET Vectors w/subscript range: 1 to dimension */ double *const Dnums = &rancd2.dnums[0] - 1; /* end of OFFSET VECTORS */ /* Copyright (c) 1996 California Institute of Technology, Pasadena, CA. * ALL RIGHTS RESERVED. * Based on Government Sponsored Research NAS7-03001. *>> 1994-10-20 DRANE Krogh Changes to use M77CON *>> 1994-06-24 DRANE CLL Changed common to use RANC[D/S]1 & RANC[D/S]2. *>> 1992-03-16 CLL *>> 1991-11-26 CLL Reorganized common. Using RANCM[A/D/S]. *>> 1991-11-22 CLL Added call to RAN0, and DGFLAG in common. *>> 1991-01-15 CLL Reordered common contents for efficiency. *>> 1990-01-23 CLL Making names in common same in all subprogams. *>> 1987-04-22 DRANE Lawson Initial code. * Returns one pseudorandom number from the Exponential * distribution with standard deviation, STDDEV, which should be * positive. * If U is random, uniform on [0, 1], the Exponential variable is * given by DRANE = -STDDEV * log(U) * This variable has mean = STDDEV * and variance = STDDEV**2 * Reference: NBS AMS 55, P. 930. * Code based on subprogram written for JPL by Stephen L. Ritchie, * Heliodyne Corp. and Wiley R. Bunton, JPL, 1969. * Adapted to Fortran 77 for the JPL MATH77 library by C. L. Lawson & * S. Y. Chiu, JPL, Apr 1987. * ------------------------------------------------------------------ *--D replaces "?": ?RANE, ?RANUA, RANC?1, RANC?2, ?PTR, ?NUMS, ?GFLAG * RANCD1 and RANCD2 are common blocks. * Calls RAN0 to initialize DPTR and DGFLAG. * ------------------------------------------------------------------ */ /* ------------------------------------------------------------------ */ if (first) { first = FALSE; ran0(); } rancd1.dptr -= 1; if (rancd1.dptr == 0) { dranua( rancd2.dnums, M ); rancd1.dptr = M; } drane_v = -stddev*log( Dnums[rancd1.dptr] ); return( drane_v ); } /* end of function */