diff --git a/docs/hoc/programming/math/random.rst b/docs/hoc/programming/math/random.rst index 9a10d30e65..b037f4fcc2 100644 --- a/docs/hoc/programming/math/random.rst +++ b/docs/hoc/programming/math/random.rst @@ -96,27 +96,6 @@ Random Class -.. hoc:method:: Random.MLCG - - - Syntax: - ``r.MLCG()`` - - ``r.MLCG(seed1)`` - - ``r.MLCG(seed1, seed2)`` - - - Description: - Use a Multiplicative Linear Congruential Generator. Not as high - quality as the ACG. It uses only 8 bytes. - - - ----- - - - .. hoc:method:: Random.MCellRan4 diff --git a/docs/python/programming/math/random.rst b/docs/python/programming/math/random.rst index 210b43500d..a699677a31 100755 --- a/docs/python/programming/math/random.rst +++ b/docs/python/programming/math/random.rst @@ -99,27 +99,6 @@ Random Class -.. method:: Random.MLCG - - - Syntax: - ``r.MLCG()`` - - ``r.MLCG(seed1)`` - - ``r.MLCG(seed1, seed2)`` - - - Description: - Use a Multiplicative Linear Congruential Generator. Not as high - quality as the ACG. It uses only 8 bytes. - - - ----- - - - .. method:: Random.MCellRan4 diff --git a/share/lib/helpdict b/share/lib/helpdict index aa978a7a17..0db82dc69b 100755 --- a/share/lib/helpdict +++ b/share/lib/helpdict @@ -496,7 +496,6 @@ min Vector classes general neuron.exe Reference 160 neuron/general/classes/vecto min_ind Vector classes general neuron.exe Reference 160 neuron/general/classes/vector/vect2.html#min_ind Miscellaneous Tools NEURONMainMenu GUI Reference 418 neuron/stdrun/0stdrun.html#Miscellaneous mktemp File classes general neuron.exe Reference 29 neuron/general/classes/file.html#mktemp -MLCG Random classes general neuron.exe Reference 97 neuron/general/classes/random.html#MLCG ModelDescriptionIssues CVode classes neuron neuron.exe Reference 257 neuron/neuron/classes/cvode.html#ModelDescriptionIssues ModelDescriptionLanguage NMODL Reference 388 neuron/nmodl/nmodl.html#ModelDescriptionLanguage MoveText Graph LookAndFeel GUI Reference 18 neuron/agui/gui.html#MoveText diff --git a/src/gnu/CMakeLists.txt b/src/gnu/CMakeLists.txt index e16ae608b9..1ce00c7fe6 100644 --- a/src/gnu/CMakeLists.txt +++ b/src/gnu/CMakeLists.txt @@ -11,7 +11,6 @@ add_library( LogNorm.cpp MCellRan4RNG.cpp mcran4.cpp - MLCG.cpp NegExp.cpp Normal.cpp nrnisaac.cpp diff --git a/src/gnu/MLCG.cpp b/src/gnu/MLCG.cpp deleted file mode 100755 index dce8358a43..0000000000 --- a/src/gnu/MLCG.cpp +++ /dev/null @@ -1,110 +0,0 @@ -// This may look like C code, but it is really -*- C++ -*- -/* -Copyright (C) 1989 Free Software Foundation - -This file is part of the GNU C++ Library. This library is free -software; you can redistribute it and/or modify it under the terms of -the GNU Library General Public License as published by the Free -Software Foundation; either version 2 of the License, or (at your -option) any later version. This library is distributed in the hope -that it will be useful, but WITHOUT ANY WARRANTY; without even the -implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. See the GNU Library General Public License for more details. -You should have received a copy of the GNU Library General Public -License along with this library; if not, write to the Free Software -Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. -*/ -#ifdef __GNUG__ -#pragma implementation -#endif -#include "MLCG.h" -// -// SEED_TABLE_SIZE must be a power of 2 -// - - -#define SEED_TABLE_SIZE 32 - -static int32_t seedTable[SEED_TABLE_SIZE] = { - /* 0xbdcc47e5 */ -1110685723, /* 0x54aea45d */ 1420731485, - /* 0xec0df859 */ -334628775, /* 0xda84637b */ -628857989, - /* 0xc8c6cb4f */ -926495921, /* 0x35574b01 */ 894913281, - /* 0x28260b7d */ 673581949, /* 0x0d07fdbf */ 218627519, - /* 0x9faaeeb0 */ -1616187728, /* 0x613dd169 */ 1631441257, - /* 0x5ce2d818 */ 1558370328, /* 0x85b9e706 */ -2051414266, - /* 0xab2469db */ -1423676965, /* 0xda02b0dc */ -637357860, - /* 0x45c60d6e */ 1170607470, /* 0xffe49d10 */ -1794800, - /* 0x7224fea3 */ 1915027107, /* 0xf9684fc9 */ -110604343, - /* 0xfc7ee074 */ -58793868, /* 0x326ce92a */ 845998378, - /* 0x366d13b5 */ 913118133, /* 0x17aaa731 */ 397059889, - /* 0xeb83a675 */ -343693707, /* 0x7781cb32 */ 2004994866, - /* 0x4ec7c92d */ 1321716013, /* 0x7f187521 */ 2132309281, - /* 0x2cf346b4 */ 754140852, /* 0xad13310f */ -1391251185, - /* 0xb89cff2b */ -1197670613, /* 0x12164de1 */ 303451617, - /* 0xa865168d */ -1469770099, /* 0x32b56cdf */ 850750687 -}; - -MLCG::MLCG(int32_t seed1, int32_t seed2) -{ - initialSeedOne = seed1; - initialSeedTwo = seed2; - reset(); -} - -void -MLCG::reset() -{ - int32_t seed1 = initialSeedOne; - int32_t seed2 = initialSeedTwo; - - // Most people pick stupid seed numbers that do not have enough - // bits. In this case, if they pick a small seed number, we - // map that to a specific seed. - - if (seed1 < 0) { - seed1 = (seed1 + 2147483561); - seed1 = (seed1 < 0) ? -seed1 : seed1; - } - - if (seed2 < 0) { - seed2 = (seed2 + 2147483561); - seed2 = (seed2 < 0) ? -seed2 : seed2; - } - - if (seed1 > -1 && seed1 < SEED_TABLE_SIZE) { - seedOne = seedTable[seed1]; - } else { - seedOne = seed1 ^ seedTable[seed1 & (SEED_TABLE_SIZE-1)]; - } - - if (seed2 > -1 && seed2 < SEED_TABLE_SIZE) { - seedTwo = seedTable[seed2]; - } else { - seedTwo = seed2 ^ seedTable[ seed2 & (SEED_TABLE_SIZE-1) ]; - } - seedOne = (seedOne % 2147483561) + 1; - seedTwo = (seedTwo % 2147483397) + 1; -} - -uint32_t MLCG::asLong() -{ - int32_t k = seedOne % 53668; - - seedOne = 40014 * (seedOne-k * 53668) - k * 12211; - if (seedOne < 0) { - seedOne += 2147483563; - } - - k = seedTwo % 52774; - seedTwo = 40692 * (seedTwo - k * 52774) - k * 3791; - if (seedTwo < 0) { - seedTwo += 2147483399; - } - - int32_t z = seedOne - seedTwo; - if (z < 1) { - z += 2147483562; - } - return( (unsigned long) z); -} - diff --git a/src/gnu/MLCG.h b/src/gnu/MLCG.h deleted file mode 100755 index eae70504a8..0000000000 --- a/src/gnu/MLCG.h +++ /dev/null @@ -1,81 +0,0 @@ -// This may look like C code, but it is really -*- C++ -*- -/* -Copyright (C) 1988 Free Software Foundation - written by Dirk Grunwald (grunwald@cs.uiuc.edu) - -This file is part of the GNU C++ Library. This library is free -software; you can redistribute it and/or modify it under the terms of -the GNU Library General Public License as published by the Free -Software Foundation; either version 2 of the License, or (at your -option) any later version. This library is distributed in the hope -that it will be useful, but WITHOUT ANY WARRANTY; without even the -implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. See the GNU Library General Public License for more details. -You should have received a copy of the GNU Library General Public -License along with this library; if not, write to the Free Software -Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. -*/ -#pragma once - -#include "RNG.h" -#include - -// -// Multiplicative Linear Conguential Generator -// - -class MLCG : public RNG { - int32_t initialSeedOne; - int32_t initialSeedTwo; - int32_t seedOne; - int32_t seedTwo; - -protected: - -public: - MLCG(int32_t seed1 = 0, int32_t seed2 = 1); - // - // Return a long-words word of random bits - // - virtual uint32_t asLong(); - virtual void reset(); - int32_t seed1(); - void seed1(int32_t); - int32_t seed2(); - void seed2(int32_t); - void reseed(int32_t, int32_t); -}; - -inline int32_t -MLCG::seed1() -{ - return(seedOne); -} - -inline void -MLCG::seed1(int32_t s) -{ - initialSeedOne = s; - reset(); -} - -inline int32_t -MLCG::seed2() -{ - return(seedTwo); -} - -inline void -MLCG::seed2(int32_t s) -{ - initialSeedTwo = s; - reset(); -} - -inline void -MLCG::reseed(int32_t s1, int32_t s2) -{ - initialSeedOne = s1; - initialSeedTwo = s2; - reset(); -} diff --git a/src/gnu/RNG.h b/src/gnu/RNG.h index e7af070623..ab37b7f90b 100755 --- a/src/gnu/RNG.h +++ b/src/gnu/RNG.h @@ -35,7 +35,7 @@ union PrivateRNGDoubleType { // used to access doubles as unsigneds }; // -// Base class for Random Number Generators. See ACG and MLCG for instances. +// Base class for Random Number Generators. See ACG for instances. // class RNG { static PrivateRNGSingleType singleMantissa; // mantissa bit vector diff --git a/src/gnu/Rand.hpp b/src/gnu/Rand.hpp index f5b47a6a61..4d49a1155e 100644 --- a/src/gnu/Rand.hpp +++ b/src/gnu/Rand.hpp @@ -7,7 +7,7 @@ struct Object; /* type_: * 0: ACG - * 1: MLCG + * 1: unused * 2: MCellRan4 * 3: Isaac64 * 4: Random123 diff --git a/src/ivoc/ivocrand.cpp b/src/ivoc/ivocrand.cpp index 183fb5d72c..7e67c17a92 100644 --- a/src/ivoc/ivocrand.cpp +++ b/src/ivoc/ivocrand.cpp @@ -18,7 +18,6 @@ #include #include -#include #include #include #include @@ -133,29 +132,6 @@ static double r_ACG(void* r) { return 1.; } -// Use a Multiplicative Linear Congruential Generator. Not as high -// quality as the ACG, but uses only 8 bytes -// syntax: -// r.MLCG([seed1],[seed2]) - -static double r_MLCG(void* r) { - Rand* x = (Rand*) r; - - unsigned long seed1 = 0; - unsigned long seed2 = 0; - - if (ifarg(1)) - seed1 = long(*getarg(1)); - if (ifarg(2)) - seed2 = long(*getarg(2)); - - x->rand->generator(new MLCG(seed1, seed2)); - delete x->gen; - x->gen = x->rand->generator(); - x->type_ = 1; - return 1.; -} - static double r_MCellRan4(void* r) { Rand* x = (Rand*) r; @@ -489,7 +465,6 @@ extern "C" void nrn_random_play() { static Member_func r_members[] = {{"ACG", r_ACG}, - {"MLCG", r_MLCG}, {"Isaac64", r_Isaac64}, {"MCellRan4", r_MCellRan4}, {"Random123", r_nrnran123},