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