casacore
Loading...
Searching...
No Matches
OddPolynomial.h
Go to the documentation of this file.
1// # OddPolynomial.h: A one dimensional odd 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_ODDPOLYNOMIAL_H
27#define SCIMATH_ODDPOLYNOMIAL_H
28
29// # Includes
30#include <casacore/casa/aips.h>
31#include <casacore/scimath/Functionals/OddPolynomialParam.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// A OddPolynomial<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// OddPolynomial<Float> pf(3); // Third order polynomial - coeffs 0 by default
62// pf.setCoefficient(0, 1.0);
63// pf[1] = 2.0; // 2x^3 + 1x^1
64// pf(2); // == 18
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 off
80// </todo>
81
82template <class T>
84 public:
85 // # Enumerations
86
87 // # Constructors
88 // Constructs a first 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 ~OddPolynomial() {}
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 OddPolynomial<T>(*this); }
122 // </group>
123
124 // # Make members of parent classes known.
125 protected:
127
128 public:
130};
131
132#define OddPolynomial_PS OddPolynomial
133
134// <summary> Partial specialization of OddPolynomial for <src>AutoDiff</src>
135// </summary>
136
137// <synopsis>
138// <note role=warning> The name <src>OddPolynomial_PS</src> is only for cxx2html
139// documentation problems. Use <src>OddPolynomial</src> in your code.</note>
140// </synopsis>
141
142template <class T>
143class OddPolynomial_PS<AutoDiff<T>> : public OddPolynomialParam<AutoDiff<T>> {
144 public:
145 // # Constructors
146 // Constructs one dimensional OddPolynomials.
147 // <group>
150 // </group>
151
152 // Copy constructor (deep copy)
153 // <group>
155 : OddPolynomialParam<AutoDiff<T>>(other) {}
156 template <class W>
158 // </group>
159 // Copy assignment (deep copy)
161 OddPolynomialParam<AutoDiff<T>>::operator=(other);
162 return *this;
163 }
164
165 // Destructor
166 virtual ~OddPolynomial_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 OddPolynomial<AutoDiff<T>>(*this); }
180 virtual Function<typename FunctionTraits<AutoDiff<T>>::DiffType> *cloneAD() const {
181 return new OddPolynomial<typename FunctionTraits<AutoDiff<T>>::DiffType>(*this);
183 virtual Function<typename FunctionTraits<AutoDiff<T>>::BaseType> *cloneNonAD() const {
184 return new OddPolynomial<typename FunctionTraits<AutoDiff<T>>::BaseType>(*this);
185 }
186 // </group>
187
188 // # Make members of parent classes known.
189 protected:
190 using OddPolynomialParam<AutoDiff<T>>::param_p;
191
192 public:
193 using OddPolynomialParam<AutoDiff<T>>::nparameters;
194};
195
196#undef OddPolynomial_PS
197
198} // namespace casacore
199
200#ifndef CASACORE_NO_AUTO_TEMPLATES
201#include <casacore/scimath/Functionals/OddPolynomial.tcc>
202#include <casacore/scimath/Functionals/OddPolynomial2.tcc>
203#endif // # CASACORE_NO_AUTO_TEMPLATES
204#endif
#define OddPolynomial_PS
const T * FunctionArg
Definition Function1D.h:76
FunctionParam< T > param_p
Definition Function.h:337
uInt order() const
What is the order of the polynomial, i.e.
OddPolynomialParam< T > & operator=(const OddPolynomialParam< T > &other)
OddPolynomialParam()
Constructs a first order polynomial, with a coeficcient of 0.0.
virtual Function< AutoDiff< T > > * clone() const
Return a copy of this object from the heap.
OddPolynomial_PS()
Constructs one dimensional OddPolynomials.
OddPolynomial_PS(const OddPolynomial_PS< W > &other)
OddPolynomial_PS(const OddPolynomial_PS< AutoDiff< T > > &other)
Copy constructor (deep copy).
virtual Function< typename FunctionTraits< AutoDiff< T > >::BaseType > * cloneNonAD() const
virtual Function< typename FunctionTraits< AutoDiff< T > >::DiffType > * cloneAD() const
OddPolynomial_PS< AutoDiff< T > > & operator=(const OddPolynomial_PS< AutoDiff< T > > &other)
Copy assignment (deep copy).
virtual AutoDiff< T > eval(typename Function< AutoDiff< T > >::FunctionArg x) const
Evaluate the polynomial and its derivatives at x wrt to the coefficients.
virtual T eval(typename Function1D< T >::FunctionArg x) const
Evaluate the polynomial at x.
OddPolynomial(uInt order)
Makes a polynomial of the given order, with all coeficcients set to zero.
OddPolynomial(const OddPolynomial< T > &other)
Copy constructor/assignment (deep copy).
virtual ~OddPolynomial()
Destructor.
OddPolynomial< T > & operator=(const OddPolynomial< T > &other)
virtual Function< T > * clone() const
Return a copy of this object from the heap.
OddPolynomial(const OddPolynomial< W > &other)
virtual Function< typename FunctionTraits< T >::BaseType > * cloneNonAD() const
virtual Function< typename FunctionTraits< T >::DiffType > * cloneAD() const
OddPolynomial()
Constructs a first order polynomial, with a coeficcient of 0.0.
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