一维傅立叶变化对应程序里面的一维:
二维傅立叶变化对应程序里面的二维:
#include
#include
using namespace std;
float fx[4] = {1, 2, 4, 4};
float fxReal[4] = {0, 0, 0, 0};
float fxImag[4] = {0, 0, 0, 0};
float Real[4] = {0, 0, 0, 0};
float Imag[4] = {0, 0, 0, 0};
float e = 2.72;
float pi = 3.14;
float fxTwo[4][4] = {{1, 2, 4, 4},
{1, 2, 4, 4},
{1, 2, 4, 4},
{1, 2, 4, 4}};
float fxRealTwo[4][4] = {{0, 0, 0, 0},
{0, 0, 0, 0},
{0, 0, 0, 0},
{0, 0, 0, 0}};
float fxImagTwo[4][4] = {{0, 0, 0, 0},
{0, 0, 0, 0},
{0, 0, 0, 0},
{0, 0, 0, 0}};
float RealTwo[4][4] = {{0, 0, 0, 0},
{0, 0, 0, 0},
{0, 0, 0, 0},
{0, 0, 0, 0}};
float ImagTwo[4][4] = {{0, 0, 0, 0},
{0, 0, 0, 0},
{0, 0, 0, 0},
{0, 0, 0, 0}};
int main(int argc, char *argv[])
{
/*一维傅里叶变换*/
for (int j = 0; j < 4; j++)
{
for (int i = 0;i < 4;i++)
{
Real[j] += fx[i] * cos(-2 * pi * j * i / 4);
Imag[j] += fx[i] * sin(-2 * pi * j * i / 4);
}
}
for (int i = 0; i < 4; i++)
{
cout <<"Real:"<