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 //# $Id: Array.h 21545 2015-01-22 19:36:35Z gervandiepen $ 00026 00027 #ifndef SCIMATH_POISSONFUNCTION_H 00028 #define SCIMATH_POISSONFUNCTION_H 00029 00030 //# Includes 00031 #include <casacore/casa/aips.h> 00032 #include <casacore/scimath/Functionals/PoissonParam.h> 00033 #include <casacore/scimath/Functionals/Function.h> 00034 00035 namespace casacore { //# NAMESPACE CASACORE - BEGIN 00036 00037 //# Forward declarations 00038 00039 // <summary> A one dimensional Poisson function 00040 // </summary> 00041 00042 // <use visibility=export> 00043 00044 // <reviewed reviewer="" date="" tests="tFunctionHolder" 00045 // demos=""> 00046 // </reviewed> 00047 00048 // <prerequisite> 00049 // <li> <linkto class="PoissonParam">PoissonParam</linkto> 00050 // <li> <linkto class="Function">Function</linkto> 00051 // </prerequisite> 00052 00053 // <etymology> 00054 // A 1-dimensional Poisson. 00055 // </etymology> 00056 00057 // <synopsis> 00058 // A <src>Poisson</src> is described by lambda. 00059 // The parameters are enumerated by LAMBDA. They have 00060 // default values of 1. 00061 // </synopsis> 00062 // 00063 // <example> 00064 // <srcblock> 00065 // PoissonFunction<Double> sf(5.0); 00066 // sf(25); // = 5.0 00067 // </srcblock> 00068 // </example> 00069 00070 // <templating arg=T> 00071 // <li> T should have standard numerical operators 00072 // </templating> 00073 00074 // <thrown> 00075 // <li> AipsError if incorrect parameter number specified. 00076 // </thrown> 00077 // 00078 00079 template<class T> class PoissonFunction : public PoissonParam<T> 00080 { 00081 public: 00082 //# Constructors 00083 // Constructs the PoissonFunction, Defaults: 00084 // lambda=1. 00085 // <note role=warning> Could not use default arguments 00086 // that worked both with gcc and IRIX </note> 00087 // <group> 00088 PoissonFunction() : PoissonParam<T>() {} 00089 explicit PoissonFunction(const T &lambda) : 00090 PoissonParam<T>(lambda) {} 00091 PoissonFunction( const T& lambda, const T& height ): 00092 PoissonParam<T>(lambda,height){} 00093 // </group> 00094 00095 // Copy constructor (deep copy) 00096 // <group> 00097 PoissonFunction(const PoissonFunction<T> &other) : PoissonParam<T>(other) {} 00098 template <class W> 00099 PoissonFunction(const PoissonFunction<W> &other) : PoissonParam<T>(other) {} 00100 // </group> 00101 00102 // Copy assignment (deep copy) 00103 PoissonFunction<T> &operator=(const PoissonFunction<T> &other) { 00104 PoissonParam<T>::operator=(other); return *this; } 00105 00106 // Destructor 00107 virtual ~PoissonFunction() {} 00108 00109 //# Operators 00110 // Evaluate the Poisson at <src>x</src>. 00111 // If a vector is used as the argument only its first element is used. 00112 // <group> 00113 virtual T eval(typename Function<T>::FunctionArg x) const; 00114 // </group> 00115 00116 //# Member functions 00117 // Return a copy of this object from the heap. The caller is responsible 00118 // for deleting this pointer. 00119 // <group> 00120 virtual Function<T> *clone() const { return new PoissonFunction<T>(*this); } 00121 virtual Function<typename FunctionTraits<T>::DiffType> *cloneAD() const { 00122 return new PoissonFunction<typename FunctionTraits<T>::DiffType>(*this); } 00123 virtual Function<typename FunctionTraits<T>::BaseType> *cloneNonAD() const { 00124 return new PoissonFunction<typename FunctionTraits<T>::BaseType>(*this); } 00125 // </group> 00126 00127 //# Make members of parent classes known. 00128 protected: 00129 using PoissonParam<T>::param_p; 00130 public: 00131 using PoissonParam<T>::nparameters; 00132 using PoissonParam<T>::LAMBDA; 00133 using PoissonParam<T>::HEIGHT; 00134 }; 00135 00136 00137 00138 #define PoissonFunction_PS PoissonFunction 00139 00140 // <summary> Partial specialization of PoissonFunction for <src>AutoDiff</src> 00141 // </summary> 00142 00143 // <synopsis> 00144 // <note role=warning> The name <src>PoissonFunction_PS</src> is only for cxx2html 00145 // documentation problems. Use <src>PoissonFunction</src> in your code.</note> 00146 // </synopsis> 00147 00148 template <class T> class PoissonFunction_PS<AutoDiff<T> > : 00149 public PoissonParam<AutoDiff<T> > 00150 { 00151 public: 00152 //# Constructors 00153 // Constructs one dimensional Poisson. 00154 // <group> 00155 PoissonFunction_PS() : PoissonParam<AutoDiff<T> >() {} 00156 explicit PoissonFunction_PS(const AutoDiff<T> &lambda) : 00157 PoissonParam<AutoDiff<T> >(lambda) {} 00158 PoissonFunction_PS( const AutoDiff<T> & lambda, const AutoDiff<T>& height): 00159 PoissonParam<AutoDiff<T> >(lambda,height){} 00160 00161 // </group> 00162 00163 // Copy constructor (deep copy) 00164 // <group> 00165 PoissonFunction_PS(const PoissonFunction_PS &other) : 00166 PoissonParam<AutoDiff<T> >(other) {} 00167 template <class W> 00168 PoissonFunction_PS(const PoissonFunction_PS<W> &other) : 00169 PoissonParam<AutoDiff<T> >(other) {} 00170 // </group> 00171 00172 // Copy assignment (deep copy) 00173 PoissonFunction_PS<AutoDiff<T> > & 00174 operator=(const PoissonFunction_PS<AutoDiff<T> > &other) { 00175 PoissonFunction<AutoDiff<T> >::operator=(other); return *this; } 00176 00177 // Destructor 00178 virtual ~PoissonFunction_PS() {} 00179 00180 //# Operators 00181 // Evaluate the Poisson and its derivatives at <src>x</src>. 00182 // <group> 00183 virtual AutoDiff<T> eval(typename Function<AutoDiff<T> >::FunctionArg x) const; 00184 // </group> 00185 00186 //# Member functions 00187 // Return a copy of this object from the heap. The caller is responsible 00188 // for deleting this pointer. 00189 // <group> 00190 virtual Function<AutoDiff<T> > *clone() const { 00191 return new PoissonFunction<AutoDiff<T> >(*this); 00192 } 00193 virtual Function<typename FunctionTraits<AutoDiff<T> >::DiffType> 00194 *cloneAD() const { 00195 return new PoissonFunction<typename FunctionTraits<AutoDiff<T> >::DiffType> 00196 (*this); 00197 } 00198 virtual Function<typename FunctionTraits<AutoDiff<T> >::BaseType> 00199 *cloneNonAD() const { 00200 return new PoissonFunction<typename FunctionTraits<AutoDiff<T> >::BaseType> 00201 (*this); 00202 } 00203 // </group> 00204 00205 //# Make members of parent classes known. 00206 protected: 00207 using PoissonParam<AutoDiff<T> >::param_p; 00208 public: 00209 using PoissonParam<AutoDiff<T> >::LAMBDA; 00210 using PoissonParam<AutoDiff<T> >::HEIGHT; 00211 }; 00212 00213 #undef PoissonFunction_PS 00214 00215 00216 } //# NAMESPACE CASACORE - END 00217 00218 #ifndef CASACORE_NO_AUTO_TEMPLATES 00219 #include <casacore/scimath/Functionals/PoissonFunction.tcc> 00220 #include <casacore/scimath/Functionals/PoissonFunction2.tcc> 00221 #endif //# CASACORE_NO_AUTO_TEMPLATES 00222 #endif