/* nag_matop_complex_herm_matrix_exp (f01fdc) Example Program.
*
* Copyright 2014 Numerical Algorithms Group.
*
* Mark 23, 2011.
*/
#include <nag.h>
#include <nag_stdlib.h>
#include <naga02.h>
#include <nagf01.h>
#include <nagx04.h>
int main(void)
{
/* Scalars */
char *outfile = 0;
Integer exit_status = 0;
Integer i, j, n, pda;
/* Arrays */
char uplo_c[40];
Complex *a = 0;
/* NAG types */
Nag_OrderType order;
NagError fail;
Nag_UploType uplo;
Nag_MatrixType matrix;
INIT_FAIL(fail);
printf("nag_matop_complex_herm_matrix_exp (f01fdc) Example Program Results");
printf("\n\n");
fflush(stdout);
/* Read matrix dimension and storage from data file*/
scanf("%*[^\n]%ld%*[^\n] %39s%*[^\n]", &n, uplo_c);
/* nag_enum_name_to_value (x04nac): Converts NAG enum member name to value */
uplo = (Nag_UploType) nag_enum_name_to_value(uplo_c);
pda = n;
if (!(a = NAG_ALLOC((pda)*(n), Complex)))
{
printf("Allocation failure\n");
exit_status = -1;
goto END;
}
#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
/* Read A from data file*/
if (uplo == Nag_Upper)
{
matrix = Nag_UpperMatrix;
for (i = 1; i <= n; i++)
for (j = i; j <= n; j++)
scanf(" ( %lf , %lf ) ", &A(i, j).re, &A(i, j).im);
}
else
{
matrix = Nag_LowerMatrix;
for (i = 1; i <= n; i++)
for (j = 1; j <= i; j++)
scanf(" ( %lf , %lf ) ", &A(i, j).re, &A(i, j).im);
}
scanf("%*[^\n]");
/* nag_matop_complex_herm_matrix_exp (f01fdc).
* Complex Hermitian matrix exponential
*/
nag_matop_complex_herm_matrix_exp(order, uplo, n, a, pda, &fail);
if (fail.code != NE_NOERROR)
{
printf("%s\n", fail.message);
exit_status = 1;
goto END;
}
/* nag_gen_complx_mat_print (x04dac).
* Print complex general matrix (easy-to-use)
*/
nag_gen_complx_mat_print(order, matrix, Nag_NonUnitDiag, n, n, a, pda,
"Hermitian Exp(A)", outfile, &fail);
if (fail.code != NE_NOERROR)
{
printf("%s\n", fail.message);
exit_status = 2;
goto END;
}
END:
NAG_FREE(a);
return exit_status;
}