Example description
/* nag_matop_real_gen_matrix_exp (f01ecc) Example Program.
 *
 * Copyright 2020 Numerical Algorithms Group.
 *
 * Mark 27.1, 2020.
 */
/* Pre-processor includes */
#include <math.h>
#include <nag.h>
#include <stdio.h>

int main(void) {
  /*Integer scalar and array declarations */
  Integer exit_status = 0;
  Integer i, j, n;
  Integer pda;
  NagError fail;
  /*Double scalar and array declarations */
  double *a = 0;
  Nag_OrderType order;

  INIT_FAIL(fail);

  printf("%s\n",
         "nag_matop_real_gen_matrix_exp (f01ecc) Example Program Results");
  printf("\n");
  /* Skip heading in data file */
  scanf("%*[^\n] ");
  scanf("%" NAG_IFMT "%*[^\n] ", &n);
#ifdef NAG_COLUMN_MAJOR
  pda = n;
#define A(I, J) a[(J - 1) * pda + I - 1]
  order = Nag_ColMajor;
#else
  pda = n;
#define A(I, J) a[(I - 1) * pda + J - 1]
  order = Nag_RowMajor;
#endif
  if (!(a = NAG_ALLOC(pda * n, double))) {
    printf("Allocation failure\n");
    exit_status = -1;
    goto END;
  }
  /* Read A from data file */
  for (i = 1; i <= n; i++) {
    for (j = 1; j <= n; j++)
      scanf("%lf", &A(i, j));
  }
  scanf("%*[^\n] ");
  /* Find exp( A ) */
  /*
   * nag_matop_real_gen_matrix_exp (f01ecc)
   * Real matrix exponential
   */
  nag_matop_real_gen_matrix_exp(order, n, a, pda, &fail);
  if (fail.code != NE_NOERROR) {
    printf("Error from nag_matop_real_gen_matrix_exp (f01ecc).\n%s\n",
           fail.message);
    exit_status = 1;
    goto END;
  }
  /* Print solution */
  /*
   * nag_file_print_matrix_real_gen (x04cac)
   * Print real general matrix (easy-to-use)
   */
  fflush(stdout);
  nag_file_print_matrix_real_gen(order, Nag_GeneralMatrix, Nag_NonUnitDiag, n,
                                 n, a, pda, "Exp(A)", 0, &fail);
  if (fail.code != NE_NOERROR) {
    printf("Error from nag_file_print_matrix_real_gen (x04cac).\n%s\n",
           fail.message);
    exit_status = 1;
  }

END:
  NAG_FREE(a);

  return exit_status;
}