Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# Object files
*.o

# Executables
gal
gal2
gal3
opt
synth_optimizer
oscillator_params
rhythm_evolution

# Distribution files
*.tar.gz
ngal-*/
34 changes: 17 additions & 17 deletions ACG.cc
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ static short randomStateTable[][3] = {
//

#define RANDOM_PERM_SIZE 64
_G_uint32_t randomPermutations[RANDOM_PERM_SIZE] = {
uint32_t randomPermutations[RANDOM_PERM_SIZE] = {
0xffffffff, 0x00000000, 0x00000000, 0x00000000, // 3210
0x0000ffff, 0x00ff0000, 0x00000000, 0xff000000, // 2310
0xff0000ff, 0x0000ff00, 0x00000000, 0x00ff0000, // 3120
Expand All @@ -149,7 +149,7 @@ _G_uint32_t randomPermutations[RANDOM_PERM_SIZE] = {
// SEED_TABLE_SIZE must be a power of 2
//
#define SEED_TABLE_SIZE 32
static _G_uint32_t seedTable[SEED_TABLE_SIZE] = {
static uint32_t seedTable[SEED_TABLE_SIZE] = {
0xbdcc47e5, 0x54aea45d, 0xec0df859, 0xda84637b,
0xc8c6cb4f, 0x35574b01, 0x28260b7d, 0x0d07fdbf,
0x9faaeeb0, 0x613dd169, 0x5ce2d818, 0x85b9e706,
Expand All @@ -171,15 +171,15 @@ static _G_uint32_t seedTable[SEED_TABLE_SIZE] = {
// LC_C = result of a long trial & error series = 3907864577
//

static const _G_uint32_t LC_A = 66049U;
static const _G_uint32_t LC_C = 3907864577U;
static inline _G_uint32_t LCG(_G_uint32_t x)
static const uint32_t LC_A = 66049U;
static const uint32_t LC_C = 3907864577U;
static inline uint32_t LCG(uint32_t x)
{
return( x * LC_A + LC_C );
}


ACG::ACG(_G_uint32_t seed, int size)
ACG::ACG(uint32_t seed, int size)
{
register int l;
initialSeed = seed;
Expand All @@ -204,8 +204,8 @@ ACG::ACG(_G_uint32_t seed, int size)
//
// Allocate the state table & the auxillary table in a single malloc
//
state = new _G_uint32_t[stateSize + auxSize];

state = new uint32_t[stateSize + auxSize];
auxState = &state[stateSize];

reset();
Expand All @@ -217,7 +217,7 @@ ACG::ACG(_G_uint32_t seed, int size)
void
ACG::reset()
{
register _G_uint32_t u;
register uint32_t u;

if (initialSeed < SEED_TABLE_SIZE) {
u = seedTable[ initialSeed ];
Expand Down Expand Up @@ -246,9 +246,9 @@ ACG::reset()
}

lcgRecurr = u;

#if 0 /* Nonsense! */
assert(sizeof(double) == 2 * sizeof(_G_int32_t));
assert(sizeof(double) == 2 * sizeof(int32_t));
#endif
}

Expand All @@ -263,24 +263,24 @@ ACG::~ACG()
// Returns 32 bits of random information.
//

_G_uint32_t
uint32_t
ACG::asLong()
{
_G_uint32_t result = state[k] + state[j];
uint32_t result = state[k] + state[j];
state[k] = result;
j = (j <= 0) ? (stateSize-1) : (j-1);
k = (k <= 0) ? (stateSize-1) : (k-1);

short int auxIndex = (result >> 24) & (auxSize - 1);
register _G_uint32_t auxACG = auxState[auxIndex];
register uint32_t auxACG = auxState[auxIndex];
auxState[auxIndex] = lcgRecurr = LCG(lcgRecurr);

//
// 3c is a magic number. We are doing four masks here, so we
// do not want to run off the end of the permutation table.
// This insures that we have always got four entries left.
//
register _G_uint32_t *perm = & randomPermutations[result & 0x3c];
register uint32_t *perm = & randomPermutations[result & 0x3c];

result = *(perm++) & auxACG;
result |= *(perm++) & ((auxACG << 24)
Expand Down
12 changes: 6 additions & 6 deletions ACG.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,26 +42,26 @@ Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.

class ACG : public RNG {

_G_uint32_t initialSeed; // used to reset generator
uint32_t initialSeed; // used to reset generator
int initialTableEntry;

_G_uint32_t *state;
_G_uint32_t *auxState;
uint32_t *state;
uint32_t *auxState;
short stateSize;
short auxSize;
_G_uint32_t lcgRecurr;
uint32_t lcgRecurr;
short j;
short k;

protected:

public:
ACG(_G_uint32_t seed = 0, int size = 55);
ACG(uint32_t seed = 0, int size = 55);
virtual ~ACG();
//
// Return a long-words word of random bits
//
virtual _G_uint32_t asLong();
virtual uint32_t asLong();
virtual void reset();
};

Expand Down
Loading