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