NAG Library Manual, Mark 28.3
Interfaces:  FL   CL   CPP   AD 

NAG CL Interface Introduction
Example description
/* nag_enum_value_to_name (x04nbc) Example Program.
 *
 * Copyright 2022 Numerical Algorithms Group.
 *
 * Mark 28.3, 2022.
 */

#include <nag.h>
#include <stdio.h>

int main(void) {
  /* Scalars */
  Integer exit_status = 0;
  Nag_OrderType order;
  Nag_TransType trans;
  Nag_DiagType unitdiag;
  Nag_MatrixType matrix;

  /* Pointers */
  const char *str_order, *str_trans, *str_matrix, *str_unitdiag;
  const char *status;

  printf("nag_enum_value_to_name (x04nbc) Example Program Results\n\n");

  /* Set some Nag types using enum member names */
  order = Nag_ColMajor;
  trans = Nag_Trans;
  matrix = Nag_GeneralMatrix;
  unitdiag = Nag_NonUnitDiag;

  /* Convert the values held by these typed variables to strings */

  /* nag_enum_value_to_name (x04nbc).
   * Converts NAG enum member value to its name
   */
  str_order = nag_enum_value_to_name(order);
  str_trans = nag_enum_value_to_name(trans);
  str_matrix = nag_enum_value_to_name(matrix);
  str_unitdiag = nag_enum_value_to_name(unitdiag);

  /* Check strings match member names and print. */
  printf("   Member name     String returned  Status\n");
  printf("----------------- ----------------- ------\n");
  status = "OK";
  if (strcmp(str_order, "Nag_ColMajor")) {
    status = "Error";
    exit_status++;
  }
  printf("%-17s %-17s %-6s\n", "Nag_ColMajor", str_order, status);

  status = "OK";
  if (strcmp(str_trans, "Nag_Trans")) {
    status = "Error";
    exit_status++;
  }
  printf("%-17s %-17s %-6s\n", "Nag_Trans", str_trans, status);

  status = "OK";
  if (strcmp(str_matrix, "Nag_GeneralMatrix")) {
    status = "Error";
    exit_status++;
  }
  printf("%-17s %-17s %-6s\n", "Nag_GeneralMatrix", str_matrix, status);

  status = "OK";
  if (strcmp(str_unitdiag, "Nag_NonUnitDiag")) {
    status = "Error";
    exit_status++;
  }
  printf("%-17s %-17s %-6s\n", "Nag_NonUnitDiag", str_unitdiag, status);

  return exit_status;
}