1 | /*************************************************************************** |
---|
2 | * blitz/random.h Random number generator wrapper class |
---|
3 | * |
---|
4 | * $Id: random.h,v 1.4 2003/12/11 03:44:22 julianc Exp $ |
---|
5 | * |
---|
6 | * Copyright (C) 1997-2001 Todd Veldhuizen <tveldhui@oonumerics.org> |
---|
7 | * |
---|
8 | * This program is free software; you can redistribute it and/or |
---|
9 | * modify it under the terms of the GNU General Public License |
---|
10 | * as published by the Free Software Foundation; either version 2 |
---|
11 | * of the License, or (at your option) any later version. |
---|
12 | * |
---|
13 | * This program is distributed in the hope that it will be useful, |
---|
14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
---|
16 | * GNU General Public License for more details. |
---|
17 | * |
---|
18 | * Suggestions: blitz-dev@oonumerics.org |
---|
19 | * Bugs: blitz-bugs@oonumerics.org |
---|
20 | * |
---|
21 | * For more information, please see the Blitz++ Home Page: |
---|
22 | * http://oonumerics.org/blitz/ |
---|
23 | * |
---|
24 | ***************************************************************************/ |
---|
25 | |
---|
26 | #ifndef BZ_RANDOM_H |
---|
27 | #define BZ_RANDOM_H |
---|
28 | |
---|
29 | #ifndef BZ_BLITZ_H |
---|
30 | #include <blitz/blitz.h> |
---|
31 | #endif |
---|
32 | |
---|
33 | BZ_NAMESPACE(blitz) |
---|
34 | |
---|
35 | template<typename P_distribution> |
---|
36 | class Random { |
---|
37 | |
---|
38 | public: |
---|
39 | typedef P_distribution T_distribution; |
---|
40 | typedef _bz_typename T_distribution::T_numtype T_numtype; |
---|
41 | |
---|
42 | Random(double parm1=0.0, double parm2=1.0, double parm3=0.0) |
---|
43 | : generator_(parm1, parm2, parm3) |
---|
44 | { } |
---|
45 | |
---|
46 | void randomize() |
---|
47 | { generator_.randomize(); } |
---|
48 | |
---|
49 | T_numtype random() |
---|
50 | { return generator_.random(); } |
---|
51 | |
---|
52 | operator T_numtype() |
---|
53 | { return generator_.random(); } |
---|
54 | |
---|
55 | protected: |
---|
56 | T_distribution generator_; |
---|
57 | }; |
---|
58 | |
---|
59 | BZ_NAMESPACE_END |
---|
60 | |
---|
61 | #include <blitz/randref.h> |
---|
62 | |
---|
63 | #endif // BZ_RANDOM_H |
---|
64 | |
---|