Created by Scott Robert Ladd at Coyote Gulch Productions.
00001 //--------------------------------------------------------------------- 00002 // Algorithmic Conjurings @ http://www.coyotegulch.com 00003 // 00004 // mwc256.cpp (libcoyotl) 00005 // 00006 // A multiply with carry psudeorandom number generator, as suggested 00007 // by George Marsaglia. 00008 //--------------------------------------------------------------------- 00009 // 00010 // Copyright 1990-2005 Scott Robert Ladd 00011 // 00012 // This program is free software; you can redistribute it and/or modify 00013 // it under the terms of the GNU General Public License as published by 00014 // the Free Software Foundation; either version 2 of the License, or 00015 // (at your option) any later version. 00016 // 00017 // This program is distributed in the hope that it will be useful, 00018 // but WITHOUT ANY WARRANTY; without even the implied warranty of 00019 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00020 // GNU General Public License for more details. 00021 // 00022 // You should have received a copy of the GNU General Public License 00023 // along with this program; if not, write to the 00024 // Free Software Foundation, Inc. 00025 // 59 Temple Place - Suite 330 00026 // Boston, MA 02111-1307, USA. 00027 // 00028 //----------------------------------------------------------------------- 00029 // 00030 // For more information on this software package, please visit 00031 // Scott's web site, Coyote Gulch Productions, at: 00032 // 00033 // http://www.coyotegulch.com 00034 // 00035 //----------------------------------------------------------------------- 00036 00037 #if !defined(LIBCOYOTL_MWC256_H) 00038 #define LIBCOYOTL_MWC256_H 00039 00040 #include "prng.h" 00041 00042 namespace libcoyotl 00043 { 00045 00049 class mwc256 : public prng 00050 { 00051 private: 00052 // Period parameters 00053 static const size_t N = 256; 00054 00055 // Working storage 00056 uint32_t m_q[N]; 00057 uint32_t m_carry; 00058 uint8_t m_index; 00059 00060 public: 00062 00066 mwc256(); 00067 00069 00073 mwc256(uint32_t seed); 00074 00076 00080 virtual void init(uint32_t seed); 00081 00082 private: 00084 00088 void init_helper(); 00089 00090 public: 00092 00096 virtual uint32_t get_rand(); 00097 }; 00098 00099 } // end namespace libcoyotl 00100 00101 #endif
© 1996-2005 Scott Robert Ladd. All rights reserved.
HTML documentation generated by Dimitri van Heesch's excellent Doxygen tool.