/* nag_sum_fft_complex_1d_multi_col (c06psc) Example Program.
*
* Copyright 2022 Numerical Algorithms Group.
*
* Mark 28.5, 2022.
*/
#include <nag.h>
#include <stdio.h>
int main(void) {
/* Scalars */
Integer exit_status = 0, i, m, n;
/* Arrays */
Complex *x = 0;
char title[60];
/* Nag Types */
NagError fail;
INIT_FAIL(fail);
printf(
"nag_sum_fft_complex_1d_multi_col (c06psc) Example Program Results\n\n");
fflush(stdout);
/* Read dimensions of array and array values from data file. */
scanf("%*[^\n] %" NAG_IFMT "%" NAG_IFMT "%*[^\n]", &m, &n);
if (!(x = NAG_ALLOC((m * n), Complex))) {
printf("Allocation failure\n");
exit_status = -1;
goto END;
}
for (i = 0; i < m * n; i++)
scanf(" ( %lf , %lf ) ", &x[i].re, &x[i].im);
/* nag_file_print_matrix_complex_gen_comp (x04dbc).
* Print complex general matrix (comprehensive).
*/
sprintf(title, "Original data values\n");
nag_file_print_matrix_complex_gen_comp(
Nag_RowMajor, Nag_GeneralMatrix, Nag_NonUnitDiag, m, n, x, n,
Nag_AboveForm, "%7.4f", title, Nag_NoLabels, 0, Nag_NoLabels, 0, 80, 0,
NULL, &fail);
if (fail.code != NE_NOERROR) {
printf("Error from nag_file_print_matrix_complex_gen_comp (x04dbc).\n%s\n",
fail.message);
exit_status = 1;
goto END;
}
/* nag_sum_fft_complex_1d_multi_col (c06psc).
* Multiple one-dimensional complex discrete Fourier transform (Forward).
*/
nag_sum_fft_complex_1d_multi_col(Nag_ForwardTransform, n, m, x, &fail);
if (fail.code != NE_NOERROR) {
printf("Error from nag_sum_fft_complex_1d_multi_col (c06psc).\n%s\n",
fail.message);
exit_status = 2;
goto END;
}
sprintf(title, "Components of discrete Fourier transform\n");
nag_file_print_matrix_complex_gen_comp(
Nag_RowMajor, Nag_GeneralMatrix, Nag_NonUnitDiag, m, n, x, n,
Nag_AboveForm, "%7.4f", title, Nag_NoLabels, 0, Nag_NoLabels, 0, 80, 0,
NULL, &fail);
if (fail.code != NE_NOERROR) {
printf("Error from nag_file_print_matrix_complex_gen_comp (x04dbc).\n%s\n",
fail.message);
exit_status = 3;
goto END;
}
/* nag_sum_fft_complex_1d_multi_col (c06psc).
* Multiple one-dimensional complex discrete Fourier transform (Backward).
*/
nag_sum_fft_complex_1d_multi_col(Nag_BackwardTransform, n, m, x, &fail);
if (fail.code != NE_NOERROR) {
printf("Error from nag_sum_fft_complex_1d_multi_col (c06psc).\n%s\n",
fail.message);
exit_status = 4;
goto END;
}
sprintf(title, "Original sequence as restored by inverse transform\n");
nag_file_print_matrix_complex_gen_comp(
Nag_RowMajor, Nag_GeneralMatrix, Nag_NonUnitDiag, m, n, x, n,
Nag_AboveForm, "%7.4f", title, Nag_NoLabels, 0, Nag_NoLabels, 0, 80, 0,
NULL, &fail);
if (fail.code != NE_NOERROR) {
printf("Error from nag_file_print_matrix_complex_gen_comp (x04dbc).\n%s\n",
fail.message);
exit_status = 5;
}
END:
NAG_FREE(x);
return exit_status;
}