diff --git a/numerical_methods/fast_fourier_transform.cpp b/numerical_methods/fast_fourier_transform.cpp index 8d7df6b22..79edfed16 100644 --- a/numerical_methods/fast_fourier_transform.cpp +++ b/numerical_methods/fast_fourier_transform.cpp @@ -15,7 +15,6 @@ #include///For storing points and coefficents #include ///For Assertions # define pi 3.14159265358979323846 -using namespace std; /** * @brief FastFourierTransform is a recursive function which returns list of complex numbers @@ -25,16 +24,16 @@ using namespace std; * @returns y if n!=1 */ -complex* FastFourierTransform(complex*p,int n) +std::complex* FastFourierTransform(std::complex*p,int n) { if(n==1) return p; ///Base Case To return - complex om=complex(cos(2*pi/n),sin(2*pi/n)); ///Calculating value of omega + std::complex om=std::complex(cos(2*pi/n),sin(2*pi/n)); ///Calculating value of omega - complex *pe= new complex[n/2]; /// Coefficents of even power + std::complex *pe= new std::complex[n/2]; /// Coefficents of even power - complex *po= new complex[n/2]; ///Coefficents of odd power + std::complex *po= new std::complex[n/2]; ///Coefficents of odd power int k1=0,k2=0; for(int j=0;j* FastFourierTransform(complex*p,int n) } - complex*ye=FastFourierTransform(pe,n/2);///Recursive Call + std::complex*ye=FastFourierTransform(pe,n/2);///Recursive Call - complex*yo=FastFourierTransform(po,n/2);///Recursive Call + std::complex*yo=FastFourierTransform(po,n/2);///Recursive Call - complex*y=new complex[n];///Final value representation list + std::complex*y=new std::complex[n];///Final value representation list for(int i=0;i* FastFourierTransform(complex*p,int n) static void test() { /* descriptions of the following test */ - complex t1[2]={1,2};///Test case 1 + std::complex t1[2]={1,2};///Test case 1 - complex t2[4]={1,2,3,4};///Test case 2 + std::complex t2[4]={1,2,3,4};///Test case 2 - int n1=sizeof(t1)/sizeof(complex); - int n2=sizeof(t2)/sizeof(complex); + int n1=sizeof(t1)/sizeof(std::complex); + int n2=sizeof(t2)/sizeof(std::complex); - complex r1[2]={{3,0},{-1,0} };///True Answer for test case 1 + std::complex r1[2]={{3,0},{-1,0} };///True Answer for test case 1 - complex r2[4]={{10,0},{-2,-2},{-2,0},{-2,2} };///True Answer for test case 2 + std::complex r2[4]={{10,0},{-2,-2},{-2,0},{-2,2} };///True Answer for test case 2 - complex *o1=FastFourierTransform(t1,n1); - complex *o2=FastFourierTransform(t2,n2); + std::complex *o1=FastFourierTransform(t1,n1); + std::complex *o2=FastFourierTransform(t2,n2); for(int i=0;i