5 #include <boost/bind.hpp>
6 #include <boost/cast.hpp>
23 struct Hamming:
public std::unary_function<double, double>
27 return 0.54 - 0.46 * cos(2 * PI * relpos);
31 struct Hanning:
public std::unary_function<double, double>
35 return 0.5 - 0.5 * cos(2 * PI * relpos);
39 struct Boxcar:
public std::unary_function<double, double>
43 if (relpos >= 0.0 && relpos <= 1.0)
51 struct Steep:
public std::unary_function<double, double>
55 const double startrange = 0.1;
56 if (relpos < startrange)
57 return 0.5 - 0.5 * cos(PI * relpos / startrange);
58 else if (relpos > (1.0 - startrange))
59 return 0.5 - 0.5 * cos(PI * ((1.0 - startrange) - relpos)
67 struct CosSq:
public std::unary_function<double, double>
71 double val = cos(PI * relpos / 2);
77 class TruncCosSq:
public std::unary_function<double, double>
88 if (std::abs(relpos) > width)
91 double val = cos(PI * relpos / (2 * width));
102 template<
typename InputIterator,
typename OutputIterator,
103 typename WindowFunctype>
inline
105 OutputIterator outbegin, WindowFunctype WFunc,
double relshift = 0.0)
107 const double length = inend - inbegin;
108 for (InputIterator it = inbegin; it != inend; ++it, ++outbegin)
109 *outbegin = (*it) * WFunc(boost::numeric_cast<double>(std::distance(
110 inbegin, it)) / length - relshift);
The cosine squared windows of fixed width.
double operator()(const double relpos)
double operator()(const double relpos)
This functor rises steeply at the edges and then has a wide range where it is unity.
This functor returns the weighting factor for the Hamming window, given the relative position relpos ...
double operator()(const double relpos)
double operator()(const double relpos)
A functor for the simple Boxcar function.
double operator()(const double relpos)
A variable width cosine squared window that is zero outside.
This functor returns the weighting factor for the Hanning window, given the relative position (0...
double operator()(const double relpos)