aboutsummaryrefslogtreecommitdiffstats
path: root/test/c/fft.c
diff options
context:
space:
mode:
Diffstat (limited to 'test/c/fft.c')
-rw-r--r--test/c/fft.c36
1 files changed, 19 insertions, 17 deletions
diff --git a/test/c/fft.c b/test/c/fft.c
index 884a8568..a4755044 100644
--- a/test/c/fft.c
+++ b/test/c/fft.c
@@ -143,13 +143,13 @@ int dfft(double x[], double y[], int np)
/* Test harness */
-double * xr, * xi;
+#define NRUNS 20
int main(int argc, char ** argv)
{
- int n, np, npm, n2, i, j;
+ int n, np, npm, n2, i, j, nruns;
double enp, t, y, z, zr, zi, zm, a;
- double * pxr, * pxi;
+ double * xr, * xi, * pxr, * pxi;
if (argc >= 2) n = atoi(argv[1]); else n = 18;
np = 1 << n;
@@ -160,21 +160,23 @@ int main(int argc, char ** argv)
xi = calloc(np, sizeof(double));
pxr = xr;
pxi = xi;
- *pxr = (enp - 1.0) * 0.5;
- *pxi = 0.0;
- n2 = np / 2;
- *(pxr+n2) = -0.5;
- *(pxi+n2) = 0.0;
- for (i = 1; i <= npm; i++) {
- j = np - i;
- *(pxr+i) = -0.5;
- *(pxr+j) = -0.5;
- z = t * (double)i;
- y = -0.5*(cos(z)/sin(z));
- *(pxi+i) = y;
- *(pxi+j) = -y;
+ for (nruns = 0; nruns < NRUNS; nruns++) {
+ *pxr = (enp - 1.0) * 0.5;
+ *pxi = 0.0;
+ n2 = np / 2;
+ *(pxr+n2) = -0.5;
+ *(pxi+n2) = 0.0;
+ for (i = 1; i <= npm; i++) {
+ j = np - i;
+ *(pxr+i) = -0.5;
+ *(pxr+j) = -0.5;
+ z = t * (double)i;
+ y = -0.5*(cos(z)/sin(z));
+ *(pxi+i) = y;
+ *(pxi+j) = -y;
+ }
+ dfft(xr,xi,np);
}
- dfft(xr,xi,np);
zr = 0.0;
zi = 0.0;
npm = np-1;