fouriertransform.cpp

来自「这是一个非常经典的FourierTransform 算法比较有新意」· C++ 代码 · 共 37 行

CPP
37
字号
// FourierTransform.cpp : Defines the entry point for the console application.
//

#include "stdafx.h"
#include "FastFourier.h"

Complex E(double x, int k)
{
	return Complex(cos(k*x), sin(k*x));
}

//教材中P362的函数f
Complex f(double x)
{
	Complex sum(0, 0);
	for(int i = 0; i < 8; i++)
		sum += (i+1)*E(x, i);

	return sum;
}

int main(int argc, char* argv[])
{
	int m = 3;
	int N = (int)pow(2, m);
	Complex *C = new Complex[N];

	FastFourierTransform(m, f, C);

	for(int i = 0; i < 8; i++)
		cout << C[i] << endl;
	
	return 0;
}


⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?