Overview

(See also Numeric Types)

C API (Component Interface)
typedef UINT32 TYPE

The TYPE constant specifies a "primitive numeric type" (storage format, primitive bit width, real or complex), and/or data about the format of a numeric array. Can also indicate some non-numeric storage formats. Note that the vast majority of usage will simply be of one of the Shortcuts (see section below) union (logical OR) one of the Complexity constants, for instance TYPE_DOUBLE | TYPE_REAL.

Notes
  • To access some of the bits of a TYPE constant, you must use the appropriate mask. This will protect you against the addition of further bits in future releases. For example, use ((type & TYPE_ELEMENT_MASK) == TYPE_DOUBLE) to test for DOUBLE-type numeric data.

Values

A TYPE constant holds a value made up of the union (logical OR) of one of each of the following value sets. The value TYPE_UNSPECIFIED is distinct, and can be used to indicate that a type constant is not set.

TYPE_UNSPECIFIED

Storage Format

Exactly one of the following values is used to indicate the storage format. Extract from a TYPE constant by logical AND with TYPE_FORMAT_MASK.

TYPE_FORMAT_UNSPECIFIED
TYPE_FORMAT_FLOAT
TYPE_FORMAT_FIXED
TYPE_FORMAT_INT
TYPE_FORMAT_UINT
TYPE_FORMAT_BOOL
TYPE_FORMAT_CHAR
TYPE_FORMAT_STRUCT
TYPE_FORMAT_CELL

Primitive Bit-width

Exactly one of the following values is used to indicate the primitive bit-width (if the storage format is TYPE_FORMAT_STRUCT or TYPE_FORMAT_CELL, the bit-width is TYPE_WIDTH_UNSPECIFIED). Extract from a TYPE constant by logical AND with TYPE_WIDTH_MASK.

TYPE_WIDTH_UNSPECIFIED
TYPE_WIDTH_8BIT
TYPE_WIDTH_16BIT
TYPE_WIDTH_32BIT
TYPE_WIDTH_64BIT

Complexity

Exactly one of the following values is used to indicate the complexity (TYPE_COMPLEX_UNSPECIFIED is zero). If the storage format is TYPE_FORMAT_STRUCT or TYPE_FORMAT_CELL, the complexity must be TYPE_COMPLEX_UNSPECIFIED. Extract from a TYPE constant by logical AND with TYPE_COMPLEX_MASK.

TYPE_COMPLEX_UNSPECIFIED
TYPE_REAL
TYPE_COMPLEX

Complex Storage Format

Exactly one of the following values is used to indicate the complex storage format (TYPE_CPXFMT_UNSPECIFIED is zero). Extract from a TYPE constant by logical AND with TYPE_CPX_MASK. TYPE_CPXFMT_ADJACENT indicates complex data stored in separate blocks (real, real, ..., imag, imag, ...). TYPE_CPXFMT_INTERLEAVED indicates complex data stored interleaved (real, imag, real, ...).

TYPE_CPXFMT_UNSPECIFIED
TYPE_CPXFMT_ADJACENT
TYPE_CPXFMT_INTERLEAVED

Ordering

Exactly one of the following values is used to indicate the order storage format (TYPE_ORDER_UNSPECIFIED is zero). Extract from a TYPE constant by logical AND with TYPE_ORDER_MASK.

TYPE_ORDER_UNSPECIFIED
TYPE_ORDER_COLUMN_MAJOR
TYPE_ORDER_ROW_MAJOR

Additional Masks

Intersect (logical AND) a TYPE constant with one of the following masks to extract aspects of the data it holds.

TYPE_ELEMENT_MASK
Element Type (TYPE_FORMAT_MASK | TYPE_WIDTH_MASK).
TYPE_ARRAY_MASK
Array Type (TYPE_ELEMENT_MASK | TYPE_COMPLEX_MASK | TYPE_CPXFMT_MASK | TYPE_ORDER_MASK).

Shortcuts

Most of the time you will use TYPE constants to indicate one of a familiar set of primitive numeric types. Shortcut constants are provided for these types, each being the union (logical OR) of exactly one Storage Format constant and exactly one Primitive Bit-width constant, as follows.

TYPE_UINT8
TYPE_UINT16
TYPE_UINT32
TYPE_UINT64
TYPE_INT8
TYPE_INT16
TYPE_INT32
TYPE_INT64
TYPE_FLOAT32
TYPE_FLOAT64
TYPE_BOOL8
TYPE_BOOL16
TYPE_BOOL32
TYPE_BOOL64
TYPE_CHAR8
TYPE_CHAR16
TYPE_CHAR32
TYPE_CHAR64

Synonyms

In addition, some synonyms are provided.

TYPE_BYTE
TYPE_UINT8
TYPE_SINGLE
TYPE_FLOAT32
TYPE_DOUBLE
TYPE_FLOAT64
TYPE_BOOL
TYPE_BOOL8
TYPE_STRUCT
TYPE_FORMAT_STRUCT
TYPE_CELL
TYPE_FORMAT_CELL
TYPE_INTA
TYPE_INT32 or TYPE_INT64, depending on the bit-width of the architecture for which BRAHMS was compiled
TYPE_UINTA
TYPE_UINT32 or TYPE_UINT64, depending on the bit-width of the architecture for which BRAHMS was compiled

Macros

The following macros are defined for use with TYPE instances.

TYPE_BYTES(type)
Returns the number of bytes per element (real data only) for the specified type.
TYPE_COMPLEX_MULT(type)
Returns 2 for complex types and 1 for real types.