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: 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: Polynomial.h 21024 2011-03-01 11:46:18Z gervandiepen $
27
28#ifndef SCIMATH_POWERLOGARITHMICPOLYNOMIAL_H
29#define SCIMATH_POWERLOGARITHMICPOLYNOMIAL_H
30
31//# Includes
32#include <casacore/casa/aips.h>
33#include <casacore/scimath/Functionals/PowerLogarithmicPolynomialParam.h>
34#include <casacore/scimath/Functionals/Function1D.h>
35#include <casacore/scimath/Mathematics/AutoDiff.h>
36#include <casacore/scimath/Mathematics/AutoDiffMath.h>
37
38namespace casacore { //# NAMESPACE CASACORE - BEGIN
39
40//# Forward declarations
41
42// <summary> A one dimensional power logarithmic polynomial class of form
43// y = c_0 * x**( c_1 + c_2*ln(x) + c_3*ln(x)**2 + ... c_n*ln(x)**(n-1))
44// </summary>
45
46// <reviewed reviewer="" date="" tests="tPowerLogarithmicPolynomial"
47// demos="">
48// </reviewed>
49
50// <prerequisite>
51// <li> <linkto class=Function>Function</linkto>
52// </prerequisite>
53//
54// <synopsis>
55// A Power Logarithmic Polynomial<T> contains a set of coefficients; its fundamental operations
56// is evaluating itself at some "x".
57//
58// <note role=tip>
59// The present implementation merely stores the coefficients in a Block. In the
60// unlikely case that we need to deal with polynomials with many zero
61// coefficients, a more efficient representation would be possible.
62// </note>
63// </synopsis>
64//
65// <example>
66// <srcblock>
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
81public:
82
83 // Constructs an empty PowerLogarithmicPolynomial
85
86 // Makes a power logaritmic polynomial with the specified number of coefficients, all set to
87 // zero.
89
90 // Make a function with the specified params.
91 PowerLogarithmicPolynomial(const vector<T>& parms) : PowerLogarithmicPolynomialParam<T>(parms) {}
92
93 // Copy constructor/assignment (deep copy)
94 // <group>
96 template <class W>
100 // </group>
101
102 // Destructor
104
105 //# Operators
106 // Evaluate the polynomial at <src>x</src>.
107 virtual T eval(typename Function1D<T>::FunctionArg x) const;
108
109
110 // Return a copy of this object from the heap. The caller is responsible for
111 // deleting the pointer.
112 // <group>
113 virtual Function<T> *clone() const { return new PowerLogarithmicPolynomial<T>(*this); }
118 // </group>
119
120 //# Make members of parent classes known.
121protected:
123public:
125
126};
127
128#define PowerLogarithmicPolynomial_PS PowerLogarithmicPolynomial
129
130// <summary> Partial specialization of PowerLogarithmicPolynomial for <src>AutoDiff</src>
131// </summary>
132
133// <synopsis>
134// <note role=warning> The name <src>PowerLogarithmicPolynomial_PS</src> is only for cxx2html
135// documentation problems. Use <src>PowerLogarithmicPolynomial</src> in your code.</note>
136// </synopsis>
138template <class T> class PowerLogarithmicPolynomial_PS<AutoDiff<T> > :
139public PowerLogarithmicPolynomialParam<AutoDiff<T> > {
140public:
141 //# Constructors
142 // Constructs one dimensional Polynomials.
143 // <group>
147 // </group>
148
149 // Copy constructor (deep copy)
153 template <class W>
154 PowerLogarithmicPolynomial_PS(const PowerLogarithmicPolynomial_PS<W> &other) :
156 // </group>
157
158 // Copy assignment (deep copy)
159 PowerLogarithmicPolynomial_PS<AutoDiff<T> > &
161 PowerLogarithmicPolynomialParam<AutoDiff<T> >::operator=(other); return *this; }
162
163 // Destructor
164 virtual ~PowerLogarithmicPolynomial_PS() {}
165
166 //# Operators
167 // Evaluate the function and its derivatives at <src>x</src> <em>wrt</em>
168 // to the coefficients.
169 // <group>
170 virtual AutoDiff<T> eval(typename Function<AutoDiff<T> >::FunctionArg x) const;
171 // </group>
172
173 //# Member functions
174 // Return a copy of this object from the heap. The caller is responsible
175 // for deleting this pointer.
176 // <group>
177 virtual Function<AutoDiff<T> > *clone() const {
178 return new PowerLogarithmicPolynomial<AutoDiff<T> >(*this); }
180 *cloneAD() const {
182 (*this); }
184 *cloneNonAD() const {
186 (*this); }
187 // </group>
188
189 //# Make members of parent classes known.
190protected:
192public:
193 using PowerLogarithmicPolynomialParam<AutoDiff<T> >::nparameters;
194};
195
196#undef PowerLogarithmicPolynomial_PS
197
198
199} //# NAMESPACE CASACORE - END
200
201#ifndef CASACORE_NO_AUTO_TEMPLATES
202#include <casacore/scimath/Functionals/PowerLogarithmicPolynomial.tcc>
203#include <casacore/scimath/Functionals/PowerLogarithmicPolynomial2.tcc>
204#endif //# CASACORE_NO_AUTO_TEMPLATES
205#endif
#define PowerLogarithmicPolynomial_PS
const T * FunctionArg
Definition Function1D.h:78
FunctionParam< T > param_p
The parameters and masks.
Definition Function.h:332
uInt nparameters() const
Returns the number of parameters.
Definition Function.h:230
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:51
PtrHolder< T > & operator=(const PtrHolder< T > &other)