\section{Ran\-Base\-Class  Class Reference}
\label{class_RanBaseClass}\index{RanBaseClass@{Ran\-Base\-Class}}
{\tt \#include $<$randomgenerator.h$>$}

Inheritance diagram for Ran\-Base\-Class\begin{figure}[H]
\begin{center}
\leavevmode
\includegraphics[width=163pt]{class_RanBaseClass_inherit_graph}
\end{center}
\end{figure}
\subsection*{Public Methods}
\begin{CompactItemize}
\item 
virtual {\bf $\sim$Ran\-Base\-Class} ()
\item 
void {\bf Seed} ({\bf uint} seed\_\-val)
\end{CompactItemize}
\subsection*{Protected Methods}
\begin{CompactItemize}
\item 
{\bf Ran\-Base\-Class} ()
\item 
double {\bf Get\-Real} () const
\end{CompactItemize}


\subsection{Constructor \& Destructor Documentation}
\index{RanBaseClass@{Ran\-Base\-Class}!~RanBaseClass@{$\sim$RanBaseClass}}
\index{~RanBaseClass@{$\sim$RanBaseClass}!RanBaseClass@{Ran\-Base\-Class}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}Ran\-Base\-Class::$\sim$Ran\-Base\-Class ()\hspace{0.3cm}{\tt  [virtual]}}\label{class_RanBaseClass_a0}




Definition at line 113 of file randomgenerator.C.\footnotesize\begin{verbatim}00114   {}
00115 \end{verbatim}\normalsize 
\index{RanBaseClass@{Ran\-Base\-Class}!RanBaseClass@{RanBaseClass}}
\index{RanBaseClass@{RanBaseClass}!RanBaseClass@{Ran\-Base\-Class}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}Ran\-Base\-Class::Ran\-Base\-Class ()\hspace{0.3cm}{\tt  [protected]}}\label{class_RanBaseClass_b0}




Definition at line 107 of file randomgenerator.C.\footnotesize\begin{verbatim}00108   {
00109     if(!z.seeded)
00110         Seed();
00111 \end{verbatim}\normalsize 


\subsection{Member Function Documentation}
\index{RanBaseClass@{Ran\-Base\-Class}!GetReal@{GetReal}}
\index{GetReal@{GetReal}!RanBaseClass@{Ran\-Base\-Class}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}double Ran\-Base\-Class::Get\-Real () const\hspace{0.3cm}{\tt  [protected]}}\label{class_RanBaseClass_b1}




Definition at line 116 of file randomgenerator.C.

Referenced by Ran\-Letter::Get(), Ran\-Char::Get(), Ran\-Int::Get(), and Ran\-Dbl::Get().\footnotesize\begin{verbatim}00117   {
00118     double uni = z.u[z.i97] - z.u[z.j97];
00119     if(uni < 0.0) uni += 1.0;
00120     z.u[z.i97] = uni;
00121     z.i97 = (z.i97 == 1) ? 97 : z.i97-1;
00122     z.j97 = (z.j97 == 1) ? 97 : z.j97-1;
00123     z.c -= z.cd;
00124     if(z.c<0.0) z.c += z.cm;
00125     uni -= z.c;
00126     if(uni<0.0) uni += 1.0;
00127     return uni;
00128 \end{verbatim}\normalsize 
\index{RanBaseClass@{Ran\-Base\-Class}!Seed@{Seed}}
\index{Seed@{Seed}!RanBaseClass@{Ran\-Base\-Class}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}void Ran\-Base\-Class::Seed ({\bf uint} {\em seed\_\-val} = 0)}\label{class_RanBaseClass_a1}




Definition at line 11 of file randomgenerator.C.

Referenced by Ran\-Base\-Class().\footnotesize\begin{verbatim}00012   {
00013     uint ij,kl;
00014     int i,j,k,l,ii,jj,m;
00015     double s,t;
00016     
00017     
00018     if (seed_val == 0){
00019       // This is a self-seed procedure
00020       // Added 4/11/2000 -JD
00021       // This effectively makes 0 an invalid seed.
00022       
00023 #ifdef WIN32
00024       while (seed_val == 0) {
00025         
00026         // This sucks big-time: returns time in seconds since Jan 1, 1970.
00027         seed_val = (unsigned) time(0);
00028       }
00029 #else
00030       // NOT WIN32
00031       while (seed_val == 0) { // 0 is an invalid seed value
00032         
00033         // This, of course, still sucks... but if we get interrupted in our read
00034         // from /dev/random below and don't get a full unsigned worth of random
00035         // bytes, we want to have *something* non-zero filling up seed_val.
00036         seed_val = (unsigned)getpid() ^ (unsigned)time(0);
00037         
00038 #ifdef HAVE_LIBPTHREAD
00039         // If we are using threads on a system w/o /dev/random, and if two threads
00040         // both try to generate one of these "magic seeds" at exactly the same
00041         // time, we don't want them both getting identical rngs.
00042         seed_val ^= (unsigned)pthread_self();
00043 #endif
00044         
00045         //#ifdef linux
00046         
00047         // I love /dev/random... but if we are on a system that doesn't support
00048         // it, this open will fail and we'll have to make due with the crappy
00049         // "randomness" from the above.
00050         int fd = open("/dev/random", O_RDONLY);
00051         if (fd != -1) {
00052           // Can we be interrupted in this read?  I guess so, so we'll settle for
00053           // some randomness, if not a full sizeof(s)-bytes worth...
00054           while (read(fd, &seed_val, sizeof(seed_val)) == 0);
00055           close(fd);
00056         }
00057         // #endif
00058         
00059       }
00060       
00061 #endif
00062       
00063     } // end self-seed procedure
00064     
00065     
00066     // ij is the first seed to the random generator and kl is the
00067     // second seed.  These seeds are derived from the bits contained
00068     // in the number seed.  Specifically, interleaved bits are
00069     // assigned to each seed and then the bits are reversed (making the
00070     // lower order bits more significant.
00071     //
00072     ij = reverse_bits( 0xAAAAAAAA & seed_val );
00073     kl = reverse_bits( 0x77777777 & seed_val );
00074     ij = (uint) (31328 * ((double) ij / (double) UINT_MAX));
00075     kl = (uint) (30081 * ((double) kl / (double) UINT_MAX));
00076 
00077     i = (ij/177)%177+2;
00078     j = ij%177 + 2;
00079     k = (kl/169)%178 + 1;
00080     l = kl%169;
00081 
00082     for(ii=1; ii<=97; ii++)
00083       {
00084         s = 0.0;
00085         t = 0.5;
00086         for(jj=1; jj<=24; jj++)
00087           {
00088             m = (((i*j)%179)*k) % 179;
00089             i = j;
00090             j = k;
00091             k = m;
00092             l = (53*1 + 1) % 169;
00093             if((l*m)%64 >= 32) s+= t;
00094             t *= 0.5;
00095           }
00096         z.u[ii] = s;
00097       }
00098 \end{verbatim}\normalsize 


The documentation for this class was generated from the following files:\begin{CompactItemize}
\item 
{\bf randomgenerator.h}\item 
{\bf randomgenerator.C}\end{CompactItemize}
