casacore
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
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>
37 
38 namespace 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 
80 template<class T> class PowerLogarithmicPolynomial: public PowerLogarithmicPolynomialParam<T> {
81 public:
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>
99  PowerLogarithmicPolynomialParam<T>::operator=(other); return *this; }
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.
121 protected:
123 public:
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>
138 template <class T> class PowerLogarithmicPolynomial_PS<AutoDiff<T> > :
139 public PowerLogarithmicPolynomialParam<AutoDiff<T> > {
140 public:
141  //# Constructors
142  // Constructs one dimensional Polynomials.
143  // <group>
145  explicit PowerLogarithmicPolynomial_PS(uInt n) :
147  // </group>
148 
149  // Copy constructor (deep copy)
150  // <group>
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.
190 protected:
192 public:
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
PowerLogarithmicPolynomial()
Constructs an empty PowerLogarithmicPolynomial.
virtual Function< typename FunctionTraits< T >::BaseType > * cloneNonAD() const
A one dimensional power logarithmic polynomial class of form y = c_0 * x**(c_1 + c_2*ln(x) + c_3*ln(x...
PowerLogarithmicPolynomial(const PowerLogarithmicPolynomial< W > &other)
PtrHolder< T > & operator=(const PtrHolder< T > &other)
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 vector< T > &parms)
Make a function with the specified params.
virtual T eval(typename Function1D< T >::FunctionArg x) const
Evaluate the polynomial at x.
PowerLogarithmicPolynomial(const PowerLogarithmicPolynomial< T > &other)
Copy constructor/assignment (deep copy)
Class that computes partial derivatives by automatic differentiation.
Definition: AutoDiff.h:257
Parameter handling for one-dimensional power logarithmic polynomials.
#define PowerLogarithmicPolynomial_PS
Numerical functional interface class for 1 dimension.
Definition: Function1D.h:75
virtual Function< typename FunctionTraits< T >::DiffType > * cloneAD() const
PowerLogarithmicPolynomialParam< T > & operator=(const PowerLogarithmicPolynomialParam< T > &other)
virtual Function< T > * clone() const
Return a copy of this object from the heap.
unsigned int uInt
Definition: aipstype.h:51