NEURON
ACG.h
Go to the documentation of this file.
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, 675 Mass Ave, Cambridge, MA 02139, USA.
17 */
18 #ifndef _ACG_h
19 #define _ACG_h 1
20 
21 #include <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 {
44 
45  uint32_t initialSeed; // used to reset generator
47 
48  uint32_t *state;
49  uint32_t *auxState;
50  short stateSize;
51  short auxSize;
52  uint32_t lcgRecurr;
53  short j;
54  short k;
55 
56 protected:
57 
58 public:
59  ACG(uint32_t seed = 0, int size = 55);
60  virtual ~ACG();
61  //
62  // Return a long-words word of random bits
63  //
64  virtual uint32_t asLong();
65  virtual void reset();
66 };
67 
68 #endif
Definition: ACG.h:43
ACG(uint32_t seed=0, int size=55)
Definition: ACG.cpp:184
uint32_t initialSeed
Definition: ACG.h:45
short stateSize
Definition: ACG.h:50
short auxSize
Definition: ACG.h:51
int initialTableEntry
Definition: ACG.h:46
uint32_t lcgRecurr
Definition: ACG.h:52
virtual void reset()
Definition: ACG.cpp:219
uint32_t * state
Definition: ACG.h:48
short k
Definition: ACG.h:54
short j
Definition: ACG.h:53
virtual uint32_t asLong()
Definition: ACG.cpp:266
uint32_t * auxState
Definition: ACG.h:49
virtual ~ACG()
Definition: ACG.cpp:254
Definition: RNG.h:55