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

FiboG.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: FiboG.h,v 1.6 2002/02/01 16:25:35 spee Exp $
00010  *
00011  * CNClass: CNFiboG --- Fibonacci 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 __FiboG_h
00035 #define __FiboG_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_FIBOG;    // CNClass CNFiboG description
00044 
00045 
00092 class CNFiboG : public CNRNG
00093 {
00094 public:
00097     virtual unsigned long as_long32();
00099     virtual void reset();
00102     virtual bool has_long32() {return TRUE;}
00105     void seed_internal(unsigned long *);
00106 
00107 private:
00108     // struct defines a knot of the circular queue 
00109     // used by the lagged Fibonacci algorithm
00110     struct Vknot
00111     {
00112         unsigned long v;
00113         Vknot *vnext;
00114     };
00115     unsigned long initialSeed;  // start value of initialization routine
00116     unsigned long Xn;           // generated value
00117     unsigned long cn, Vn;       // temporary values
00118     Vknot *V33, *V97, *Vanker;  // some pointers to the queue
00119 
00120     /****** Constructors ******************************************************/
00121 public:
00123     CNFiboG(CNParam *) {}
00125     CNFiboG(unsigned long init = 54217137);
00127     virtual ~CNFiboG();
00128 
00129     /****** Member functions required by CNCL *********************************/
00130 public:
00131     virtual CNClassDesc class_desc() const      // CNClass description
00132     {
00133         return CN_FIBOG;
00134     };
00135             
00137     virtual bool is_a(CNClassDesc desc) const
00138     {
00139         return desc == CN_FIBOG ? TRUE : CNRNG::is_a(desc);
00140     };
00141         
00143     static CNFiboG *cast_from_object(CNObject *obj)
00144     {
00145 #   ifdef NO_TYPE_CHECK
00146         return (CNFiboG *)obj;
00147 #   else
00148         return (CNFiboG *)( !obj || obj->is_a(CN_FIBOG)
00149                ? obj : fatal_type(obj->class_desc(), CN_FIBOG) );
00150 #   endif
00151     }
00152     
00154     static CNObject *new_object(CNParam *param = NIL)
00155     { return param ? new CNFiboG(param) : new CNFiboG; }
00156     
00158     virtual void print(ostream &strm = cout) const;
00160     virtual void dump (ostream &strm = cout) const;
00161 };
00162 
00163 
00164 #endif 

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