/* Fttest.c Test case for two-dimensional Fourier transform. From Claerbout (1985) p. 69. Usage: fttest >outfile Compile: cc fttest.c ft2d.c fft.c -lm -o fttest */ /* Get the usual standard output and math definitions */ #include #include /* Declare the structure to hold complex numbers */ struct complex { float re; float im; }; /* Enter main part of program */ main(ac, av) int ac; char **av; { /* Declare all variables */ int it, nt, ix, nx; /* float p[64][64]; struct complex cp[64][64], cwork[64]; * Use rows of time * */ float *p, *cwork; struct complex *cp; /* Assign sizes */ if (ac < 2 || ac > 3) nx = 512; else nx = atoi(av[1]); if (ac == 3) nt = atoi(av[2]); else nt = nx; cp = (struct complex *)malloc(nx*nt*sizeof(struct complex)); allocerr(cp, nx*nt*sizeof(struct complex), "cp"); p = (float *)malloc(nx*nt*sizeof(float)); allocerr(p, nx*nt*sizeof(float), "p"); cwork = (float *)malloc(nx*nt*sizeof(float)); allocerr(cwork, nx*nt*sizeof(float), "cwork"); /* Nested loops to set complex array to zero; time varies fastest */ for(ix=0; ix 100000000) fprintf(EROUT, "Don't be so greedy!\n"); exit(-1); } return(0); }