/* nag_ftt_multid_full(c06pjc) Example Program * * Copyright 2002 Numerical Algorithms Group. * * Mark 7, 2002. */ #include #include #include #include #include int main(void) { /* Scalars */ Integer i, n, ndim; Integer exit_status=0; NagError fail; /* Arrays */ Complex *x=0; Integer *nd=0; INIT_FAIL(fail); Vprintf("c06pjc Example Program Results\n"); /* Skip heading in data file */ Vscanf("%*[^\n]"); Vscanf("%ld%ld", &ndim, &n); if (n >= 1) { /* Allocate memory */ if ( !(x = NAG_ALLOC(n, Complex)) || !(nd = NAG_ALLOC(ndim, Integer)) ) { Vprintf("Allocation failure\n"); exit_status = -1; goto END; } for (i = 0; i < ndim; ++i) { Vscanf("%ld",&nd[i]); } /* Read in complex data and print out. */ Vscanf("%*[^\n]"); for (i = 0; i < n; ++i) { Vscanf(" ( %lf, %lf ) ", &x[i].re, &x[i].im); } Vscanf("%*[^\n]"); Vprintf("\n"); x04dbc(Nag_ColMajor, Nag_GeneralMatrix, Nag_NonUnitDiag, nd[0], n/nd[0], x, nd[0], Nag_BracketForm, "%6.3f", "Original data values\n", Nag_NoLabels, 0, Nag_NoLabels, 0, 90, 0, 0, &fail); if (fail.code != NE_NOERROR) { Vprintf("Error from x04dbc.\n%s\n", fail.message); exit_status = 1; goto END; } /* Compute transform */ c06pjc(Nag_ForwardTransform, ndim, nd, n, x, &fail); if (fail.code != NE_NOERROR) { Vprintf("Error from c06pjc.\n%s\n", fail.message); exit_status = 1; goto END; } Vprintf("\n"); x04dbc(Nag_ColMajor, Nag_GeneralMatrix, Nag_NonUnitDiag, nd[0], n/nd[0], x, nd[0], Nag_BracketForm, "%6.3f", "Components of discrete Fourier transform\n", Nag_NoLabels, 0, Nag_NoLabels, 0, 90, 0, 0, &fail); if (fail.code != NE_NOERROR) { Vprintf("Error from x04dbc.\n%s\n", fail.message); exit_status = 1; goto END; } /* Compute inverse transform */ c06pjc(Nag_BackwardTransform, ndim, nd, n, x, &fail); if (fail.code != NE_NOERROR) { Vprintf("Error from c06pjc.\n%s\n", fail.message); exit_status = 1; goto END; } Vprintf("\n"); x04dbc(Nag_ColMajor, Nag_GeneralMatrix, Nag_NonUnitDiag, nd[0], n/nd[0], x, nd[0], Nag_BracketForm, "%6.3f", "Original data as restored by inverse transform\n", Nag_NoLabels, 0, Nag_NoLabels, 0, 90, 0, 0, &fail); if (fail.code != NE_NOERROR) { Vprintf("Error from x04dbc.\n%s\n", fail.message); exit_status = 1; goto END; } } else { Vfprintf(stderr,"\nInvalid value of n.\n"); } END: if (x) NAG_FREE(x); if (nd) NAG_FREE(nd); return exit_status; }