# NAG Library Function Document

## 1Purpose

nag_enum_name_to_value (x04nac) returns a value corresponding to the name of a NAG enumeration member.

## 2Specification

 #include #include
 int nag_enum_name_to_value (const char *enum_string)

## 3Description

nag_enum_name_to_value (x04nac) takes a string argument, which must be the name of a NAG enumeration member (e.g., "Nag_ColMajor", "Nag_LogNormal"", etc.), and returns, as an int, the corresponding NAG enumeration member value. If the input string is not the name of a valid NAG enumeration member then the value $-1$ is returned.
The reverse process of converting from enumeration member value to enumeration member name is also available using nag_enum_value_to_name (x04nbc).
Converting enumeration members to and from name and value may be of use when saving a set of problem arguments to file or reading problem arguments from a file for use in an application. In the case of saving problem arguments, any enumeration members to be saved should be saved using their names to be subsequently read as strings. When these strings are read back by an application, nag_enum_name_to_value (x04nac) can be used to convert the strings to values suitable for inclusion in NAG C Library function calls.
nag_enum_name_to_value (x04nac) is also useful when calling NAG C Library functions from external application interfaces that do not facilitate enumeration types. In such cases, NAG function calls that expect an enumeration member name as one of its input arguments can pass instead its corresponding integer value following a call to nag_enum_name_to_value (x04nac).

None.

## 5Arguments

1:    $\mathbf{enum_string}$const char *Input
On entry: the name of a NAG enumeration member, e.g., "Nag_GeneralMatrix".

## 6Error Indicators and Warnings

If the value $-1$ is returned then the input string is not recognized as a valid NAG enumeration member name.

Not applicable.

## 8Parallelism and Performance

nag_enum_name_to_value (x04nac) is not threaded in any implementation.

None.

## 10Example

This example reads problem arguments from input, converts enumeration member names to their correponding value using nag_enum_name_to_value (x04nac), and passes these values to a function for solving a system of equations.

### 10.1Program Text

Program Text (x04nace.c)

### 10.2Program Data

Program Data (x04nace.d)

### 10.3Program Results

Program Results (x04nace.r)

© The Numerical Algorithms Group Ltd, Oxford, UK. 2017