casa  $Rev:20696$
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines
Sinusoid1DParam.h
Go to the documentation of this file.
00001 //# Sinusoid1DParam.h: Parameter handling for one dimensional Sinusoid 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: Sinusoid1DParam.h 21024 2011-03-01 11:46:18Z gervandiepen $
00027 
00028 #ifndef SCIMATH_SINUSOID1DPARAM_H
00029 #define SCIMATH_SINUSOID1DPARAM_H
00030 
00031 //# Includes
00032 #include <casa/aips.h>
00033 #include <scimath/Functionals/Function1D.h>
00034 #include <casa/BasicSL/String.h>
00035 
00036 namespace casa { //# NAMESPACE CASA - BEGIN
00037 
00038 //# Forward declarations
00039 
00040 // <summary> Parameter handling for one dimensional Sinusoid class
00041 // </summary>
00042 
00043 // <use visibility=local>
00044 
00045 // <reviewed reviewer="UNKNOWN" date="before2004/08/25" tests="tSinusoid1D" 
00046 // demos="">
00047 // </reviewed>
00048 
00049 // <prerequisite>
00050 //   <li> <linkto class="FunctionParam">FunctionParam</linkto> class
00051 //   <li> <linkto class="Function1D">Function1D</linkto> class
00052 // </prerequisite>
00053 
00054 // <etymology> 
00055 // A 1-dimensional sinusoid's parameters.
00056 // </etymology>
00057 
00058 // <synopsis> 
00059 // A <src>Sinusoid1D</src> is described by an amplitude, a period,
00060 // and a location of a peak.
00061 // The parameters (amplitude, period, and x0) may be changed at run time. 
00062 //
00063 // The functional form is <src> A*cos(2*pi(x-x0)/P) </src>
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 // There are 3 parameters that are used to describe the Sinusoid:
00071 // <ol>
00072 // <li> The amplitude of the Sinusoid. This is the value 
00073 //      returned using the <src> amplitude </src> member function.
00074 // <li> The period of the Sinusoid in the x direction. This is 
00075 //      the value returned using the <src> period </src> member function.
00076 //      The period is expressed in full cycles.
00077 // <li> The location of a peak of the Sinusoid (i.e. where
00078 // <src>x=pi+k.2pi</src>)
00079 // </ol>
00080 //
00081 // An enumeration for the <src>AMPLITUDE</src>, <src>PERIOD</src> and
00082 // <src>X0</src> parameter index is provided.
00083 //
00084 // This class is in general used implicitly by the <src>Sinusoid1D</src>
00085 // class only.
00086 // </synopsis>
00087 
00088 // <example>
00089 // <srcblock>
00090 //    Sinusoid1D<Double> sf(5.0, 25.0, 7);
00091 //    sf(25);            // = -4.911
00092 //    sf.setAmplitude(1.0);
00093 //    sf[Sinusoid1D<Double>::PERIOD] = 2.0;                
00094 //    sf.setX0(0.0);
00095 //    sf(0.5);             // = 1.0
00096 // </srcblock>
00097 // </example>
00098 
00099 // <templating arg=T>
00100 //  <li> T should have standard numerical operators and exp() function. Current
00101 //      implementation only tested for real types (and their AutoDiffs).
00102 // </templating>
00103 
00104 // <thrown>
00105 //    <li> Assertion in debug mode if attempt is made to set a negative width
00106 //    <li> AipsError if incorrect parameter number specified.
00107 // </thrown>
00108 
00109 template<class T> class Sinusoid1DParam : public Function1D<T>
00110 {
00111 public:
00112   //# Enumerations
00113   // Parameter numbers
00114   enum { AMPLITUDE=0, PERIOD, X0 };
00115   
00116   //# Constructors
00117   // Constructs the Sinusoids, Defaults:
00118   //  amplitude=1, period==1, x0=0. I.e. a cosinusoid with <src>cos(x)</src>.
00119   // <note role=warning> Could not use default arguments
00120   // that worked both with gcc and IRIX </note>
00121   // <group>
00122   Sinusoid1DParam();
00123   explicit Sinusoid1DParam(const T &amplitude);
00124   Sinusoid1DParam(const T &amplitude, const T &period);
00125   Sinusoid1DParam(const T &amplitude, const T &period, const T &x0);
00126   // </group>
00127 
00128   // Copy constructor (deep copy)
00129   // <group>
00130   Sinusoid1DParam(const Sinusoid1DParam &other);
00131   template <class W>
00132     Sinusoid1DParam(const Sinusoid1DParam<W> &other) :
00133     Function1D<T>(other) {}
00134   // </group>
00135 
00136   // Copy assignment (deep copy)
00137   Sinusoid1DParam<T> &operator=(const Sinusoid1DParam<T> &other);
00138     
00139   // Destructor
00140   virtual ~Sinusoid1DParam();
00141 
00142   //# Operators    
00143     
00144   //# Member functions
00145   // Give name of function
00146   virtual const String &name() const { static String x("sinusoid1d");
00147     return x; }
00148 
00149   // Get or set the amplitude of the Sinusoid
00150   // <group>
00151   T amplitude() const { return param_p[AMPLITUDE]; }
00152   void setAmplitude(const T &amplitude) { param_p[AMPLITUDE] = amplitude; }
00153   // </group>
00154 
00155   // Get or set the x0 of the Sinusoid, the location of a peak.
00156   // <group>
00157   T x0() const { return param_p[X0]; }
00158   void setX0(const T &x0) { param_p[X0] = x0; }
00159   // </group>
00160 
00161   // Get or set the period of the Sinusoid in full cycles.
00162   // <group>
00163   T period() const { return param_p[PERIOD]; }
00164   void setPeriod(const T &period) { param_p[PERIOD] = period; }
00165   // </group>
00166 
00167   //# Make members of parent classes known.
00168 protected:
00169   using Function1D<T>::param_p;
00170 public:
00171   using Function1D<T>::nparameters;
00172 };
00173 
00174 
00175 } //# NAMESPACE CASA - END
00176 
00177 #ifndef CASACORE_NO_AUTO_TEMPLATES
00178 #include <scimath/Functionals/Sinusoid1DParam.tcc>
00179 #endif //# CASACORE_NO_AUTO_TEMPLATES
00180 #endif