/*Translated by FOR_C, v3.4.2 (-), on 07/09/115 at 08:31:59 */ /*FOR_C Options SET: ftn=u io=c no=p op=aimnv s=dbov str=l x=f - prototypes */ #include #include "fcrt.h" #include "srane.h" #include /* PARAMETER translations */ #define M 97 /* end of PARAMETER translations */ /* COMMON translations */ struct t_rancs2 { float snums[M]; } rancs2; struct t_rancs1 { long int sptr; LOGICAL32 sgflag; } rancs1; /* end of COMMON translations */ float /*FUNCTION*/ srane( float stddev) { float srane_v; static LOGICAL32 first = TRUE; /* OFFSET Vectors w/subscript range: 1 to dimension */ float *const Snums = &rancs2.snums[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 SRANE Krogh Changes to use M77CON *>> 1994-06-24 SRANE 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 SGFLAG 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 SRANE 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 SRANE = -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. * ------------------------------------------------------------------ *--S replaces "?": ?RANE, ?RANUA, RANC?1, RANC?2, ?PTR, ?NUMS, ?GFLAG * RANCS1 and RANCS2 are common blocks. * Calls RAN0 to initialize SPTR and SGFLAG. * ------------------------------------------------------------------ */ /* ------------------------------------------------------------------ */ if (first) { first = FALSE; ran0(); } rancs1.sptr -= 1; if (rancs1.sptr == 0) { sranua( rancs2.snums, M ); rancs1.sptr = M; } srane_v = -stddev*logf( Snums[rancs1.sptr] ); return( srane_v ); } /* end of function */