casacore
Loading...
Searching...
No Matches
SincFunction.h
Go to the documentation of this file.
1// # SincFunction.h: A one dimensional sin(x)/x
2// # Copyright (C) 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_SINCFUNCTION_H
27#define SCIMATH_SINCFUNCTION_H
28
29// # Includes
30#include <casacore/casa/aips.h>
31#include <casacore/scimath/Functionals/SincParam.h>
32#include <casacore/scimath/Functionals/Function.h>
33
34namespace casacore { // # NAMESPACE CASACORE - BEGIN
35
36// # Forward declarations
37
38// <summary> A one dimensional sin(x)/x
39// </summary>
40
41// <use visibility=export>
42
43// <reviewed reviewer="UNKNOWN" date="before2004/08/25" tests="tFunctionHolder"
44// demos="">
45// </reviewed>
46
47// <prerequisite>
48// <li> <linkto class="SincParam">SincParam</linkto>
49// <li> <linkto class="Function">Function</linkto>
50// </prerequisite>
51
52// <etymology>
53// A 1-dimensional sinc function.
54// </etymology>
55
56// <synopsis>
57// A <src>Sinc</src> is described by a height, a center and a width
58// (halfwidth). The value is:
59// <srcblock>
60// let y = (x-center)/width
61// height (x == center)
62// height*sin(pi*y)/(pi*y) (x |= center)
63// </srcblock>
64// The parameters are enumerated by HEIGHT, CENTER and WIDTH. They have
65// default values of (1, 0, 1).
66// </synopsis>
67//
68// <example>
69// <srcblock>
70// SincFunction<Double> sf(5.0, 25.0, 7);
71// sf(25); // = 5.0
72// </srcblock>
73// </example>
74
75// <templating arg=T>
76// <li> T should have standard numerical operators
77// </templating>
78
79// <thrown>
80// <li> AipsError if incorrect parameter number specified.
81// </thrown>
82//
83
84template <class T>
85class SincFunction : public SincParam<T> {
86 public:
87 // # Constructors
88 // Constructs the SincFunction, Defaults:
89 // height=1, center=0, width=1.
90 // <note role=warning> Could not use default arguments
91 // that worked both with gcc and IRIX </note>
92 // <group>
94 explicit SincFunction(const T &height) : SincParam<T>(height) {}
95 SincFunction(const T &height, const T &center) : SincParam<T>(height, center) {}
96 SincFunction(const T &height, const T &center, const T &width)
97 : SincParam<T>(height, center, width) {}
98 // </group>
99
100 // Copy constructor (deep copy)
101 // <group>
102 SincFunction(const SincFunction<T> &other) : SincParam<T>(other) {}
103 template <class W>
104 SincFunction(const SincFunction<W> &other) : SincParam<T>(other) {}
105 // </group>
106
107 // Copy assignment (deep copy)
110 return *this;
111 }
112
113 // Destructor
114 virtual ~SincFunction() {}
115
116 // # Operators
117 // Evaluate the Sinc at <src>x</src>.
118 // If a vector is used as the argument only its first element is used.
119 // <group>
120 virtual T eval(typename Function<T>::FunctionArg x) const;
121 // </group>
122
123 // # Member functions
124 // Return a copy of this object from the heap. The caller is responsible
125 // for deleting this pointer.
126 // <group>
127 virtual Function<T> *clone() const { return new SincFunction<T>(*this); }
134 // </group>
135
136 // # Make members of parent classes known.
137 protected:
138 using SincParam<T>::param_p;
139
140 public:
141 using SincParam<T>::nparameters;
142 using SincParam<T>::CENTER;
143 using SincParam<T>::WIDTH;
144 using SincParam<T>::HEIGHT;
145};
146
147} // namespace casacore
148
149#ifndef CASACORE_NO_AUTO_TEMPLATES
150#include <casacore/scimath/Functionals/SincFunction.tcc>
151#endif // # CASACORE_NO_AUTO_TEMPLATES
152#endif
FunctionParam< T > param_p
The parameters and masks.
Definition Function.h:337
uInt nparameters() const
Returns the number of parameters.
Definition Function.h:226
const ArgType * FunctionArg
Definition Function.h:204
SincFunction(const SincFunction< T > &other)
Copy constructor (deep copy).
SincFunction(const T &height)
SincFunction(const SincFunction< W > &other)
SincFunction()
Constructs the SincFunction, Defaults: height=1, center=0, width=1.
SincFunction(const T &height, const T &center)
SincFunction(const T &height, const T &center, const T &width)
virtual ~SincFunction()
Destructor.
virtual Function< T > * clone() const
Return a copy of this object from the heap.
virtual Function< typename FunctionTraits< T >::BaseType > * cloneNonAD() const
virtual Function< typename FunctionTraits< T >::DiffType > * cloneAD() const
virtual T eval(typename Function< T >::FunctionArg x) const
Evaluate the Sinc at x.
SincFunction< T > & operator=(const SincFunction< T > &other)
Copy assignment (deep copy).
SincParam()
Constructs the Sinc, Defaults: height=1, center=0, width=1.
SincParam< T > & operator=(const SincParam< T > &other)
Copy assignment (deep copy).
For temporary backward namespace compatibility, use casa as alias for casacore.
Definition mainpage.dox:28