Quick Reference:Simple Interface

Next:Default Interface


Quick Reference for the Simple Interface

Header files and Macros

C++: Include the header file sprng_cpp.h.
FORTRAN: Include the header file sprng_f.h.

Define the following macro before including a SPRNG header file:
SIMPLE_SPRNG to obtain this simple interface.
FLOAT_GEN to obtain single precision numbers when calling sprng, instead of the double precision default.
USE_MPI to get the same seed on all processors with make_sprng_seed, or if user does not plan to call init_sprng, in the MPI version.

sprng_f.h defines the macro SPRNG_POINTER to be a FORTRAN integer large enough to hold a C++ pointer.

SPRNG Functions

The C++ call is given first, followed by the FORTRAN call.
int * init_sprng(int seed, int param, int rng_type = 0)
SPRNG_POINTER init_sprng(integer seed, integer param)

Initialize a random number stream with seed seed and parameter param. Return 0 if unsuccessful.

double sprng()
real*8 sprng()

The next random number in [0,1) is returned.

int isprng()
integer isprng()

The next random number in [0,231) is returned.

int print_sprng()
integer print_sprng()

Print information about the random number stream.

int make_sprng_seed()
integer make_sprng_seed()

Produce a seed. Define USE_MPI to get the same seed on all processors with the MPI version.

int pack_sprng(char **buffer)
integer pack_sprng(character buffer)

Pack the stream into an array and return the number of bytes of storage required. fbuffer is an array of size MAX_PACKED_LENGTH. In C++, SPRNG allocates memory and has the result stored in *buffer.

int * unpack_sprng(char *buffer, int rng_type = 0)
SPRNG_POINTER unpack_sprng(character buffer)

Recreate the stream that had been packed into buffer. Return 0 if unsuccessful.


[Quick Start] [User's Guide] [Reference Manual] [Quick Reference] [Next: Default Interface]