\section{lib/c/random.c File Reference}
\label{random_8c}\index{lib/c/random.c@{lib/c/random.c}}
A portable random number generator. 

\subsection*{Data Structures}
\begin{CompactItemize}
\item 
struct {\bf prandom\_\-t}
\begin{CompactList}\small\item\em A pseudo-random number generator. \item\end{CompactList}\end{CompactItemize}
\subsection*{Defines}
\begin{CompactItemize}
\item 
\#define {\bf PRANDOM\_\-SLOTS}\ 16
\item 
\#define {\bf PRANDOM\_\-MASK}\ 0x3fc91ab4
\item 
\#define {\bf PRANDOM\_\-A}\ 16807
\item 
\#define {\bf PRANDOM\_\-M}\ 2147483647
\item 
\#define {\bf PRANDOM\_\-Q}\ 127773
\item 
\#define {\bf PRANDOM\_\-R}\ 2836
\end{CompactItemize}
\subsection*{Functions}
\begin{CompactItemize}
\item 
void {\bf randstep} (long $\ast$val)
\begin{CompactList}\small\item\em a primitive randomizing step, using a linear congruential generator. \item\end{CompactList}\item 
void {\bf srandom} (unsigned \_\-seed)
\begin{CompactList}\small\item\em Initialize pseudo-random number generator from seed. \item\end{CompactList}\item 
long {\bf random} ()
\begin{CompactList}\small\item\em generate a random number \item\end{CompactList}\end{CompactItemize}
\subsection*{Variables}
\begin{CompactItemize}
\item 
{\bf prandom\_\-t} {\bf generator}
\begin{CompactList}\small\item\em the generator used. \item\end{CompactList}\end{CompactItemize}


\subsection{Detailed Description}
A portable random number generator. 

\begin{Desc}
\item[Author:]Copyright (c) 2000 Markus L. Noga $<${\tt markus@noga.de}$>$\end{Desc}
See Numerical Recipes in C 2nd Edition, p. 279-281 for inspiration.

Definition in file {\bf random.c}.

\subsection{Define Documentation}
\index{random.c@{random.c}!PRANDOM_A@{PRANDOM\_\-A}}
\index{PRANDOM_A@{PRANDOM\_\-A}!random.c@{random.c}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}\#define PRANDOM\_\-A\ 16807}\label{random_8c_a2}




Definition at line 19 of file random.c.

Referenced by randstep().\index{random.c@{random.c}!PRANDOM_M@{PRANDOM\_\-M}}
\index{PRANDOM_M@{PRANDOM\_\-M}!random.c@{random.c}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}\#define PRANDOM\_\-M\ 2147483647}\label{random_8c_a3}




Definition at line 20 of file random.c.\index{random.c@{random.c}!PRANDOM_MASK@{PRANDOM\_\-MASK}}
\index{PRANDOM_MASK@{PRANDOM\_\-MASK}!random.c@{random.c}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}\#define PRANDOM\_\-MASK\ 0x3fc91ab4}\label{random_8c_a1}




Definition at line 17 of file random.c.\index{random.c@{random.c}!PRANDOM_Q@{PRANDOM\_\-Q}}
\index{PRANDOM_Q@{PRANDOM\_\-Q}!random.c@{random.c}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}\#define PRANDOM\_\-Q\ 127773}\label{random_8c_a4}




Definition at line 21 of file random.c.\index{random.c@{random.c}!PRANDOM_R@{PRANDOM\_\-R}}
\index{PRANDOM_R@{PRANDOM\_\-R}!random.c@{random.c}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}\#define PRANDOM\_\-R\ 2836}\label{random_8c_a5}




Definition at line 22 of file random.c.

Referenced by randstep().\index{random.c@{random.c}!PRANDOM_SLOTS@{PRANDOM\_\-SLOTS}}
\index{PRANDOM_SLOTS@{PRANDOM\_\-SLOTS}!random.c@{random.c}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}\#define PRANDOM\_\-SLOTS\ 16}\label{random_8c_a0}




Definition at line 16 of file random.c.

Referenced by random(), and srandom().

\subsection{Function Documentation}
\index{random.c@{random.c}!random@{random}}
\index{random@{random}!random.c@{random.c}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}long random (void)}\label{random_8c_a9}


generate a random number 

The {\bf random()}{\rm (p.\,\pageref{stdlib_8h_a3})} function returns successive pseudo-random numbers \begin{Desc}
\item[Returns:]a random number in the range from 0 to RAND\_\-MAX \end{Desc}


Definition at line 77 of file random.c.

References prandom\_\-t::entry, generator, PRANDOM\_\-SLOTS, randstep(), prandom\_\-t::select, and prandom\_\-t::state.\index{random.c@{random.c}!randstep@{randstep}}
\index{randstep@{randstep}!random.c@{random.c}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}void randstep (long $\ast$ {\em val})}\label{random_8c_a7}


a primitive randomizing step, using a linear congruential generator. 



Definition at line 49 of file random.c.

References PRANDOM\_\-A, and PRANDOM\_\-R.

Referenced by random(), and srandom().\index{random.c@{random.c}!srandom@{srandom}}
\index{srandom@{srandom}!random.c@{random.c}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}void srandom (unsigned {\em \_\-seed})}\label{random_8c_a8}


Initialize pseudo-random number generator from seed. 



Definition at line 58 of file random.c.

References prandom\_\-t::entry, generator, PRANDOM\_\-SLOTS, randstep(), prandom\_\-t::select, and prandom\_\-t::state.

\subsection{Variable Documentation}
\index{random.c@{random.c}!generator@{generator}}
\index{generator@{generator}!random.c@{random.c}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}{\bf prandom\_\-t} {\bf generator}\hspace{0.3cm}{\tt  [static]}}\label{random_8c_a6}


the generator used. 



Definition at line 39 of file random.c.

Referenced by random(), and srandom().