casa  $Rev:20696$
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines
ConstantNDParam.h
Go to the documentation of this file.
00001 //# HyperPlaneParam.h: Parameters For a hyper plane function
00002 //# Copyright (C) 2001,2002,2004,2005
00003 //# Associated Universities, Inc. Washington DC, USA.
00004 //#
00005 //# This library is free software; you can redistribute it and/or modify it
00006 //# under the terms of the GNU Library General Public License as published by
00007 //# the Free Software Foundation; either version 2 of the License, or (at your
00008 //# option) any later version.
00009 //#
00010 //# This library is distributed in the hope that it will be useful, but WITHOUT
00011 //# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
00012 //# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Library General Public
00013 //# License for more details.
00014 //#
00015 //# You should have received a copy of the GNU Library General Public License
00016 //# along with this library; if not, write to the Free Software Foundation,
00017 //# Inc., 675 Massachusetts Ave, Cambridge, MA 02139, USA.
00018 //#
00019 //# Correspondence concerning AIPS++ should be addressed as follows:
00020 //#        Internet email: aips2-request@nrao.edu.
00021 //#        Postal address: AIPS++ Project Office
00022 //#                        National Radio Astronomy Observatory
00023 //#                        520 Edgemont Road
00024 //#                        Charlottesville, VA 22903-2475 USA
00025 //#
00026 //#
00027 //# $Id: HyperPlaneParam.h 20229 2008-01-29 15:19:06Z gervandiepen $
00028 
00029 #ifndef SCIMATH_CONSTANTNDPARAM_H
00030 #define SCIMATH_CONSTANTNDPARAM_H
00031 
00032 
00033 #include <casa/aips.h>
00034 #include <scimath/Functionals/Function.h>
00035 #include <casa/BasicSL/String.h>
00036 
00037 namespace casa { //# NAMESPACE CASA - BEGIN
00038 
00039 // <summary> Parameter handling for a constant function in a space of arbitrary dimensionality.
00040 // </summary>
00041 //
00042 // <use visibility=local>
00043 // <reviewed reviewer="" date="" tests="tConstant" demos="">
00044 // </reviewed>
00045 //
00046 // <prerequisite>
00047 //   <li> <linkto class="FunctionParam">FunctionParam</linkto> class
00048 //   <li> <linkto class="Function">Function</linkto> class
00049 // </prerequisite>
00050 //
00051 // <synopsis>
00052 // This class forms a function of the form
00053 // f(x<sub>0</sub>,x<sub>1</sub>,..,x<sub>m-1</sub>) = constant
00054 // in an m-dimensional parameter space where
00055 // x<sub>i</sub> are independent arguments.
00056 //
00057 // Since the <src>Constant</src> is a <src>Function</src>, the derivatives
00058 // can be obtained as well (and in fact are 0 of course).
00059 //
00060 // The parameter interface (see 
00061 // <linkto class="FunctionParam">FunctionParam</linkto> class), 
00062 // is used to provide an interface to the
00063 // <linkto module="Fitting">Fitting</linkto> classes. 
00064 //
00065 // This class is in general used implicitly by the <src>Constant</src>
00066 // class only.
00067 // </synopsis>
00068 //
00069 // <example>
00070 // <srcblock>
00071 //  form a constant function in 4-D space
00072 //  Constant<Double> constant(4); // constant in 4-D param space
00073 //  constant.parameters()[0] = 22;
00074 //  // Evaluate at x0=5, x3=7
00075 //  Vector<Double> x(4);
00076 //  x=0; x[0]=5; x[3]=7;
00077 //  cout << "constant value: " << constant(x) << endl;
00078 //  constant value: 22
00079 // </srcblock>
00080 // </example>
00081 
00082 // <templating arg=T>
00083 //  <li> T should have standard numerical operators and exp() function. Current
00084 //      implementation only tested for real types (and their AutoDiffs).
00085 // </templating>
00086 
00087 // <thrown>
00088 //    <li> Assertion in debug mode if attempt is made to set a negative width
00089 //    <li> AipsError if incorrect parameter number specified.
00090 // </thrown>
00091 
00092 // <motivation>
00093 // This class was created because HyperPlane does not support a constant
00094 // offset and modifying that class really required an interface change
00095 // (ie that the constant offset be at the beginning of the parameter vector
00096 // and that the parameter vector increase by one) so rather than breaking
00097 // any code that already used HyperPlane I simply made a trivial Constant
00098 // class.
00099 // </motivation>
00100 
00101 // <todo asof="2011/07/01">
00102 //  <li> Nothing I know of
00103 // </todo>
00104 
00105 template<class T> class ConstantNDParam : public Function<T>
00106 {
00107 public:
00108   //# Constructors
00109   // Construct a constant in m-dimensional space.  By
00110   // default, the constant value is initialized to zero.
00111   // <group>
00112   explicit ConstantNDParam(uInt m=0);
00113   // </group>
00114 
00115   // Copy constructor (deep copy)
00116   // <group>
00117   ConstantNDParam(const ConstantNDParam &other);
00118   template <class W>
00119     ConstantNDParam(const ConstantNDParam<W> &other) :
00120     Function<T>(other), _ndim(other.ndim()) {}
00121   // </group>
00122 
00123   // Copy assignment (deep copy)
00124   ConstantNDParam<T> &operator=(const ConstantNDParam<T> &other);
00125 
00126   // Destructor
00127   virtual ~ConstantNDParam();
00128 
00129   //# Operators    
00130   // Comparisons.  
00131   // HyperPlanes are equal if they are of the same order and have the same
00132   // parameters
00133   // <group>
00134   Bool operator==(const ConstantNDParam<T> &other) const {
00135     return (this->param_p == other.param_p); };
00136   Bool operator!=(const ConstantNDParam<T> &other) const {
00137     return (this->param_p != other.param_p); };
00138   // </group>
00139     
00140   //# Member functions
00141   // Give name of function
00142   virtual const String &name() const { static String x("constant");
00143     return x; };
00144 
00145   // What is the dimension of the parameter list
00146   virtual uInt ndim() const { return _ndim; };
00147 
00148   //# Make members of parent classes known.
00149 protected:
00150   using Function<T>::param_p;
00151 public:
00152   using Function<T>::nparameters;
00153 private:
00154   uInt _ndim;
00155 };
00156 
00157 
00158 } //# NAMESPACE CASA - END
00159 
00160 #ifndef CASACORE_NO_AUTO_TEMPLATES
00161 #include <scimath/Functionals/ConstantNDParam.tcc>
00162 #endif //# CASACORE_NO_AUTO_TEMPLATES
00163 #endif