00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00019 #ifndef __Exponential_h
00020 #define __Exponential_h
00021
00022 #ifndef ANSI_HDRS
00023 #include <math.h>
00024 #else
00025 #include <cmath>
00026 #endif
00027 #include "Uniform.h"
00028
00029
00030
00031 #ifdef SWIG
00032 class Exponential: public CRandVar {
00033 #else
00034 class UTILIB_API Exponential: public CRandVar {
00035 #endif
00036 public:
00037
00039 Exponential(RNG* gen=0, double _meanval=1.0)
00040 : CRandVar(gen),uvar(gen) {b=_meanval;}
00041
00043 double meanval()
00044 {return b;}
00046 void meanval(double _b)
00047 {b=_b;}
00048
00049 #ifndef SWIG
00050
00051 virtual double operator()();
00052 #endif
00053
00054 protected:
00055
00057 double b;
00059 Uniform uvar;
00060 };
00061
00062 #ifndef SWIG
00063
00064
00065 inline double Exponential::operator()()
00066 {
00067 double temp;
00068 RNG* rng;
00069
00070 if ((rng = generator()) == NULL) {
00071 ErrReturn("Exponential::operator() : Attempting to use a NULL RNG.");
00072 }
00073 else {
00074 temp = - b * log( uvar() );
00075 return(temp);
00076 }
00077 }
00078 #endif
00079
00080 #endif