|
||||
File indexing completed on 2025-01-18 09:54:37
0001 // $Id: RandChiSquare.h,v 1.5 2010/06/16 17:24:53 garren Exp $ 0002 // -*- C++ -*- 0003 // 0004 // ----------------------------------------------------------------------- 0005 // HEP Random 0006 // --- RandChiSquare --- 0007 // class header file 0008 // ----------------------------------------------------------------------- 0009 0010 // Class defining methods for shooting Chi^2 distributed random values, 0011 // given a number of degrees of freedom a (default=1.0). 0012 // Default values are used for operator()(). 0013 0014 // Valid values of a satisfy a > 1. When invalid values are presented, 0015 // the code silently returns -1.0. 0016 0017 // ======================================================================= 0018 // John Marraffino - Created: 12th May 1998 Based on the C-Rand package 0019 // by Ernst Stadlober and Franz Niederl of the Technical 0020 // University of Graz, Austria. 0021 // Gabriele Cosmo - Removed useless methods and data: 5th Jan 1999 0022 // M Fischler - put and get to/from streams 12/10/04 0023 // ======================================================================= 0024 0025 #ifndef RandChiSquare_h 0026 #define RandChiSquare_h 1 0027 0028 #include "CLHEP/Random/defs.h" 0029 #include "CLHEP/Random/Random.h" 0030 #include "CLHEP/Utility/memory.h" 0031 0032 namespace CLHEP { 0033 0034 /** 0035 * @author 0036 * @ingroup random 0037 */ 0038 class RandChiSquare : public HepRandom { 0039 0040 public: 0041 0042 inline RandChiSquare ( HepRandomEngine& anEngine, double a=1 ); 0043 inline RandChiSquare ( HepRandomEngine* anEngine, double a=1 ); 0044 // These constructors should be used to instantiate a RandChiSquare 0045 // distribution object defining a local engine for it. 0046 // The static generator will be skipped using the non-static methods 0047 // defined below. 0048 // If the engine is passed by pointer the corresponding engine object 0049 // will be deleted by the RandChiSquare destructor. 0050 // If the engine is passed by reference the corresponding engine object 0051 // will not be deleted by the RandChiSquare destructor. 0052 0053 virtual ~RandChiSquare(); 0054 // Destructor 0055 0056 // Static methods to shoot random values using the static generator 0057 0058 static inline double shoot(); 0059 0060 static double shoot( double a ); 0061 0062 static void shootArray ( const int size, double* vect, 0063 double a=1.0 ); 0064 0065 // Static methods to shoot random values using a given engine 0066 // by-passing the static generator. 0067 0068 static inline double shoot( HepRandomEngine* anEngine ); 0069 0070 static double shoot( HepRandomEngine* anEngine, 0071 double a ); 0072 0073 static void shootArray ( HepRandomEngine* anEngine, const int size, 0074 double* vect, double a=1.0 ); 0075 0076 // Methods using the localEngine to shoot random values, by-passing 0077 // the static generator. 0078 0079 inline double fire(); 0080 0081 double fire( double a ); 0082 0083 void fireArray ( const int size, double* vect); 0084 void fireArray ( const int size, double* vect, 0085 double a ); 0086 inline double operator()(); 0087 inline double operator()( double a ); 0088 0089 // Save and restore to/from streams 0090 0091 std::ostream & put ( std::ostream & os ) const; 0092 std::istream & get ( std::istream & is ); 0093 0094 std::string name() const; 0095 HepRandomEngine & engine(); 0096 0097 static std::string distributionName() {return "RandChiSquare";} 0098 // Provides the name of this distribution class 0099 0100 private: 0101 0102 static double genChiSquare( HepRandomEngine *anEngine, double a ); 0103 0104 std::shared_ptr<HepRandomEngine> localEngine; 0105 double defaultA; 0106 0107 }; 0108 0109 } // namespace CLHEP 0110 0111 #ifdef ENABLE_BACKWARDS_COMPATIBILITY 0112 // backwards compatibility will be enabled ONLY in CLHEP 1.9 0113 using namespace CLHEP; 0114 #endif 0115 0116 #include "CLHEP/Random/RandChiSquare.icc" 0117 0118 #endif
[ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
This page was automatically generated by the 2.3.7 LXR engine. The LXR team |