\chapter{\converse{} Pseudorandom Number Generator}

\converse{} provides three different Linear Congruential Random Number Generators.
Each random number stream has a cycle length of $2^{64}$ as opposed to
ANSI C standard's $2^{48}$.
Also, each of the three random number streams can be split into a number of
per processor streams, so that the random number sequences can be computed 
in parallel, and are reproducible. Furthermore, there is no implicit critical
section in the random number generator,and yet, this functionality is
thread-safe, because all the state information is stored in the structure
allocated by the programmer. Further, this state information is stored in a
first class object, and can be passed to other processors through messages.
This module of \converse{} is based on the public-domain 
SPRNG\footnote{URL:{\tt http://www.ncsa.uiuc.edu/Apps/SPRNG/www/}} 
package developed
by Ashok Srinivasan\footnote{Email:{\tt ashoks@ncsa.uiuc.edu}} at NCSA.

For minimal change to programs already using C functions {\tt rand()},
{\tt srand()}, and {\tt drand48()}, \converse{} also maintains a ``default''
random number stream.

Interface to the \converse{} Pseudorandom Number Generator module is as follows:

\function{typedef ... CrnStream;}
\index{CrnStream}
\desc{State information for generating the next random number in the sequence.}

\function{void CrnInitStream(CrnStream *stream, int seed, int type)}
\index{CrnInitStream}
\desc{Initializes the new random number stream \param{stream} 
of \param{type} using \param{seed}. \param{type} can have values 0, 1, or 2
to represent three types of linear congruential random number generators.}


\function{int CrnInt(CrnStream *stream)}
\index{CrnInt}
\desc{Returns an integer between 0 and $2^{31}-1$ corresponding to the next
random number in the sequence associated with \param{stream}. 
Advances \param{stream} by one in the sequence.}

\function{double CrnDouble(CrnStream *stream)}
\index{CrnDouble}
\desc{Returns an double precision floating point number between 0 and 1
corresponding to the next
random number in the sequence associated with \param{stream}. 
Advances \param{stream} by one in the sequence.}
\desc{}

\function{float CrnFloat(CrnStream *stream)}
\index{CrnFloat}
\desc{Returns a single precision floating point number between 0 and 1 
corresponding to the next
random number in the sequence associated with \param{stream}. 
Advances \param{stream} by one in the sequence.}

\function{void CrnSrand(int seed)}
\index{CrnSrand}
\desc{
Specifies a different seed for the default random number stream.
Replaces {\tt srand()}.
}

\function{int CrnRand(void)}
\index{CrnRand}
\desc{
Generate the next integer random number from the default random number
stream. Replaces {\tt rand()}.
}

\function{double CrnDrand(void)}
\index{CrnDrand}
\desc{
Generate the next double precision random number from the default random number
stream. Replaces {\tt drand48()}.
}
