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