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
79public:
80
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>
94 template <class W>
98 // </group>
99
100 // Destructor
102
103 //# Operators
104 // Evaluate the polynomial at <src>x</src>.
105 virtual T eval(typename Function1D<T>::FunctionArg x) const;
106
107
108 // Return a copy of this object from the heap. The caller is responsible for
109 // deleting the pointer.
110 // <group>
111 virtual Function<T> *clone() const { return new PowerLogarithmicPolynomial<T>(*this); }
116 // </group>
117
118 //# Make members of parent classes known.
119protected:
121public:
123
124};
125
126#define PowerLogarithmicPolynomial_PS PowerLogarithmicPolynomial
127
128// <summary> Partial specialization of PowerLogarithmicPolynomial for <src>AutoDiff</src>
129// </summary>
130
131// <synopsis>
132// <note role=warning> The name <src>PowerLogarithmicPolynomial_PS</src> is only for cxx2html
133// documentation problems. Use <src>PowerLogarithmicPolynomial</src> in your code.</note>
134// </synopsis>
136template <class T> class PowerLogarithmicPolynomial_PS<AutoDiff<T> > :
137public PowerLogarithmicPolynomialParam<AutoDiff<T> > {
138public:
139 //# Constructors
140 // Constructs one dimensional Polynomials.
141 // <group>
145 // </group>
146
147 // Copy constructor (deep copy)
151 template <class W>
152 PowerLogarithmicPolynomial_PS(const PowerLogarithmicPolynomial_PS<W> &other) :
154 // </group>
155
156 // Copy assignment (deep copy)
157 PowerLogarithmicPolynomial_PS<AutoDiff<T> > &
159 PowerLogarithmicPolynomialParam<AutoDiff<T> >::operator=(other); return *this; }
160
161 // Destructor
162 virtual ~PowerLogarithmicPolynomial_PS() {}
163
164 //# Operators
165 // Evaluate the function and its derivatives at <src>x</src> <em>wrt</em>
166 // to the coefficients.
167 // <group>
168 virtual AutoDiff<T> eval(typename Function<AutoDiff<T> >::FunctionArg x) const;
169 // </group>
170
171 //# Member functions
172 // Return a copy of this object from the heap. The caller is responsible
173 // for deleting this pointer.
174 // <group>
175 virtual Function<AutoDiff<T> > *clone() const {
176 return new PowerLogarithmicPolynomial<AutoDiff<T> >(*this); }
178 *cloneAD() const {
180 (*this); }
182 *cloneNonAD() const {
184 (*this); }
185 // </group>
186
187 //# Make members of parent classes known.
188protected:
190public:
191 using PowerLogarithmicPolynomialParam<AutoDiff<T> >::nparameters;
192};
193
194#undef PowerLogarithmicPolynomial_PS
195
196
197} //# NAMESPACE CASACORE - END
198
199#ifndef CASACORE_NO_AUTO_TEMPLATES
200#include <casacore/scimath/Functionals/PowerLogarithmicPolynomial.tcc>
201#include <casacore/scimath/Functionals/PowerLogarithmicPolynomial2.tcc>
202#endif //# CASACORE_NO_AUTO_TEMPLATES
203#endif
#define PowerLogarithmicPolynomial_PS
const T * FunctionArg
Definition Function1D.h:76
FunctionParam< T > param_p
The parameters and masks.
Definition Function.h:330
uInt nparameters() const
Returns the number of parameters.
Definition Function.h:228
PowerLogarithmicPolynomialParam< T > & operator=(const PowerLogarithmicPolynomialParam< T > &other)
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.
this file contains all the compiler specific defines
Definition mainpage.dox:28
unsigned int uInt
Definition aipstype.h:49
PtrHolder< T > & operator=(const PtrHolder< T > &other)