基于VS和C/C++语言的凯撒窗函数。
#define M_EPS 1e-8
double I0(double alpha)
{
double dNew;
double K = alpha / 2.0;
const int MAXTERM = 25 + 1;
double J = 1.0, dOld = 1.0;
bool converge = false;
for (int i = 1; i < MAXTERM; ++i)
{
J *= K / i;
dNew = dOld + J * J;
if ((dNew - dOld) < M_EPS)
{
converge = true;
break;
}
dOld = dNew;
}
if (!converge)
return 0;
return dNew;
}
std::vector<double> kaiser(int n, double alpha)
{
std::vector<double> win(n);
for (int i = 0; i < (n + 1) / 2; ++i)
{
double beta = 2 * alpha * sqrt(i * (n - i - 1.0)) / (n - 1.0);
win[i] = I0(beta) / I0(alpha);
win[n - 1 - i] = win[i];
}
return win;
}
1.本功能函数测试用例计算结果与matlab kaiser(64,0.5)函数同参数计算结果曲线对比
2.计算结果部分数值对比