/* []----------------------------------------[] | Rand.cpp | []----------------------------------------[] | | | AUTHOR: MFSomers 2005. | | USE: A basic random number | | generator (rand POSIX | | 1003.1-2003)... | | | []----------------------------------------[] */ // Copyright (C) 2005 M.F. Somers, Theoretical Chemistry Department, Leiden University // // This is free software; you can redistribute it and/or modify it under the terms of // the GNU Lesser General Public License as published by the Free Software Foundation. // // http://www.gnu.org/licenses/lgpl.txt #include "Rand.h" /* ---------------------------------------------------------------------------- */ unsigned long Rand_State = 1L; /* ---------------------------------------------------------------------------- */ /* Implementation taken from POSIX 1003.1-2003, see the 'rand' manual pages... */ int Rand( unsigned long& State ) { State = State * 1103515245L + 12345L; return( ( int )( ( State >> 16 ) & 0x000007FFFL ) ); } /* ---------------------------------------------------------------------------- */ void SRand( unsigned long Seed, unsigned long& State ) { State = Seed; } /* ---------------------------------------------------------------------------- */ unsigned long GRand( unsigned long& State ) { return( State ); } /* ---------------------------------------------------------------------------- */