casacore
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
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: aips2-request@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 //# $Id$
27 
28 #ifndef SCIMATH_EVENPOLYNOMIAL_H
29 #define SCIMATH_EVENPOLYNOMIAL_H
30 
31 //# Includes
32 #include <casacore/casa/aips.h>
37 
38 namespace casacore { //# NAMESPACE CASACORE - BEGIN
39 
40 //# Forward declarations
41 
42 // <summary> A one dimensional odd polynomial class
43 // </summary>
44 
45 // <reviewed reviewer="tcornwel" date="1996/02/22" tests="tSpecialPolynomial"
46 // demos="">
47 // </reviewed>
48 
49 // <prerequisite>
50 // <li> <linkto class=Function>Function</linkto>
51 // </prerequisite>
52 //
53 // <synopsis>
54 // An EvenPolynomial<T> contains a set of coefficients;
55 // its fundamental operation is evaluating itself at some "x".
56 // The number of coefficients is the order of the polynomial divided by two,
57 // plus one, so is the number of available parameters.
58 //
59 // </synopsis>
60 //
61 // <example>
62 // <srcblock>
63 // EvenPolynomial<Float> pf(3); // Second order polynomial - coeffs 0 by default
64 // pf.setCoefficient(0, 1.0);
65 // pf[1] = 2.0; // 2x^2 + 1x^0
66 // pf(2); // == 8
67 // </srcblock>
68 // </example>
69 
70 // <templating arg=T>
71 // <li> T should have standard numerical operators. Current
72 // implementation only tested for real types (and their AutoDiffs).
73 // </templating>
74 
75 // <thrown>
76 // <li> Assertion in debug mode if attempt is made to address incorrect
77 // coefficients
78 // </thrown>
79 
80 // <todo asof="2002/02/26">
81 // <li> Nothing I know of
82 // </todo>
83 
84 template<class T> class EvenPolynomial: public EvenPolynomialParam<T>
85 {
86 public:
87  //# Enumerations
88 
89  //# Constructors
90  // Constructs a zeroth order polynomial, with a coeficcient of 0.0.
92  // Makes a polynomial of the given order, with all coeficcients set to
93  // zero.
94  explicit EvenPolynomial(uInt order) : EvenPolynomialParam<T>(order) {}
95  // Copy constructor/assignment (deep copy)
96  // <group>
98  EvenPolynomialParam<T>(other) {}
99  template <class W>
101  EvenPolynomialParam<T>(other) {}
103  EvenPolynomialParam<T>::operator=(other); return *this; }
104  // </group>
105 
106  // Destructor
107  virtual ~EvenPolynomial() {}
108 
109  //# Operators
110  // Evaluate the polynomial at <src>x</src>.
111  virtual T eval(typename Function1D<T>::FunctionArg x) const;
112 
113  //# Member functions
114  // Return a copy of this object from the heap. The caller is responsible for
115  // deleting the pointer.
116  // <group>
117  virtual Function<T> *clone() const { return new EvenPolynomial<T>(*this); }
122  // </group>
123 
124  //# Make members of parent classes known.
125 protected:
127 public:
129 };
130 
131 #define EvenPolynomial_PS EvenPolynomial
132 
133 // <summary> Partial specialization of EvenPolynomial for <src>AutoDiff</src>
134 // </summary>
135 
136 // <synopsis>
137 // <note role=warning> The name <src>EvenPolynomial_PS</src> is only for cxx2html
138 // documentation problems. Use <src>EvenPolynomial</src> in your code.</note>
139 // </synopsis>
141 template <class T> class EvenPolynomial_PS<AutoDiff<T> > :
142 public EvenPolynomialParam<AutoDiff<T> >
143 {
144 public:
145  //# Constructors
146  // Constructs one dimensional EvenPolynomials.
147  // <group>
149  explicit EvenPolynomial_PS(uInt order) :
150  EvenPolynomialParam<AutoDiff<T> >(order) {}
151  // </group>
152 
153  // Copy constructor (deep copy)
154  // <group>
156  EvenPolynomialParam<AutoDiff<T> >(other) {}
157  template <class W>
158  EvenPolynomial_PS(const EvenPolynomial_PS<W> &other) :
159  EvenPolynomialParam<AutoDiff<T> >(other) {}
160  // </group>
161  // Copy assignment (deep copy)
162  EvenPolynomial_PS<AutoDiff<T> > &
163  operator=(const EvenPolynomial_PS<AutoDiff<T> > &other) {
164  EvenPolynomialParam<AutoDiff<T> >::operator=(other); return *this; }
165 
166  // Destructor
167  virtual ~EvenPolynomial_PS() {}
168 
169  //# Operators
170  // Evaluate the polynomial and its derivatives at <src>x</src> <em>wrt</em>
171  // to the coefficients.
172  // <group>
173  virtual AutoDiff<T> eval(typename Function<AutoDiff<T> >::FunctionArg x) const;
174  // </group>
175 
176  //# Member functions
177  // Return a copy of this object from the heap. The caller is responsible
178  // for deleting this pointer.
179  // <group>
180  virtual Function<AutoDiff<T> > *clone() const {
181  return new EvenPolynomial<AutoDiff<T> >(*this); }
183  *cloneAD() const {
185  (*this); }
187  *cloneNonAD() const {
189  (*this); }
190  // </group>
191 
192  //# Make members of parent classes known.
193 protected:
194  using EvenPolynomialParam<AutoDiff<T> >::param_p;
195 public:
196  using EvenPolynomialParam<AutoDiff<T> >::nparameters;
197 };
198 
199 #undef EvenPolynomial_PS
200 
201 
202 } //# NAMESPACE CASACORE - END
203 
204 #ifndef CASACORE_NO_AUTO_TEMPLATES
205 #include <casacore/scimath/Functionals/EvenPolynomial.tcc>
206 #include <casacore/scimath/Functionals/EvenPolynomial2.tcc>
207 #endif //# CASACORE_NO_AUTO_TEMPLATES
208 #endif
EvenPolynomial(const EvenPolynomial< W > &other)
EvenPolynomialParam< T > & operator=(const EvenPolynomialParam< T > &other)
PtrHolder< T > & operator=(const PtrHolder< T > &other)
virtual ~EvenPolynomial()
Destructor.
EvenPolynomial(uInt order)
Makes a polynomial of the given order, with all coeficcients set to zero.
virtual Function< typename FunctionTraits< T >::BaseType > * cloneNonAD() const
#define EvenPolynomial_PS
uInt order() const
What is the order of the polynomial, i.e.
Class that computes partial derivatives by automatic differentiation.
Definition: AutoDiff.h:257
virtual Function< T > * clone() const
Return a copy of this object from the heap.
virtual Function< typename FunctionTraits< T >::DiffType > * cloneAD() const
Numerical functional interface class for 1 dimension.
Definition: Function1D.h:75
Parameter handling for even polynomials.
A one dimensional odd polynomial class.
EvenPolynomial(const EvenPolynomial< T > &other)
Copy constructor/assignment (deep copy)
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.
EvenPolynomial< T > & operator=(const EvenPolynomial< T > &other)
unsigned int uInt
Definition: aipstype.h:51