casa  5.7.0-16
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
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: 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_ODDPOLYNOMIAL_H
29 #define SCIMATH_ODDPOLYNOMIAL_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 // A OddPolynomial<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 // OddPolynomial<Float> pf(3); // Third order polynomial - coeffs 0 by default
64 // pf.setCoefficient(0, 1.0);
65 // pf[1] = 2.0; // 2x^3 + 1x^1
66 // pf(2); // == 18
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 off
82 // </todo>
83 
84 template<class T> class OddPolynomial: public OddPolynomialParam<T>
85 {
86 public:
87  //# Enumerations
88 
89  //# Constructors
90  // Constructs a first 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 OddPolynomial(uInt order) : OddPolynomialParam<T>(order) {}
95  // Copy constructor/assignment (deep copy)
96  // <group>
98  OddPolynomialParam<T>(other) {}
99  template <class W>
101  OddPolynomialParam<T>(other) {}
103  OddPolynomialParam<T>::operator=(other); return *this; }
104  // </group>
105 
106  // Destructor
107  virtual ~OddPolynomial() {}
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 OddPolynomial<T>(*this); }
122  // </group>
123 
124  //# Make members of parent classes known.
125 protected:
127 public:
129 };
130 
131 #define OddPolynomial_PS OddPolynomial
132 
133 // <summary> Partial specialization of OddPolynomial for <src>AutoDiff</src>
134 // </summary>
135 
136 // <synopsis>
137 // <note role=warning> The name <src>OddPolynomial_PS</src> is only for cxx2html
138 // documentation problems. Use <src>OddPolynomial</src> in your code.</note>
139 // </synopsis>
141 template <class T> class OddPolynomial_PS<AutoDiff<T> > :
142 public OddPolynomialParam<AutoDiff<T> >
143 {
144 public:
145  //# Constructors
146  // Constructs one dimensional OddPolynomials.
147  // <group>
149  explicit OddPolynomial_PS(uInt order) :
150  OddPolynomialParam<AutoDiff<T> >(order) {}
151  // </group>
152 
153  // Copy constructor (deep copy)
154  // <group>
156  OddPolynomialParam<AutoDiff<T> >(other) {}
157  template <class W>
158  OddPolynomial_PS(const OddPolynomial_PS<W> &other) :
159  OddPolynomialParam<AutoDiff<T> >(other) {}
160  // </group>
161  // Copy assignment (deep copy)
162  OddPolynomial_PS<AutoDiff<T> > &
163  operator=(const OddPolynomial_PS<AutoDiff<T> > &other) {
164  OddPolynomialParam<AutoDiff<T> >::operator=(other); return *this; }
165 
166  // Destructor
167  virtual ~OddPolynomial_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 OddPolynomial<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 OddPolynomialParam<AutoDiff<T> >::param_p;
195 public:
196  using OddPolynomialParam<AutoDiff<T> >::nparameters;
197 };
198 
199 #undef OddPolynomial_PS
200 
201 
202 } //# NAMESPACE CASACORE - END
203 
204 #ifndef CASACORE_NO_AUTO_TEMPLATES
205 #include <casacore/scimath/Functionals/OddPolynomial.tcc>
206 #include <casacore/scimath/Functionals/OddPolynomial2.tcc>
207 #endif //# CASACORE_NO_AUTO_TEMPLATES
208 #endif
#define OddPolynomial_PS
OddPolynomial(uInt order)
Makes a polynomial of the given order, with all coeficcients set to zero.
Definition: OddPolynomial.h:94
OddPolynomialParam< T > & operator=(const OddPolynomialParam< T > &other)
OddPolynomial()
Constructs a first order polynomial, with a coeficcient of 0.0.
Definition: OddPolynomial.h:91
PtrHolder< T > & operator=(const PtrHolder< T > &other)
OddPolynomial(const OddPolynomial< T > &other)
Copy constructor/assignment (deep copy)
Definition: OddPolynomial.h:97
virtual ~OddPolynomial()
Destructor.
OddPolynomial< T > & operator=(const OddPolynomial< T > &other)
virtual T eval(typename Function1D< T >::FunctionArg x) const
Evaluate the polynomial at x.
A one dimensional odd polynomial class.
Definition: OddPolynomial.h:84
virtual Function< typename FunctionTraits< T >::DiffType > * cloneAD() const
Class that computes partial derivatives by automatic differentiation.
Definition: AutoDiff.h:257
virtual Function< typename FunctionTraits< T >::BaseType > * cloneNonAD() const
uInt order() const
What is the order of the polynomial, i.e.
casacore::Bool clone(const casacore::String &imageName, const casacore::String &newImageName)
Numerical functional interface class for 1 dimension.
Definition: Function1D.h:75
OddPolynomial(const OddPolynomial< W > &other)
Parameter handling for odd polynomials.
unsigned int uInt
Definition: aipstype.h:51
virtual Function< T > * clone() const
Return a copy of this object from the heap.
#define casacore
&lt;X11/Intrinsic.h&gt; #defines true, false, casacore::Bool, and String.
Definition: X11Intrinsic.h:42