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>
78class PoissonFunction : public PoissonParam<T> {
79 public:
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) : PoissonParam<T>(lambda) {}
88 PoissonFunction(const T &lambda, const T &height) : PoissonParam<T>(lambda, height) {}
89 // </group>
90
91 // Copy constructor (deep copy)
92 // <group>
93 PoissonFunction(const PoissonFunction<T> &other) : PoissonParam<T>(other) {}
94 template <class W>
95 PoissonFunction(const PoissonFunction<W> &other) : PoissonParam<T>(other) {}
96 // </group>
97
98 // Copy assignment (deep copy)
101 return *this;
102 }
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); }
125 // </group>
126
127 // # Make members of parent classes known.
128 protected:
129 using PoissonParam<T>::param_p;
130
131 public:
133 using PoissonParam<T>::LAMBDA;
134 using PoissonParam<T>::HEIGHT;
135};
136
137#define PoissonFunction_PS PoissonFunction
138
139// <summary> Partial specialization of PoissonFunction for <src>AutoDiff</src>
140// </summary>
141
142// <synopsis>
143// <note role=warning> The name <src>PoissonFunction_PS</src> is only for cxx2html
144// documentation problems. Use <src>PoissonFunction</src> in your code.</note>
145// </synopsis>
146
147template <class T>
148class PoissonFunction_PS<AutoDiff<T>> : public PoissonParam<AutoDiff<T>> {
149 public:
150 // # Constructors
151 // Constructs one dimensional Poisson.
152 // <group>
155 PoissonFunction_PS(const AutoDiff<T> &lambda, const AutoDiff<T> &height)
156 : PoissonParam<AutoDiff<T>>(lambda, height) {}
157
158 // </group>
159
160 // Copy constructor (deep copy)
161 // <group>
162 PoissonFunction_PS(const PoissonFunction_PS &other) : PoissonParam<AutoDiff<T>>(other) {}
163 template <class W>
165 // </group>
166
167 // Copy assignment (deep copy)
169 PoissonFunction<AutoDiff<T>>::operator=(other);
170 return *this;
171 }
172
173 // Destructor
174 virtual ~PoissonFunction_PS() {}
175
176 // # Operators
177 // Evaluate the Poisson and its derivatives at <src>x</src>.
178 // <group>
179 virtual AutoDiff<T> eval(typename Function<AutoDiff<T>>::FunctionArg x) const;
180 // </group>
181
182 // # Member functions
183 // Return a copy of this object from the heap. The caller is responsible
184 // for deleting this pointer.
185 // <group>
186 virtual Function<AutoDiff<T>> *clone() const { return new PoissonFunction<AutoDiff<T>>(*this); }
187 virtual Function<typename FunctionTraits<AutoDiff<T>>::DiffType> *cloneAD() const {
188 return new PoissonFunction<typename FunctionTraits<AutoDiff<T>>::DiffType>(*this);
190 virtual Function<typename FunctionTraits<AutoDiff<T>>::BaseType> *cloneNonAD() const {
191 return new PoissonFunction<typename FunctionTraits<AutoDiff<T>>::BaseType>(*this);
192 }
193 // </group>
194
195 // # Make members of parent classes known.
196 protected:
197 using PoissonParam<AutoDiff<T>>::param_p;
198
199 public:
200 using PoissonParam<AutoDiff<T>>::LAMBDA;
201 using PoissonParam<AutoDiff<T>>::HEIGHT;
202};
203
204#undef PoissonFunction_PS
205
206} // namespace casacore
207
208#ifndef CASACORE_NO_AUTO_TEMPLATES
209#include <casacore/scimath/Functionals/PoissonFunction.tcc>
210#include <casacore/scimath/Functionals/PoissonFunction2.tcc>
211#endif // # CASACORE_NO_AUTO_TEMPLATES
212#endif
#define PoissonFunction_PS
FunctionParam< T > param_p
The parameters and masks.
Definition Function.h:337
uInt nparameters() const
Returns the number of parameters.
Definition Function.h:226
const ArgType * FunctionArg
Definition Function.h:204
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).
PoissonParam()
Constructs the Poisson, Defaults: lambda=1.
T lambda() const
Get or set lambda.
For temporary backward namespace compatibility, use casa as alias for casacore.
Definition mainpage.dox:28
virtual Function< typename FunctionTraits< T >::DiffType > * cloneAD() const
Definition Polynomial.h:126
virtual Function< typename FunctionTraits< T >::BaseType > * cloneNonAD() const
Definition Polynomial.h:129