casacore
Loading...
Searching...
No Matches
HyperPlaneParam.h
Go to the documentation of this file.
1// # HyperPlaneParam.h: Parameters For a hyper plane function
2// # Copyright (C) 2001,2002,2004,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_HYPERPLANEPARAM_H
27#define SCIMATH_HYPERPLANEPARAM_H
28
29#include <casacore/casa/aips.h>
30#include <casacore/scimath/Functionals/Function.h>
31#include <casacore/casa/BasicSL/String.h>
32
33namespace casacore { // # NAMESPACE CASACORE - BEGIN
34
35// <summary> Parameter handling for a hyper plane function.
36// </summary>
37//
38// <use visibility=local>
39// <reviewed reviewer="wbrouw" date="2004/05/25" tests="tHyperPlane" demos="">
40// </reviewed>
41//
42// <prerequisite>
43// <li> <linkto class="FunctionParam">FunctionParam</linkto> class
44// <li> <linkto class="Function">Function</linkto> class
45// </prerequisite>
46//
47// <synopsis>
48// This class forms a function of the form
49// f(x<sub>0</sub>,x<sub>1</sub>,..,x<sub>m-1</sub>) =
50// p<sub>0</sub>*x<sub>0</sub> + p<sub>1</sub>*x<sub>1</sub> + ...
51// + p<sub>m-1</sub>*x<sub>m-1</sub>,
52// where p<sub>i</sub> are coefficients (parameters) and x<sub>i</sub>
53// are independent arguments.
54//
55// f(x<sub>0</sub>,x<sub>1</sub>,..,x<sub>m-1</sub>) represents a hyper plane
56// of dimension <src>m</src>.
57//
58// Since the <src>HyperPlane</src> is a <src>Function</src>, the derivatives
59// can be obtained as well.
60//
61// The parameter interface (see
62// <linkto class="FunctionParam">FunctionParam</linkto> class),
63// is used to provide an interface to the
64// <linkto module="Fitting">Fitting</linkto> classes.
65//
66// This class is in general used implicitly by the <src>HyperPlane</src>
67// class only.
68// </synopsis>
69//
70// <example>
71// <srcblock>
72// // form the hyper plane function of this form:
73// // 6*x0 + 2*x3
74// HyperPlane<Double> hyper(4); // 4-dim hyperplane
75// hyper.parameters()[0] = 6;
76// hyper.parameters()[3] = 2;
77// // Evaluate at x0=5, x3=7
78// Vector<Double> x(4);
79// x=0; x[0]=5; x[3]=7;
80// cout << "Hypervalue: " << hyper(x) << endl;
81// Hypervalue: 44
82// </srcblock>
83// </example>
84
85// <templating arg=T>
86// <li> T should have standard numerical operators and exp() function. Current
87// implementation only tested for real types (and their AutoDiffs).
88// </templating>
89
90// <thrown>
91// <li> Assertion in debug mode if attempt is made to set a negative width
92// <li> AipsError if incorrect parameter number specified.
93// </thrown>
94
95// <motivation>
96// This class was created to facilitate linear constraint functions
97// for the use of least-squares fits.
98// </motivation>
99
100// <todo asof="2004/05/22">
101// <li> Nothing I know of
102// </todo>
103
104template <class T>
105class HyperPlaneParam : public Function<T> {
106 public:
107 // # Constructors
108 // Construct an m-dimensional hyper plane which has m parameters. By
109 // default, the coefficients are initialized to zero. The default plane has
110 // <src>m=0</src>
111 // <group>
112 explicit HyperPlaneParam(uInt m = 0);
113 // </group>
114
115 // Copy constructor (deep copy)
116 // <group>
118 template <class W>
119 HyperPlaneParam(const HyperPlaneParam<W> &other) : Function<T>(other) {}
120 // </group>
121
122 // Copy assignment (deep copy)
124
125 // Destructor
127
128 // # Operators
129 // Comparisons.
130 // HyperPlanes are equal if they are of the same order and have the same
131 // parameters
132 // <group>
133 Bool operator==(const HyperPlaneParam<T> &other) const {
134 return (this->param_p == other.param_p);
135 }
136 Bool operator!=(const HyperPlaneParam<T> &other) const {
137 return (this->param_p != other.param_p);
138 }
139 // </group>
140
141 // # Member functions
142 // Give name of function
143 virtual const String &name() const {
144 static String x("hyperplane");
145 return x;
146 }
147
148 // What is the dimension of the parameter list
149 virtual uInt ndim() const { return this->param_p.nelements(); }
150
151 // # Make members of parent classes known.
152 protected:
153 using Function<T>::param_p;
154
155 public:
156 using Function<T>::nparameters;
157};
158
159} // namespace casacore
160
161#ifndef CASACORE_NO_AUTO_TEMPLATES
162#include <casacore/scimath/Functionals/HyperPlaneParam.tcc>
163#endif // # CASACORE_NO_AUTO_TEMPLATES
164#endif
FunctionParam< T > param_p
The parameters and masks.
Definition Function.h:337
Function()
Constructors.
Definition Function.h:209
uInt nparameters() const
Returns the number of parameters.
Definition Function.h:226
HyperPlaneParam(const HyperPlaneParam &other)
Copy constructor (deep copy).
HyperPlaneParam(uInt m=0)
Construct an m-dimensional hyper plane which has m parameters.
HyperPlaneParam(const HyperPlaneParam< W > &other)
virtual const String & name() const
Give name of function.
virtual ~HyperPlaneParam()
Destructor.
virtual uInt ndim() const
What is the dimension of the parameter list.
Bool operator==(const HyperPlaneParam< T > &other) const
Comparisons.
HyperPlaneParam< T > & operator=(const HyperPlaneParam< T > &other)
Copy assignment (deep copy).
Bool operator!=(const HyperPlaneParam< T > &other) const
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