Type definitions
DQCsim defines some types and enumerations. These are documented below. Note that DQCsim does not define any structures; all types used on the interface are primitive. This should hopefully simplify using the bindings from languages other than C, which may not support such things.
Return codes
Almost all functions in DQCsim can fail. They indicate failure through their
return value. For some types this return value is obvious; for instance, NULL
is used for functions that return a string or another kind of pointer. For
enumerations, the failure return value is usually 0 or -1. In other cases, the
failure return value will be listed in the function documentation.
There are two special cases: functions that return a boolean and functions that don't otherwise return a value. These have the following two special enumerations defined for them:
dqcs_return_t
Default return type for functions that don't need to return anything.
Default return type for functions that don't need to return anything.
typedef enum { ... } dqcs_return_t;
Variants:
DQCS_FAILURE = -1
DQCS_SUCCESS = 0
dqcs_bool_return_t
Return type for functions that normally return a boolean but can also fail.
Return type for functions that normally return a boolean but can also fail.
typedef enum { ... } dqcs_bool_return_t;
Variants:
DQCS_BOOL_FAILURE = -1
DQCS_FALSE = 0
DQCS_TRUE = 1
Simulator object references
The following types are used to refer to simulator objects.
dqcs_handle_t
Type for a handle.
Type for a handle.
typedef unsigned long long dqcs_handle_t;
Handles are like pointers into DQCsim's internal structures: all API calls
use these to refer to objects. Besides the object, they contain type
information. This type can be retrieved using dqcs_handle_type()
.
Handles are always positive integers, counting upwards from 1 upon allocation, and they are not reused even after being deleted. Thus, every subsequent object allocation returns a handle one greater than the previous. Note however that DQCsim may allocate objects as well without the user specifically requesting this, so external code should generally not rely on this behavior unless otherwise noted. The value zero is reserved for invalid references or error propagation.
Note that the scope for handles is thread-local. That is, data referenced by a handle cannot be shared or moved between threads.
The value zero is reserved for invalid references or error propagation.
dqcs_qubit_t
Type for a qubit reference.
Type for a qubit reference.
typedef unsigned long long dqcs_qubit_t;
Qubit references are exchanged between the frontend, operator, and backend plugins to indicate which qubits a gate operates on. Note that this makes them fundamentally different from handles, which are thread-local.
Qubit references are always positive integers, counting upwards from 1 upon allocation, and they are not reused even after the qubit is deallocated. Thus, every subsequent allocation returns a qubit reference one greater than the previous. This is guaranteed behavior that external code can rely upon. The value zero is reserved for invalid references or error propagation.
dqcs_plugin_state_t
Type for a plugin state.
Type for a plugin state.
typedef void *dqcs_plugin_state_t;
This is an opaque type that is passed along to plugin implementation
callback functions, which those callbacks can then use to interact with the
plugin instance. User code shall not create or modify values of this type,
and shall only use the values when calling dqcs_plugin_*
functions.
Timekeeping
DQCsim supports timed simulation using integral cycle numbers as a unit. The following typedef is used to refer to such timestamps.
dqcs_cycle_t
Type for a simulation cycle timestamp.
Type for a simulation cycle timestamp.
typedef long long dqcs_cycle_t;
Timestamps count upward from zero. The type is signed to allow usage of -1 for errors, and to allow numerical differences to be represented.
Misc. enumerations
The following enumerations are used for various purposes within the API.
dqcs_handle_type_t
Enumeration of types that can be associated with a handle.
Enumeration of types that can be associated with a handle.
typedef enum { ... } dqcs_handle_type_t;
Variants:
This indicates one of the following: This means that the handle supports the This means that the handle supports the This means that the handle supports the This means that the handle supports the This means that the handle supports the This means that the handle supports the This means that the handle supports the This means that the handle supports the This means that the handle supports the This means that the handle supports the This means that the handle supports the This means that the handle supports the This means that the handle supports the This means that the handle supports the This means that the handle supports the This means that the handle supports the This means that the handle supports the This means that the handle supports the This means that the handle supports the This means that the handle supports the This means that the handle supports the DQCS_HTYPE_INVALID = 0
DQCS_HTYPE_ARB_DATA = 100
handle
and arb
interfaces.DQCS_HTYPE_ARB_CMD = 101
handle
, arb
, and cmd
interfaces.DQCS_HTYPE_ARB_CMD_QUEUE = 102
handle
, arb
, cmd
, and
cq
interfaces.DQCS_HTYPE_QUBIT_SET = 103
handle
and qbset
interfaces.DQCS_HTYPE_GATE = 104
handle
, gate
, and arb
interfaces.DQCS_HTYPE_MEAS = 105
handle
, meas
, and arb
interfaces. It can also be used in place of a qubit measurement result
set by functions that consume the object.DQCS_HTYPE_MEAS_SET = 106
handle
and mset
interfaces.DQCS_HTYPE_MATRIX = 107
handle
and mat
interfaces.DQCS_HTYPE_GATE_MAP = 108
handle
and gm
interfaces.DQCS_HTYPE_FRONT_PROCESS_CONFIG = 200
handle
, pcfg
, and xcfg
interfaces.DQCS_HTYPE_OPER_PROCESS_CONFIG = 201
handle
, pcfg
, and xcfg
interfaces.DQCS_HTYPE_BACK_PROCESS_CONFIG = 203
handle
, pcfg
, and xcfg
interfaces.DQCS_HTYPE_FRONT_THREAD_CONFIG = 204
handle
, tcfg
, and xcfg
interfaces.DQCS_HTYPE_OPER_THREAD_CONFIG = 205
handle
, tcfg
, and xcfg
interfaces.DQCS_HTYPE_BACK_THREAD_CONFIG = 206
handle
, tcfg
, and xcfg
interfaces.DQCS_HTYPE_SIM_CONFIG = 207
handle
and scfg
interfaces.DQCS_HTYPE_SIM = 208
handle
and sim
interfaces.DQCS_HTYPE_FRONT_DEF = 300
handle
and pdef
interfaces.DQCS_HTYPE_OPER_DEF = 301
handle
and pdef
interfaces.DQCS_HTYPE_BACK_DEF = 302
handle
and pdef
interfaces.DQCS_HTYPE_PLUGIN_JOIN = 303
handle
and pjoin
interfaces.
dqcs_loglevel_t
Enumeration of loglevels and logging modes.
Enumeration of loglevels and logging modes.
typedef enum { ... } dqcs_loglevel_t;
Variants:
DQCS_LOG_INVALID = -1
DQCS_LOG_OFF = 0
DQCS_LOG_FATAL = 1
DQCS_LOG_ERROR = 2
DQCS_LOG_WARN = 3
DQCS_LOG_NOTE = 4
DQCS_LOG_INFO = 5
DQCS_LOG_DEBUG = 6
DQCS_LOG_TRACE = 7
DQCS_LOG_PASS = 8
dqcs_measurement_t
Qubit measurement value.
Qubit measurement value.
typedef enum { ... } dqcs_measurement_t;
Variants:
DQCS_MEAS_INVALID = -1
DQCS_MEAS_ZERO = 0
DQCS_MEAS_ONE = 1
DQCS_MEAS_UNDEFINED = 2
dqcs_path_style_t
Reproduction file path style.
Reproduction file path style.
typedef enum { ... } dqcs_path_style_t;
Variants:
DQCS_PATH_STYLE_INVALID = -1
DQCS_PATH_STYLE_KEEP = 0
DQCS_PATH_STYLE_RELATIVE = 1
DQCS_PATH_STYLE_ABSOLUTE = 2
dqcs_plugin_type_t
Enumeration of the three types of plugins.
Enumeration of the three types of plugins.
typedef enum { ... } dqcs_plugin_type_t;
Variants:
DQCS_PTYPE_INVALID = -1
DQCS_PTYPE_FRONT = 0
DQCS_PTYPE_OPER = 1
DQCS_PTYPE_BACK = 2