diff options
author | Joseph Hunkeler <jhunkeler@gmail.com> | 2015-03-04 21:21:30 -0500 |
---|---|---|
committer | Joseph Hunkeler <jhunkeler@gmail.com> | 2015-03-04 21:21:30 -0500 |
commit | d54fe7c1f704a63824c5bfa0ece65245572e9b27 (patch) | |
tree | afc52015ffc2c74e0266653eecef1c8ef8ba5d91 /src/slalib/rtl_random.c | |
download | calfuse-d54fe7c1f704a63824c5bfa0ece65245572e9b27.tar.gz |
Initial commit
Diffstat (limited to 'src/slalib/rtl_random.c')
-rw-r--r-- | src/slalib/rtl_random.c | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/src/slalib/rtl_random.c b/src/slalib/rtl_random.c new file mode 100644 index 0000000..a8730c0 --- /dev/null +++ b/src/slalib/rtl_random.c @@ -0,0 +1,33 @@ +#include <stdlib.h> + +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; +} |