→フーリエ変換 →フーリエ逆変換
→離散フーリエ変換 →離散逆フーリエ変換
→時間離散フーリエ変換 →時間離散逆フーリエ変換
kill(all)$ N:8$ k:makelist(k-N/2,k,0,N);
T:1$ f0:1/T$ x:1$ a:1/2$
R(t):=if abs(t)<= a/2 then 1 else 0$
wxplot2d(R(t),[t,-T/2,T/2],[y,-0.2,1.2],[xlabel,"t"],[ylabel,"Amplitude"]);
j:%i$ omega:2*%pi*f0$
Ck:(1/T)*integrate(x*exp(-j*omega*k*t),t,-a/2,a/2);
wxplot2d([discrete,k/T,realpart(Ck)],[style,[points,2,1,1]],[xlabel,"f[Hz]"],[ylabel,"Ck"]);
wxplot2d([realpart(Ck.exp(j*omega*k*t)),R(t)],[t,-T/2,T/2],[ylabel,"Amplitude"]);
N:16$ k:makelist(k-N/2,k,0,N);
Ck:(1/T)*integrate(x*exp(-j*omega*k*t),t,-a/2,a/2);
wxplot2d([discrete,k/T,realpart(Ck)],[style,[points,2,1,1]],[xlabel,"f[Hz]"],[ylabel,"Ck"]);
wxplot2d([realpart(Ck.exp(j*omega*k*t)),R(t)],[t,-T/2,T/2],[ylabel,"Amplitude"]);
N:32$ k:makelist(k-N/2,k,0,N);
Ck:(1/T)*integrate(x*exp(-j*omega*k*t),t,-a/2,a/2);
wxplot2d([discrete,k/T,realpart(Ck)],[style,[points,2,1,1]],[xlabel,"f[Hz]"],[ylabel,"Ck"]);
wxplot2d([realpart(Ck.exp(j*omega*k*t)),R(t)],[t,-T/2,T/2],[ylabel,"Amplitude"]);
→時間離散フーリエ変換 →時間離散逆フーリエ変換
kill(all)$
x:[0,0,1,1,1,0,0,0];
N:length(x)$ Ts:1/N$
n:makelist(n,n,0,N-1); t:Ts*n;
wxplot2d([discrete,n-3,x],[y,-0.2,1.2],[style,[points,2,1,1]]);
Xs:sum(exp(-%i*w*Ts*n)*x[n+1],n,0,N-1);
wxplot2d(abs(Xs),[w,-4*%pi/Ts,4*%pi/Ts]);
xo:expand(Ts*integrate(exp(%i*w*Ts*n)*Xs,w,-%pi/Ts,%pi/Ts)/(2*%pi));
a:3/8$ N:8$ Ts:1/N$
wxplot2d([sin(a*w/2)/(w/2)],[w,-10*%pi/Ts,10*%pi/Ts],[y,-0.2,0.5]);
kill(all)$
x:[0,0,1,1,1,0,0,0];
N:length(x)$ Ts:1/N$
n:makelist(n,n,0,N-1); t:Ts*n;
Xs:sum(exp(-%i*w*Ts*(n-3))*x[n+1],n,0,N-1);
wxplot2d(Xs,[w,-4*%pi/Ts,4*%pi/Ts]);
a:3/8$
wxplot2d([sin(a*w/2)/(w/2),realpart(Xs)*Ts],[w,-4*%pi/Ts,4*%pi/Ts],[y,-0.2,0.5]);
x:[0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,0];
N:length(x)$ Ts:1/N$
n:makelist(n,n,0,N-1); t:Ts*n;
wxplot2d([discrete,n-N/2+1,x],[y,-0.2,1.2],[style,[points,2,1,1]]);
Xs:sum(exp(-%i*w*Ts*(n-N/2+1))*x[n+1],n,0,N-1);
wxplot2d(realpart(Xs),[w,-4*%pi/Ts,4*%pi/Ts]);
a:3/8$
wxplot2d([sin(a*w/2)/(w/2),realpart(Xs)*Ts],[w,-4*%pi/Ts,4*%pi/Ts],[y,-0.2,0.5]);
% pulse 128 1 | gp_pulse2 > p128_1w.png
% pulse 128 1 | fftw | gp_fftl > p128_1fft.png
% pulse 128 2 | gp_pulse2 > p128_2w.png
% pulse 128 2 | fftw | gp_fftl > p128_2fft.png
% pulse 128 3 | gp_pulse2 > p128_3w.png
% pulse 128 3 | fftw | gp_fftl > p128_3fft.png
% pulse 128 4 | gp_pulse2 > p128_4w.png
% pulse 128 4 | fftw | gp_fftl > p128_4fft.png
% pulse 128 8 | gp_pulse2 > p128_8w.png
% pulse 128 8 | fftw | gp_fftl > p128_8fft.png
% pulse 128 16 | gp_pulse2 > p128_16w.png
% pulse 128 16 | fftw | gp_fftl > p128_16fft.png
% pulse 128 128 | gp_pulse2 > p128_128w.png
% pulse 128 128 | fftw | gp_fftlx > p128_128fft.png
% white0 1000000 1 | fftw | head -40 | gp_fftl > w1_1fft.png
% white0 1000000 1 | gp_wav2 > w1_1w.png
% white0 1000000 2 | fftw | head -40 | gp_fftl > w1_2fft.png
% white0 1000000 2 | gp_wav2 > w1_2w.png
% white0 1000000 3 | fftw | head -40 | gp_fftl > w1_3fft.png
% white0 1000000 3 | gp_wav2 > w1_3w.png
% white0 1000000 4 | fftw | head -40 | gp_fftl > w1_4fft.png
% white0 1000000 4 | gp_wav2 > w1_4w.png
% white0 1000000 8 | fftw | head -40 | gp_fftl > w1_8fft.png
% white0 1000000 8 | gp_wav2 > w1_8w.png
% white0 1000000 16 | fftw | head -40 | gp_fftl > w1_16fft.png
% white0 1000000 16 | gp_wav2 > w1_16w.png
% white0 1000000 100 | fftw | head -200 | gp_fftl > w1_100fft.png
% white0 1000000 100 | gp_wav2 > w1_100w.png
% white0 1000000 100 100 | fftw | head -120 | tail -25 | gp_fftl > w100_100fft.png
% white0 1000000 100 100 | gp_wav2 > w100_100w.png
% white0 1000000 101 100 | fftw | head -120 | tail -25 | gp_fftl > w100_101fft.png
% white0 1000000 101 100 | gp_wav2 > w100_101w.png
% white0 1000000 102 100 | fftw | head -120 | tail -25 | gp_fftl > w100_102fft.png
% white0 1000000 102 100 | gp_wav2 > w100_102w.png
% white0 1000000 103 100 | fftw | head -120 | tail -25 | gp_fftl > w100_103fft.png
% white0 1000000 103 100 | gp_wav2 > w100_103w.png
% white0 1000000 107 100 | fftw | head -120 | tail -25 | gp_fftl > w100_107fft.png
% white0 1000000 107 100 | gp_wav2 > w100_107w.png
% white0 1000000 115 100 | fftw | head -120 | tail -25 | gp_fftl > w100_115fft.png
% white0 1000000 115 100 | gp_wav2 > w100_115w.png
#include<stdio.h>
#include<math.h>
#define TAP 301
#define N 1000000
double para[N];
double buff[N];
double sinc(double x) {
if (!x) return 1;
return sin(M_PI*x)/(M_PI*x);
}
int make_para(int tap, int z)
{
double d;
int t, n=0;
d = (double)z*2/(tap-1);
for (t=-(tap-1)/2; t<=(tap-1)/2 ;t++) {
para[n++] = sinc(t*d);
if (n>=N) break;
}
return n;
}
main( int argc, char *argv[] )
{
int z, tap, s, n, i=0, x;
double in, out;
tap = TAP;
z = 10;
s = 0;
if (argc>1)
z = atoi(argv[1]);
if (argc>2)
tap = atoi(argv[2]);
if (argc>3)
s = atoi(argv[3]);
if (z<1 || tap<2) return;
n = make_para(tap,z);
if (!s) {
while(fscanf(stdin,"%lf",&in)!=EOF) {
buff[i] = in;
out = 0;
for (x=0; x<n ;x++)
out += buff[(x+i+n)%n] * para[x];
printf("%lf\n",out);
i = (i+1)%n;
}
}
else {
for (x=0; x<s ;x++)
printf("%lf\n",para[x]);
for (; x<s ;x++)
printf("%lf\n",0.0);
}
}
% sincf 10 301 301 | gp_wav2 > sinc10_301.png
% sincf 10 301 301 | fftw | gp_fftl > sinc10_301fft.png
% sincf 20 301 301 | gp_wav2 > sinc20_301.png
% sincf 20 301 301 | fftw | gp_fftl > sinc20_301fft.png
% sincf 40 301 301 | gp_wav2 > sinc40_301.png
% sincf 40 301 301 | fftw | gp_fftl > sinc40_301fft.png
% sincf 80 301 301 | gp_wav2 > sinc80_301.png
% sincf 80 301 301 | fftw | gp_fftl > sinc80_301fft.png
% sincf 100 301 301 | gp_wav2 > sinc100_301.png
% sincf 100 301 301 | fftw | gp_fftl > sinc100_301fft.png
% sincf 140 301 301 | gp_wav2 > sinc140_301.png
% sincf 140 301 301 | fftw | gp_fftl > sinc140_301fft.png
% sincf 149 301 301 | gp_wav2 > sinc149_301.png
% sincf 149 301 301 | fftw | gp_fftl > sinc149_301fft.png
% sincf 150 301 301 | gp_wav2 > sinc150_301.png
% sincf 150 301 301 | fftw | gp_fftl > sinc150_301fft.png
% sincf 10 301 301 | gp_wav2 > sinc10_301.png
% sincf 10 301 301 | fftw | gp_fftl > sinc10_301fft.png
% sincf 10 301 302 | gp_wav2 > sinc10_301_302s.png
% sincf 10 301 302 | fftw | gp_fftl > sinc10_301_302sfft.png
% sincf 10 301 303 | gp_wav2 > sinc10_301_303s.png
% sincf 10 301 303 | fftw | gp_fftl > sinc10_301_303sfft.png
% sincf 10 301 400 | gp_wav2 > sinc10_301_400s.png
% sincf 10 301 400 | fftw | gp_fftl > sinc10_301_400sfft.png
% sincf 10 301 1000 | gp_wav2 > sinc10_301_1ks.png
% sincf 10 301 1000 | fftw | gp_fftl > sinc10_301_1ksfft.png
% sincf 10 301 10000 | gp_wav2 > sinc10_301_10ks.png
% sincf 10 301 10000 | fftw | gp_fftl > sinc10_301_10ksfft.png
% sincf 10 301 100000 | gp_wav2 > sinc10_301_100ks.png
% sincf 10 301 100000 | fftw | gp_fftl > sinc10_301_100ksfft.png
% sincf 10 301 1000000 | gp_wav2 > sinc10_301_1Ms.png
% sincf 10 301 1000000 | fftw | gp_fftl > sinc10_301_1Msfft.png
% sincf 10 301 1000000 | gp_wav2 > sinc10_301_1Ms.png
% sincf 10 301 1000000 | fftw | gp_fftl > sinc10_301_1Msfft.png
% sincf 10 302 1000000 | gp_wav2 > sinc10_302_1Ms.png
% sincf 10 302 1000000 | fftw | gp_fftl > sinc10_302_1Msfft.png
% sincf 10 1000 1000000 | gp_wav2 > sinc10_1k_1Ms.png
% sincf 10 1000 1000000 | fftw | gp_fftl > sinc10_1k_1Msfft.png
% sincf 10 10000 1000000 | gp_wav2 > sinc10_10k_1Ms.png
% sincf 10 10000 1000000 | fftw | gp_fftl > sinc10_10k_1Msfft.png
% sincf 10 100000 1000000 | gp_wav2 > sinc10_100k_1Ms.png
% sincf 10 100000 1000000 | fftw | gp_fftl > sinc10_100k_1Msfft.png
% sincf 10 1000000 1000000 | gp_wav2 > sinc10_1M_1Ms.png
% sincf 10 1000000 1000000 | fftw | gp_fftl > sinc10_1M_1Msfft.png