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> class OddPolynomial: public OddPolynomialParam<T>
83{
84public:
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 OddPolynomialParam<T>(other) {}
97 template <class W>
99 OddPolynomialParam<T>(other) {}
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); }
120 // </group>
121
122 //# Make members of parent classes known.
123protected:
125public:
127};
128
129#define OddPolynomial_PS OddPolynomial
130
131// <summary> Partial specialization of OddPolynomial for <src>AutoDiff</src>
132// </summary>
133
134// <synopsis>
135// <note role=warning> The name <src>OddPolynomial_PS</src> is only for cxx2html
136// documentation problems. Use <src>OddPolynomial</src> in your code.</note>
137// </synopsis>
139template <class T> class OddPolynomial_PS<AutoDiff<T> > :
140public OddPolynomialParam<AutoDiff<T> >
141{
142public:
143 //# Constructors
144 // Constructs one dimensional OddPolynomials.
145 // <group>
148 OddPolynomialParam<AutoDiff<T> >(order) {}
149 // </group>
150
151 // Copy constructor (deep copy)
152 // <group>
154 OddPolynomialParam<AutoDiff<T> >(other) {}
155 template <class W>
156 OddPolynomial_PS(const OddPolynomial_PS<W> &other) :
157 OddPolynomialParam<AutoDiff<T> >(other) {}
158 // </group>
159 // Copy assignment (deep copy)
160 OddPolynomial_PS<AutoDiff<T> > &
161 operator=(const OddPolynomial_PS<AutoDiff<T> > &other) {
162 OddPolynomialParam<AutoDiff<T> >::operator=(other); return *this; }
163
164 // Destructor
165 virtual ~OddPolynomial_PS() {}
166
167 //# Operators
168 // Evaluate the polynomial and its derivatives at <src>x</src> <em>wrt</em>
169 // to the coefficients.
170 // <group>
171 virtual AutoDiff<T> eval(typename Function<AutoDiff<T> >::FunctionArg x) const;
172 // </group>
173
174 //# Member functions
175 // Return a copy of this object from the heap. The caller is responsible
176 // for deleting this pointer.
177 // <group>
178 virtual Function<AutoDiff<T> > *clone() const {
179 return new OddPolynomial<AutoDiff<T> >(*this); }
181 *cloneAD() const {
183 (*this); }
185 *cloneNonAD() const {
187 (*this); }
188 // </group>
189
190 //# Make members of parent classes known.
191protected:
192 using OddPolynomialParam<AutoDiff<T> >::param_p;
193public:
194 using OddPolynomialParam<AutoDiff<T> >::nparameters;
195};
196
197#undef OddPolynomial_PS
198
199
200} //# NAMESPACE CASACORE - END
201
202#ifndef CASACORE_NO_AUTO_TEMPLATES
203#include <casacore/scimath/Functionals/OddPolynomial.tcc>
204#include <casacore/scimath/Functionals/OddPolynomial2.tcc>
205#endif //# CASACORE_NO_AUTO_TEMPLATES
206#endif
#define OddPolynomial_PS
const T * FunctionArg
Definition Function1D.h:76
FunctionParam< T > param_p
The parameters and masks.
Definition Function.h:330
uInt nparameters() const
Returns the number of parameters.
Definition Function.h:228
uInt order() const
What is the order of the polynomial, i.e.
OddPolynomialParam< T > & operator=(const OddPolynomialParam< T > &other)
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.
this file contains all the compiler specific defines
Definition mainpage.dox:28
unsigned int uInt
Definition aipstype.h:49
PtrHolder< T > & operator=(const PtrHolder< T > &other)