modules/up/src/Core/gnu/ACG.h

/* [<][>]
[^][v][top][bottom][index][help] */

FUNCTIONS

This source file includes following functions.
  1. ACG

   1 // This may look like C code, but it is really -*- C++ -*-
   2 /* 
   3 Copyright (C) 1988 Free Software Foundation
   4     written by Dirk Grunwald (grunwald@cs.uiuc.edu)
   5 
   6 This file is part of the GNU C++ Library.  This library is free
   7 software; you can redistribute it and/or modify it under the terms of
   8 the GNU Library General Public License as published by the Free
   9 Software Foundation; either version 2 of the License, or (at your
  10 option) any later version.  This library is distributed in the hope
  11 that it will be useful, but WITHOUT ANY WARRANTY; without even the
  12 implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
  13 PURPOSE.  See the GNU Library General Public License for more details.
  14 You should have received a copy of the GNU Library General Public
  15 License along with this library; if not, write to the Free Software
  16 Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
  17 */
  18 #ifndef _ACG_h
  19 #define _ACG_h 1 
  20 
  21 #include "gnu/RNG.h"
  22 #include <math.h>
  23 #ifdef __GNUG__
  24 #pragma interface
  25 #endif
  26 
  27 //
  28 //      Additive number generator. This method is presented in Volume II
  29 //      of The Art of Computer Programming by Knuth. I've coded the algorithm
  30 //      and have added the extensions by Andres Nowatzyk of CMU to randomize
  31 //      the result of algorithm M a bit by using an LCG & a spatial
  32 //      permutation table.
  33 //
  34 //      The version presented uses the same constants for the LCG that Andres
  35 //      uses (chosen by trial & error). The spatial permutation table is
  36 //      the same size (it's based on word size). This is for 32-bit words.
  37 //
  38 //      The ``auxillary table'' used by the LCG table varies in size, and
  39 //      is chosen to be the the smallest power of two which is larger than
  40 //      twice the size of the state table.
  41 //
  42 
  43 class ACG : public RNG {
     /* [<][>][^][v][top][bottom][index][help] */
  44 
  45     _G_uint32_t initialSeed;    // used to reset generator
  46     int initialTableEntry;
  47 
  48     _G_uint32_t *state;
  49     _G_uint32_t *auxState;
  50     short stateSize;
  51     short auxSize;
  52     _G_uint32_t lcgRecurr;
  53     short j;
  54     short k;
  55 
  56 protected:
  57 
  58 public:
  59     ACG(_G_uint32_t seed = 0, int size = 55);
  60     virtual ~ACG();
  61     //
  62     // Return a long-words word of random bits
  63     //
  64     virtual _G_uint32_t asLong();
  65     virtual void reset();
  66 };
  67 
  68 #endif

/* [<][>][^][v][top][bottom][index][help] */