1 | //STARTHEADER
|
---|
2 | // simple random number generator class taken from nlojet++.
|
---|
3 | // $Id: BasicRandom.cc 859 2012-11-28 01:49:23Z pavel $
|
---|
4 | //
|
---|
5 | // Copyright (C) 2002 Zoltan Nagy
|
---|
6 | //
|
---|
7 | // This program is free software; you can redistribute it and/or modify
|
---|
8 | // it under the terms of the GNU General Public License as published by
|
---|
9 | // the Free Software Foundation; either version 2 of the License, or
|
---|
10 | // (at your option) any later version.
|
---|
11 | //
|
---|
12 | // This program is distributed in the hope that it will be useful,
|
---|
13 | // but WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
14 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
---|
15 | // GNU General Public License for more details.
|
---|
16 | //
|
---|
17 | // You should have received a copy of the GNU General Public License
|
---|
18 | // along with this program; if not, write to the Free Software
|
---|
19 | // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
---|
20 | //ENDHEADER
|
---|
21 |
|
---|
22 | // nlo includes
|
---|
23 | #include "fastjet/internal/BasicRandom.hh"
|
---|
24 |
|
---|
25 |
|
---|
26 | FASTJET_BEGIN_NAMESPACE // defined in fastjet/internal/base.hh
|
---|
27 |
|
---|
28 |
|
---|
29 | //
|
---|
30 | // random number generator
|
---|
31 | // uses method of L'Ecuyer, (via F.James, comp. phys. comm. 60(1990)329)
|
---|
32 | //
|
---|
33 | int __default_random_generator(int *__iseed)
|
---|
34 | {
|
---|
35 | int __k = __iseed[0]/53668;
|
---|
36 | __iseed[0] = (__iseed[0] - __k*53668)*40014 - __k*12211;
|
---|
37 | if(__iseed[0] < 0) __iseed[0] += 2147483563;
|
---|
38 |
|
---|
39 | __k = __iseed[1]/52774;
|
---|
40 | __iseed[1] = (__iseed[1] - __k*52774)*40692 - __k*3791;
|
---|
41 | if(__iseed[1] < 0) __iseed[1] += 2147483399;
|
---|
42 |
|
---|
43 | int __iz = __iseed[0] - __iseed[1];
|
---|
44 | if(__iz < 1) __iz += 2147483562;
|
---|
45 |
|
---|
46 | return __iz;
|
---|
47 | }
|
---|
48 |
|
---|
49 | // global defined random number generator
|
---|
50 | BasicRandom<int> _G_random_int;
|
---|
51 | BasicRandom<double> _G_random_double;
|
---|
52 |
|
---|
53 |
|
---|
54 | FASTJET_END_NAMESPACE
|
---|
55 |
|
---|