LTI-Lib latest version v1.9 - last update 10 Apr 2010

ltiGammaDist.h

00001 /*
00002  * Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006
00003  * Lehrstuhl fuer Technische Informatik, RWTH-Aachen, Germany
00004  *
00005  * This file is part of the LTI-Computer Vision Library (LTI-Lib)
00006  *
00007  * The LTI-Lib is free software; you can redistribute it and/or
00008  * modify it under the terms of the GNU Lesser General Public License (LGPL)
00009  * as published by the Free Software Foundation; either version 2.1 of
00010  * the License, or (at your option) any later version.
00011  *
00012  * The LTI-Lib is distributed in the hope that it will be
00013  * useful, but WITHOUT ANY WARRANTY; without even the implied warranty
00014  * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00015  * GNU Lesser General Public License for more details.
00016  *
00017  * You should have received a copy of the GNU Lesser General Public
00018  * License along with the LTI-Lib; see the file LICENSE.  If
00019  * not, write to the Free Software Foundation, Inc., 59 Temple Place -
00020  * Suite 330, Boston, MA 02111-1307, USA.
00021  */
00022 
00023 
00024 /*----------------------------------------------------------------
00025  * project ....: LTI Digital Image/Signal Processing Library
00026  * file .......: ltiGammaDist.h
00027  * authors ....: Thomas Rusert
00028  * organization: LTI, RWTH Aachen
00029  * creation ...: 21.04.99
00030  * revisions ..: $Id: ltiGammaDist.h,v 1.5 2006/02/08 12:23:01 ltilib Exp $
00031  */
00032 #ifndef _LTI_GAMMADIST_H_
00033 #define _LTI_GAMMADIST_H_
00034 
00035 #include "ltiContinuousRandDist.h"
00036 
00037 namespace lti {
00038   /**
00039    * Gamma distributed random number class.
00040    */
00041   class gammaDistribution : public continuousRandomDistribution {
00042   public:
00043     /**
00044      * parameters for the gamma distribution
00045      */
00046     class parameters : public continuousRandomDistribution::parameters {
00047     public:
00048 
00049       /**
00050        * default constructor
00051        */
00052       parameters() : continuousRandomDistribution::parameters(),order(1) {};
00053 
00054       /**
00055        * copy constructor
00056        */
00057 
00058       parameters(const parameters& other)
00059         : continuousRandomDistribution::parameters() {
00060         copy(other);
00061       };
00062 
00063       /**
00064        * destructor
00065        */
00066       ~parameters() {};
00067 
00068       /**
00069        * the order
00070        */
00071       int order;
00072 
00073       /**
00074        * copy data of "other" parameters
00075        */
00076       parameters& copy(const parameters& other) {
00077 #ifndef _LTI_MSC_6
00078         // MS Visual C++ 6 is not able to compile this...
00079         continuousRandomDistribution::parameters::copy(other);
00080 #else
00081         // ...so we have to use this workaround.
00082         // Conditional on that, copy may not be virtual.
00083         continuousRandomDistribution::parameters&
00084           (continuousRandomDistribution::parameters::*p_copy)(const continuousRandomDistribution::parameters&) =
00085           continuousRandomDistribution::parameters::copy;
00086         (this->*p_copy)(other);
00087 #endif
00088 
00089         order = other.order;
00090 
00091         return (*this);
00092       };
00093 
00094       /**
00095        * returns a pointer to a clone of the parameters.
00096        */
00097       virtual functor::parameters* clone() const {
00098         return (new parameters(*this));
00099       };
00100 
00101       /**
00102        * returns the name of this type
00103        */
00104       virtual const char* getTypeName() const {
00105         return "gammaDistribution::parameters";
00106       };
00107     };
00108 
00109     /**
00110      * default constructor.
00111      */
00112     gammaDistribution() : continuousRandomDistribution() {};
00113 
00114     /**
00115      * constructor, sets the parameters
00116      */
00117     gammaDistribution(const parameters& theParams);
00118 
00119     /**
00120      * constructor, sets order theOrder
00121      */
00122     gammaDistribution(const int theOrder);
00123 
00124     /**
00125      * destructor
00126      */
00127     virtual ~gammaDistribution() {};
00128 
00129     /**
00130      * returns the current parameters.
00131      */
00132     const parameters& getParameters() const;
00133 
00134     /**
00135      * gamma distribution. Returns a deviate distributed  as a gamma
00136      * distribution of the given integer order, i.e. a waiting time to the
00137      * (theOrder)th event in a Poisson process of unit mean.
00138      */
00139     virtual double draw() const;
00140 
00141     /**
00142      * returns a pointer to a clone of the functor.
00143      */
00144     virtual functor* clone() const {
00145       return (new gammaDistribution(*this));
00146     };
00147 
00148     /**
00149      * returns the name of this type
00150      */
00151     virtual const char* getTypeName() const {
00152       return "gammaDistribution";
00153     };
00154   };
00155 }
00156 
00157 #endif

Generated on Sat Apr 10 15:25:33 2010 for LTI-Lib by Doxygen 1.6.1