?? fouriertransform.cpp
字號(hào):
//FourierTransform.cpp 快速傅里葉變換
#include <iostream> //模板類輸入輸出流標(biāo)準(zhǔn)頭文件
#include <Transform.h> //數(shù)學(xué)變換頭文件
using namespace std; //名字空間
void main(void)
{
valarray< complex<long double> > p(64);
valarray< complex<long double> > f(64);
for(int i = 0; i < 64; i++)
{
p[i] = complex<long double>(exp(-0.1*(i+0.5)), 0.0);
}
cout << "序列Pi(i=0,1,...,63):" << endl;
for(i = 0; i< 16; i++)
{
for(int j = 0; j < 4; j++)
cout << " " << p[4 * i + j] << " ";
cout << endl;
}
cout << endl;
cout.setf(ios::fixed); //輸出數(shù)據(jù)為定點(diǎn)法
cout.precision(6); //精度6位
FourierTransform(p, f, 0, 1);
cout << "Pi的傅里葉變換Fi(i=0,1,...,63):" << endl;
for(i = 0; i<32; i++)
{
for(int j = 0; j<2; j++)
cout << " " << f[2*i+j]<< "\t";
cout << endl;
}
cout << endl;
cout << "Pi的傅里葉變換Fi(i=0,1,...,63)的模:" << endl;
for(i=0; i<16; i++)
{
for(int j=0; j<4; j++)
cout << " " << p[4*i+j].real() << "\t";
cout << endl;
}
cout << endl;
cout << "Pi的傅里葉變換Fi(i=0,1,...,63)的幅角(單位為度):" << endl;
for(i=0; i<16; i++)
{
for(int j=0; j<4; j++)
cout << " " << p[4*i+j].imag() << "\t";
cout << endl;
}
cout << endl;
FourierTransform(f, p, 1, 1);
cout << "Fi的逆傅里葉變換Pi(i=0,1,...,63)的模:" << endl;
for(i=0; i<16; i++)
{
for(int j=0; j<4; j++)
cout << " " << f[4*i+j].real() << "\t";
cout << endl;
}
cout << endl;
}
?? 快捷鍵說(shuō)明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -