casacore
Loading...
Searching...
No Matches
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: casa-feedback@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#ifndef SCIMATH_SINUSOID1DPARAM_H
27#define SCIMATH_SINUSOID1DPARAM_H
28
29//# Includes
30#include <casacore/casa/aips.h>
31#include <casacore/scimath/Functionals/Function1D.h>
32#include <casacore/casa/BasicSL/String.h>
33
34namespace casacore { //# NAMESPACE CASACORE - BEGIN
35
36//# Forward declarations
37
38// <summary> Parameter handling for one dimensional Sinusoid class
39// </summary>
40
41// <use visibility=local>
42
43// <reviewed reviewer="UNKNOWN" date="before2004/08/25" tests="tSinusoid1D"
44// demos="">
45// </reviewed>
46
47// <prerequisite>
48// <li> <linkto class="FunctionParam">FunctionParam</linkto> class
49// <li> <linkto class="Function1D">Function1D</linkto> class
50// </prerequisite>
51
52// <etymology>
53// A 1-dimensional sinusoid's parameters.
54// </etymology>
55
56// <synopsis>
57// A <src>Sinusoid1D</src> is described by an amplitude, a period,
58// and a location of a peak.
59// The parameters (amplitude, period, and x0) may be changed at run time.
60//
61// The functional form is <src> A*cos(2*pi(x-x0)/P) </src>
62//
63// The parameter interface (see
64// <linkto class="FunctionParam">FunctionParam</linkto> class),
65// is used to provide an interface to the
66// <linkto module="Fitting">Fitting</linkto> classes.
67//
68// There are 3 parameters that are used to describe the Sinusoid:
69// <ol>
70// <li> The amplitude of the Sinusoid. This is the value
71// returned using the <src> amplitude </src> member function.
72// <li> The period of the Sinusoid in the x direction. This is
73// the value returned using the <src> period </src> member function.
74// The period is expressed in full cycles.
75// <li> The location of a peak of the Sinusoid (i.e. where
76// <src>x=pi+k.2pi</src>)
77// </ol>
78//
79// An enumeration for the <src>AMPLITUDE</src>, <src>PERIOD</src> and
80// <src>X0</src> parameter index is provided.
81//
82// This class is in general used implicitly by the <src>Sinusoid1D</src>
83// class only.
84// </synopsis>
85
86// <example>
87// <srcblock>
88// Sinusoid1D<Double> sf(5.0, 25.0, 7);
89// sf(25); // = -4.911
90// sf.setAmplitude(1.0);
91// sf[Sinusoid1D<Double>::PERIOD] = 2.0;
92// sf.setX0(0.0);
93// sf(0.5); // = 1.0
94// </srcblock>
95// </example>
96
97// <templating arg=T>
98// <li> T should have standard numerical operators and exp() function. Current
99// implementation only tested for real types (and their AutoDiffs).
100// </templating>
101
102// <thrown>
103// <li> Assertion in debug mode if attempt is made to set a negative width
104// <li> AipsError if incorrect parameter number specified.
105// </thrown>
106
107template<class T> class Sinusoid1DParam : public Function1D<T>
108{
109public:
110 //# Enumerations
111 // Parameter numbers
112 enum { AMPLITUDE=0, PERIOD, X0 };
113
114 //# Constructors
115 // Constructs the Sinusoids, Defaults:
116 // amplitude=1, period==1, x0=0. I.e. a cosinusoid with <src>cos(x)</src>.
117 // <note role=warning> Could not use default arguments
118 // that worked both with gcc and IRIX </note>
119 // <group>
121 explicit Sinusoid1DParam(const T &amplitude);
122 Sinusoid1DParam(const T &amplitude, const T &period);
123 Sinusoid1DParam(const T &amplitude, const T &period, const T &x0);
124 // </group>
125
126 // Copy constructor (deep copy)
127 // <group>
129 template <class W>
131 Function1D<T>(other) {}
132 // </group>
133
134 // Copy assignment (deep copy)
136
137 // Destructor
139
140 //# Operators
141
142 //# Member functions
143 // Give name of function
144 virtual const String &name() const { static String x("sinusoid1d");
145 return x; }
146
147 // Get or set the amplitude of the Sinusoid
148 // <group>
149 T amplitude() const { return param_p[AMPLITUDE]; }
151 // </group>
152
153 // Get or set the x0 of the Sinusoid, the location of a peak.
154 // <group>
155 T x0() const { return param_p[X0]; }
156 void setX0(const T &x0) { param_p[X0] = x0; }
157 // </group>
158
159 // Get or set the period of the Sinusoid in full cycles.
160 // <group>
161 T period() const { return param_p[PERIOD]; }
162 void setPeriod(const T &period) { param_p[PERIOD] = period; }
163 // </group>
164
165 //# Make members of parent classes known.
166protected:
167 using Function1D<T>::param_p;
168public:
170};
171
172
173} //# NAMESPACE CASACORE - END
174
175#ifndef CASACORE_NO_AUTO_TEMPLATES
176#include <casacore/scimath/Functionals/Sinusoid1DParam.tcc>
177#endif //# CASACORE_NO_AUTO_TEMPLATES
178#endif
FunctionParam< T > param_p
The parameters and masks.
Definition Function.h:330
uInt nparameters() const
Returns the number of parameters.
Definition Function.h:228
virtual const String & name() const
Give name of function.
void setPeriod(const T &period)
void setAmplitude(const T &amplitude)
Sinusoid1DParam(const Sinusoid1DParam< W > &other)
virtual ~Sinusoid1DParam()
Destructor.
T x0() const
Get or set the x0 of the Sinusoid, the location of a peak.
T amplitude() const
Get or set the amplitude of the Sinusoid.
Sinusoid1DParam(const T &amplitude, const T &period)
Sinusoid1DParam(const T &amplitude, const T &period, const T &x0)
Sinusoid1DParam(const Sinusoid1DParam &other)
Copy constructor (deep copy)
Sinusoid1DParam()
Constructs the Sinusoids, Defaults: amplitude=1, period==1, x0=0.
T period() const
Get or set the period of the Sinusoid in full cycles.
Sinusoid1DParam< T > & operator=(const Sinusoid1DParam< T > &other)
Copy assignment (deep copy)
Sinusoid1DParam(const T &amplitude)
String: the storage and methods of handling collections of characters.
Definition String.h:223
this file contains all the compiler specific defines
Definition mainpage.dox:28