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