From fa080de7afc95aa1c19a6e6fc0e0708ced2eadc4 Mon Sep 17 00:00:00 2001 From: Joseph Hunkeler Date: Wed, 8 Jul 2015 20:46:52 -0400 Subject: Initial commit --- math/slalib/rtl_random.c | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 math/slalib/rtl_random.c (limited to 'math/slalib/rtl_random.c') diff --git a/math/slalib/rtl_random.c b/math/slalib/rtl_random.c new file mode 100644 index 00000000..a8730c0c --- /dev/null +++ b/math/slalib/rtl_random.c @@ -0,0 +1,33 @@ +#include + +float +random_ ( int *iseed ) +/* +** - - - - - - - +** r a n d o m +** - - - - - - - +** +** Generate pseudo-random real number in the range 0 <= x < 1. +** +** (single precision) +** +** This function is designed to replace the Fortran->C interface routine +** random(3f) on systems which do not have this library (for example Linux) +** +** Fortran call: X = RANDOM(ISEED) +** +** Given: +** iseed int seed value +** +** If iseed !=0 random-number generator is initialised and first number +** is returned. +** iseed == 0 next number in the sequence is returned +** +** B.K.McIlwrath Starlink 12 January 1996 +*/ +{ + if( *iseed != 0 ) + srand(*iseed); + + return (float) rand() / (float) RAND_MAX; +} -- cgit