/* nag_gen_complx_mat_print (x04dac) Example Program.
*
* NAGPRODCODE Version.
*
* Copyright 2016 Numerical Algorithms Group.
*
* Mark 26, 2016.
*/
#include <nag.h>
#include <nag_stdlib.h>
#include <naga02.h>
#include <nagf01.h>
#include <nagx04.h>
int main(void)
{
Integer exit_status = 0, n = 5;
Integer i, j, pda;
double aa;
Complex *a = 0;
/* Nag Types */
Nag_OrderType order;
NagError fail;
#ifdef NAG_COLUMN_MAJOR
#define A(I, J) a[(J-1)*pda + I-1]
order = Nag_ColMajor;
#else
#define A(I, J) a[(I-1)*pda + J-1]
order = Nag_RowMajor;
#endif
INIT_FAIL(fail);
printf("nag_gen_complx_mat_print (x04dac) Example Program Results\n\n");
pda = n;
if (!(a = NAG_ALLOC(pda * n, Complex))) {
printf("Allocation failure\n");
exit_status = -1;
goto END;
}
/* Generate a full-format symmetric array of data. */
for (i = 1; i <= n; i++) {
for (j = 1; j <= n; j++) {
aa = (double) (10 * i + j);
A(i, j) = nag_complex(aa, -aa);
}
}
/* Print n by (n-1) rectangular matrix
* using nag_geb_complx_mat_print (x04dac).
*/
fflush(stdout);
nag_gen_complx_mat_print(order, Nag_GeneralMatrix, Nag_NonUnitDiag, n, n - 1,
a, pda, "Example 1:", NULL, &fail);
if (fail.code != NE_NOERROR) {
printf("Error from nag_gen_complx_mat_print (x04dac).\n%s\n",
fail.message);
exit_status = 1;
goto END;
}
printf("\n");
/* Print the order-n upper-triangular matrix with Unit diagonal
* using nag_gen_complx_mat_print (x04dac).
*/
fflush(stdout);
nag_gen_complx_mat_print(order, Nag_UpperMatrix, Nag_UnitDiag, n, n,
a, pda, "Example 2:", NULL, &fail);
if (fail.code != NE_NOERROR) {
printf("Error from nag_gen_complx_mat_print (x04dac).\n%s\n",
fail.message);
exit_status = 2;
goto END;
}
printf("\n");
END:
NAG_FREE(a);
return exit_status;
}