typedef double HepDouble; typedef int HepInt; class HepJamesRandom { public: HepDouble flat(); private: HepDouble u[97]; HepDouble c, cd, cm; HepInt i97, j97; }; HepDouble HepJamesRandom::flat() { HepDouble uni; do { uni = u[i97] - u[j97]; if ( uni < 0.0 ) uni++; u[i97] = uni; if (i97 == 0) i97 = 96; else i97--; if (j97 == 0) j97 = 96; else j97--; c -= cd; if (c < 0.0) c += cm; uni -= c; if (uni < 0.0) uni += 1.0; } while ( uni <= 0.0 || uni >= 1.0 ); return uni; }