casa  $Rev:20696$
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines
DiracDFunction.h
Go to the documentation of this file.
00001 //# DiracDFunction.h: A one dimensional Dirac delta function
00002 //# Copyright (C) 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: DiracDFunction.h 21024 2011-03-01 11:46:18Z gervandiepen $
00027 
00028 #ifndef SCIMATH_DIRACDFUNCTION_H
00029 #define SCIMATH_DIRACDFUNCTION_H
00030 
00031 //# Includes
00032 #include <casa/aips.h>
00033 #include <scimath/Functionals/DiracDParam.h>
00034 #include <scimath/Functionals/Function.h>
00035 
00036 namespace casa { //# NAMESPACE CASA - BEGIN
00037 
00038 //# Forward declarations
00039 
00040 // <summary> A one dimensional Dirac delta function
00041 // </summary>
00042 
00043 // <use visibility=export>
00044 
00045 // <reviewed reviewer="" date="" tests="tFunctionHolder" 
00046 // demos="">
00047 // </reviewed>
00048 
00049 // <prerequisite>
00050 //   <li> <linkto class="DiracDParam">DiracDParam</linkto>
00051 //   <li> <linkto class="Function">Function</linkto>
00052 // </prerequisite>
00053 
00054 // <etymology> 
00055 // A 1-dimensional Dirac delta.
00056 // </etymology>
00057 
00058 // <synopsis> 
00059 // A <src>DiracD</src> is described by a height, a center and a width
00060 // (halfwidth). The value is:
00061 // <srcblock>
00062 //      height          (|x-center| == 0.0)
00063 //      0               (|x-center| != 0.0)
00064 // </srcblock>
00065 // The parameters are enumerated by HEIGHT, CENTER and WIDTH. They have
00066 // default values of (1, 0).
00067 // </synopsis> 
00068 //
00069 // <example>
00070 // <srcblock>
00071 //    DiracDFunction<Double> sf(5.0, 25.0);
00072 //    sf(25);            // = 5.0
00073 // </srcblock>
00074 // </example>
00075 
00076 // <templating arg=T>
00077 //  <li> T should have standard numerical operators
00078 // </templating>
00079 
00080 // <thrown>
00081 //    <li> AipsError if incorrect parameter number specified.
00082 // </thrown>
00083 //
00084 
00085 template<class T> class DiracDFunction : public DiracDParam<T>
00086 {
00087 public:
00088   //# Constructors
00089   // Constructs the DiracDFunction, Defaults:
00090   // height=1, center=0.
00091   // <note role=warning> Could not use default arguments
00092   // that worked both with gcc and IRIX </note>
00093   // <group>
00094   DiracDFunction() : DiracDParam<T>() {}
00095   explicit DiracDFunction(const T &height) :
00096     DiracDParam<T>(height) {}
00097   DiracDFunction(const T &height, const T &center) :
00098     DiracDParam<T>(height, center) {}
00099   // </group>
00100 
00101   // Copy constructor (deep copy)
00102   // <group>
00103   DiracDFunction(const DiracDFunction<T> &other) : DiracDParam<T>(other) {}
00104   template <class W>
00105   DiracDFunction(const DiracDFunction<W> &other) : DiracDParam<T>(other) {}
00106   // </group>
00107 
00108   // Copy assignment (deep copy)
00109   DiracDFunction<T> &operator=(const DiracDFunction<T> &other) {
00110     DiracDParam<T>::operator=(other); return *this; }
00111     
00112   // Destructor
00113   virtual ~DiracDFunction() {}
00114 
00115   //# Operators    
00116   // Evaluate the DiracD at <src>x</src>.
00117   // If a vector is used as the argument only its first element is used.
00118   // <group>
00119   virtual T eval(typename Function<T>::FunctionArg x) const;
00120   // </group>
00121     
00122   //# Member functions
00123   // Return a copy of this object from the heap. The caller is responsible 
00124   // for deleting this pointer. 
00125   // <group>
00126   virtual Function<T> *clone() const { return new DiracDFunction<T>(*this); }
00127   virtual Function<typename FunctionTraits<T>::DiffType> *cloneAD() const {
00128     return new DiracDFunction<typename FunctionTraits<T>::DiffType>(*this); }
00129   virtual Function<typename FunctionTraits<T>::BaseType> *cloneNonAD() const {
00130     return new DiracDFunction<typename FunctionTraits<T>::BaseType>(*this); }
00131   // </group>
00132 
00133   //# Make members of parent classes known.
00134 protected:
00135   using DiracDParam<T>::param_p;
00136 public:
00137   using DiracDParam<T>::nparameters;
00138   using DiracDParam<T>::HEIGHT;
00139   using DiracDParam<T>::CENTER;
00140 };
00141 
00142 
00143 } //# NAMESPACE CASA - END
00144 
00145 #ifndef CASACORE_NO_AUTO_TEMPLATES
00146 #include <scimath/Functionals/DiracDFunction.tcc>
00147 #endif //# CASACORE_NO_AUTO_TEMPLATES
00148 #endif