```/* nag_ztfsm (f16zlc) Example Program.
*
* NAGPRODCODE Version.
*
* Copyright 2016 Numerical Algorithms Group.
*
* Mark 26, 2016.
*/

#include <nag.h>
#include <nag_stdlib.h>
#include <nagf01.h>
#include <nagf16.h>
#include <nagx04.h>

int main(void)
{
/* Scalars */
Integer exit_status = 0;
Complex alpha;
Integer i, j, m, n, pda, pdb;
/* Arrays */
Complex *a = 0, *ar = 0, *b = 0;
char nag_enum_arg[40];
/* Nag Types */
Nag_OrderType order;
Nag_RFP_Store transr;
Nag_SideType side;
Nag_UploType uplo;
Nag_TransType trans;
NagError fail;

INIT_FAIL(fail);

printf("nag_ztfsm (f16zlc) Example Program Results\n");
/* Skip heading in data file */
scanf("%*[^\n] ");
scanf("%" NAG_IFMT "%" NAG_IFMT "%*[^\n] ", &m, &n);
pda = m;

#ifdef NAG_COLUMN_MAJOR
order = Nag_ColMajor;
pdb = m;
#define A(I, J) a[(J-1)*pda + I-1]
#define B(I, J) b[(J-1)*pdb + I-1]
#else
order = Nag_RowMajor;
pdb = n;
#define A(I, J) a[(I-1)*pda + J-1]
#define B(I, J) b[(I-1)*pdb + J-1]
#endif

if (!(a = NAG_ALLOC(pda * m, Complex)) ||
!(ar = NAG_ALLOC((m * (m + 1)) / 2, Complex)) ||
!(b = NAG_ALLOC(m * n, Complex)))
{
printf("Allocation failure\n");
exit_status = -1;
goto END;
}

/* Nag_RFP_Store */
scanf("%39s ", nag_enum_arg);
transr = (Nag_RFP_Store) nag_enum_name_to_value(nag_enum_arg);
/* Nag_SideType */
scanf("%39s  %*[^\n] ", nag_enum_arg);
side = (Nag_SideType) nag_enum_name_to_value(nag_enum_arg);
/* Nag_UploType */
scanf("%39s ", nag_enum_arg);
uplo = (Nag_UploType) nag_enum_name_to_value(nag_enum_arg);
/* Nag_TransType */
scanf("%39s  %*[^\n] ", nag_enum_arg);
trans = (Nag_TransType) nag_enum_name_to_value(nag_enum_arg);
scanf(" ( %lf , %lf ) %*[^\n] ", &alpha.re, &alpha.im);
/* Read upper or lower triangle of matrix A from data file */
if (uplo == Nag_Lower) {
for (i = 1; i <= m; i++) {
for (j = 1; j <= i; j++) {
scanf(" ( %lf , %lf ) ", &A(i, j).re, &A(i, j).im);
}
}
}
else {
for (i = 1; i <= m; i++) {
for (j = i; j <= m; j++) {
scanf(" ( %lf , %lf ) ", &A(i, j).re, &A(i, j).im);
}
}
}
scanf("%*[^\n] ");

/* Read matrix B from data file */
for (i = 1; i <= m; i++) {
for (j = 1; j <= n; j++) {
scanf(" ( %lf , %lf ) ", &B(i, j).re, &B(i, j).im);
}
}
/* Convert complex triangular matrix A from full to rectangular full packed
* storage format (stored in ar) using nag_ztrttf (f01vfc).
*/
nag_ztrttf(order, transr, uplo, m, a, pda, ar, &fail);
if (fail.code != NE_NOERROR) {
printf("Error from nag_ztrttf (f01vfc).\n%s\n", fail.message);
exit_status = 1;
goto END;
}

printf("\n");
/* Solve AX = B, where complex triangular matrix A is stored using RFP format
* in ar, using nag_ztfsm (f16zlc).
*/
nag_ztfsm(order, transr, side, uplo, trans, Nag_NonUnitDiag, m, n, alpha,
ar, b, pdb, &fail);
if (fail.code != NE_NOERROR) {
printf("Error from nag_ztfsm (f16zlc).\n%s\n", fail.message);
exit_status = 1;
goto END;
}

/* Print the result using easy-to-use complex general matrix printing routine
* nag_gen_complx_mat_print (x04dac).
*/
fflush(stdout);
nag_gen_complx_mat_print(order, Nag_GeneralMatrix, Nag_NonUnitDiag, m, n, b,
pdb, "The Solution", 0, &fail);
if (fail.code != NE_NOERROR) {
printf("Error from nag_gen_complx_mat_print (x04dac).\n%s\n",
fail.message);
exit_status = 1;
}

END:
NAG_FREE(a);
NAG_FREE(ar);
NAG_FREE(b);
return exit_status;
}
```