modules/up/src/Core/gnu/RNG.h

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

FUNCTIONS

This source file includes following functions.
  1. RNG

   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 _RNG_h
  19 #define _RNG_h 1
  20 #ifdef __GNUG__
  21 #pragma interface
  22 #endif
  23 
  24 #include <assert.h>
  25 #include <math.h>
  26 #include <_G_config.h>
  27 
  28 union PrivateRNGSingleType {                    // used to access floats as unsigneds
  29     float s;
  30     _G_uint32_t u;
  31 };
  32 
  33 union PrivateRNGDoubleType {                    // used to access doubles as unsigneds
  34     double d;
  35     _G_uint32_t u[2];
  36 };
  37 
  38 //
  39 // Base class for Random Number Generators. See ACG and MLCG for instances.
  40 //
  41 class RNG {
     /* [<][>][^][v][top][bottom][index][help] */
  42     static PrivateRNGSingleType singleMantissa; // mantissa bit vector
  43     static PrivateRNGDoubleType doubleMantissa; // mantissa bit vector
  44 public:
  45     RNG();
  46     //
  47     // Return a long-words word of random bits
  48     //
  49     virtual _G_uint32_t asLong() = 0;
  50     virtual void reset() = 0;
  51     //
  52     // Return random bits converted to either a float or a double
  53     //
  54     float asFloat();
  55     double asDouble();
  56 };
  57 
  58 #endif

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