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