1.1 --- a/src/common/random-uniform-mrg32k3a.cc Tue Aug 29 17:43:19 2006 +0200
1.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
1.3 @@ -1,137 +0,0 @@
1.4 -/* -*- Mode:C++; c-basic-offset:8; tab-width:8; indent-tabs-mode:t -*- */
1.5 -/*
1.6 - * Copyright (c) 2006 INRIA
1.7 - * All rights reserved.
1.8 - *
1.9 - * This program is free software; you can redistribute it and/or modify
1.10 - * it under the terms of the GNU General Public License version 2 as
1.11 - * published by the Free Software Foundation;
1.12 - *
1.13 - * This program is distributed in the hope that it will be useful,
1.14 - * but WITHOUT ANY WARRANTY; without even the implied warranty of
1.15 - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1.16 - * GNU General Public License for more details.
1.17 - *
1.18 - * You should have received a copy of the GNU General Public License
1.19 - * along with this program; if not, write to the Free Software
1.20 - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
1.21 - *
1.22 - * Author: Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
1.23 - */
1.24 -#include "random-uniform.h"
1.25 -#include "seed-generator.h"
1.26 -#include "rng-mrg32k3a.h"
1.27 -
1.28 -namespace yans {
1.29 -
1.30 -class RandomUniformPrivate {
1.31 -public:
1.32 - RandomUniformPrivate ();
1.33 - ~RandomUniformPrivate ();
1.34 -
1.35 - void reset (uint32_t seed);
1.36 -
1.37 - uint32_t get_max (void) const;
1.38 - uint32_t get_min (void) const;
1.39 -
1.40 - uint32_t get_uint (void);
1.41 - uint32_t get_uint (uint32_t n);
1.42 - uint32_t get_uint (uint32_t a, uint32_t b);
1.43 - double get_double (void);
1.44 -private:
1.45 - RngMrg32k3a m_rng;
1.46 -};
1.47 -
1.48 -RandomUniformPrivate::RandomUniformPrivate ()
1.49 - : m_rng ()
1.50 -{
1.51 - m_rng.reset (SeedGenerator::get ());
1.52 -}
1.53 -RandomUniformPrivate::~RandomUniformPrivate ()
1.54 -{}
1.55 -
1.56 -void
1.57 -RandomUniformPrivate::reset (uint32_t seed)
1.58 -{
1.59 - m_rng.reset (seed);
1.60 -}
1.61 -uint32_t
1.62 -RandomUniformPrivate::get_max (void) const
1.63 -{
1.64 - return m_rng.get_max ();
1.65 -}
1.66 -uint32_t
1.67 -RandomUniformPrivate::get_min (void) const
1.68 -{
1.69 - return m_rng.get_min ();
1.70 -}
1.71 -uint32_t
1.72 -RandomUniformPrivate::get_uint (void)
1.73 -{
1.74 - return m_rng.get_uint ();
1.75 -}
1.76 -uint32_t
1.77 -RandomUniformPrivate::get_uint (uint32_t n)
1.78 -{
1.79 - return m_rng.get_uint (n);
1.80 -}
1.81 -uint32_t
1.82 -RandomUniformPrivate::get_uint (uint32_t a, uint32_t b)
1.83 -{
1.84 - return m_rng.get_uint (a, b);
1.85 -}
1.86 -double
1.87 -RandomUniformPrivate::get_double (void)
1.88 -{
1.89 - return m_rng.get_double ();
1.90 -}
1.91 -
1.92 -
1.93 -
1.94 -RandomUniform::RandomUniform ()
1.95 - : m_priv (new RandomUniformPrivate ())
1.96 -{}
1.97 -RandomUniform::~RandomUniform ()
1.98 -{
1.99 - delete m_priv;
1.100 - m_priv = reinterpret_cast<RandomUniformPrivate *> (0xdeadbeaf);
1.101 -}
1.102 -
1.103 -void
1.104 -RandomUniform::reset (uint32_t seed)
1.105 -{
1.106 - m_priv->reset (seed);
1.107 -}
1.108 -uint32_t
1.109 -RandomUniform::get_max (void) const
1.110 -{
1.111 - return m_priv->get_max ();
1.112 -}
1.113 -uint32_t
1.114 -RandomUniform::get_min (void) const
1.115 -{
1.116 - return m_priv->get_min ();
1.117 -}
1.118 -uint32_t
1.119 -RandomUniform::get_uint (void)
1.120 -{
1.121 - return m_priv->get_uint ();
1.122 -}
1.123 -uint32_t
1.124 -RandomUniform::get_uint (uint32_t n)
1.125 -{
1.126 - return m_priv->get_uint (n);
1.127 -}
1.128 -uint32_t
1.129 -RandomUniform::get_uint (uint32_t a, uint32_t b)
1.130 -{
1.131 - return m_priv->get_uint (a, b);
1.132 -}
1.133 -double
1.134 -RandomUniform::get_double (void)
1.135 -{
1.136 - return m_priv->get_double ();
1.137 -}
1.138 -
1.139 -}; // namespace yans
1.140 -
2.1 --- a/src/common/random-uniform.h Tue Aug 29 17:43:19 2006 +0200
2.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
2.3 @@ -1,57 +0,0 @@
2.4 -/* -*- Mode:C++; c-basic-offset:8; tab-width:8; indent-tabs-mode:t -*- */
2.5 -/*
2.6 - * Copyright (c) 2006 INRIA
2.7 - * All rights reserved.
2.8 - *
2.9 - * This program is free software; you can redistribute it and/or modify
2.10 - * it under the terms of the GNU General Public License version 2 as
2.11 - * published by the Free Software Foundation;
2.12 - *
2.13 - * This program is distributed in the hope that it will be useful,
2.14 - * but WITHOUT ANY WARRANTY; without even the implied warranty of
2.15 - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
2.16 - * GNU General Public License for more details.
2.17 - *
2.18 - * You should have received a copy of the GNU General Public License
2.19 - * along with this program; if not, write to the Free Software
2.20 - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
2.21 - *
2.22 - * Author: Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
2.23 - */
2.24 -#ifndef RANDOM_UNIFORM_H
2.25 -#define RANDOM_UNIFORM_H
2.26 -
2.27 -#include <stdint.h>
2.28 -
2.29 -namespace yans {
2.30 -
2.31 -class RandomUniformPrivate;
2.32 -
2.33 -class RandomUniform {
2.34 -public:
2.35 - RandomUniform ();
2.36 - ~RandomUniform ();
2.37 -
2.38 - void reset (uint32_t seed);
2.39 -
2.40 - uint32_t get_max (void) const;
2.41 - uint32_t get_min (void) const;
2.42 -
2.43 - /* return an integer in the range [min,max] */
2.44 - uint32_t get_uint (void);
2.45 - /* return an integer in the range [0,n] */
2.46 - uint32_t get_uint (uint32_t n);
2.47 - /* return an integer in the range [a,b] */
2.48 - uint32_t get_uint (uint32_t a, uint32_t b);
2.49 - /* return a floating-point number in the
2.50 - * range [0,1)
2.51 - */
2.52 - double get_double (void);
2.53 -private:
2.54 - RandomUniformPrivate *m_priv;
2.55 -};
2.56 -
2.57 -}; // namespace yans
2.58 -
2.59 -
2.60 -#endif /* RANDOM_UNIFORM_H */
3.1 --- a/src/common/rng-mrg32k3a.cc Tue Aug 29 17:43:19 2006 +0200
3.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
3.3 @@ -1,336 +0,0 @@
3.4 -/* -*- Mode:C++; c-basic-offset:8; tab-width:8; indent-tabs-mode:t -*- */
3.5 -/*
3.6 - * Copyright (C) 2001 Pierre L'Ecuyer (lecuyer@iro.umontreal.ca)
3.7 - *
3.8 - * This program is free software; you can redistribute it and/or modify
3.9 - * it under the terms of the GNU General Public License as published by
3.10 - * the Free Software Foundation; either version 2 of the License, or
3.11 - * (at your option) any later version.
3.12 - *
3.13 - * This program is distributed in the hope that it will be useful,
3.14 - * but WITHOUT ANY WARRANTY; without even the implied warranty of
3.15 - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
3.16 - * GNU General Public License for more details.
3.17 - *
3.18 - * You should have received a copy of the GNU General Public License
3.19 - * along with this program; if not, write to the Free Software
3.20 - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
3.21 - * 02110-1301 USA
3.22 - */
3.23 -
3.24 -#include "rng-mrg32k3a.h"
3.25 -#include "seed-generator.h"
3.26 -#include <iostream>
3.27 -
3.28 -#ifndef MAXINT
3.29 -#define MAXINT 2147483647 // XX [for now]
3.30 -#endif
3.31 -
3.32 -
3.33 -using namespace std;
3.34 -namespace
3.35 -{
3.36 - const double m1 = 4294967087.0;
3.37 - const double m2 = 4294944443.0;
3.38 - const double norm = 1.0 / (m1 + 1.0);
3.39 - const double a12 = 1403580.0;
3.40 - const double a13n = 810728.0;
3.41 - const double a21 = 527612.0;
3.42 - const double a23n = 1370589.0;
3.43 - const double two17 = 131072.0;
3.44 - const double two53 = 9007199254740992.0;
3.45 - const double fact = 5.9604644775390625e-8; /* 1 / 2^24 */
3.46 -
3.47 - // The following are the transition matrices of the two MRG
3.48 - // components (in matrix form), raised to the powers -1, 1,
3.49 - // 2^76, and 2^127, resp.
3.50 -
3.51 - const double InvA1[3][3] = { // Inverse of A1p0
3.52 - { 184888585.0, 0.0, 1945170933.0 },
3.53 - { 1.0, 0.0, 0.0 },
3.54 - { 0.0, 1.0, 0.0 }
3.55 - };
3.56 -
3.57 - const double InvA2[3][3] = { // Inverse of A2p0
3.58 - { 0.0, 360363334.0, 4225571728.0 },
3.59 - { 1.0, 0.0, 0.0 },
3.60 - { 0.0, 1.0, 0.0 }
3.61 - };
3.62 -
3.63 - const double A1p0[3][3] = {
3.64 - { 0.0, 1.0, 0.0 },
3.65 - { 0.0, 0.0, 1.0 },
3.66 - { -810728.0, 1403580.0, 0.0 }
3.67 - };
3.68 -
3.69 - const double A2p0[3][3] = {
3.70 - { 0.0, 1.0, 0.0 },
3.71 - { 0.0, 0.0, 1.0 },
3.72 - { -1370589.0, 0.0, 527612.0 }
3.73 - };
3.74 -
3.75 - const double A1p76[3][3] = {
3.76 - { 82758667.0, 1871391091.0, 4127413238.0 },
3.77 - { 3672831523.0, 69195019.0, 1871391091.0 },
3.78 - { 3672091415.0, 3528743235.0, 69195019.0 }
3.79 - };
3.80 -
3.81 - const double A2p76[3][3] = {
3.82 - { 1511326704.0, 3759209742.0, 1610795712.0 },
3.83 - { 4292754251.0, 1511326704.0, 3889917532.0 },
3.84 - { 3859662829.0, 4292754251.0, 3708466080.0 }
3.85 - };
3.86 -
3.87 - const double A1p127[3][3] = {
3.88 - { 2427906178.0, 3580155704.0, 949770784.0 },
3.89 - { 226153695.0, 1230515664.0, 3580155704.0 },
3.90 - { 1988835001.0, 986791581.0, 1230515664.0 }
3.91 - };
3.92 -
3.93 - const double A2p127[3][3] = {
3.94 - { 1464411153.0, 277697599.0, 1610723613.0 },
3.95 - { 32183930.0, 1464411153.0, 1022607788.0 },
3.96 - { 2824425944.0, 32183930.0, 2093834863.0 }
3.97 - };
3.98 -
3.99 -} // end of anonymous namespace
3.100 -
3.101 -//-------------------------------------------------------------------
3.102 -// Return (a*s + c) MOD m; a, s, c and m must be < 2^35
3.103 -//
3.104 -
3.105 -double
3.106 -RngMrg32k3a::MultModM (double a, double s, double c, double m)
3.107 -{
3.108 - double v;
3.109 - long a1;
3.110 - v=a*s+c;
3.111 -
3.112 - if (v >= two53 || v <= -two53) {
3.113 - a1 = static_cast<long> (a / two17); a -= a1 * two17;
3.114 - v =a1*s;
3.115 - a1 = static_cast<long> (v / m); v -= a1 * m;
3.116 - v = v * two17 + a * s + c;
3.117 - }
3.118 - a1 = static_cast<long> (v / m);
3.119 - /* in case v < 0)*/
3.120 - if ((v -= a1 * m) < 0.0) return v += m; else return v;
3.121 -}
3.122 -
3.123 -//-------------------------------------------------------------------
3.124 -// Compute the vector v = A*s MOD m. Assume that -m < s[i] < m.
3.125 -// Works also when v = s.
3.126 -//
3.127 -void
3.128 -RngMrg32k3a::MatVecModM (const double A[3][3], const double s[3], double v[3],
3.129 - double m)
3.130 -{
3.131 - int i;
3.132 - double x[3]; // Necessary if v = s
3.133 - for (i = 0; i < 3; ++i) {
3.134 - x[i] = MultModM (A[i][0], s[0], 0.0, m);
3.135 - x[i] = MultModM (A[i][1], s[1], x[i], m);
3.136 - x[i] = MultModM (A[i][2], s[2], x[i], m);
3.137 - }
3.138 - for (i = 0; i < 3; ++i)
3.139 - v[i] = x[i];
3.140 -}
3.141 -
3.142 -//-------------------------------------------------------------------
3.143 -// Compute the matrix C = A*B MOD m. Assume that -m < s[i] < m.
3.144 -// Note: works also if A = C or B = C or A = B = C.
3.145 -//
3.146 -void
3.147 -RngMrg32k3a::MatMatModM (const double A[3][3], const double B[3][3],
3.148 - double C[3][3], double m)
3.149 -{
3.150 - int i, j;
3.151 - double V[3], W[3][3];
3.152 - for (i = 0; i < 3; ++i) {
3.153 - for (j = 0; j < 3; ++j)
3.154 - V[j] = B[j][i];
3.155 - MatVecModM (A, V, V, m);
3.156 - for (j = 0; j < 3; ++j)
3.157 -
3.158 - W[j][i] = V[j];
3.159 - }
3.160 - for (i = 0; i < 3; ++i)
3.161 - for (j = 0; j < 3; ++j)
3.162 - C[i][j] = W[i][j];
3.163 -}
3.164 -
3.165 -//-------------------------------------------------------------------
3.166 -// Compute the matrix B = (A^(2^e) Mod m); works also if A = B.
3.167 -//
3.168 -void
3.169 -RngMrg32k3a::MatTwoPowModM (const double A[3][3], double B[3][3], double m,
3.170 - long e)
3.171 -{
3.172 - int i, j;
3.173 - /* initialize: B = A */
3.174 - if (A != B) {
3.175 - for (i = 0; i < 3; ++i)
3.176 - for (j = 0; j < 3; ++j)
3.177 - B[i][j] = A[i][j];
3.178 - }
3.179 - /* Compute B = A^(2^e) mod m */
3.180 - for (i = 0; i < e; i++)
3.181 - MatMatModM (B, B, B, m);
3.182 -}
3.183 -
3.184 -//-------------------------------------------------------------------
3.185 -// Compute the matrix B = (A^n Mod m); works even if A = B.
3.186 -//
3.187 -void
3.188 -RngMrg32k3a::MatPowModM (const double A[3][3], double B[3][3], double m,
3.189 - long n)
3.190 -{
3.191 - int i, j;
3.192 - double W[3][3];
3.193 - /* initialize: W = A; B = I */
3.194 - for (i = 0; i < 3; ++i)
3.195 - for (j = 0; j < 3; ++j) {
3.196 - W[i][j] = A[i][j];
3.197 - B[i][j] = 0.0;
3.198 - }
3.199 - for (j = 0; j < 3; ++j)
3.200 - B[j][j] = 1.0;
3.201 - /* Compute B = A^n mod m using the binary decomposition of n */
3.202 - while (n > 0) {
3.203 - if (n % 2) MatMatModM (W, B, B, m);
3.204 - MatMatModM (W, W, W, m);
3.205 -
3.206 - n/=2;
3.207 - }
3.208 -}
3.209 -
3.210 -//--------------------------------------------------------------------
3.211 -// Check that the seeds are legitimate values. Returns 0 if legal
3.212 -// seeds, -1 otherwise.
3.213 -//
3.214 -int
3.215 -RngMrg32k3a::CheckSeed (const unsigned long seed[6])
3.216 -{
3.217 - int i;
3.218 - for (i = 0; i < 3; ++i) {
3.219 - if (seed[i] >= m1) {
3.220 - std::cerr << "****************************************" << std::endl
3.221 - << "ERROR: Seed["<<i<<"] >= 4294967087, Seed is not set." << std::endl
3.222 - << "****************************************" << std::endl;
3.223 - return (-1);
3.224 - }
3.225 - }
3.226 - for (i = 3; i < 6; ++i) {
3.227 - if (seed[i] >= m2) {
3.228 - std::cerr << "****************************************" << std::endl
3.229 - << "ERROR: Seed["<<i<<"] >= 429444443, Seed is not set."<<std::endl
3.230 - << "****************************************" <<std::endl;
3.231 - return (-1);
3.232 - }
3.233 - }
3.234 - if (seed[0] == 0 && seed[1] == 0 && seed[2] == 0) {
3.235 - std::cerr<< "****************************************" << std::endl
3.236 - << "ERROR: First 3 seeds = 0." << std::endl
3.237 - << "****************************************" << std::endl;
3.238 - return (-1);
3.239 - }
3.240 - if (seed[3] == 0 && seed[4] == 0 && seed[5] == 0) {
3.241 - std::cerr << "****************************************" <<std::endl
3.242 - << "ERROR: Last 3 seeds = 0." << std::endl
3.243 - << "****************************************" << std::endl;
3.244 - return (-1);
3.245 - }
3.246 - return 0;
3.247 -}
3.248 -
3.249 -
3.250 -//-------------------------------------------------------------------------
3.251 -// Generate the next random number.
3.252 -//
3.253 -double RngMrg32k3a::U01 ()
3.254 -{
3.255 - long k;
3.256 - double p1, p2, u;
3.257 - /* Component 1 */
3.258 - p1 = a12 * Cg_[1] - a13n * Cg_[0];
3.259 - k = static_cast<long> (p1 / m1);
3.260 - p1 -= k * m1;
3.261 - if (p1 < 0.0) p1 += m1;
3.262 - Cg_[0] = Cg_[1]; Cg_[1] = Cg_[2]; Cg_[2] = p1;
3.263 - /* Component 2 */
3.264 - p2 = a21 * Cg_[5] - a23n * Cg_[3];
3.265 - k = static_cast<long> (p2 / m2);
3.266 - p2 -= k * m2;
3.267 - if (p2 < 0.0) p2 += m2;
3.268 - Cg_[3] = Cg_[4]; Cg_[4] = Cg_[5]; Cg_[5] = p2;
3.269 - /* Combination */
3.270 - u = ((p1 > p2) ? (p1 - p2) * norm : (p1 - p2 + m1) * norm);
3.271 - return u;
3.272 -}
3.273 -
3.274 -//-------------------------------------------------------------------------
3.275 -// Generate the next random number with extended (53 bits) precision.
3.276 -//
3.277 -double RngMrg32k3a::U01d ()
3.278 -{
3.279 - double u;
3.280 - u = U01();
3.281 - u += (U01() - 1.0) * fact;
3.282 - return (u < 0.0) ? u + 1.0 : u;
3.283 -}
3.284 -
3.285 -//*************************************************************************
3.286 -// Public members of the class start here
3.287 -//-------------------------------------------------------------------------
3.288 -
3.289 -RngMrg32k3a::RngMrg32k3a ()
3.290 -{}
3.291 -
3.292 -void RngMrg32k3a::reset (long seed)
3.293 -{
3.294 - for (int i = 0; i < 6; ++i) {
3.295 - Bg_[i] = Cg_[i] = Ig_[i] = seed;
3.296 - }
3.297 -}
3.298 -
3.299 -
3.300 -//-------------------------------------------------------------------------
3.301 -// Generate the next random number.
3.302 -//
3.303 -
3.304 -uint32_t
3.305 -RngMrg32k3a::get_max (void) const
3.306 -{
3.307 - return MAXINT;
3.308 -}
3.309 -uint32_t
3.310 -RngMrg32k3a::get_min (void) const
3.311 -{
3.312 - return 0;
3.313 -}
3.314 -
3.315 -uint32_t
3.316 -RngMrg32k3a::get_uint (void)
3.317 -{
3.318 - return get_uint (0, MAXINT);
3.319 -}
3.320 -
3.321 -uint32_t
3.322 -RngMrg32k3a::get_uint (uint32_t n)
3.323 -{
3.324 - return get_uint (0, n);
3.325 -}
3.326 -
3.327 -uint32_t
3.328 -RngMrg32k3a::get_uint (uint32_t low, uint32_t high)
3.329 -{
3.330 - return ((uint32_t) (low + (uint32_t) (((uint32_t)
3.331 - (high-low+1)) * U01())));
3.332 -}
3.333 -
3.334 -double
3.335 -RngMrg32k3a::get_double (void)
3.336 -{
3.337 -
3.338 - return U01d ();
3.339 -}
4.1 --- a/src/common/rng-mrg32k3a.h Tue Aug 29 17:43:19 2006 +0200
4.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
4.3 @@ -1,65 +0,0 @@
4.4 -/* -*- Mode:C++; c-basic-offset:8; tab-width:8; indent-tabs-mode:t -*- */
4.5 -/*
4.6 - * Copyright (C) 2001 Pierre L'Ecuyer (lecuyer@iro.umontreal.ca)
4.7 - *
4.8 - * This program is free software; you can redistribute it and/or modify
4.9 - * it under the terms of the GNU General Public License as published by
4.10 - * the Free Software Foundation; either version 2 of the License, or
4.11 - * (at your option) any later version.
4.12 - *
4.13 - * This program is distributed in the hope that it will be useful,
4.14 - * but WITHOUT ANY WARRANTY; without even the implied warranty of
4.15 - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
4.16 - * GNU General Public License for more details.
4.17 - *
4.18 - * You should have received a copy of the GNU General Public License
4.19 - * along with this program; if not, write to the Free Software
4.20 - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
4.21 - * 02110-1301 USA
4.22 - *
4.23 - */
4.24 -#ifndef RNG_MRG32k3A_H
4.25 -#define RNG_MRG32k3A_H
4.26 -
4.27 -#include <stdint.h>
4.28 -
4.29 -
4.30 -/*
4.31 - * Use class RNG in real programs.
4.32 - */
4.33 -class RngMrg32k3a {
4.34 -public:
4.35 - RngMrg32k3a ();
4.36 -
4.37 - void reset (long seed);
4.38 -
4.39 -
4.40 - uint32_t get_max (void) const;
4.41 - uint32_t get_min (void) const;
4.42 - uint32_t get_uint (void);
4.43 - uint32_t get_uint (uint32_t n);
4.44 - uint32_t get_uint (uint32_t low, uint32_t high);
4.45 - double get_double (void);
4.46 -
4.47 -private:
4.48 - double U01 ();
4.49 - double U01d ();
4.50 - double MultModM (double a, double s, double c, double m);
4.51 - void MatVecModM (const double A[3][3], const double s[3], double v[3],
4.52 - double m);
4.53 - void MatMatModM (const double A[3][3], const double B[3][3],
4.54 - double C[3][3], double m) ;
4.55 - void MatTwoPowModM (const double A[3][3], double B[3][3], double m,
4.56 - long e);
4.57 - void MatPowModM (const double A[3][3], double B[3][3], double m,
4.58 - long n);
4.59 - int CheckSeed (const unsigned long seed[6]);
4.60 -
4.61 - /*
4.62 - Vectors to store the current seed, the beginning of the current block
4.63 - (substream) and the beginning of the current stream.
4.64 - */
4.65 - double Cg_[6], Bg_[6], Ig_[6];
4.66 -};
4.67 -
4.68 -#endif /* RNG_MRG32k3A_H */
5.1 --- a/src/common/sgi-hashmap.h Tue Aug 29 17:43:19 2006 +0200
5.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
5.3 @@ -1,32 +0,0 @@
5.4 -/* This code snippet was ripped out of the gcc
5.5 - * documentation and slightly modified to work
5.6 - * with gcc 4.x
5.7 - */
5.8 -#ifndef SGI_HASHMAP_H
5.9 -#define SGI_HASHMAP_H
5.10 -
5.11 -/* To use gcc extensions.
5.12 - */
5.13 -#ifdef __GNUC__
5.14 - #if __GNUC__ < 3
5.15 - #include <hash_map.h>
5.16 -namespace Sgi { using ::hash_map; }; // inherit globals
5.17 - #else
5.18 - #if __GNUC__ < 4
5.19 - #include <ext/hash_map>
5.20 - #if __GNUC_MINOR__ == 0
5.21 -namespace Sgi = std; // GCC 3.0
5.22 - #else
5.23 -namespace Sgi = ::__gnu_cxx; // GCC 3.1 and later
5.24 - #endif
5.25 - #else // gcc 4.x and later
5.26 - #include <ext/hash_map>
5.27 - namespace Sgi = ::__gnu_cxx;
5.28 - #endif
5.29 - #endif
5.30 -#else // ... there are other compilers, right?
5.31 -namespace Sgi = std;
5.32 -#endif
5.33 -
5.34 -
5.35 -#endif /* SGI_HASHMAP_H */
6.1 --- a/src/common/timeout.cc Tue Aug 29 17:43:19 2006 +0200
6.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
6.3 @@ -1,77 +0,0 @@
6.4 -/* -*- Mode:C++; c-basic-offset:8; tab-width:8; indent-tabs-mode:t -*- */
6.5 -/*
6.6 - * Copyright (c) 2005 INRIA
6.7 - * All rights reserved.
6.8 - *
6.9 - * This program is free software; you can redistribute it and/or modify
6.10 - * it under the terms of the GNU General Public License version 2 as
6.11 - * published by the Free Software Foundation;
6.12 - *
6.13 - * This program is distributed in the hope that it will be useful,
6.14 - * but WITHOUT ANY WARRANTY; without even the implied warranty of
6.15 - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
6.16 - * GNU General Public License for more details.
6.17 - *
6.18 - * You should have received a copy of the GNU General Public License
6.19 - * along with this program; if not, write to the Free Software
6.20 - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
6.21 - *
6.22 - * Author: Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
6.23 - */
6.24 -#include "timeout.h"
6.25 -#include "yans/simulator.h"
6.26 -#include "yans/event.tcc"
6.27 -
6.28 -namespace yans {
6.29 -
6.30 -Timeout::Timeout (ExpireCallback callback)
6.31 - : m_interval_us (0),
6.32 - m_count (0),
6.33 - m_current_count (0),
6.34 - m_stop (false),
6.35 - m_callback (callback)
6.36 -{}
6.37 -Timeout::~Timeout ()
6.38 -{}
6.39 -void
6.40 -Timeout::set_interval (uint64_t us)
6.41 -{
6.42 - m_interval_us = us;
6.43 -}
6.44 -void
6.45 -Timeout::set_count (uint32_t count)
6.46 -{
6.47 - m_count = count;
6.48 -}
6.49 -
6.50 -
6.51 -void Timeout::start (void)
6.52 -{
6.53 - Simulator::schedule_rel_us (m_interval_us,
6.54 - make_event (&Timeout::expire, this));
6.55 -}
6.56 -void Timeout::stop (void)
6.57 -{
6.58 - m_stop = true;
6.59 -}
6.60 -void Timeout::restart (void)
6.61 -{
6.62 - m_current_count = m_count;
6.63 -}
6.64 -void
6.65 -Timeout::expire (void)
6.66 -{
6.67 - if (m_stop) {
6.68 - return;
6.69 - }
6.70 - m_current_count--;
6.71 - if (m_current_count == 0) {
6.72 - m_callback ();
6.73 - return;
6.74 - }
6.75 - Simulator::schedule_rel_us (m_interval_us,
6.76 - make_event (&Timeout::expire, this));
6.77 -}
6.78 -
6.79 -
6.80 -}; // namespace yans
7.1 --- a/src/common/timeout.h Tue Aug 29 17:43:19 2006 +0200
7.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
7.3 @@ -1,52 +0,0 @@
7.4 -/* -*- Mode:C++; c-basic-offset:8; tab-width:8; indent-tabs-mode:t -*- */
7.5 -/*
7.6 - * Copyright (c) 2005 INRIA
7.7 - * All rights reserved.
7.8 - *
7.9 - * This program is free software; you can redistribute it and/or modify
7.10 - * it under the terms of the GNU General Public License version 2 as
7.11 - * published by the Free Software Foundation;
7.12 - *
7.13 - * This program is distributed in the hope that it will be useful,
7.14 - * but WITHOUT ANY WARRANTY; without even the implied warranty of
7.15 - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
7.16 - * GNU General Public License for more details.
7.17 - *
7.18 - * You should have received a copy of the GNU General Public License
7.19 - * along with this program; if not, write to the Free Software
7.20 - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
7.21 - *
7.22 - * Author: Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
7.23 - */
7.24 -
7.25 -#ifndef TIMEOUT_H
7.26 -#define TIMEOUT_H
7.27 -
7.28 -#include <stdint.h>
7.29 -#include "yans/callback.h"
7.30 -
7.31 -namespace yans {
7.32 -
7.33 -class Timeout {
7.34 -public:
7.35 - typedef Callback<void> ExpireCallback;
7.36 - Timeout (ExpireCallback callback);
7.37 - ~Timeout ();
7.38 - void set_interval (uint64_t us);
7.39 - void set_count (uint32_t count);
7.40 - void start (void);
7.41 - void stop (void);
7.42 - void restart (void);
7.43 -private:
7.44 - Timeout ();
7.45 - void expire (void);
7.46 - uint64_t m_interval_us;
7.47 - uint32_t m_count;
7.48 - uint32_t m_current_count;
7.49 - bool m_stop;
7.50 - ExpireCallback m_callback;
7.51 -};
7.52 -
7.53 -}; // namespace yans
7.54 -
7.55 -#endif /* TIMEOUT_H */