casa
$Rev:20696$
|
00001 //# Lorentzian1DParam.h: Parameter handling for one-dimensional Lorentzian class 00002 //# Copyright (C) 2001,2002,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 //# $Id: Lorentzian1DParam.h 20229 2010-02-15 12:19:06Z Wataru.Kawasaki $ 00027 00028 #ifndef SCIMATH_LORENTZIAN1DPARAM_H 00029 #define SCIMATH_LORENTZIAN1DPARAM_H 00030 00031 //# Includes 00032 #include <casa/aips.h> 00033 #include <casa/BasicSL/String.h> 00034 #include <scimath/Functionals/Function1D.h> 00035 00036 namespace casa { //# NAMESPACE CASA - BEGIN 00037 00038 //# Forward declarations 00039 00040 // <summary> Parameter handling for one dimensional Lorentzian class.</summary> 00041 00042 // <use visibility=local> 00043 00044 // <reviewed reviewer="tcornwel" date="1996/02/22" tests="tLorentzian1D" 00045 // demos=""> 00046 // </reviewed> 00047 00048 // <prerequisite> 00049 // <li> <linkto class="FunctionParam">FunctionParam</linkto> class 00050 // <li> <linkto class="Function1D">Function1D</linkto> class 00051 // </prerequisite> 00052 00053 // <etymology> 00054 // A 1-dimensional Lorentzian's parameters. 00055 // </etymology> 00056 00057 // <synopsis> 00058 // A <src>Lorentzian1D</src> is described by a height, center, and width. 00059 // The parameters (height, center and width) may be changed at run time. 00060 // 00061 // The width of the Lorentzian (for the constructors or the <src>setWidth 00062 // </src> function) is always specified in terms of the full width at half 00063 // maximum (FWHM). It is always positive and attempts to set a non-positive 00064 // width will throw an assertion when in debug mode. 00065 // 00066 // The peak height of the Lorentzian can be specified at construction time or 00067 // by using the <src> setHeight </src> function. Alternatively the <src> 00068 // setFlux </src> function can be used to implicitly set the peak height by 00069 // specifying the integrated area under the Lorentzian. The height (or flux) 00070 // can be positive, negative or zero, as this class makes no assumptions on 00071 // what quantity the height represents. 00072 // 00073 // <note role=tip> Changing the width of the Lorentzian will not affect 00074 // its peak height but will change its flux. So you should always set the 00075 // width before setting the flux. </note> 00076 // 00077 // The parameter interface (see 00078 // <linkto class="FunctionParam">FunctionParam</linkto> class), 00079 // is used to provide an interface to the 00080 // <linkto module="Fitting">Fitting</linkto> classes. 00081 // 00082 // There are 3 parameters that are used to describe the Lorentzian: 00083 // <ol> 00084 // <li> The height of the Lorentzian. This is identical to the value 00085 // returned using the <src>height()</src> member function. 00086 // <li> The center of the Lorentzian in the x direction. This is identical to 00087 // the value returned using the <src>center()</src> member function. 00088 // <li> The width (FWHM) of the Lorentzian. To aid convergence of 00089 // the non-linear fitting routines this parameter is allowed to be 00090 // negative. This does not affect the shape of the Lorentzian as the 00091 // square of the width is used when evaluating the function. 00092 // </ol> 00093 // 00094 // An enumeration for the <src>HEIGHT</src>, <src>WIDTH</src> and 00095 // <src>CENTER</src> parameter index is provided, enabling the setting 00096 // and reading of parameters with the <src>[]</src> operator. The 00097 // <src>mask()</src> methods can be used to check and set the parameter masks. 00098 // 00099 // This class is in general used implicitly by the <src>Lorentzian1D</src> 00100 // class only. 00101 // </synopsis> 00102 00103 // <example> 00104 // <srcblock> 00105 // Lorentzian1D<Double> gf(5.0, 25.0, 7); 00106 // gf(25); // = 5.0 00107 // gf.setHeight(1.0); 00108 // gf[WIDTH](2.0); 00109 // gf[CENTER](0.0); 00110 // gf(1); // = 0.5*height = 0.5 00111 // </srcblock> 00112 // </example> 00113 00114 // <templating arg=T> 00115 // <li> T should have standard numerical operators and exp() function. Current 00116 // implementation only tested for real types (and their AutoDiffs). 00117 // </templating> 00118 00119 // <thrown> 00120 // <li> Assertion in debug mode if attempt is made to set a negative width 00121 // <li> AipsError if incorrect parameter number specified. 00122 // </thrown> 00123 00124 // <todo asof="2001/08/19"> 00125 // <li> Lorentzians that know about their DFT's could be required eventually. 00126 // </todo> 00127 00128 template<class T> class Lorentzian1DParam : public Function1D<T> { 00129 public: 00130 //# Enumerations 00131 enum { HEIGHT=0, CENTER, WIDTH }; 00132 00133 //# Constructors 00134 // Constructs the one dimensional Lorentzians. Defaults: 00135 // height=1, center=0, width(FWHM)=1. 00136 // <note role=warning> Could not use default arguments 00137 // that worked both with gcc and IRIX and all templates</note> 00138 // <group> 00139 Lorentzian1DParam(); 00140 explicit Lorentzian1DParam(const T &height); 00141 Lorentzian1DParam(const T &height, const T ¢er); 00142 Lorentzian1DParam(const T &height, const T ¢er, const T &width); 00143 // </group> 00144 00145 // Copy constructor (deep copy) 00146 // <group> 00147 Lorentzian1DParam(const Lorentzian1DParam<T> &other); 00148 template <class W> 00149 Lorentzian1DParam(const Lorentzian1DParam<W> &other) : 00150 Function1D<T>(other), 00151 fwhm2int(T(1.0)/T(2.0)) {} 00152 // </group> 00153 // Copy assignment (deep copy) 00154 Lorentzian1DParam<T> &operator=(const Lorentzian1DParam<T> &other); 00155 00156 // Destructor 00157 virtual ~Lorentzian1DParam(); 00158 00159 //# Operators 00160 00161 //# Member functions 00162 // Give name of function 00163 virtual const String &name() const { static String x("lorentzian1d"); 00164 return x; }; 00165 00166 // Get or set the peak height of the Lorentzian 00167 // <group> 00168 T height() const { return param_p[HEIGHT]; }; 00169 void setHeight(const T &height) { param_p[HEIGHT] = height; }; 00170 // </group> 00171 00172 // Get or set the analytical integrated area underneath the Lorentzian. 00173 // Use these functions as an alternative to the height functions. 00174 // <group> 00175 T flux() const; 00176 void setFlux(const T &flux); 00177 // </group> 00178 00179 // Get or set the center ordinate of the Lorentzian 00180 // <group> 00181 T center() const { return param_p[CENTER]; }; 00182 void setCenter(const T &cnter) { param_p[CENTER] = cnter; }; 00183 // </group> 00184 00185 // Get or set the FWHM of the Lorentzian. 00186 // <group> 00187 T width() const { return param_p[WIDTH]; }; 00188 void setWidth(const T &width) { param_p[WIDTH] = width; }; 00189 // </group> 00190 00191 protected: 00192 // Constant to scale halfwidth at 1/e to FWHM 00194 T fwhm2int; 00195 00196 //# Make members of parent classes known. 00197 protected: 00198 using Function1D<T>::param_p; 00199 public: 00200 using Function1D<T>::nparameters; 00201 }; 00202 00203 00204 } //# NAMESPACE CASA - END 00205 00206 #ifndef CASACORE_NO_AUTO_TEMPLATES 00207 #include "Lorentzian1DParam.tcc" 00208 #endif //# CASACORE_NO_AUTO_TEMPLATES 00209 #endif