PowerLogarithmicPolynomial.h

Go to the documentation of this file.
00001 //# Polynomial.h: A one dimensional polynomial class
00002 //# Copyright (C) 1994,1995,1996,2001,2002,2005
00003 //# Associated Universities, Inc. Washington DC, USA.
00004 //#
00005 //# This library is free software; you can redistribute it and/or modify it
00006 //# under the terms of the GNU Library General Public License as published by
00007 //# the Free Software Foundation; either version 2 of the License, or (at your
00008 //# option) any later version.
00009 //#
00010 //# This library is distributed in the hope that it will be useful, but WITHOUT
00011 //# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
00012 //# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Library General Public
00013 //# License for more details.
00014 //#
00015 //# You should have received a copy of the GNU Library General Public License
00016 //# along with this library; if not, write to the Free Software Foundation,
00017 //# Inc., 675 Massachusetts Ave, Cambridge, MA 02139, USA.
00018 //#
00019 //# Correspondence concerning AIPS++ should be addressed as follows:
00020 //#        Internet email: aips2-request@nrao.edu.
00021 //#        Postal address: AIPS++ Project Office
00022 //#                        National Radio Astronomy Observatory
00023 //#                        520 Edgemont Road
00024 //#                        Charlottesville, VA 22903-2475 USA
00025 //#
00026 //# $Id: Polynomial.h 21024 2011-03-01 11:46:18Z gervandiepen $
00027 
00028 #ifndef SCIMATH_POWERLOGARITHMICPOLYNOMIAL_H
00029 #define SCIMATH_POWERLOGARITHMICPOLYNOMIAL_H
00030 
00031 //# Includes
00032 #include <casacore/casa/aips.h>
00033 #include <casacore/scimath/Functionals/PowerLogarithmicPolynomialParam.h>
00034 #include <casacore/scimath/Functionals/Function1D.h>
00035 #include <casacore/scimath/Mathematics/AutoDiff.h>
00036 #include <casacore/scimath/Mathematics/AutoDiffMath.h>
00037 
00038 namespace casacore { //# NAMESPACE CASACORE - BEGIN
00039 
00040 //# Forward declarations
00041 
00042 // <summary> A one dimensional power logarithmic polynomial class of form
00043 // y = c_0 * x**( c_1 + c_2*ln(x) + c_3*ln(x)**2 + ... c_n*ln(x)**(n-1))
00044 // </summary>
00045 
00046 // <reviewed reviewer="" date="" tests="tPowerLogarithmicPolynomial"
00047 // demos="">
00048 // </reviewed>
00049 
00050 // <prerequisite>
00051 //   <li> <linkto class=Function>Function</linkto>
00052 // </prerequisite>
00053 //
00054 // <synopsis> 
00055 // A Power Logarithmic Polynomial<T> contains a set of coefficients; its fundamental operations
00056 // is evaluating itself at some "x".
00057 //
00058 // <note role=tip>
00059 // The present implementation merely stores the coefficients in a Block. In the
00060 // unlikely case that we need to deal with polynomials with many zero
00061 // coefficients, a more efficient representation would be possible.
00062 // </note>
00063 // </synopsis> 
00064 //
00065 // <example>
00066 // <srcblock>
00067 // </srcblock>
00068 // </example>
00069 
00070 // <templating arg=T>
00071 //  <li> T should have standard numerical operators. Current
00072 //      implementation only tested for real types (and their AutoDiffs).
00073 // </templating>
00074 
00075 // <thrown>
00076 //    <li> Assertion in debug mode if attempt is made to address incorrect
00077 //              coefficients
00078 // </thrown>
00079 
00080 template<class T> class PowerLogarithmicPolynomial: public PowerLogarithmicPolynomialParam<T> {
00081 public:
00082   
00083         // Constructs an empty PowerLogarithmicPolynomial
00084         PowerLogarithmicPolynomial() : PowerLogarithmicPolynomialParam<T>() {}
00085 
00086         // Makes a power logaritmic polynomial with the specified number of coefficients, all set to
00087         // zero.
00088         explicit PowerLogarithmicPolynomial(uInt n) : PowerLogarithmicPolynomialParam<T>(n) {}
00089 
00090         // Make a function with the specified params.
00091         PowerLogarithmicPolynomial(const vector<T>& parms) : PowerLogarithmicPolynomialParam<T>(parms) {}
00092 
00093         // Copy constructor/assignment (deep copy)
00094         // <group>
00095   PowerLogarithmicPolynomial(const PowerLogarithmicPolynomial<T> &other) : PowerLogarithmicPolynomialParam<T>(other) {}
00096   template <class W>
00097   PowerLogarithmicPolynomial(const PowerLogarithmicPolynomial<W> &other) : PowerLogarithmicPolynomialParam<T>(other) {}
00098   PowerLogarithmicPolynomial<T> &operator=(const PowerLogarithmicPolynomial<T> &other) {
00099           PowerLogarithmicPolynomialParam<T>::operator=(other); return *this; }
00100   // </group>
00101   
00102   // Destructor
00103   virtual ~PowerLogarithmicPolynomial() {}
00104   
00105   //# Operators    
00106   // Evaluate the polynomial at <src>x</src>.
00107   virtual T eval(typename Function1D<T>::FunctionArg x) const;
00108   
00109   
00110   // Return a copy of this object from the heap. The caller is responsible for
00111   // deleting the pointer.
00112   // <group>
00113   virtual Function<T> *clone() const { return new PowerLogarithmicPolynomial<T>(*this); }
00114   virtual Function<typename FunctionTraits<T>::DiffType> *cloneAD() const {
00115     return new PowerLogarithmicPolynomial<typename FunctionTraits<T>::DiffType>(*this); }
00116   virtual Function<typename FunctionTraits<T>::BaseType> *cloneNonAD() const {
00117     return new PowerLogarithmicPolynomial<typename FunctionTraits<T>::BaseType>(*this); }
00118   // </group>
00119 
00120   //# Make members of parent classes known.
00121 protected:
00122   using PowerLogarithmicPolynomialParam<T>::param_p;
00123 public:
00124   using PowerLogarithmicPolynomialParam<T>::nparameters;
00125 
00126 };
00127 
00128 #define PowerLogarithmicPolynomial_PS PowerLogarithmicPolynomial
00129 
00130 // <summary> Partial specialization of PowerLogarithmicPolynomial for <src>AutoDiff</src>
00131 // </summary>
00132 
00133 // <synopsis>
00134 // <note role=warning> The name <src>PowerLogarithmicPolynomial_PS</src> is only for cxx2html
00135 // documentation problems. Use <src>PowerLogarithmicPolynomial</src> in your code.</note>
00136 // </synopsis>
00137 
00138 template <class T> class PowerLogarithmicPolynomial_PS<AutoDiff<T> > :
00139 public PowerLogarithmicPolynomialParam<AutoDiff<T> > {
00140 public:
00141   //# Constructors
00142   // Constructs one dimensional Polynomials.
00143   // <group>
00144         PowerLogarithmicPolynomial_PS() : PowerLogarithmicPolynomialParam<AutoDiff<T> >() {}
00145   explicit PowerLogarithmicPolynomial_PS(uInt n) :
00146                 PowerLogarithmicPolynomialParam<AutoDiff<T> >(n) {}
00147   // </group>
00148 
00149   // Copy constructor (deep copy)
00150   // <group>
00151   PowerLogarithmicPolynomial_PS(const PowerLogarithmicPolynomial_PS<AutoDiff<T> > &other) :
00152           PowerLogarithmicPolynomialParam<AutoDiff<T> >(other) {}
00153   template <class W>
00154   PowerLogarithmicPolynomial_PS(const PowerLogarithmicPolynomial_PS<W> &other) :
00155   PowerLogarithmicPolynomialParam<AutoDiff<T> >(other) {}
00156   // </group>
00157 
00158   // Copy assignment (deep copy)
00159   PowerLogarithmicPolynomial_PS<AutoDiff<T> > &
00160     operator=(const PowerLogarithmicPolynomial_PS<AutoDiff<T> > &other) {
00161           PowerLogarithmicPolynomialParam<AutoDiff<T> >::operator=(other); return *this; }
00162     
00163   // Destructor
00164   virtual ~PowerLogarithmicPolynomial_PS() {}
00165 
00166   //# Operators    
00167   // Evaluate the function and its derivatives at <src>x</src> <em>wrt</em>
00168   // to the coefficients.
00169   // <group>
00170   virtual AutoDiff<T> eval(typename Function<AutoDiff<T> >::FunctionArg x) const;
00171   // </group>
00172 
00173   //# Member functions
00174   // Return a copy of this object from the heap. The caller is responsible 
00175   // for deleting this pointer.
00176   // <group>
00177   virtual Function<AutoDiff<T> > *clone() const {
00178     return new PowerLogarithmicPolynomial<AutoDiff<T> >(*this); }
00179   virtual Function<typename FunctionTraits<AutoDiff<T> >::DiffType>
00180     *cloneAD() const {
00181     return new PowerLogarithmicPolynomial<typename FunctionTraits<AutoDiff<T> >::DiffType>
00182       (*this); }
00183   virtual Function<typename FunctionTraits<AutoDiff<T> >::BaseType>
00184     *cloneNonAD() const {
00185     return new PowerLogarithmicPolynomial<typename FunctionTraits<AutoDiff<T> >::BaseType>
00186       (*this); }
00187   // </group>
00188 
00189   //# Make members of parent classes known.
00190 protected:
00191   using PowerLogarithmicPolynomialParam<AutoDiff<T> >::param_p;
00192 public:
00193   using PowerLogarithmicPolynomialParam<AutoDiff<T> >::nparameters;
00194 };
00195 
00196 #undef PowerLogarithmicPolynomial_PS
00197 
00198 
00199 } //# NAMESPACE CASACORE - END
00200 
00201 #ifndef CASACORE_NO_AUTO_TEMPLATES
00202 #include <casacore/scimath/Functionals/PowerLogarithmicPolynomial.tcc>
00203 #include <casacore/scimath/Functionals/PowerLogarithmicPolynomial2.tcc>
00204 #endif //# CASACORE_NO_AUTO_TEMPLATES
00205 #endif
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines

Generated on 31 Aug 2016 for casa by  doxygen 1.6.1