casacore
SPolynomial.h
Go to the documentation of this file.
1 //# SPolynomial.h: A one dimensional scaled 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_SPOLYNOMIAL_H
29 #define SCIMATH_SPOLYNOMIAL_H
30 
31 //# Includes
32 #include <casacore/casa/aips.h>
33 #include <casacore/scimath/Functionals/SPolynomialParam.h>
34 #include <casacore/scimath/Functionals/Function.h>
35 #include <casacore/scimath/Mathematics/AutoDiff.h>
36 #include <casacore/scimath/Mathematics/AutoDiffMath.h>
37 
38 namespace casacore { //# NAMESPACE CASACORE - BEGIN
39 
40 //# Forward declarations
41 
42 // <summary> A one dimensional scaled polynomial class
43 // </summary>
44 
45 // <reviewed reviewer="" date="" tests="tSPolynomial"
46 // demos="">
47 // </reviewed>
48 
49 // <prerequisite>
50 // <li> <linkto class=Function>Function</linkto>
51 // </prerequisite>
52 //
53 // <synopsis>
54 // A SPolynomial<T> contains a set of coefficients; its fundamental operations
55 // is evaluating itself at some "x". The number of coefficients is the order
56 // of the polynomial plus one, plus an additional 3 as height, center, width.
57 //
58 // </synopsis>
59 //
60 // <example>
61 // <srcblock>
62 // SPolynomial<Float> pf(3); // Third order polynomial - coeffs 0 by default
63 // pf.setCoefficient(1, 1.0);
64 // pf[5] = 2.0;
65 // pf.setCoefficient(3, 3.0); // 3x^3 + 2x^2 + x
66 // pf(2); // == 34
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/05/20">
81 // <li> Nothing I know of
82 // </todo>
83 
84 template<class T> class SPolynomial: public SPolynomialParam<T>
85 {
86 public:
87  //# Enumerations
88 
89  //# Constructors
90  // Constructs a zero'th order polynomial, with a coeficcient of 0.0.
92  // Makes a polynomial of the given order, with all coeficcients set to
93  // zero, and height, center, width to 1,0,1.
95  // Copy constructor/assignment (deep copy)
96  // <group>
97  SPolynomial(const SPolynomial<T> &other) : SPolynomialParam<T>(other) {}
98  template <class W>
99  SPolynomial(const SPolynomial<W> &other) : SPolynomialParam<T>(other) {}
101  SPolynomialParam<T>::operator=(other); return *this; }
102  // </group>
103 
104  // Destructor
105  virtual ~SPolynomial() {}
106 
107  //# Operators
108  // Evaluate the polynomial at <src>x</src>.
109  virtual T eval(typename Function<T>::FunctionArg x) const;
110 
111  //# Member functions
112 
113  // Return a copy of this object from the heap. The caller is responsible for
114  // deleting the pointer.
115  // <group>
116  virtual Function<T> *clone() const { return new SPolynomial<T>(*this); }
121  // </group>
122 
123  //# Make members of parent classes known.
124 protected:
126 public:
129 };
130 
131 
132 } //# NAMESPACE CASACORE - END
133 
134 #ifndef CASACORE_NO_AUTO_TEMPLATES
135 #include <casacore/scimath/Functionals/SPolynomial.tcc>
136 #endif //# CASACORE_NO_AUTO_TEMPLATES
137 #endif
const ArgType * FunctionArg
Definition: Function.h:207
uInt order() const
What is the order of the polynomial, i.e.
SPolynomialParam< T > & operator=(const SPolynomialParam< T > &other)
virtual Function< typename FunctionTraits< T >::BaseType > * cloneNonAD() const
Definition: SPolynomial.h:119
virtual Function< typename FunctionTraits< T >::DiffType > * cloneAD() const
Definition: SPolynomial.h:117
virtual ~SPolynomial()
Destructor.
Definition: SPolynomial.h:105
SPolynomial(const SPolynomial< W > &other)
Definition: SPolynomial.h:99
virtual Function< T > * clone() const
Return a copy of this object from the heap.
Definition: SPolynomial.h:116
SPolynomial< T > & operator=(const SPolynomial< T > &other)
Definition: SPolynomial.h:100
SPolynomial()
Constructs a zero'th order polynomial, with a coeficcient of 0.0.
Definition: SPolynomial.h:91
SPolynomial(uInt order)
Makes a polynomial of the given order, with all coeficcients set to zero, and height,...
Definition: SPolynomial.h:94
virtual T eval(typename Function< T >::FunctionArg x) const
Evaluate the polynomial at x.
SPolynomial(const SPolynomial< T > &other)
Copy constructor/assignment (deep copy)
Definition: SPolynomial.h:97
this file contains all the compiler specific defines
Definition: mainpage.dox:28
unsigned int uInt
Definition: aipstype.h:51