casacore
PowerLogarithmicPolynomialParam.h
Go to the documentation of this file.
1 //# PolynomialParam.h: Parameter handling for one-dimensional polynomials
2 //# Copyright (C) 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: PolynomialParam.h 21024 2011-03-01 11:46:18Z gervandiepen $
27 
28 #ifndef SCIMATH_POWERLOGARITHMICPOLYNOMIALPARAM_H
29 #define SCIMATH_POWERLOGARITHMICPOLYNOMIALPARAM_H
30 
31 //# Includes
32 #include <casacore/casa/aips.h>
33 #include <casacore/casa/BasicSL/String.h>
34 #include <casacore/casa/Utilities/Assert.h>
35 #include <casacore/scimath/Functionals/Function1D.h>
36 #include <casacore/casa/Arrays/ArrayFwd.h>
37 #include <casacore/casa/vector.h>
38 
39 namespace casacore { //# NAMESPACE CASACORE - BEGIN
40 
41 // <summary> Parameter handling for one-dimensional power logarithmic polynomials
42 // </summary>
43 
44 // <reviewed reviewer="" date="" tests="tPowerLogarithmicPolynomial"
45 // demos="">
46 // </reviewed>
47 
48 // <prerequisite>
49 // <li> <linkto class="FunctionParam">FunctionParam</linkto> class
50 // <li> <linkto class=Function1D>Function1D</linkto>
51 // </prerequisite>
52 
53 // <etymology>
54 // A 1-dimensional power logaritmic olynomial's parameters.
55 // </etymology>
56 //
57 // <synopsis>
58 // A <src>power logarithmic polynomial</src> is described by a set of coefficients;
59 // its fundamental operation is evaluating itself at some "x".
60 //
61 // Since the <src> power logarithmic olynomial</src> is a <src>Function</src>, the derivatives
62 // can be obtained as well.
63 //
64 // The parameter interface (see
65 // <linkto class="FunctionParam">FunctionParam</linkto> class),
66 // is used to provide an interface to the
67 // <linkto module="Fitting">Fitting</linkto> classes.
68 //
69 // This class is in general used implicitly by the <src>PowerLogarithmicPolynomial</src>
70 // class only.
71 // </synopsis>
72 //
73 // <example>
74 // <srcblock>
75 // </srcblock>
76 // </example>
77 
78 // <templating arg=T>
79 // <li> T should have standard numerical operators. Current
80 // implementation only tested for real types (and their AutoDiffs).
81 // </templating>
82 
83 // <thrown>
84 // <li> Assertion in debug mode if attempt is made to address incorrect
85 // coefficients
86 // </thrown>
87 
88 
89 template<class T> class PowerLogarithmicPolynomialParam: public Function1D<T> {
90 public:
91  //# Constructors
92  // Constructs a function with two coefficients, both 1 (so y = x).
94 
95  // Makes a polynomial of the specified number of coefficients, all set to zero.
97 
98  PowerLogarithmicPolynomialParam(const vector<T>& parms);
99 
100  // Make this a copy of other (deep copy).
101  // <group>
103  template <class W>
105  Function1D<T>(other) {}
107  // </group>
108 
109  // Destructor
111 
112  //# Operators
113  // Comparisons.
114  // <group>
116  return (param_p == other.param_p); }
118  return (param_p != other.param_p); }
119  // </group>
120 
121  //# Member functions
122  // Give name of function
123  virtual const String &name() const { static String x("power logarithmic polynomial");
124  return x; }
125 
126  // What is the <em>which</em>'th coefficient of the polynomial. For an nth
127  // degree polynomial, <em>which</em> varies between zero and n.
128  T coefficient(uInt which) const {
129  DebugAssert(which<=nparameters(), AipsError); return param_p[which]; }
130 
131  // Return all the coefficients as a vector.
132  const Vector<T> &coefficients() const;
133 
134  // Set the <em>which</em>'th coefficient to <em>value</em>.
135  void setCoefficient(uInt which, const T value) {
136  DebugAssert(which<=nparameters(), AipsError); param_p[which] = value; }
137 
138  // Set all the coefficients at once, throw away all existing coefficients.
140 
141  //# Make members of parent classes known.
142 protected:
144 public:
146 };
147 
148 
149 } //# NAMESPACE CASACORE - END
150 
151 #ifndef CASACORE_NO_AUTO_TEMPLATES
152 #include <casacore/scimath/Functionals/PowerLogarithmicPolynomialParam.tcc>
153 #endif //# CASACORE_NO_AUTO_TEMPLATES
154 #endif
#define DebugAssert(expr, exception)
Definition: Assert.h:185
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)
virtual ~PowerLogarithmicPolynomialParam()
Destructor.
void setCoefficient(uInt which, const T value)
Set the which'th coefficient to value.
PowerLogarithmicPolynomialParam(const PowerLogarithmicPolynomialParam< T > &other)
Make this a copy of other (deep copy).
virtual const String & name() const
Give name of function.
const Vector< T > & coefficients() const
Return all the coefficients as a vector.
PowerLogarithmicPolynomialParam(const PowerLogarithmicPolynomialParam< W > &other)
T coefficient(uInt which) const
What is the which'th coefficient of the polynomial.
PowerLogarithmicPolynomialParam(const vector< T > &parms)
void setCoefficients(const Vector< T > &coefficients)
Set all the coefficients at once, throw away all existing coefficients.
PowerLogarithmicPolynomialParam()
Constructs a function with two coefficients, both 1 (so y = x).
Bool operator!=(const PowerLogarithmicPolynomialParam< T > &other) const
Bool operator==(const PowerLogarithmicPolynomialParam< T > &other) const
Comparisons.
PowerLogarithmicPolynomialParam(uInt n)
Makes a polynomial of the specified number of coefficients, all set to zero.
String: the storage and methods of handling collections of characters.
Definition: String.h:225
this file contains all the compiler specific defines
Definition: mainpage.dox:28
unsigned int uInt
Definition: aipstype.h:51
bool Bool
Define the standard types used by Casacore.
Definition: aipstype.h:42
LatticeExprNode value(const LatticeExprNode &expr)
This function returns the value of the expression without a mask.