casacore
Loading...
Searching...
No Matches
EvenPolynomial.h
Go to the documentation of this file.
1// # EvenPolynomial.h: A one dimensional even polynomial class
2// # Copyright (C) 2002,2005
3// # Associated Universities, Inc. Washington DC, USA.
4// #
5// # This library is free software; you can redistribute it and/or modify it
6// # under the terms of the GNU Library General Public License as published by
7// # the Free Software Foundation; either version 2 of the License, or (at your
8// # option) any later version.
9// #
10// # This library is distributed in the hope that it will be useful, but WITHOUT
11// # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12// # FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public
13// # License for more details.
14// #
15// # You should have received a copy of the GNU Library General Public License
16// # along with this library; if not, write to the Free Software Foundation,
17// # Inc., 675 Massachusetts Ave, Cambridge, MA 02139, USA.
18// #
19// # Correspondence concerning AIPS++ should be addressed as follows:
20// # Internet email: casa-feedback@nrao.edu.
21// # Postal address: AIPS++ Project Office
22// # National Radio Astronomy Observatory
23// # 520 Edgemont Road
24// # Charlottesville, VA 22903-2475 USA
25
26#ifndef SCIMATH_EVENPOLYNOMIAL_H
27#define SCIMATH_EVENPOLYNOMIAL_H
28
29// # Includes
30#include <casacore/casa/aips.h>
31#include <casacore/scimath/Functionals/EvenPolynomialParam.h>
32#include <casacore/scimath/Functionals/Function1D.h>
33#include <casacore/scimath/Mathematics/AutoDiff.h>
34#include <casacore/scimath/Mathematics/AutoDiffMath.h>
35
36namespace casacore { // # NAMESPACE CASACORE - BEGIN
37
38// # Forward declarations
39
40// <summary> A one dimensional odd polynomial class
41// </summary>
42
43// <reviewed reviewer="tcornwel" date="1996/02/22" tests="tSpecialPolynomial"
44// demos="">
45// </reviewed>
46
47// <prerequisite>
48// <li> <linkto class=Function>Function</linkto>
49// </prerequisite>
50//
51// <synopsis>
52// An EvenPolynomial<T> contains a set of coefficients;
53// its fundamental operation is evaluating itself at some "x".
54// The number of coefficients is the order of the polynomial divided by two,
55// plus one, so is the number of available parameters.
56//
57// </synopsis>
58//
59// <example>
60// <srcblock>
61// EvenPolynomial<Float> pf(3); // Second order polynomial - coeffs 0 by default
62// pf.setCoefficient(0, 1.0);
63// pf[1] = 2.0; // 2x^2 + 1x^0
64// pf(2); // == 8
65// </srcblock>
66// </example>
67
68// <templating arg=T>
69// <li> T should have standard numerical operators. Current
70// implementation only tested for real types (and their AutoDiffs).
71// </templating>
72
73// <thrown>
74// <li> Assertion in debug mode if attempt is made to address incorrect
75// coefficients
76// </thrown>
77
78// <todo asof="2002/02/26">
79// <li> Nothing I know of
80// </todo>
81
82template <class T>
84 public:
85 // # Enumerations
86
87 // # Constructors
88 // Constructs a zeroth order polynomial, with a coeficcient of 0.0.
90 // Makes a polynomial of the given order, with all coeficcients set to
91 // zero.
93 // Copy constructor/assignment (deep copy)
94 // <group>
96 template <class W>
100 return *this;
101 }
102 // </group>
103
104 // Destructor
105 virtual ~EvenPolynomial() {}
106
107 // # Operators
108 // Evaluate the polynomial at <src>x</src>.
109 virtual T eval(typename Function1D<T>::FunctionArg x) const;
110
111 // # Member functions
112 // Return a copy of this object from the heap. The caller is responsible for
113 // deleting the pointer.
114 // <group>
115 virtual Function<T> *clone() const { return new EvenPolynomial<T>(*this); }
122 // </group>
123
124 // # Make members of parent classes known.
125 protected:
127
128 public:
130};
131
132#define EvenPolynomial_PS EvenPolynomial
133
134// <summary> Partial specialization of EvenPolynomial for <src>AutoDiff</src>
135// </summary>
136
137// <synopsis>
138// <note role=warning> The name <src>EvenPolynomial_PS</src> is only for cxx2html
139// documentation problems. Use <src>EvenPolynomial</src> in your code.</note>
140// </synopsis>
141
142template <class T>
143class EvenPolynomial_PS<AutoDiff<T>> : public EvenPolynomialParam<AutoDiff<T>> {
144 public:
145 // # Constructors
146 // Constructs one dimensional EvenPolynomials.
147 // <group>
150 // </group>
151
152 // Copy constructor (deep copy)
153 // <group>
155 : EvenPolynomialParam<AutoDiff<T>>(other) {}
156 template <class W>
158 // </group>
159 // Copy assignment (deep copy)
161 EvenPolynomialParam<AutoDiff<T>>::operator=(other);
162 return *this;
163 }
164
165 // Destructor
166 virtual ~EvenPolynomial_PS() {}
167
168 // # Operators
169 // Evaluate the polynomial and its derivatives at <src>x</src> <em>wrt</em>
170 // to the coefficients.
171 // <group>
172 virtual AutoDiff<T> eval(typename Function<AutoDiff<T>>::FunctionArg x) const;
173 // </group>
174
175 // # Member functions
176 // Return a copy of this object from the heap. The caller is responsible
177 // for deleting this pointer.
178 // <group>
179 virtual Function<AutoDiff<T>> *clone() const { return new EvenPolynomial<AutoDiff<T>>(*this); }
180 virtual Function<typename FunctionTraits<AutoDiff<T>>::DiffType> *cloneAD() const {
181 return new EvenPolynomial<typename FunctionTraits<AutoDiff<T>>::DiffType>(*this);
183 virtual Function<typename FunctionTraits<AutoDiff<T>>::BaseType> *cloneNonAD() const {
184 return new EvenPolynomial<typename FunctionTraits<AutoDiff<T>>::BaseType>(*this);
185 }
186 // </group>
187
188 // # Make members of parent classes known.
189 protected:
190 using EvenPolynomialParam<AutoDiff<T>>::param_p;
191
192 public:
193 using EvenPolynomialParam<AutoDiff<T>>::nparameters;
194};
195
196#undef EvenPolynomial_PS
197
198} // namespace casacore
199
200#ifndef CASACORE_NO_AUTO_TEMPLATES
201#include <casacore/scimath/Functionals/EvenPolynomial.tcc>
202#include <casacore/scimath/Functionals/EvenPolynomial2.tcc>
203#endif // # CASACORE_NO_AUTO_TEMPLATES
204#endif
#define EvenPolynomial_PS
EvenPolynomialParam()
Constructs a zero'th order polynomial, with a coeficcient of 0.0.
uInt order() const
What is the order of the polynomial, i.e.
EvenPolynomialParam< T > & operator=(const EvenPolynomialParam< T > &other)
virtual Function< typename FunctionTraits< AutoDiff< T > >::BaseType > * cloneNonAD() const
EvenPolynomial_PS(const EvenPolynomial_PS< AutoDiff< T > > &other)
Copy constructor (deep copy).
EvenPolynomial_PS()
Constructs one dimensional EvenPolynomials.
virtual Function< AutoDiff< T > > * clone() const
Return a copy of this object from the heap.
EvenPolynomial_PS< AutoDiff< T > > & operator=(const EvenPolynomial_PS< AutoDiff< T > > &other)
Copy assignment (deep copy).
virtual Function< typename FunctionTraits< AutoDiff< T > >::DiffType > * cloneAD() const
EvenPolynomial_PS(const EvenPolynomial_PS< W > &other)
virtual AutoDiff< T > eval(typename Function< AutoDiff< T > >::FunctionArg x) const
Evaluate the polynomial and its derivatives at x wrt to the coefficients.
EvenPolynomial< T > & operator=(const EvenPolynomial< T > &other)
virtual T eval(typename Function1D< T >::FunctionArg x) const
Evaluate the polynomial at x.
EvenPolynomial()
Constructs a zeroth order polynomial, with a coeficcient of 0.0.
virtual ~EvenPolynomial()
Destructor.
EvenPolynomial(const EvenPolynomial< W > &other)
virtual Function< typename FunctionTraits< T >::DiffType > * cloneAD() const
EvenPolynomial(const EvenPolynomial< T > &other)
Copy constructor/assignment (deep copy).
virtual Function< typename FunctionTraits< T >::BaseType > * cloneNonAD() const
virtual Function< T > * clone() const
Return a copy of this object from the heap.
EvenPolynomial(uInt order)
Makes a polynomial of the given order, with all coeficcients set to zero.
const T * FunctionArg
Definition Function1D.h:76
FunctionParam< T > param_p
Definition Function.h:337
For temporary backward namespace compatibility, use casa as alias for casacore.
Definition mainpage.dox:28
unsigned int uInt
Definition aipstype.h:49
virtual Function< typename FunctionTraits< T >::DiffType > * cloneAD() const
Definition Polynomial.h:126
uInt order() const
What is the order of the polynomial, i.e.
virtual Function< typename FunctionTraits< T >::BaseType > * cloneNonAD() const
Definition Polynomial.h:129