casa
$Rev:20696$
|
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 21024 2011-03-01 11:46:18Z gervandiepen $ 00028 00029 #ifndef SCIMATH_HYPERPLANEPARAM_H 00030 #define SCIMATH_HYPERPLANEPARAM_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 hyper plane function. 00040 // </summary> 00041 // 00042 // <use visibility=local> 00043 // <reviewed reviewer="wbrouw" date="2004/05/25" tests="tHyperPlane" 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>) = 00054 // p<sub>0</sub>*x<sub>0</sub> + p<sub>1</sub>*x<sub>1</sub> + ... 00055 // + p<sub>m-1</sub>*x<sub>m-1</sub>, 00056 // where p<sub>i</sub> are coefficients (parameters) and x<sub>i</sub> 00057 // are independent arguments. 00058 // 00059 // f(x<sub>0</sub>,x<sub>1</sub>,..,x<sub>m-1</sub>) represents a hyper plane 00060 // of dimension <src>m</src>. 00061 // 00062 // Since the <src>HyperPlane</src> is a <src>Function</src>, the derivatives 00063 // can be obtained as well. 00064 // 00065 // The parameter interface (see 00066 // <linkto class="FunctionParam">FunctionParam</linkto> class), 00067 // is used to provide an interface to the 00068 // <linkto module="Fitting">Fitting</linkto> classes. 00069 // 00070 // This class is in general used implicitly by the <src>HyperPlane</src> 00071 // class only. 00072 // </synopsis> 00073 // 00074 // <example> 00075 // <srcblock> 00076 // // form the hyper plane function of this form: 00077 // // 6*x0 + 2*x3 00078 // HyperPlane<Double> hyper(4); // 4-dim hyperplane 00079 // hyper.parameters()[0] = 6; 00080 // hyper.parameters()[3] = 2; 00081 // // Evaluate at x0=5, x3=7 00082 // Vector<Double> x(4); 00083 // x=0; x[0]=5; x[3]=7; 00084 // cout << "Hypervalue: " << hyper(x) << endl; 00085 // Hypervalue: 44 00086 // </srcblock> 00087 // </example> 00088 00089 // <templating arg=T> 00090 // <li> T should have standard numerical operators and exp() function. Current 00091 // implementation only tested for real types (and their AutoDiffs). 00092 // </templating> 00093 00094 // <thrown> 00095 // <li> Assertion in debug mode if attempt is made to set a negative width 00096 // <li> AipsError if incorrect parameter number specified. 00097 // </thrown> 00098 00099 // <motivation> 00100 // This class was created to facilitate linear constraint functions 00101 // for the use of least-squares fits. 00102 // </motivation> 00103 00104 // <todo asof="2004/05/22"> 00105 // <li> Nothing I know of 00106 // </todo> 00107 00108 template<class T> class HyperPlaneParam : public Function<T> 00109 { 00110 public: 00111 //# Constructors 00112 // Construct an m-dimensional hyper plane which has m parameters. By 00113 // default, the coefficients are initialized to zero. The default plane has 00114 // <src>m=0</src> 00115 // <group> 00116 explicit HyperPlaneParam(uInt m=0); 00117 // </group> 00118 00119 // Copy constructor (deep copy) 00120 // <group> 00121 HyperPlaneParam(const HyperPlaneParam &other); 00122 template <class W> 00123 HyperPlaneParam(const HyperPlaneParam<W> &other) : 00124 Function<T>(other) {} 00125 // </group> 00126 00127 // Copy assignment (deep copy) 00128 HyperPlaneParam<T> &operator=(const HyperPlaneParam<T> &other); 00129 00130 // Destructor 00131 virtual ~HyperPlaneParam(); 00132 00133 //# Operators 00134 // Comparisons. 00135 // HyperPlanes are equal if they are of the same order and have the same 00136 // parameters 00137 // <group> 00138 Bool operator==(const HyperPlaneParam<T> &other) const { 00139 return (this->param_p == other.param_p); } 00140 Bool operator!=(const HyperPlaneParam<T> &other) const { 00141 return (this->param_p != other.param_p); } 00142 // </group> 00143 00144 //# Member functions 00145 // Give name of function 00146 virtual const String &name() const { static String x("hyperplane"); 00147 return x; } 00148 00149 // What is the dimension of the parameter list 00150 virtual uInt ndim() const { return this->param_p.nelements(); } 00151 00152 //# Make members of parent classes known. 00153 protected: 00154 using Function<T>::param_p; 00155 public: 00156 using Function<T>::nparameters; 00157 }; 00158 00159 00160 } //# NAMESPACE CASA - END 00161 00162 #ifndef CASACORE_NO_AUTO_TEMPLATES 00163 #include <scimath/Functionals/HyperPlaneParam.tcc> 00164 #endif //# CASACORE_NO_AUTO_TEMPLATES 00165 #endif