common.h

Common types and functions used by the debugger.

This file contains declarations for several common types required for quantum computation, such as complex numbers, state vectors, etc.

Defines

LOAD_RESULT_MESSAGE_MAX

Maximum length of a load error message (including null terminator).

Enums

enum Result

The result of an operation.

Can be either OK or ERROR.

Values:

enumerator OK

Indicates that the operation was successful.

enumerator ERROR

Indicates that an error occurred during the operation.

enum LoadResultStatus

The result of a code loading operation.

Values:

enumerator LOAD_OK

Indicates that the code was loaded successfully.

enumerator LOAD_PARSE_ERROR

Indicates that the code could not be parsed.

enumerator LOAD_INTERNAL_ERROR

Indicates that an internal error occurred while loading the code.

enum VariableType

The type of classical variables.

Supports Bool, Int, and Float.

Values:

enumerator VarBool
enumerator VarInt
enumerator VarFloat
struct LoadResult
#include <common.h>

The result of a code loading operation.

Public Members

LoadResultStatus status

Indicates whether the load was successful and why it failed.

size_t line

The line number of the error location, or 0 if unknown.

size_t column

The column number of the error location, or 0 if unknown.

char message[LOAD_RESULT_MESSAGE_MAX]

A human-readable error message, or empty string if none is available.

union VariableValue
#include <common.h>

@biref Represents the value of a classical variable.

Public Members

bool boolValue

The value represented as a boolean.

int intValue

The value represented as a integer.

double floatValue

The value represented as a floating point number.

struct Variable
#include <common.h>

Represents a classical variable.

Public Members

const char *name
VariableType type
VariableValue value
struct Complex
#include <common.h>

Represents a complex number.

Public Members

double real

The real component of the complex number.

double imaginary

The imaginary component of the complex number.

struct Statevector
#include <common.h>

Represents a quantum statevector.

The number of qubits is fixed and the number of states is 2^numQubits.

Public Members

size_t numQubits

The number of qubits in the statevector.

size_t numStates

The number of states in the statevector.

This is equal to 2^numQubits.

Complex *amplitudes

An area of memory containing the amplitudes of the statevector.

The allocated memory must be enough to store numStates Complex numbers.

struct CompilationSettings
#include <common.h>

The settings that should be used to compile an assertion program.

Public Members

uint8_t opt

The optimization level that should be used. Exact meaning depends on the implementation, but typically 0 means no optimization.

size_t sliceIndex

The index of the slice that should be compiled.