casacore
Loading...
Searching...
No Matches
HyperPlane.h
Go to the documentation of this file.
1//# HyperPlane.h: Form 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_HYPERPLANE_H
27#define SCIMATH_HYPERPLANE_H
28
29//# Includes
30#include <casacore/casa/aips.h>
31#include <casacore/scimath/Functionals/HyperPlaneParam.h>
32#include <casacore/scimath/Functionals/Function.h>
33#include <casacore/scimath/Mathematics/AutoDiff.h>
34#include <casacore/scimath/Mathematics/AutoDiffMath.h>
35
36namespace casacore { //# NAMESPACE CASACORE - BEGIN
37
38// <summary> A hyper plane function.
39// </summary>
40//
41// <use visibility=export>
42// <reviewed reviewer="wbrouw" date="2004/05/25" tests="tHyperPlane" demos="">
43// </reviewed>
44//
45// <prerequisite>
46// <li> <linkto class=Function>Function</linkto>
47// </prerequisite>
48//
49// <synopsis>
50// This class forms a function of the form
51// f(x<sub>0</sub>,x<sub>1</sub>,..,x<sub>m-1</sub>) =
52// p<sub>0</sub>*x<sub>0</sub> + p<sub>1</sub>*x<sub>1</sub> + ...
53// + p<sub>m-1</sub>*x<sub>m-1</sub>,
54// where p<sub>i</sub> are coefficients (parameters) and x<sub>i</sub>
55// are independent arguments.
56//
57// f(x<sub>0</sub>,x<sub>1</sub>,..,x<sub>m-1</sub>) represents a hyper plane
58// of dimension <src>m</src>.
59//
60// Since the <src>HyperPlane</src> is a <src>Function</src>, the derivatives
61// can be obtained as well.
62//
63// The parameter interface (see
64// <linkto class="FunctionParam">FunctionParam</linkto> class),
65// is used to provide an interface to the
66// <linkto module="Fitting">Fitting</linkto> classes.
67//
68// This class is in general used implicitly by the <src>HyperPlane</src>
69// class only.
70// </synopsis>
71//
72// <example>
73// <srcblock>
74// // form the hyper plane function of this form:
75// // 6*x0 + 2*x3
76// HyperPlane<Double> hyper(4); // 4-dim hyperplane
77// hyper.parameters()[0] = 6;
78// hyper.parameters()[3] = 2;
79// // Evaluate at x0=5, x3=7
80// Vector<Double> x(4);
81// x=0; x[0]=5; x[3]=7;
82// cout << "Hypervalue: " << hyper(x) << endl;
83// Hypervalue: 44
84// </srcblock>
85// </example>
86
87// <templating arg=T>
88// <li> T should have standard numerical operators. Current
89// implementation only tested for real types (and their AutoDiffs).
90// </templating>
91
92// <thrown>
93// <li> Assertion in debug mode if attempt is made to address incorrect
94// coefficients
95// </thrown>
96
97// <motivation>
98// This class was created to allow the creation of linear constraint functions
99// for the use of linear least-squares fit.
100// </motivation>
101//
102// <todo asof="2004/05/25>
103// <li> Nothing I know of
104// </todo>
105
106template<class T> class HyperPlane : public HyperPlaneParam<T>
107{
108public:
109 //# Constructors
110 // Construct an m-dimensional hyper plane which has m parameters. By
111 // default, the coefficients are initialised to zero, and <src>m=0</src>
112 explicit HyperPlane(const uInt m=0) : HyperPlaneParam<T>(m) {;}
113 // Copy constructor/assignment (deep copy)
114 // <group>
115 HyperPlane(const HyperPlane<T> &other) : HyperPlaneParam<T>(other) {}
116 template <class W>
117 HyperPlane(const HyperPlane<W> &other) : HyperPlaneParam<T>(other) {}
119 HyperPlaneParam<T>::operator=(other); return *this; }
120 // </group>
121
122 // Destructor
123 virtual ~HyperPlane() {}
124
125 //# Operators
126 // Evaluate the hyper plane function at
127 // (x<sub>0</sub>,x<sub>1</sub>,..,x<sub>m-1</sub>).
128 virtual T eval(typename Function<T>::FunctionArg x) const;
129
130 // Return a copy of this object from the heap. The caller is responsible for
131 // deleting the pointer.
132 // <group>
133 virtual Function<T> *clone() const { return new HyperPlane<T>(*this); }
138 // </group>
139
140 //# Make members of parent classes known.
141protected:
143public:
145};
146
147#define HyperPlane_PS HyperPlane
148
149// <summary> Partial specialization of HyperPlane for <src>AutoDiff</src>
150// </summary>
151
152// <synopsis>
153// <note role=warning> The name <src>HyperPlane_PS</src> is only for cxx2html
154// documentation problems. Use <src>HyperPlane</src> in your code.</note>
155// </synopsis>
157template <class T> class HyperPlane_PS<AutoDiff<T> > :
158public HyperPlaneParam<AutoDiff<T> >
159{
160public:
161 //# Construct
162 // Constructors an m-dimensional hyper plane which has m parameters. By
163 // default, the coefficients are initialized to zero, and <src>m=0</src>
164 explicit HyperPlane_PS(const uInt m=0) :
165 HyperPlaneParam<AutoDiff<T> >(m) {}
166 // Copy constructor/assignment (deep copy)
167 // <group>
168 HyperPlane_PS(const HyperPlane_PS<AutoDiff<T> > &other) :
169 HyperPlaneParam<AutoDiff<T> >(other) {}
170 template <class W>
171 HyperPlane_PS(const HyperPlane_PS<W> &other) :
172 HyperPlaneParam<AutoDiff<T> >(other) {}
173 HyperPlane_PS<AutoDiff<T> > &
174 operator=(const HyperPlane_PS<AutoDiff<T> > &other) {
175 HyperPlaneParam<AutoDiff<T> >::operator=(other); return *this; }
176 // </group>
177
178 // Destructor
179 virtual ~HyperPlane() {}
180
181 //# Operators
182 // Evaluate the hyper plane function at
183 // (x<sub>0</sub>,x<sub>1</sub>,..,x<sub>m-1</sub>).
184 virtual AutoDiff<T>
185 eval(typename Function<AutoDiff<T> >::FunctionArg x) const;
186
187 // Return a copy of this object from the heap. The caller is responsible for
188 // deleting the pointer.
189 // <group>
190 virtual Function<AutoDiff<T> > *clone() const {
191 return new HyperPlane_PS<AutoDiff<T> >(*this); }
193 *cloneAD() const {
195 (*this); }
197 *cloneNonAD() const {
199 (*this); }
200 // </group>
201
202 //# Make members of parent classes known.
203protected:
204 using HyperPlaneParam<AutoDiff<T> >::param_p;
205public:
206 using HyperPlaneParam<AutoDiff<T> >::nparameters;
207};
208
209#undef HyperPlane_PS
210
211
212} //# NAMESPACE CASACORE - END
213
214#ifndef CASACORE_NO_AUTO_TEMPLATES
215#include <casacore/scimath/Functionals/HyperPlane.tcc>
216#include <casacore/scimath/Functionals/HyperPlane2.tcc>
217#endif //# CASACORE_NO_AUTO_TEMPLATES
218#endif
#define HyperPlane_PS
Definition HyperPlane.h:147
FunctionParam< T > param_p
The parameters and masks.
Definition Function.h:330
uInt nparameters() const
Returns the number of parameters.
Definition Function.h:228
HyperPlaneParam< T > & operator=(const HyperPlaneParam< T > &other)
Copy assignment (deep copy)
HyperPlane_PS(const HyperPlane_PS< W > &other)
Definition HyperPlane.h:170
HyperPlane_PS(const HyperPlane_PS< AutoDiff< T > > &other)
Copy constructor/assignment (deep copy)
Definition HyperPlane.h:167
virtual AutoDiff< T > eval(typename Function< AutoDiff< T > >::FunctionArg x) const
Evaluate the hyper plane function at (x0,x1,..,xm-1).
HyperPlane_PS(const uInt m=0)
Constructors an m-dimensional hyper plane which has m parameters.
Definition HyperPlane.h:163
virtual Function< typename FunctionTraits< AutoDiff< T > >::BaseType > * cloneNonAD() const
Definition HyperPlane.h:196
HyperPlane_PS< AutoDiff< T > > & operator=(const HyperPlane_PS< AutoDiff< T > > &other)
Definition HyperPlane.h:173
virtual Function< AutoDiff< T > > * clone() const
Return a copy of this object from the heap.
Definition HyperPlane.h:189
virtual Function< typename FunctionTraits< AutoDiff< T > >::DiffType > * cloneAD() const
Definition HyperPlane.h:192
virtual Function< typename FunctionTraits< T >::DiffType > * cloneAD() const
Definition HyperPlane.h:134
HyperPlane(const HyperPlane< T > &other)
Copy constructor/assignment (deep copy)
Definition HyperPlane.h:115
HyperPlane(const HyperPlane< W > &other)
Definition HyperPlane.h:117
virtual Function< T > * clone() const
Return a copy of this object from the heap.
Definition HyperPlane.h:133
virtual ~HyperPlane()
Destructor.
Definition HyperPlane.h:123
HyperPlane< T > & operator=(const HyperPlane< T > &other)
Definition HyperPlane.h:118
virtual Function< typename FunctionTraits< T >::BaseType > * cloneNonAD() const
Definition HyperPlane.h:136
HyperPlane(const uInt m=0)
Construct an m-dimensional hyper plane which has m parameters.
Definition HyperPlane.h:112
virtual T eval(typename Function< T >::FunctionArg x) const
Evaluate the hyper plane function at (x0,x1,..,xm-1).
this file contains all the compiler specific defines
Definition mainpage.dox:28
unsigned int uInt
Definition aipstype.h:49
PtrHolder< T > & operator=(const PtrHolder< T > &other)