libcoyotl - A Library of C++ Tools

Created by Scott Robert Ladd at Coyote Gulch Productions.


cmwc4096.h
00001 //---------------------------------------------------------------------
00002 //  Algorithmic Conjurings @ http://www.coyotegulch.com
00003 //
00004 //  cmwc4096.cpp (libcoyotl)
00005 //
00006 //  The cmwc4096 class encapsulates a complimentary-multiply-with-carry
00007 //  algorithm for psuedorandom number generation, as suggested by George 
00008 //  Marsaglia.
00009 //---------------------------------------------------------------------
00010 //
00011 //  Copyright 1990-2005 Scott Robert Ladd
00012 //
00013 //  This program is free software; you can redistribute it and/or modify
00014 //  it under the terms of the GNU General Public License as published by
00015 //  the Free Software Foundation; either version 2 of the License, or
00016 //  (at your option) any later version.
00017 //  
00018 //  This program is distributed in the hope that it will be useful,
00019 //  but WITHOUT ANY WARRANTY; without even the implied warranty of
00020 //  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00021 //  GNU General Public License for more details.
00022 //  
00023 //  You should have received a copy of the GNU General Public License
00024 //  along with this program; if not, write to the
00025 //      Free Software Foundation, Inc.
00026 //      59 Temple Place - Suite 330
00027 //      Boston, MA 02111-1307, USA.
00028 //
00029 //-----------------------------------------------------------------------
00030 //
00031 //  For more information on this software package, please visit
00032 //  Scott's web site, Coyote Gulch Productions, at:
00033 //
00034 //      http://www.coyotegulch.com
00035 //  
00036 //-----------------------------------------------------------------------
00037 
00038 #if !defined(LIBCOYOTL_CMWC4096_H)
00039 #define LIBCOYOTL_CMWC4096_H
00040 
00041 #include "prng.h"
00042 
00043 namespace libcoyotl
00044 {
00046 
00051     class cmwc4096 : public prng
00052     {
00053     private:
00054         // Period parameters
00055         static const size_t N = 4096;
00056 
00057         // Working storage
00058         uint32_t m_q[N];
00059         uint32_t m_carry;
00060         int      m_index;
00061 
00062     public:
00064 
00068         cmwc4096();
00069 
00071 
00075         cmwc4096(uint32_t seed);
00076 
00078 
00082         virtual void init(uint32_t seed);
00083 
00084     private:
00086 
00090         void init_helper();
00091 
00092     public:
00094 
00098         virtual uint32_t get_rand();
00099     };
00100 
00101 } // end namespace libcoyotl
00102 
00103 #endif

© 1996-2005 Scott Robert Ladd. All rights reserved.
HTML documentation generated by Dimitri van Heesch's excellent Doxygen tool.