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>
83class SPolynomial : public SPolynomialParam<T> {
84 public:
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) {}
100 return *this;
101 }
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); }
123 // </group>
124
125 // # Make members of parent classes known.
126 protected:
128
129 public:
131 using SPolynomialParam<T>::mask;
132};
133
134} // namespace casacore
135
136#ifndef CASACORE_NO_AUTO_TEMPLATES
137#include <casacore/scimath/Functionals/SPolynomial.tcc>
138#endif // # CASACORE_NO_AUTO_TEMPLATES
139#endif
FunctionParam< T > param_p
The parameters and masks.
Definition Function.h:337
uInt nparameters() const
Returns the number of parameters.
Definition Function.h:226
const ArgType * FunctionArg
Definition Function.h:204
SPolynomialParam< T > & operator=(const SPolynomialParam< T > &other)
uInt order() const
What is the order of the polynomial, i.e.
SPolynomialParam()
Constructs a zero'th order polynomial, with a coeficcient of 0.0.
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.
For temporary backward namespace compatibility, use casa as alias for casacore.
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.