Main Page | Modules | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members

randnum.h

Go to the documentation of this file.
00001 
00005 /*
00006  * Author: Grant Tang, 03/10/2008 (gtang@bcm.edu)
00007  * Copyright (c) 2000-2006 Baylor College of Medicine
00008  * 
00009  * This software is issued under a joint BSD/GNU license. You may use the
00010  * source code in this file under either license. However, note that the
00011  * complete EMAN2 and SPARX software packages have some GPL dependencies,
00012  * so you are responsible for compliance with the licenses of these packages
00013  * if you opt to use BSD licensing. The warranty disclaimer below holds
00014  * in either instance.
00015  * 
00016  * This complete copyright notice must be included in any revised version of the
00017  * source code. Additional authorship citations may be added, but existing
00018  * author citations must be preserved.
00019  * 
00020  * This program is free software; you can redistribute it and/or modify
00021  * it under the terms of the GNU General Public License as published by
00022  * the Free Software Foundation; either version 2 of the License, or
00023  * (at your option) any later version.
00024  * 
00025  * This program is distributed in the hope that it will be useful,
00026  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00027  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
00028  * GNU General Public License for more details.
00029  * 
00030  * You should have received a copy of the GNU General Public License
00031  * along with this program; if not, write to the Free Software
00032  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
00033  * 
00034  * */
00035  
00036 #ifndef randnum_h__
00037 #define randnum_h__ 
00038 
00039 #include <gsl/gsl_rng.h>
00040  
00041 namespace EMAN
00042 {
00090         class Randnum {
00091           public:
00092                 static Randnum * Instance();
00093                 static Randnum * Instance(const gsl_rng_type * _t);
00094                                 
00105                 void set_seed(unsigned long long seed);
00106                 
00110                 unsigned long long get_seed();
00111                 
00119                 long long get_irand(long long lo, long long hi) const;
00120                 
00127                 float get_frand(double lo=0.0, double hi=1.0) const;
00128                 
00135                 float get_frand_pos(double lo=0.0, double hi=1.0) const;
00136                 
00143                 float get_gauss_rand(float mean, float sigma) const;
00144                 
00146             void print_generator_type() const;
00147           
00148           protected:
00152                 Randnum();
00153                 Randnum(const Randnum&);
00154                 
00162                 explicit Randnum(const gsl_rng_type * _t);
00163                 
00164                 ~Randnum();
00165                 
00166                 
00167                 
00168           private:
00169                 const static gsl_rng_type * T;
00170         static gsl_rng * r;
00171         static unsigned long long _seed;
00172         
00173         static Randnum* _instance;
00174         }; 
00175         
00176 }
00177 
00178 #endif  //randnum_h__

Generated on Tue Jun 11 13:46:18 2013 for EMAN2 by  doxygen 1.3.9.1