## modules/up/src/Core/gnu/MLCG.h

/* [<][>][^][v][top][bottom][index][help] */

## FUNCTIONS

This source file includes following functions.

1. MLCG
2. seed1
3. seed1
4. seed2
5. seed2
6. reseed

       1 // This may look like C code, but it is really -*- C++ -*-
       2 /*
       3 Copyright (C) 1988 Free Software Foundation
       4     written by Dirk Grunwald (grunwald@cs.uiuc.edu)
       5
       6 This file is part of the GNU C++ Library.  This library is free
       7 software; you can redistribute it and/or modify it under the terms of
       8 the GNU Library General Public License as published by the Free
       9 Software Foundation; either version 2 of the License, or (at your
      10 option) any later version.  This library is distributed in the hope
      11 that it will be useful, but WITHOUT ANY WARRANTY; without even the
      12 implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
      13 PURPOSE.  See the GNU Library General Public License for more details.
      14 You should have received a copy of the GNU Library General Public
      15 License along with this library; if not, write to the Free Software
      16 Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
      17 */
      18 #ifndef _MLCG_h
      19 #define _MLCG_h 1
      20 #ifdef __GNUG__
      21 #pragma interface
      22 #endif
      23
      24 #include "gnu/RNG.h"
      25 #include <math.h>
      26
      27 //
      28 //      Multiplicative Linear Conguential Generator
      29 //
      30
      31 class MLCG : public RNG {
         /* [<][>][^][v][top][bottom][index][help] */
      32     _G_int32_t initialSeedOne;
      33     _G_int32_t initialSeedTwo;
      34     _G_int32_t seedOne;
      35     _G_int32_t seedTwo;
      36
      37 protected:
      38
      39 public:
      40     MLCG(_G_int32_t seed1 = 0, _G_int32_t seed2 = 1);
      41     //
      42     // Return a long-words word of random bits
      43     //
      44     virtual _G_uint32_t asLong();
      45     virtual void reset();
      46     _G_int32_t seed1();
      47     void seed1(_G_int32_t);
      48     _G_int32_t seed2();
      49     void seed2(_G_int32_t);
      50     void reseed(_G_int32_t, _G_int32_t);
      51 };
      52
      53 inline _G_int32_t
      54 MLCG::seed1()
         /* [<][>][^][v][top][bottom][index][help] */
      55 {
      56     return(seedOne);
      57 }
      58
      59 inline void
      60 MLCG::seed1(_G_int32_t s)
         /* [<][>][^][v][top][bottom][index][help] */
      61 {
      62     initialSeedOne = s;
      63     reset();
      64 }
      65
      66 inline _G_int32_t
      67 MLCG::seed2()
         /* [<][>][^][v][top][bottom][index][help] */
      68 {
      69     return(seedTwo);
      70 }
      71
      72 inline void
      73 MLCG::seed2(_G_int32_t s)
         /* [<][>][^][v][top][bottom][index][help] */
      74 {
      75     initialSeedTwo = s;
      76     reset();
      77 }
      78
      79 inline void
      80 MLCG::reseed(_G_int32_t s1, _G_int32_t s2)
         /* [<][>][^][v][top][bottom][index][help] */
      81 {
      82     initialSeedOne = s1;
      83     initialSeedTwo = s2;
      84     reset();
      85 }
      86
      87 #endif

/* [<][>][^][v][top][bottom][index][help] */