casa  5.7.0-16
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
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: aips2-request@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 //# $Id: Array.h 21545 2015-01-22 19:36:35Z gervandiepen $
26 
27 #ifndef SCIMATH_POISSONFUNCTION_H
28 #define SCIMATH_POISSONFUNCTION_H
29 
30 //# Includes
31 #include <casacore/casa/aips.h>
34 
35 namespace casacore { //# NAMESPACE CASACORE - BEGIN
36 
37 //# Forward declarations
38 
39 // <summary> A one dimensional Poisson function
40 // </summary>
41 
42 // <use visibility=export>
43 
44 // <reviewed reviewer="" date="" tests="tFunctionHolder"
45 // demos="">
46 // </reviewed>
47 
48 // <prerequisite>
49 // <li> <linkto class="PoissonParam">PoissonParam</linkto>
50 // <li> <linkto class="Function">Function</linkto>
51 // </prerequisite>
52 
53 // <etymology>
54 // A 1-dimensional Poisson.
55 // </etymology>
56 
57 // <synopsis>
58 // A <src>Poisson</src> is described by lambda.
59 // The parameters are enumerated by LAMBDA. They have
60 // default values of 1.
61 // </synopsis>
62 //
63 // <example>
64 // <srcblock>
65 // PoissonFunction<Double> sf(5.0);
66 // sf(25); // = 5.0
67 // </srcblock>
68 // </example>
69 
70 // <templating arg=T>
71 // <li> T should have standard numerical operators
72 // </templating>
73 
74 // <thrown>
75 // <li> AipsError if incorrect parameter number specified.
76 // </thrown>
77 //
78 
79 template<class T> class PoissonFunction : public PoissonParam<T>
80 {
81 public:
82  //# Constructors
83  // Constructs the PoissonFunction, Defaults:
84  // lambda=1.
85  // <note role=warning> Could not use default arguments
86  // that worked both with gcc and IRIX </note>
87  // <group>
89  explicit PoissonFunction(const T &lambda) :
90  PoissonParam<T>(lambda) {}
91  PoissonFunction( const T& lambda, const T& height ):
92  PoissonParam<T>(lambda,height){}
93  // </group>
94 
95  // Copy constructor (deep copy)
96  // <group>
97  PoissonFunction(const PoissonFunction<T> &other) : PoissonParam<T>(other) {}
98  template <class W>
99  PoissonFunction(const PoissonFunction<W> &other) : PoissonParam<T>(other) {}
100  // </group>
101 
102  // Copy assignment (deep copy)
104  PoissonParam<T>::operator=(other); return *this; }
105 
106  // Destructor
107  virtual ~PoissonFunction() {}
108 
109  //# Operators
110  // Evaluate the Poisson at <src>x</src>.
111  // If a vector is used as the argument only its first element is used.
112  // <group>
113  virtual T eval(typename Function<T>::FunctionArg x) const;
114  // </group>
115 
116  //# Member functions
117  // Return a copy of this object from the heap. The caller is responsible
118  // for deleting this pointer.
119  // <group>
120  virtual Function<T> *clone() const { return new PoissonFunction<T>(*this); }
125  // </group>
126 
127  //# Make members of parent classes known.
128 protected:
130 public:
134 };
135 
136 
137 
138 #define PoissonFunction_PS PoissonFunction
139 
140 // <summary> Partial specialization of PoissonFunction for <src>AutoDiff</src>
141 // </summary>
142 
143 // <synopsis>
144 // <note role=warning> The name <src>PoissonFunction_PS</src> is only for cxx2html
145 // documentation problems. Use <src>PoissonFunction</src> in your code.</note>
146 // </synopsis>
148 template <class T> class PoissonFunction_PS<AutoDiff<T> > :
149 public PoissonParam<AutoDiff<T> >
150 {
151 public:
152  //# Constructors
153  // Constructs one dimensional Poisson.
154  // <group>
156  explicit PoissonFunction_PS(const AutoDiff<T> &lambda) :
157  PoissonParam<AutoDiff<T> >(lambda) {}
158  PoissonFunction_PS( const AutoDiff<T> & lambda, const AutoDiff<T>& height):
159  PoissonParam<AutoDiff<T> >(lambda,height){}
160 
161  // </group>
162 
163  // Copy constructor (deep copy)
164  // <group>
165  PoissonFunction_PS(const PoissonFunction_PS &other) :
166  PoissonParam<AutoDiff<T> >(other) {}
167  template <class W>
168  PoissonFunction_PS(const PoissonFunction_PS<W> &other) :
169  PoissonParam<AutoDiff<T> >(other) {}
170  // </group>
171 
172  // Copy assignment (deep copy)
173  PoissonFunction_PS<AutoDiff<T> > &
174  operator=(const PoissonFunction_PS<AutoDiff<T> > &other) {
175  PoissonFunction<AutoDiff<T> >::operator=(other); return *this; }
176 
177  // Destructor
178  virtual ~PoissonFunction_PS() {}
179 
180  //# Operators
181  // Evaluate the Poisson and its derivatives at <src>x</src>.
182  // <group>
183  virtual AutoDiff<T> eval(typename Function<AutoDiff<T> >::FunctionArg x) const;
184  // </group>
185 
186  //# Member functions
187  // Return a copy of this object from the heap. The caller is responsible
188  // for deleting this pointer.
189  // <group>
190  virtual Function<AutoDiff<T> > *clone() const {
191  return new PoissonFunction<AutoDiff<T> >(*this);
192  }
194  *cloneAD() const {
196  (*this);
197  }
199  *cloneNonAD() const {
201  (*this);
202  }
203  // </group>
204 
205  //# Make members of parent classes known.
206 protected:
207  using PoissonParam<AutoDiff<T> >::param_p;
208 public:
209  using PoissonParam<AutoDiff<T> >::LAMBDA;
210  using PoissonParam<AutoDiff<T> >::HEIGHT;
211 };
212 
213 #undef PoissonFunction_PS
214 
215 
216 } //# NAMESPACE CASACORE - END
217 
218 #ifndef CASACORE_NO_AUTO_TEMPLATES
219 #include <casacore/scimath/Functionals/PoissonFunction.tcc>
220 #include <casacore/scimath/Functionals/PoissonFunction2.tcc>
221 #endif //# CASACORE_NO_AUTO_TEMPLATES
222 #endif
virtual T eval(typename Function< T >::FunctionArg x) const
Evaluate the Poisson at x.
A one dimensional Poisson function.
Definition: PoissonParam.h:83
PoissonFunction(const PoissonFunction< W > &other)
T lambda() const
Get or set lambda.
Definition: PoissonParam.h:126
PoissonFunction(const PoissonFunction< T > &other)
Copy constructor (deep copy)
PoissonFunction(const T &lambda, const T &height)
A one dimensional Poisson function.
PtrHolder< T > & operator=(const PtrHolder< T > &other)
virtual Function< T > * clone() const
Return a copy of this object from the heap.
PoissonParam< T > & operator=(const PoissonParam< T > &other)
Copy assignment (deep copy)
PoissonFunction()
Constructs the PoissonFunction, Defaults: lambda=1.
PoissonFunction(const T &lambda)
#define PoissonFunction_PS
Numerical functional interface class.
Class that computes partial derivatives by automatic differentiation.
Definition: AutoDiff.h:257
casacore::Bool clone(const casacore::String &imageName, const casacore::String &newImageName)
virtual ~PoissonFunction()
Destructor.
PoissonFunction_PS(const AutoDiff< T > &lambda)
PoissonFunction< T > & operator=(const PoissonFunction< T > &other)
Copy assignment (deep copy)
virtual Function< typename FunctionTraits< T >::DiffType > * cloneAD() const
virtual Function< typename FunctionTraits< T >::BaseType > * cloneNonAD() const
#define casacore
&lt;X11/Intrinsic.h&gt; #defines true, false, casacore::Bool, and String.
Definition: X11Intrinsic.h:42