casacore
Loading...
Searching...
No Matches
PowerLogarithmicPolynomial.h
Go to the documentation of this file.
1// # Polynomial.h: A one dimensional polynomial class
2// # Copyright (C) 1994,1995,1996,2001,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_POWERLOGARITHMICPOLYNOMIAL_H
27#define SCIMATH_POWERLOGARITHMICPOLYNOMIAL_H
28
29// # Includes
30#include <casacore/casa/aips.h>
31#include <casacore/scimath/Functionals/PowerLogarithmicPolynomialParam.h>
32#include <casacore/scimath/Functionals/Function1D.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 power logarithmic polynomial class of form
41// y = c_0 * x**( c_1 + c_2*ln(x) + c_3*ln(x)**2 + ... c_n*ln(x)**(n-1))
42// </summary>
43
44// <reviewed reviewer="" date="" tests="tPowerLogarithmicPolynomial"
45// demos="">
46// </reviewed>
47
48// <prerequisite>
49// <li> <linkto class=Function>Function</linkto>
50// </prerequisite>
51//
52// <synopsis>
53// A Power Logarithmic Polynomial<T> contains a set of coefficients; its fundamental operations
54// is evaluating itself at some "x".
55//
56// <note role=tip>
57// The present implementation merely stores the coefficients in a Block. In the
58// unlikely case that we need to deal with polynomials with many zero
59// coefficients, a more efficient representation would be possible.
60// </note>
61// </synopsis>
62//
63// <example>
64// <srcblock>
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
78template <class T>
80 public:
81 // Constructs an empty PowerLogarithmicPolynomial
83
84 // Makes a power logaritmic polynomial with the specified number of coefficients, all set to
85 // zero.
87
88 // Make a function with the specified params.
89 PowerLogarithmicPolynomial(const vector<T> &parms) : PowerLogarithmicPolynomialParam<T>(parms) {}
90
91 // Copy constructor/assignment (deep copy)
92 // <group>
95 template <class W>
102 // </group>
103
104 // Destructor
106
107 // # Operators
108 // Evaluate the polynomial at <src>x</src>.
109 virtual T eval(typename Function1D<T>::FunctionArg x) const;
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 PowerLogarithmicPolynomial<T>(*this); }
121 // </group>
122
123 // # Make members of parent classes known.
124 protected:
126
127 public:
129};
130
131#define PowerLogarithmicPolynomial_PS PowerLogarithmicPolynomial
132
133// <summary> Partial specialization of PowerLogarithmicPolynomial for <src>AutoDiff</src>
134// </summary>
135
136// <synopsis>
137// <note role=warning> The name <src>PowerLogarithmicPolynomial_PS</src> is only for cxx2html
138// documentation problems. Use <src>PowerLogarithmicPolynomial</src> in your code.</note>
139// </synopsis>
140
141template <class T>
143 : public PowerLogarithmicPolynomialParam<AutoDiff<T>> {
144 public:
145 // # Constructors
146 // Constructs one dimensional Polynomials.
147 // <group>
151 // </group>
152
153 // Copy constructor (deep copy)
160 // </group>
161
162 // Copy assignment (deep copy)
166 return *this;
167 }
168
169 // Destructor
171
172 // # Operators
173 // Evaluate the function and its derivatives at <src>x</src> <em>wrt</em>
174 // to the coefficients.
175 // <group>
176 virtual AutoDiff<T> eval(typename Function<AutoDiff<T>>::FunctionArg x) const;
177 // </group>
178
179 // # Member functions
180 // Return a copy of this object from the heap. The caller is responsible
181 // for deleting this pointer.
182 // <group>
183 virtual Function<AutoDiff<T>> *clone() const {
191 }
192 // </group>
193
194 // # Make members of parent classes known.
195 protected:
196 using PowerLogarithmicPolynomialParam<AutoDiff<T>>::param_p;
197
198 public:
199 using PowerLogarithmicPolynomialParam<AutoDiff<T>>::nparameters;
200};
201
202#undef PowerLogarithmicPolynomial_PS
203
204} // namespace casacore
205
206#ifndef CASACORE_NO_AUTO_TEMPLATES
207#include <casacore/scimath/Functionals/PowerLogarithmicPolynomial.tcc>
208#include <casacore/scimath/Functionals/PowerLogarithmicPolynomial2.tcc>
209#endif // # CASACORE_NO_AUTO_TEMPLATES
210#endif
#define PowerLogarithmicPolynomial_PS
const T * FunctionArg
Definition Function1D.h:76
FunctionParam< T > param_p
Definition Function.h:337
PowerLogarithmicPolynomialParam< T > & operator=(const PowerLogarithmicPolynomialParam< T > &other)
PowerLogarithmicPolynomialParam()
Constructs a function with two coefficients, both 1 (so y = x).
PowerLogarithmicPolynomial_PS()
Constructs one dimensional Polynomials.
PowerLogarithmicPolynomial_PS(const PowerLogarithmicPolynomial_PS< W > &other)
virtual Function< AutoDiff< T > > * clone() const
Return a copy of this object from the heap.
PowerLogarithmicPolynomial_PS< AutoDiff< T > > & operator=(const PowerLogarithmicPolynomial_PS< AutoDiff< T > > &other)
Copy assignment (deep copy).
PowerLogarithmicPolynomial_PS(const PowerLogarithmicPolynomial_PS< AutoDiff< T > > &other)
Copy constructor (deep copy).
virtual AutoDiff< T > eval(typename Function< AutoDiff< T > >::FunctionArg x) const
Evaluate the function and its derivatives at x wrt to the coefficients.
virtual Function< typename FunctionTraits< AutoDiff< T > >::BaseType > * cloneNonAD() const
virtual Function< typename FunctionTraits< AutoDiff< T > >::DiffType > * cloneAD() const
virtual Function< typename FunctionTraits< T >::BaseType > * cloneNonAD() const
virtual T eval(typename Function1D< T >::FunctionArg x) const
Evaluate the polynomial at x.
virtual Function< typename FunctionTraits< T >::DiffType > * cloneAD() const
PowerLogarithmicPolynomial()
Constructs an empty PowerLogarithmicPolynomial.
virtual Function< T > * clone() const
Return a copy of this object from the heap.
PowerLogarithmicPolynomial< T > & operator=(const PowerLogarithmicPolynomial< T > &other)
PowerLogarithmicPolynomial(uInt n)
Makes a power logaritmic polynomial with the specified number of coefficients, all set to zero.
PowerLogarithmicPolynomial(const PowerLogarithmicPolynomial< W > &other)
PowerLogarithmicPolynomial(const PowerLogarithmicPolynomial< T > &other)
Copy constructor/assignment (deep copy).
PowerLogarithmicPolynomial(const vector< T > &parms)
Make a function with the specified params.
For temporary backward namespace compatibility, use casa as alias for casacore.
Definition mainpage.dox:28
unsigned int uInt
Definition aipstype.h:49
virtual Function< typename FunctionTraits< T >::DiffType > * cloneAD() const
Definition Polynomial.h:126
virtual Function< typename FunctionTraits< T >::BaseType > * cloneNonAD() const
Definition Polynomial.h:129