casacore
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Sinusoid1DParam.h
Go to the documentation of this file.
1 //# Sinusoid1DParam.h: Parameter handling for one dimensional Sinusoid class
2 //# Copyright (C) 2001,2002,2005
3 //# Associated Universities, Inc. Washington DC, USA.
4 //#
5 //# This library is free software; you can redistribute it and/or modify it
6 //# under the terms of the GNU Library General Public License as published by
7 //# the Free Software Foundation; either version 2 of the License, or (at your
8 //# option) any later version.
9 //#
10 //# This library is distributed in the hope that it will be useful, but WITHOUT
11 //# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12 //# FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public
13 //# License for more details.
14 //#
15 //# You should have received a copy of the GNU Library General Public License
16 //# along with this library; if not, write to the Free Software Foundation,
17 //# Inc., 675 Massachusetts Ave, Cambridge, MA 02139, USA.
18 //#
19 //# Correspondence concerning AIPS++ should be addressed as follows:
20 //# Internet email: aips2-request@nrao.edu.
21 //# Postal address: AIPS++ Project Office
22 //# National Radio Astronomy Observatory
23 //# 520 Edgemont Road
24 //# Charlottesville, VA 22903-2475 USA
25 //#
26 //# $Id$
27 
28 #ifndef SCIMATH_SINUSOID1DPARAM_H
29 #define SCIMATH_SINUSOID1DPARAM_H
30 
31 //# Includes
32 #include <casacore/casa/aips.h>
35 
36 namespace casacore { //# NAMESPACE CASACORE - BEGIN
37 
38 //# Forward declarations
39 
40 // <summary> Parameter handling for one dimensional Sinusoid class
41 // </summary>
42 
43 // <use visibility=local>
44 
45 // <reviewed reviewer="UNKNOWN" date="before2004/08/25" tests="tSinusoid1D"
46 // demos="">
47 // </reviewed>
48 
49 // <prerequisite>
50 // <li> <linkto class="FunctionParam">FunctionParam</linkto> class
51 // <li> <linkto class="Function1D">Function1D</linkto> class
52 // </prerequisite>
53 
54 // <etymology>
55 // A 1-dimensional sinusoid's parameters.
56 // </etymology>
57 
58 // <synopsis>
59 // A <src>Sinusoid1D</src> is described by an amplitude, a period,
60 // and a location of a peak.
61 // The parameters (amplitude, period, and x0) may be changed at run time.
62 //
63 // The functional form is <src> A*cos(2*pi(x-x0)/P) </src>
64 //
65 // The parameter interface (see
66 // <linkto class="FunctionParam">FunctionParam</linkto> class),
67 // is used to provide an interface to the
68 // <linkto module="Fitting">Fitting</linkto> classes.
69 //
70 // There are 3 parameters that are used to describe the Sinusoid:
71 // <ol>
72 // <li> The amplitude of the Sinusoid. This is the value
73 // returned using the <src> amplitude </src> member function.
74 // <li> The period of the Sinusoid in the x direction. This is
75 // the value returned using the <src> period </src> member function.
76 // The period is expressed in full cycles.
77 // <li> The location of a peak of the Sinusoid (i.e. where
78 // <src>x=pi+k.2pi</src>)
79 // </ol>
80 //
81 // An enumeration for the <src>AMPLITUDE</src>, <src>PERIOD</src> and
82 // <src>X0</src> parameter index is provided.
83 //
84 // This class is in general used implicitly by the <src>Sinusoid1D</src>
85 // class only.
86 // </synopsis>
87 
88 // <example>
89 // <srcblock>
90 // Sinusoid1D<Double> sf(5.0, 25.0, 7);
91 // sf(25); // = -4.911
92 // sf.setAmplitude(1.0);
93 // sf[Sinusoid1D<Double>::PERIOD] = 2.0;
94 // sf.setX0(0.0);
95 // sf(0.5); // = 1.0
96 // </srcblock>
97 // </example>
98 
99 // <templating arg=T>
100 // <li> T should have standard numerical operators and exp() function. Current
101 // implementation only tested for real types (and their AutoDiffs).
102 // </templating>
103 
104 // <thrown>
105 // <li> Assertion in debug mode if attempt is made to set a negative width
106 // <li> AipsError if incorrect parameter number specified.
107 // </thrown>
108 
109 template<class T> class Sinusoid1DParam : public Function1D<T>
110 {
111 public:
112  //# Enumerations
113  // Parameter numbers
114  enum { AMPLITUDE=0, PERIOD, X0 };
115 
116  //# Constructors
117  // Constructs the Sinusoids, Defaults:
118  // amplitude=1, period==1, x0=0. I.e. a cosinusoid with <src>cos(x)</src>.
119  // <note role=warning> Could not use default arguments
120  // that worked both with gcc and IRIX </note>
121  // <group>
122  Sinusoid1DParam();
123  explicit Sinusoid1DParam(const T &amplitude);
124  Sinusoid1DParam(const T &amplitude, const T &period);
125  Sinusoid1DParam(const T &amplitude, const T &period, const T &x0);
126  // </group>
127 
128  // Copy constructor (deep copy)
129  // <group>
130  Sinusoid1DParam(const Sinusoid1DParam &other);
131  template <class W>
133  Function1D<T>(other) {}
134  // </group>
135 
136  // Copy assignment (deep copy)
138 
139  // Destructor
140  virtual ~Sinusoid1DParam();
141 
142  //# Operators
143 
144  //# Member functions
145  // Give name of function
146  virtual const String &name() const { static String x("sinusoid1d");
147  return x; }
148 
149  // Get or set the amplitude of the Sinusoid
150  // <group>
151  T amplitude() const { return param_p[AMPLITUDE]; }
153  // </group>
154 
155  // Get or set the x0 of the Sinusoid, the location of a peak.
156  // <group>
157  T x0() const { return param_p[X0]; }
158  void setX0(const T &x0) { param_p[X0] = x0; }
159  // </group>
160 
161  // Get or set the period of the Sinusoid in full cycles.
162  // <group>
163  T period() const { return param_p[PERIOD]; }
164  void setPeriod(const T &period) { param_p[PERIOD] = period; }
165  // </group>
166 
167  //# Make members of parent classes known.
168 protected:
170 public:
172 };
173 
174 
175 } //# NAMESPACE CASACORE - END
176 
177 #ifndef CASACORE_NO_AUTO_TEMPLATES
178 #include <casacore/scimath/Functionals/Sinusoid1DParam.tcc>
179 #endif //# CASACORE_NO_AUTO_TEMPLATES
180 #endif
Sinusoid1DParam< T > & operator=(const Sinusoid1DParam< T > &other)
Copy assignment (deep copy)
FunctionParam< T > param_p
The parameters and masks.
Definition: Function.h:332
Sinusoid1DParam(const Sinusoid1DParam< W > &other)
virtual ~Sinusoid1DParam()
Destructor.
virtual const String & name() const
Give name of function.
void setPeriod(const T &period)
Sinusoid1DParam()
Constructs the Sinusoids, Defaults: amplitude=1, period==1, x0=0.
void setAmplitude(const T &amplitude)
T amplitude() const
Get or set the amplitude of the Sinusoid.
Numerical functional interface class for 1 dimension.
Definition: Function1D.h:75
T x0() const
Get or set the x0 of the Sinusoid, the location of a peak.
String: the storage and methods of handling collections of characters.
Definition: String.h:225
T period() const
Get or set the period of the Sinusoid in full cycles.
Parameter handling for one dimensional Sinusoid class.