複素数の絶対値について
このプログラムでx2[i]y2[i]の絶対値の2乗がほしいんですけどどうすればよろしいで
しょうか??
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#define PI 3.14159265358979323846
/*省略*/
/* FFT main routine */
int fft(n, x, y)
/*省略*/
/*** Main Program ***/
#define N 256
int main(argc, argv)
int argc;
char *argv[];
{
FILE *fp;
int i;
static float x1[N], y1[N], x2[N], y2[N], x3[N], y3[N];
if ((fp = fopen(c1.txt, "r")) ==NULL){
printf ("File Open Error \"%s \" file.\n", c1.txt);
exit(1);
}
for (i = 0; i < N; i++) {
fscanf(fp, "%f", &x1[i]);
x2[i] = x1[i] ;
y1[i] = y2[i] = 0;
}
if (fft(N, x2, y2)) return EXIT_FAILURE;
for (i = 0; i < N; i++) {
x3[i] = x2[i]; y3[i] = y2[i];
}
if (fft(-N, x3, y3)) return EXIT_FAILURE;
printf(" Original data Fourier Transformed Inverse Transformed\n");
for (i = 0; i < N; i++)
printf("%4d | %6.3f %6.3f | %6.3f %6.3f | %6.3f %6.3f\n",
i, x1[i], y1[i], x2[i], y2[i], x3[i], y3[i]);
return EXIT_SUCCESS;
}