PowerLogarithmicPolynomialParam.h

Go to the documentation of this file.
00001 //# PolynomialParam.h: Parameter handling for one-dimensional polynomials
00002 //# Copyright (C) 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: PolynomialParam.h 21024 2011-03-01 11:46:18Z gervandiepen $
00027 
00028 #ifndef SCIMATH_POWERLOGARITHMICPOLYNOMIALPARAM_H
00029 #define SCIMATH_POWERLOGARITHMICPOLYNOMIALPARAM_H
00030 
00031 //# Includes
00032 #include <casacore/casa/aips.h>
00033 #include <casacore/casa/BasicSL/String.h>
00034 #include <casacore/casa/Utilities/Assert.h>
00035 #include <casacore/scimath/Functionals/Function1D.h>
00036 
00037 namespace casacore { //# NAMESPACE CASACORE - BEGIN
00038 
00039 //# Forward declarations
00040 template<class T> class Vector;
00041 
00042 // <summary>  Parameter handling for one-dimensional power logarithmic polynomials
00043 // </summary>
00044 
00045 // <reviewed reviewer="" date="" tests="tPowerLogarithmicPolynomial"
00046 // demos="">
00047 // </reviewed>
00048 
00049 // <prerequisite>
00050 //   <li> <linkto class="FunctionParam">FunctionParam</linkto> class
00051 //   <li> <linkto class=Function1D>Function1D</linkto>
00052 // </prerequisite>
00053 
00054 // <etymology> 
00055 // A 1-dimensional power logaritmic olynomial's parameters.
00056 // </etymology>
00057 //
00058 // <synopsis> 
00059 // A <src>power logarithmic polynomial</src> is described by a set of coefficients;
00060 // its fundamental operation is evaluating itself at some "x".
00061 //
00062 // Since the <src> power logarithmic olynomial</src> is a <src>Function</src>, the derivatives
00063 // can be obtained as well. 
00064 //
00065 // The parameter interface (see 
00066 // <linkto class="FunctionParam">FunctionParam</linkto> class), 
00067 // is used to provide an interface to the
00068 // <linkto module="Fitting">Fitting</linkto> classes. 
00069 //
00070 // This class is in general used implicitly by the <src>PowerLogarithmicPolynomial</src>
00071 // class only.
00072 // </synopsis> 
00073 //
00074 // <example>
00075 // <srcblock>
00076 // </srcblock>
00077 // </example>
00078 
00079 // <templating arg=T>
00080 //  <li> T should have standard numerical operators. Current
00081 //      implementation only tested for real types (and their AutoDiffs).
00082 // </templating>
00083 
00084 // <thrown>
00085 //    <li> Assertion in debug mode if attempt is made to address incorrect
00086 //              coefficients
00087 // </thrown>
00088 
00089 
00090 template<class T> class PowerLogarithmicPolynomialParam: public Function1D<T> {
00091 public:
00092   //# Constructors
00093   // Constructs a function with two coefficients, both 1 (so y = x).
00094   PowerLogarithmicPolynomialParam();
00095   
00096   // Makes a polynomial of the specified number of coefficients, all set to zero.
00097   explicit PowerLogarithmicPolynomialParam(uInt n);
00098   
00099   PowerLogarithmicPolynomialParam(const vector<T>& parms);
00100 
00101   // Make this a copy of other (deep copy).
00102   // <group>
00103   PowerLogarithmicPolynomialParam(const PowerLogarithmicPolynomialParam<T> &other);
00104   template <class W>
00105     PowerLogarithmicPolynomialParam(const PowerLogarithmicPolynomialParam<W> &other) :
00106     Function1D<T>(other) {}
00107   PowerLogarithmicPolynomialParam<T> &operator=(const PowerLogarithmicPolynomialParam<T> &other);
00108   // </group>
00109   
00110   // Destructor
00111   virtual ~PowerLogarithmicPolynomialParam();
00112 
00113   //# Operators  
00114   // Comparisons.  
00115   // <group>
00116   Bool operator==(const PowerLogarithmicPolynomialParam<T> &other) const {
00117     return (param_p == other.param_p); }
00118   Bool operator!=(const PowerLogarithmicPolynomialParam<T> &other) const {
00119     return (param_p != other.param_p); }
00120   // </group>
00121 
00122   //# Member functions
00123   // Give name of function
00124   virtual const String &name() const { static String x("power logarithmic polynomial");
00125     return x; }
00126 
00127   // What is the <em>which</em>'th coefficient of the polynomial. For an nth
00128   // degree polynomial, <em>which</em> varies between zero and n.
00129   T coefficient(uInt which) const {
00130     DebugAssert(which<=nparameters, AipsError); return param_p[which]; }
00131   
00132   // Return all the coefficients as a vector.
00133   const Vector<T> &coefficients() const;
00134 
00135   // Set the <em>which</em>'th coefficient to <em>value</em>. 
00136   void setCoefficient(uInt which, const T value) {
00137     DebugAssert(which<=nparameters, AipsError); param_p[which] = value; }
00138   
00139   // Set all the coefficients at once, throw away all existing coefficients.
00140   void setCoefficients(const Vector<T> &coefficients);
00141 
00142   //# Make members of parent classes known.
00143 protected:
00144   using Function1D<T>::param_p;
00145 public:
00146   using Function1D<T>::nparameters;
00147 };
00148 
00149 
00150 } //# NAMESPACE CASACORE - END
00151 
00152 #ifndef CASACORE_NO_AUTO_TEMPLATES
00153 #include <casacore/scimath/Functionals/PowerLogarithmicPolynomialParam.tcc>
00154 #endif //# CASACORE_NO_AUTO_TEMPLATES
00155 #endif
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines

Generated on 31 Aug 2016 for casa by  doxygen 1.6.1