blitz/random.h

Go to the documentation of this file.
00001 /***************************************************************************
00002  * blitz/random.h       Random number generator wrapper class
00003  *
00004  * $Id: random.h,v 1.4 2003/12/11 03:44:22 julianc Exp $
00005  *
00006  * Copyright (C) 1997-2001 Todd Veldhuizen <tveldhui@oonumerics.org>
00007  *
00008  * This program is free software; you can redistribute it and/or
00009  * modify it under the terms of the GNU General Public License
00010  * as published by the Free Software Foundation; either version 2
00011  * of the License, or (at your option) any later version.
00012  *
00013  * This program is distributed in the hope that it will be useful,
00014  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00015  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00016  * GNU General Public License for more details.
00017  *
00018  * Suggestions:          blitz-dev@oonumerics.org
00019  * Bugs:                 blitz-bugs@oonumerics.org
00020  *
00021  * For more information, please see the Blitz++ Home Page:
00022  *    http://oonumerics.org/blitz/
00023  *
00024  ***************************************************************************/
00025 
00026 #ifndef BZ_RANDOM_H
00027 #define BZ_RANDOM_H
00028 
00029 #ifndef BZ_BLITZ_H
00030  #include <blitz/blitz.h>
00031 #endif
00032 
00033 BZ_NAMESPACE(blitz)
00034 
00035 template<typename P_distribution>
00036 class Random {
00037 
00038 public:
00039     typedef P_distribution T_distribution;
00040     typedef _bz_typename T_distribution::T_numtype T_numtype;
00041 
00042     Random(double parm1=0.0, double parm2=1.0, double parm3=0.0)
00043         : generator_(parm1, parm2, parm3)
00044     { }
00045 
00046     void randomize()
00047     { generator_.randomize(); }
00048    
00049     T_numtype random()
00050     { return generator_.random(); }
00051 
00052     operator T_numtype()
00053     { return generator_.random(); }
00054 
00055 protected: 
00056     T_distribution generator_;
00057 };
00058 
00059 BZ_NAMESPACE_END
00060 
00061 #include <blitz/randref.h>
00062 
00063 #endif // BZ_RANDOM_H
00064 

Generated on Wed Oct 17 17:52:55 2007 for blitz by  doxygen 1.5.2