Main Page   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   Related Pages  

LCG.h

00001 //   -*- C++ -*-
00002 /*****************************************************************************
00003  *
00004  *   |_|_|_  |_|_    |_    |_|_|_  |_                C O M M U N I C A T I O N
00005  * |_        |_  |_  |_  |_        |_                          N E T W O R K S
00006  * |_        |_  |_  |_  |_        |_                                C L A S S
00007  *   |_|_|_  |_    |_|_    |_|_|_  |_|_|_|_                      L I B R A R Y
00008  *
00009  * $Id: LCG.h,v 1.3 2002/02/01 08:46:13 spee Exp $
00010  *
00011  * CNClass: CNLCG --- Linear congruence random number generator
00012  *
00013  *****************************************************************************
00014  * Copyright (C) 1992-2002   Communication Networks
00015  *                           Aachen University of Technology
00016  *                           D-52056 Aachen
00017  *                           Germany
00018  *                           Email: cncl-adm@comnets.rwth-aachen.de
00019  *****************************************************************************
00020  * This file is part of the CN class library. All files marked with
00021  * this header are free software; you can redistribute it and/or modify
00022  * it under the terms of the GNU Library General Public License as
00023  * published by the Free Software Foundation; either version 2 of the
00024  * License, or (at your option) any later version.  This library is
00025  * distributed in the hope that it will be useful, but WITHOUT ANY
00026  * WARRANTY; without even the implied warranty of MERCHANTABILITY or
00027  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Library General Public
00028  * License for more details.  You should have received a copy of the GNU
00029  * Library General Public License along with this library; if not, write
00030  * to the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139,
00031  * USA.
00032  *****************************************************************************/
00033 
00034 #ifndef __LCG_h
00035 #define __LCG_h
00036 
00037 
00038 #include <CNCL/Class.h>
00039 #include <CNCL/Param.h>
00040 
00041 #include <CNCL/RNG.h>           // Base class
00042 
00043 extern CNClassDesc CN_LCG;      // CNClass CNLCG description
00044 
00045 
00046 
00050 class CNLCG : public CNRNG
00051 {
00052 public:
00053     virtual unsigned long as_long32();
00055     virtual void reset();
00057     virtual bool has_long32() {return FALSE;}
00058     
00060     virtual void seed(unsigned long s);
00061 
00063 private:
00064     unsigned long initialSeed;
00066     long state;
00067 
00068     /****** Constructors ******************************************************/
00069 public:
00071     CNLCG(unsigned long seed = 929);
00074     CNLCG(CNParam *) {}                 // CNParam constructor
00075 
00076     /****** Member functions required by CNCL *********************************/
00077 public:
00078     virtual CNClassDesc class_desc() const      // CNClass description
00079     {
00080         return CN_LCG;
00081     };
00082             
00084     virtual bool is_a(CNClassDesc desc) const   // Type checking
00085     {
00086         return desc == CN_LCG ? TRUE : CNRNG::is_a(desc);
00087     };
00088         
00090     static CNLCG *cast_from_object(CNObject *obj) 
00091     {
00092 #   ifdef NO_TYPE_CHECK
00093         return (CNLCG *)obj;
00094 #   else
00095         return (CNLCG *)( !obj || obj->is_a(CN_LCG)
00096                ? obj : fatal_type(obj->class_desc(), CN_LCG) );
00097 #   endif
00098     }
00099     
00102     static CNObject *new_object(CNParam *param = NIL) 
00103     { return param ? new CNLCG(param) : new CNLCG; }
00104     
00106     virtual void print(ostream &strm = cout) const;
00108     virtual void dump (ostream &strm = cout) const;
00109 };
00110 
00111 #endif 

Generated on Fri Feb 1 19:53:54 2002 for CNCL by doxygen1.2.13.1 written by Dimitri van Heesch, © 1997-2001