casa  5.7.0-16
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
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>
36 
37 namespace casacore { //# NAMESPACE CASACORE - BEGIN
38 
39 //# Forward declarations
40 template<class T> class Vector;
41 
42 // <summary> Parameter handling for one-dimensional power logarithmic polynomials
43 // </summary>
44 
45 // <reviewed reviewer="" date="" tests="tPowerLogarithmicPolynomial"
46 // demos="">
47 // </reviewed>
48 
49 // <prerequisite>
50 // <li> <linkto class="FunctionParam">FunctionParam</linkto> class
51 // <li> <linkto class=Function1D>Function1D</linkto>
52 // </prerequisite>
53 
54 // <etymology>
55 // A 1-dimensional power logaritmic olynomial's parameters.
56 // </etymology>
57 //
58 // <synopsis>
59 // A <src>power logarithmic polynomial</src> is described by a set of coefficients;
60 // its fundamental operation is evaluating itself at some "x".
61 //
62 // Since the <src> power logarithmic olynomial</src> is a <src>Function</src>, the derivatives
63 // can be obtained as well.
64 //
65 // The parameter interface (see
66 // <linkto class="FunctionParam">FunctionParam</linkto> class),
67 // is used to provide an interface to the
68 // <linkto module="Fitting">Fitting</linkto> classes.
69 //
70 // This class is in general used implicitly by the <src>PowerLogarithmicPolynomial</src>
71 // class only.
72 // </synopsis>
73 //
74 // <example>
75 // <srcblock>
76 // </srcblock>
77 // </example>
78 
79 // <templating arg=T>
80 // <li> T should have standard numerical operators. Current
81 // implementation only tested for real types (and their AutoDiffs).
82 // </templating>
83 
84 // <thrown>
85 // <li> Assertion in debug mode if attempt is made to address incorrect
86 // coefficients
87 // </thrown>
88 
89 
90 template<class T> class PowerLogarithmicPolynomialParam: public Function1D<T> {
91 public:
92  //# Constructors
93  // Constructs a function with two coefficients, both 1 (so y = x).
95 
96  // Makes a polynomial of the specified number of coefficients, all set to zero.
98 
99  PowerLogarithmicPolynomialParam(const vector<T>& parms);
100 
101  // Make this a copy of other (deep copy).
102  // <group>
104  template <class W>
106  Function1D<T>(other) {}
108  // </group>
109 
110  // Destructor
112 
113  //# Operators
114  // Comparisons.
115  // <group>
117  return (param_p == other.param_p); }
119  return (param_p != other.param_p); }
120  // </group>
121 
122  //# Member functions
123  // Give name of function
124  virtual const String &name() const { static String x("power logarithmic polynomial");
125  return x; }
126 
127  // What is the <em>which</em>'th coefficient of the polynomial. For an nth
128  // degree polynomial, <em>which</em> varies between zero and n.
129  T coefficient(uInt which) const {
130  DebugAssert(which<=nparameters, AipsError); return param_p[which]; }
131 
132  // Return all the coefficients as a vector.
133  const Vector<T> &coefficients() const;
134 
135  // Set the <em>which</em>'th coefficient to <em>value</em>.
136  void setCoefficient(uInt which, const T value) {
137  DebugAssert(which<=nparameters, AipsError); param_p[which] = value; }
138 
139  // Set all the coefficients at once, throw away all existing coefficients.
141 
142  //# Make members of parent classes known.
143 protected:
145 public:
147 };
148 
149 
150 } //# NAMESPACE CASACORE - END
151 
152 #ifndef CASACORE_NO_AUTO_TEMPLATES
153 #include <casacore/scimath/Functionals/PowerLogarithmicPolynomialParam.tcc>
154 #endif //# CASACORE_NO_AUTO_TEMPLATES
155 #endif
uInt nparameters() const
Returns the number of parameters.
Definition: Function.h:238
A 1-D Specialization of the Array class.
FunctionParam< T > param_p
The parameters and masks.
Definition: Function.h:340
std::vector< double > Vector
Definition: ds9context.h:24
Bool operator!=(const PowerLogarithmicPolynomialParam< T > &other) const
virtual ~PowerLogarithmicPolynomialParam()
Destructor.
virtual const String & name() const
Give name of function.
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).
T coefficient(uInt which) const
What is the which&#39;th coefficient of the polynomial.
void setCoefficient(uInt which, const T value)
Set the which&#39;th coefficient to value.
#define DebugAssert(expr, exception)
Definition: Assert.h:185
bool Bool
Define the standard types used by Casacore.
Definition: aipstype.h:42
Parameter handling for one-dimensional power logarithmic polynomials.
const Vector< T > & coefficients() const
Return all the coefficients as a vector.
Numerical functional interface class for 1 dimension.
Definition: Function1D.h:75
Bool operator==(const PowerLogarithmicPolynomialParam< T > &other) const
Comparisons.
Base class for all Casacore library errors.
Definition: Error.h:134
PowerLogarithmicPolynomialParam(const PowerLogarithmicPolynomialParam< W > &other)
String: the storage and methods of handling collections of characters.
Definition: String.h:223
PowerLogarithmicPolynomialParam< T > & operator=(const PowerLogarithmicPolynomialParam< T > &other)
LatticeExprNode value(const LatticeExprNode &expr)
This function returns the value of the expression without a mask.
unsigned int uInt
Definition: aipstype.h:51
#define casacore
&lt;X11/Intrinsic.h&gt; #defines true, false, casacore::Bool, and String.
Definition: X11Intrinsic.h:42