Sync usage with man page.
[netbsd-mini2440.git] / gnu / lib / libg++ / g++-include / MLCG.h
blob73791f055ce14bef2a00c22795882d4cbf41c5c3
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)
6 This file is part of GNU CC.
8 GNU CC is distributed in the hope that it will be useful,
9 but WITHOUT ANY WARRANTY. No author or distributor
10 accepts responsibility to anyone for the consequences of using it
11 or for whether it serves any particular purpose or works at all,
12 unless he says so in writing. Refer to the GNU CC General Public
13 License for full details.
15 Everyone is granted permission to copy, modify and redistribute
16 GNU CC, but only under the conditions described in the
17 GNU CC General Public License. A copy of this license is
18 supposed to have been given to you along with GNU CC so you
19 can know your rights and responsibilities. It should be in a
20 file named COPYING. Among other things, the copyright notice
21 and this notice must be preserved on all copies.
23 #ifndef _MLCG_h
24 #define _MLCG_h 1
25 #ifdef __GNUG__
26 #pragma once
27 #pragma interface
28 #endif
30 #include <RNG.h>
31 #include <math.h>
34 // Multiplicative Linear Conguential Generator
37 class MLCG : public RNG {
38 long initialSeedOne;
39 long initialSeedTwo;
40 long seedOne;
41 long seedTwo;
43 protected:
45 public:
46 MLCG(long seed1 = 0, long seed2 = 1);
48 // Return a long-words word of random bits
50 virtual unsigned long asLong();
51 virtual void reset();
52 long seed1();
53 void seed1(long);
54 long seed2();
55 void seed2(long);
56 void reseed(long, long);
59 #if defined(__OPTIMIZE__) || defined(USE_LIBGXX_INLINES)
61 inline long
62 MLCG::seed1()
64 return(seedOne);
67 inline void
68 MLCG::seed1(long s)
70 initialSeedOne = s;
71 reset();
74 inline long
75 MLCG::seed2()
77 return(seedTwo);
80 inline void
81 MLCG::seed2(long s)
83 initialSeedTwo = s;
84 reset();
87 inline void
88 MLCG::reseed(long s1, long s2)
90 initialSeedOne = s1;
91 initialSeedTwo = s2;
92 reset();
95 #endif
97 #endif