cout << setiosflags(ios::fixed) << setprecision(6) <<sum.real << "\t" << sum.imag << endl;
#if 1
#include <stdio.h>
#include <complex.h>
#include <fftw3.h>
#include <math.h>
#include<stdlib.h>
#include <string.h>
#include<iostream>
#include<iomanip>
using namespace std;
static void swap(double *v1, double *v2)
{
double tmp = *v1;
*v1 = *v2;
*v2 = tmp;
}
void fftshift(double *data, int count)
{
int k = 0;
int c = (int)floor((float)count / 2);
// For odd and for even numbers of element.We are useing different algorithm Here.
if (count % 2 == 0)//This is for Even Count
{
for (k = 0; k < c; k++)
swap(&data[k], &data[k + c]);
}
else // This is for Odd Count
{
double tmp = data[0];
for (k = 0; k < c; k++)
{
data[k] = data[c + k + 1];
data[c + k + 1] = data[k + 1];
}
data[c] = tmp;
}
}
void ifftshift(double *data, int count) //This is used for Circular shift of Complex values.
{
int k = 0;
int c = (int)floor((float)count / 2);
if (count % 2 == 0)
{
for (k = 0; k < c; k++)
swap(&data[k], &data[k + c]);
}
else
{
double tmp = data[count - 1];
for (k = c - 1; k >= 0; k--)
{
data[c + k + 1] = data[k];
data[k] = data[c + k];
}
data[c] = tmp;
}
}
void main()
{
//static
double *aa; int count; double Fs = 100e6;
aa = (double *)malloc(sizeof(double) * 3997);
for (int i = 0; i < 3997; i++)
aa[i] = i + 1 - (3997.0) / 2 ;
fftshift(aa, 3997);
for (int i = 0; i < 3997; i++)
aa[i] = aa[i] / 3997.0*Fs;
cout << setiosflags(ios::fixed) << setprecision(15) << aa[0] << endl;
return;
}
#endif