Commit 12729e45 authored by thomas.forbriger's avatar thomas.forbriger
Browse files

libpsdxx [WP][FEATURE]: implement taper function

parent fd3a9285
......@@ -35,6 +35,7 @@
#include <psdxx/helper.h>
#include <psdxx/error.h>
#include <cmath>
namespace psd {
......@@ -76,6 +77,54 @@ namespace psd {
double Taper::operator()(const double& f)
{
double retval=0;
double rindex=this->Mli->operator()(f);
// taper function
// 0.5*(1.-cos(ri*pi))
if (this->Mloc==Flower_end)
{
// index of center frequency is 0
// index range is from -1 to +1
// taper is 1 for frequency index <= 0
if ((rindex > 0.) && (rindex < 1.))
{
retval=0.5*(1.-std::sin(rindex*M_PI));
}
else if (rindex <= 0.)
{
retval=1.;
}
}
else if (this->Mloc==Fupper_end)
{
// index of center frequency is 2
// index range is from +1 to +3
// taper is 1 for frequency index >= 2
if ((rindex < 2.) && (rindex > 1.))
{
retval=0.5*(1.-std::sin(rindex*M_PI));
}
else if (rindex >= 2.)
{
retval=1.;
}
}
else if (this->Mloc==Fmiddle)
{
// index of center frequency is 1
// index range is from 0 to +2
if ((rindex > -2.) && (rindex < 2.))
{
retval=0.5*(1.-std::cos(rindex*M_PI));
}
}
else
{
PSDXX_abort("illegal mode; this should never happen; "
"report this as a bug");
}
this->Msum += retval;
return(retval);
} // double Taper::operator()(const double& f) const
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment