casa  $Rev:20696$
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines
PoissonFunction.h
Go to the documentation of this file.
00001 //# Copyright (C) 2002,2005
00002 //# Associated Universities, Inc. Washington DC, USA.
00003 //#
00004 //# This library is free software; you can redistribute it and/or modify it
00005 //# under the terms of the GNU Library General Public License as published by
00006 //# the Free Software Foundation; either version 2 of the License, or (at your
00007 //# option) any later version.
00008 //#
00009 //# This library is distributed in the hope that it will be useful, but WITHOUT
00010 //# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
00011 //# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Library General Public
00012 //# License for more details.
00013 //#
00014 //# You should have received a copy of the GNU Library General Public License
00015 //# along with this library; if not, write to the Free Software Foundation,
00016 //# Inc., 675 Massachusetts Ave, Cambridge, MA 02139, USA.
00017 //#
00018 //# Correspondence concerning AIPS++ should be addressed as follows:
00019 //#        Internet email: aips2-request@nrao.edu.
00020 //#        Postal address: AIPS++ Project Office
00021 //#                        National Radio Astronomy Observatory
00022 //#                        520 Edgemont Road
00023 //#                        Charlottesville, VA 22903-2475 USA
00024 //#
00025 
00026 #ifndef SCIMATH_POISSONFUNCTION_H
00027 #define SCIMATH_POISSONFUNCTION_H
00028 
00029 //# Includes
00030 #include <casa/aips.h>
00031 #include <scimath/Functionals/PoissonParam.h>
00032 #include <scimath/Functionals/Function.h>
00033 
00034 namespace casa { //# NAMESPACE CASA - BEGIN
00035 
00036 //# Forward declarations
00037 
00038 // <summary> A one dimensional Poisson function
00039 // </summary>
00040 
00041 // <use visibility=export>
00042 
00043 // <reviewed reviewer="" date="" tests="tFunctionHolder" 
00044 // demos="">
00045 // </reviewed>
00046 
00047 // <prerequisite>
00048 //   <li> <linkto class="PoissonParam">PoissonParam</linkto>
00049 //   <li> <linkto class="Function">Function</linkto>
00050 // </prerequisite>
00051 
00052 // <etymology> 
00053 // A 1-dimensional Poisson.
00054 // </etymology>
00055 
00056 // <synopsis> 
00057 // A <src>Poisson</src> is described by lambda.
00058 // The parameters are enumerated by LAMBDA. They have
00059 // default values of 1.
00060 // </synopsis> 
00061 //
00062 // <example>
00063 // <srcblock>
00064 //    PoissonFunction<Double> sf(5.0);
00065 //    sf(25);            // = 5.0
00066 // </srcblock>
00067 // </example>
00068 
00069 // <templating arg=T>
00070 //  <li> T should have standard numerical operators
00071 // </templating>
00072 
00073 // <thrown>
00074 //    <li> AipsError if incorrect parameter number specified.
00075 // </thrown>
00076 //
00077 
00078 template<class T> class PoissonFunction : public PoissonParam<T>
00079 {
00080 public:
00081   //# Constructors
00082   // Constructs the PoissonFunction, Defaults:
00083   // lambda=1.
00084   // <note role=warning> Could not use default arguments
00085   // that worked both with gcc and IRIX </note>
00086   // <group>
00087   PoissonFunction() : PoissonParam<T>() {}
00088   explicit PoissonFunction(const T &lambda) :
00089     PoissonParam<T>(lambda) {}
00090   PoissonFunction( const T& lambda, const T& height ):
00091           PoissonParam<T>(lambda,height){}
00092   // </group>
00093 
00094   // Copy constructor (deep copy)
00095   // <group>
00096   PoissonFunction(const PoissonFunction<T> &other) : PoissonParam<T>(other) {}
00097   template <class W>
00098   PoissonFunction(const PoissonFunction<W> &other) : PoissonParam<T>(other) {}
00099   // </group>
00100 
00101   // Copy assignment (deep copy)
00102   PoissonFunction<T> &operator=(const PoissonFunction<T> &other) {
00103     PoissonParam<T>::operator=(other); return *this; }
00104     
00105   // Destructor
00106   virtual ~PoissonFunction() {}
00107 
00108   //# Operators    
00109   // Evaluate the Poisson at <src>x</src>.
00110   // If a vector is used as the argument only its first element is used.
00111   // <group>
00112   virtual T eval(typename Function<T>::FunctionArg x) const;
00113   // </group>
00114     
00115   //# Member functions
00116   // Return a copy of this object from the heap. The caller is responsible 
00117   // for deleting this pointer. 
00118   // <group>
00119   virtual Function<T> *clone() const { return new PoissonFunction<T>(*this); }
00120   virtual Function<typename FunctionTraits<T>::DiffType> *cloneAD() const {
00121     return new PoissonFunction<typename FunctionTraits<T>::DiffType>(*this); }
00122   virtual Function<typename FunctionTraits<T>::BaseType> *cloneNonAD() const {
00123     return new PoissonFunction<typename FunctionTraits<T>::BaseType>(*this); }
00124   // </group>
00125 
00126   //# Make members of parent classes known.
00127 protected:
00128   using PoissonParam<T>::param_p;
00129 public:
00130   using PoissonParam<T>::nparameters;
00131   using PoissonParam<T>::LAMBDA;
00132   using PoissonParam<T>::HEIGHT;
00133 };
00134 
00135 
00136 
00137 #define PoissonFunction_PS PoissonFunction
00138 
00139 // <summary> Partial specialization of PoissonFunction for <src>AutoDiff</src>
00140 // </summary>
00141 
00142 // <synopsis>
00143 // <note role=warning> The name <src>PoissonFunction_PS</src> is only for cxx2html
00144 // documentation problems. Use <src>PoissonFunction</src> in your code.</note>
00145 // </synopsis>
00146 
00147 template <class T> class PoissonFunction_PS<AutoDiff<T> > :
00148 public PoissonParam<AutoDiff<T> >
00149 {
00150 public:
00151   //# Constructors
00152   // Constructs one dimensional Poisson.
00153   // <group>
00154   PoissonFunction_PS() : PoissonParam<AutoDiff<T> >() {}
00155   explicit PoissonFunction_PS(const AutoDiff<T> &lambda) :
00156     PoissonParam<AutoDiff<T> >(lambda) {}
00157   PoissonFunction_PS( const AutoDiff<T> & lambda, const AutoDiff<T>& height):
00158           PoissonParam<AutoDiff<T> >(lambda,height){}
00159 
00160   // </group>
00161 
00162   // Copy constructor (deep copy)
00163   // <group>
00164   PoissonFunction_PS(const PoissonFunction_PS &other) :
00165     PoissonParam<AutoDiff<T> >(other) {}
00166   template <class W>
00167   PoissonFunction_PS(const PoissonFunction_PS<W> &other) :
00168     PoissonParam<AutoDiff<T> >(other) {}
00169   // </group>
00170 
00171   // Copy assignment (deep copy)
00172   PoissonFunction_PS<AutoDiff<T> > &
00173     operator=(const PoissonFunction_PS<AutoDiff<T> > &other) {
00174     PoissonFunction<AutoDiff<T> >::operator=(other); return *this; }
00175 
00176   // Destructor
00177   virtual ~PoissonFunction_PS() {}
00178 
00179   //# Operators
00180   // Evaluate the Poisson and its derivatives at <src>x</src>.
00181   // <group>
00182   virtual AutoDiff<T> eval(typename Function<AutoDiff<T> >::FunctionArg x) const;
00183   // </group>
00184 
00185   //# Member functions
00186   // Return a copy of this object from the heap. The caller is responsible
00187   // for deleting this pointer.
00188   // <group>
00189   virtual Function<AutoDiff<T> > *clone() const {
00190     return new PoissonFunction<AutoDiff<T> >(*this);
00191   }
00192   virtual Function<typename FunctionTraits<AutoDiff<T> >::DiffType>
00193     *cloneAD() const {
00194     return new PoissonFunction<typename FunctionTraits<AutoDiff<T> >::DiffType>
00195       (*this);
00196   }
00197   virtual Function<typename FunctionTraits<AutoDiff<T> >::BaseType>
00198     *cloneNonAD() const {
00199     return new PoissonFunction<typename FunctionTraits<AutoDiff<T> >::BaseType>
00200       (*this);
00201   }
00202   // </group>
00203 
00204   //# Make members of parent classes known.
00205 protected:
00206   using PoissonParam<AutoDiff<T> >::param_p;
00207 public:
00208   using PoissonParam<AutoDiff<T> >::LAMBDA;
00209   using PoissonParam<AutoDiff<T> >::HEIGHT;
00210 };
00211 
00212 #undef PoissonFunction_PS
00213 
00214 
00215 } //# NAMESPACE CASA - END
00216 
00217 #ifndef CASACORE_NO_AUTO_TEMPLATES
00218 #include <scimath/Functionals/PoissonFunction.tcc>
00219 #include <scimath/Functionals/PoissonFunction2.tcc>
00220 #endif //# CASACORE_NO_AUTO_TEMPLATES
00221 #endif