casacore
Loading...
Searching...
No Matches
ConstantNDParam.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_CONSTANTNDPARAM_H
27#define SCIMATH_CONSTANTNDPARAM_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 constant function in a space of arbitrary dimensionality.
36// </summary>
37//
38// <use visibility=local>
39// <reviewed reviewer="" date="" tests="tConstant" 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>) = constant
50// in an m-dimensional parameter space where
51// x<sub>i</sub> are independent arguments.
52//
53// Since the <src>Constant</src> is a <src>Function</src>, the derivatives
54// can be obtained as well (and in fact are 0 of course).
55//
56// The parameter interface (see
57// <linkto class="FunctionParam">FunctionParam</linkto> class),
58// is used to provide an interface to the
59// <linkto module="Fitting">Fitting</linkto> classes.
60//
61// This class is in general used implicitly by the <src>Constant</src>
62// class only.
63// </synopsis>
64//
65// <example>
66// <srcblock>
67// form a constant function in 4-D space
68// Constant<Double> constant(4); // constant in 4-D param space
69// constant.parameters()[0] = 22;
70// // Evaluate at x0=5, x3=7
71// Vector<Double> x(4);
72// x=0; x[0]=5; x[3]=7;
73// cout << "constant value: " << constant(x) << endl;
74// constant value: 22
75// </srcblock>
76// </example>
77
78// <templating arg=T>
79// <li> T should have standard numerical operators and exp() function. Current
80// implementation only tested for real types (and their AutoDiffs).
81// </templating>
82
83// <thrown>
84// <li> Assertion in debug mode if attempt is made to set a negative width
85// <li> AipsError if incorrect parameter number specified.
86// </thrown>
87
88// <motivation>
89// This class was created because HyperPlane does not support a constant
90// offset and modifying that class really required an interface change
91// (ie that the constant offset be at the beginning of the parameter vector
92// and that the parameter vector increase by one) so rather than breaking
93// any code that already used HyperPlane I simply made a trivial Constant
94// class.
95// </motivation>
96
97// <todo asof="2011/07/01">
98// <li> Nothing I know of
99// </todo>
100
101template <class T>
102class ConstantNDParam : public Function<T> {
103 public:
104 // # Constructors
105 // Construct a constant in m-dimensional space. By
106 // default, the constant value is initialized to zero.
107 // <group>
108 explicit ConstantNDParam(uInt m = 0);
109 // </group>
110
111 // Copy constructor (deep copy)
112 // <group>
114 template <class W>
115 ConstantNDParam(const ConstantNDParam<W> &other) : Function<T>(other), _ndim(other.ndim()) {}
116 // </group>
117
118 // Copy assignment (deep copy)
120
121 // Destructor
123
124 // # Operators
125 // Comparisons.
126 // HyperPlanes are equal if they are of the same order and have the same
127 // parameters
128 // <group>
129 Bool operator==(const ConstantNDParam<T> &other) const {
130 return (this->param_p == other.param_p);
131 };
132 Bool operator!=(const ConstantNDParam<T> &other) const {
133 return (this->param_p != other.param_p);
134 };
135 // </group>
136
137 // # Member functions
138 // Give name of function
139 virtual const String &name() const {
140 static String x("constant");
141 return x;
142 };
143
144 // What is the dimension of the parameter list
145 virtual uInt ndim() const { return _ndim; };
146
147 // # Make members of parent classes known.
148 protected:
149 using Function<T>::param_p;
150
151 public:
152 using Function<T>::nparameters;
153
154 private:
156};
157
158} // namespace casacore
159
160#ifndef CASACORE_NO_AUTO_TEMPLATES
161#include <casacore/scimath/Functionals/ConstantNDParam.tcc>
162#endif // # CASACORE_NO_AUTO_TEMPLATES
163#endif
virtual uInt ndim() const
What is the dimension of the parameter list.
virtual ~ConstantNDParam()
Destructor.
ConstantNDParam(const ConstantNDParam &other)
Copy constructor (deep copy).
ConstantNDParam< T > & operator=(const ConstantNDParam< T > &other)
Copy assignment (deep copy).
Bool operator==(const ConstantNDParam< T > &other) const
Comparisons.
ConstantNDParam(const ConstantNDParam< W > &other)
Bool operator!=(const ConstantNDParam< T > &other) const
virtual const String & name() const
Give name of function.
ConstantNDParam(uInt m=0)
Construct a constant in m-dimensional space.
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
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