[301] | 1 | // ----------------------------------------------------------------------- |
---|
| 2 | // Hanning.hh: Definition of Hanning class, used to Hanning-smooth a |
---|
| 3 | // 1D spectrum. |
---|
| 4 | // ----------------------------------------------------------------------- |
---|
| 5 | // Copyright (C) 2006, Matthew Whiting, ATNF |
---|
| 6 | // |
---|
| 7 | // This program is free software; you can redistribute it and/or modify it |
---|
| 8 | // under the terms of the GNU General Public License as published by the |
---|
| 9 | // Free Software Foundation; either version 2 of the License, or (at your |
---|
| 10 | // option) any later version. |
---|
| 11 | // |
---|
| 12 | // Duchamp is distributed in the hope that it will be useful, but WITHOUT |
---|
| 13 | // ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
---|
| 14 | // FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
---|
| 15 | // for more details. |
---|
| 16 | // |
---|
| 17 | // You should have received a copy of the GNU General Public License |
---|
| 18 | // along with Duchamp; if not, write to the Free Software Foundation, |
---|
| 19 | // Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA |
---|
| 20 | // |
---|
| 21 | // Correspondence concerning Duchamp may be directed to: |
---|
| 22 | // Internet email: Matthew.Whiting [at] atnf.csiro.au |
---|
| 23 | // Postal address: Dr. Matthew Whiting |
---|
| 24 | // Australia Telescope National Facility, CSIRO |
---|
| 25 | // PO Box 76 |
---|
| 26 | // Epping NSW 1710 |
---|
| 27 | // AUSTRALIA |
---|
| 28 | // ----------------------------------------------------------------------- |
---|
[201] | 29 | #ifndef HANNING_H |
---|
| 30 | #define HANNING_H |
---|
| 31 | |
---|
[528] | 32 | /// @brief |
---|
| 33 | /// Define a Hanning filter. |
---|
| 34 | /// @details |
---|
| 35 | /// A simple class to define a Hanning filter. It is characterised by |
---|
| 36 | /// a full width \f$2a-1\f$ (this is the number of coefficients and a |
---|
| 37 | /// set of coefficients that follow the functional form of \f$c(x) = |
---|
| 38 | /// 0.5 + 0.5\cos(\pi x / a)\f$. |
---|
[201] | 39 | |
---|
| 40 | class Hanning |
---|
| 41 | { |
---|
| 42 | public: |
---|
[275] | 43 | Hanning(); ///< Basic constructor -- no filter width set. |
---|
| 44 | virtual ~Hanning(); ///< Destructor |
---|
[365] | 45 | Hanning(const Hanning& h); |
---|
| 46 | Hanning& operator=(const Hanning& h); |
---|
[528] | 47 | Hanning(int size); ///< Specific constructor that sets width and coefficients |
---|
[201] | 48 | |
---|
[528] | 49 | void define(int size); ///< Define the size and the array of coefficients. |
---|
[275] | 50 | |
---|
[528] | 51 | float *smooth(float *array, int npts); ///< Smooth an array with the Hanning filter. |
---|
[201] | 52 | |
---|
| 53 | private: |
---|
[221] | 54 | int hanningSize; ///< The full width of the filter (number of coefficients) |
---|
| 55 | float *coeffs; ///< The coefficients of the filter |
---|
| 56 | bool allocated; ///< Have the coefficients been allocated in memory? |
---|
[201] | 57 | |
---|
| 58 | }; |
---|
| 59 | |
---|
| 60 | #endif // HANNING_H |
---|