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