static void make_sintbl(int n, float sintbl[])
{
int i, n2, n4, n8;
double c, s, dc, ds, t;
n2 = n / 2; n4 = n / 4; n8 = n / 8;
t = sin(PI / n);
dc = 2 * t * t; ds = sqrt(dc * (2 - dc));
t = 2 * dc; c = sintbl[n4] = 1; s = sintbl[0] = 0;
for (i = 1; i < n8; i++) {
c -= dc; dc += t * c;
s += ds; ds -= t * s;
sintbl[i] = (float)s;
sintbl[n4 - i] = (float)c;
}
if (n8 != 0) sintbl[n8] = (float)sqrt(0.5);
for (i = 0; i < n4; i++)
sintbl[n2 - i] = sintbl[i];
for (i = 0; i < n2 + n4; i++)
sintbl[i + n2] = - sintbl[i];
}
static void make_sintbl(int n, float sintbl[])
{
int i, n2, n4, n8;
double c, s, dc, ds, t;
n2 = n / 2; n4 = n / 4; n8 = n / 8;
t = sin(PI / n);
dc = 2 * t * t; ds = sqrt(dc * (2 - dc));
t = 2 * dc; c = sintbl[n4] = 1; s = sintbl[0] = 0;
for (i = 1; i < n8; i++) {
c -= dc; dc += t * c;
s += ds; ds -= t * s;
sintbl[i] = (float)s;
sintbl[n4 - i] = (float)c;
}
if (n8 != 0) sintbl[n8] = (float)sqrt(0.5);
for (i = 0; i < n4; i++)
sintbl[n2 - i] = sintbl[i];
for (i = 0; i < n2 + n4; i++)
sintbl[i + n2] = - sintbl[i];
}
C言語による最新アルゴリズム辞典:奥村晴彦著:技術評論社より
※ 同書の該当部分に「標本点の数 n は2の整数乗に限る」との記載あり