casacore
Loading...
Searching...
No Matches
PoissonFunction.h
Go to the documentation of this file.
1//# Copyright (C) 2002,2005
2//# Associated Universities, Inc. Washington DC, USA.
3//#
4//# This library is free software; you can redistribute it and/or modify it
5//# under the terms of the GNU Library General Public License as published by
6//# the Free Software Foundation; either version 2 of the License, or (at your
7//# option) any later version.
8//#
9//# This library is distributed in the hope that it will be useful, but WITHOUT
10//# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11//# FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public
12//# License for more details.
13//#
14//# You should have received a copy of the GNU Library General Public License
15//# along with this library; if not, write to the Free Software Foundation,
16//# Inc., 675 Massachusetts Ave, Cambridge, MA 02139, USA.
17//#
18//# Correspondence concerning AIPS++ should be addressed as follows:
19//# Internet email: casa-feedback@nrao.edu.
20//# Postal address: AIPS++ Project Office
21//# National Radio Astronomy Observatory
22//# 520 Edgemont Road
23//# Charlottesville, VA 22903-2475 USA
24
25#ifndef SCIMATH_POISSONFUNCTION_H
26#define SCIMATH_POISSONFUNCTION_H
27
28//# Includes
29#include <casacore/casa/aips.h>
30#include <casacore/scimath/Functionals/PoissonParam.h>
31#include <casacore/scimath/Functionals/Function.h>
32
33namespace casacore { //# NAMESPACE CASACORE - BEGIN
34
35//# Forward declarations
36
37// <summary> A one dimensional Poisson function
38// </summary>
39
40// <use visibility=export>
41
42// <reviewed reviewer="" date="" tests="tFunctionHolder"
43// demos="">
44// </reviewed>
45
46// <prerequisite>
47// <li> <linkto class="PoissonParam">PoissonParam</linkto>
48// <li> <linkto class="Function">Function</linkto>
49// </prerequisite>
50
51// <etymology>
52// A 1-dimensional Poisson.
53// </etymology>
54
55// <synopsis>
56// A <src>Poisson</src> is described by lambda.
57// The parameters are enumerated by LAMBDA. They have
58// default values of 1.
59// </synopsis>
60//
61// <example>
62// <srcblock>
63// PoissonFunction<Double> sf(5.0);
64// sf(25); // = 5.0
65// </srcblock>
66// </example>
67
68// <templating arg=T>
69// <li> T should have standard numerical operators
70// </templating>
71
72// <thrown>
73// <li> AipsError if incorrect parameter number specified.
74// </thrown>
75//
76
77template<class T> class PoissonFunction : public PoissonParam<T>
78{
79public:
80 //# Constructors
81 // Constructs the PoissonFunction, Defaults:
82 // lambda=1.
83 // <note role=warning> Could not use default arguments
84 // that worked both with gcc and IRIX </note>
85 // <group>
87 explicit PoissonFunction(const T &lambda) :
88 PoissonParam<T>(lambda) {}
89 PoissonFunction( const T& lambda, const T& height ):
91 // </group>
92
93 // Copy constructor (deep copy)
94 // <group>
95 PoissonFunction(const PoissonFunction<T> &other) : PoissonParam<T>(other) {}
96 template <class W>
97 PoissonFunction(const PoissonFunction<W> &other) : PoissonParam<T>(other) {}
98 // </group>
99
100 // Copy assignment (deep copy)
102 PoissonParam<T>::operator=(other); return *this; }
103
104 // Destructor
105 virtual ~PoissonFunction() {}
106
107 //# Operators
108 // Evaluate the Poisson at <src>x</src>.
109 // If a vector is used as the argument only its first element is used.
110 // <group>
111 virtual T eval(typename Function<T>::FunctionArg x) const;
112 // </group>
113
114 //# Member functions
115 // Return a copy of this object from the heap. The caller is responsible
116 // for deleting this pointer.
117 // <group>
118 virtual Function<T> *clone() const { return new PoissonFunction<T>(*this); }
123 // </group>
124
125 //# Make members of parent classes known.
126protected:
127 using PoissonParam<T>::param_p;
128public:
130 using PoissonParam<T>::LAMBDA;
131 using PoissonParam<T>::HEIGHT;
132};
133
134
135
136#define PoissonFunction_PS PoissonFunction
137
138// <summary> Partial specialization of PoissonFunction for <src>AutoDiff</src>
139// </summary>
140
141// <synopsis>
142// <note role=warning> The name <src>PoissonFunction_PS</src> is only for cxx2html
143// documentation problems. Use <src>PoissonFunction</src> in your code.</note>
144// </synopsis>
146template <class T> class PoissonFunction_PS<AutoDiff<T> > :
147public PoissonParam<AutoDiff<T> >
148{
149public:
150 //# Constructors
151 // Constructs one dimensional Poisson.
152 // <group>
154 explicit PoissonFunction_PS(const AutoDiff<T> &lambda) :
155 PoissonParam<AutoDiff<T> >(lambda) {}
156 PoissonFunction_PS( const AutoDiff<T> & lambda, const AutoDiff<T>& height):
157 PoissonParam<AutoDiff<T> >(lambda,height){}
158
159 // </group>
160
161 // Copy constructor (deep copy)
162 // <group>
164 PoissonParam<AutoDiff<T> >(other) {}
165 template <class W>
166 PoissonFunction_PS(const PoissonFunction_PS<W> &other) :
167 PoissonParam<AutoDiff<T> >(other) {}
168 // </group>
169
170 // Copy assignment (deep copy)
171 PoissonFunction_PS<AutoDiff<T> > &
173 PoissonFunction<AutoDiff<T> >::operator=(other); return *this; }
174
175 // Destructor
176 virtual ~PoissonFunction_PS() {}
177
178 //# Operators
179 // Evaluate the Poisson and its derivatives at <src>x</src>.
180 // <group>
181 virtual AutoDiff<T> eval(typename Function<AutoDiff<T> >::FunctionArg x) const;
182 // </group>
183
184 //# Member functions
185 // Return a copy of this object from the heap. The caller is responsible
186 // for deleting this pointer.
187 // <group>
188 virtual Function<AutoDiff<T> > *clone() const {
189 return new PoissonFunction<AutoDiff<T> >(*this);
190 }
192 *cloneAD() const {
194 (*this);
195 }
197 *cloneNonAD() const {
199 (*this);
200 }
201 // </group>
202
203 //# Make members of parent classes known.
204protected:
205 using PoissonParam<AutoDiff<T> >::param_p;
206public:
207 using PoissonParam<AutoDiff<T> >::LAMBDA;
208 using PoissonParam<AutoDiff<T> >::HEIGHT;
209};
210
211#undef PoissonFunction_PS
212
213
214} //# NAMESPACE CASACORE - END
215
216#ifndef CASACORE_NO_AUTO_TEMPLATES
217#include <casacore/scimath/Functionals/PoissonFunction.tcc>
218#include <casacore/scimath/Functionals/PoissonFunction2.tcc>
219#endif //# CASACORE_NO_AUTO_TEMPLATES
220#endif
#define PoissonFunction_PS
FunctionParam< T > param_p
The parameters and masks.
Definition Function.h:330
uInt nparameters() const
Returns the number of parameters.
Definition Function.h:228
virtual Function< typename FunctionTraits< AutoDiff< T > >::BaseType > * cloneNonAD() const
PoissonFunction_PS(const AutoDiff< T > &lambda)
PoissonFunction_PS< AutoDiff< T > > & operator=(const PoissonFunction_PS< AutoDiff< T > > &other)
Copy assignment (deep copy)
PoissonFunction_PS(const PoissonFunction_PS< W > &other)
PoissonFunction_PS()
Constructs one dimensional Poisson.
PoissonFunction_PS(const AutoDiff< T > &lambda, const AutoDiff< T > &height)
PoissonFunction_PS(const PoissonFunction_PS &other)
Copy constructor (deep copy)
virtual Function< typename FunctionTraits< AutoDiff< T > >::DiffType > * cloneAD() const
virtual Function< AutoDiff< T > > * clone() const
Return a copy of this object from the heap.
virtual AutoDiff< T > eval(typename Function< AutoDiff< T > >::FunctionArg x) const
Evaluate the Poisson and its derivatives at x.
PoissonFunction< T > & operator=(const PoissonFunction< T > &other)
Copy assignment (deep copy)
PoissonFunction()
Constructs the PoissonFunction, Defaults: lambda=1.
virtual Function< typename FunctionTraits< T >::DiffType > * cloneAD() const
PoissonFunction(const PoissonFunction< T > &other)
Copy constructor (deep copy)
PoissonFunction(const PoissonFunction< W > &other)
virtual Function< typename FunctionTraits< T >::BaseType > * cloneNonAD() const
PoissonFunction(const T &lambda)
virtual T eval(typename Function< T >::FunctionArg x) const
Evaluate the Poisson at x.
virtual ~PoissonFunction()
Destructor.
virtual Function< T > * clone() const
Return a copy of this object from the heap.
PoissonFunction(const T &lambda, const T &height)
PoissonParam< T > & operator=(const PoissonParam< T > &other)
Copy assignment (deep copy)
T lambda() const
Get or set lambda.
this file contains all the compiler specific defines
Definition mainpage.dox:28
PtrHolder< T > & operator=(const PtrHolder< T > &other)