LCG.h

00001 /*  _________________________________________________________________________
00002  *
00003  *  UTILIB: A utility library for developing portable C++ codes.
00004  *  Copyright (c) 2001, Sandia National Laboratories.
00005  *  This software is distributed under the GNU Lesser General Public License.
00006  *  For more information, see the README file in the top UTILIB directory.
00007  *  _________________________________________________________________________
00008  */
00009 
00010 //
00011 // LCG.h
00012 //
00023 #ifndef _LCG_h
00024 #define _LCG_h
00025 
00026 #include "RNG.h"
00027 
00028 
00029 class UTILIB_API LCG : public RNG {
00030 
00031 public:
00037   LCG(unsigned short seed = 0);
00038 
00040   void          reseed(unsigned seed);
00042   unsigned short        getSeed() { return Seed; }
00043 
00045   virtual void          reset();
00047   virtual unsigned long asLong();
00048 #if defined (COUGAR) || defined(SGI) || defined(NON_ANSI) || defined(OSF)
00049 
00050   virtual int           write(ostream& output) const;
00052   virtual int           read(istream& input);
00053 #else
00054 
00055   virtual int           write(std::ostream& output) const;
00057   virtual int           read(std::istream& input);
00058 #endif
00059 
00060 private:
00062   unsigned short State[3];
00068   unsigned short Seed;
00069 
00070 };
00071 
00072 #endif
00073 
00074