DQCsim
Namespaces | Classes | Typedefs | Enumerations | Functions
dqcsim::wrap Namespace Reference

Namespace containing thin wrapper objects around the handles exposed by the raw C interface. More...

Namespaces

 callback
 Namespace containing all necessarily specializations of Callback as typedefs.
 

Classes

class  Arb
 Class wrapper for handles that support the arb interface. More...
 
class  ArbCmd
 Class wrapper for ArbCmd handles. More...
 
class  ArbCmdQueue
 Class wrapper for queues (lists) of ArbCmds. More...
 
class  ArbData
 Class wrapper for ArbData handles. More...
 
class  Callback
 Class template shared between all callback functions. More...
 
class  Cmd
 Class wrapper for handles that support the cmd interface. More...
 
class  CustomGateConverter
 Class that you can inherit from to make your own custom gate converter for use within DQCsim. More...
 
class  CustomUnitaryGateConverter
 Class that you can inherit from to make your own unitary gate converter for use within DQCsim. More...
 
class  Gate
 Represents any kind of gate with qubits bound to it. More...
 
class  GateMap
 Gate map wrapper class. More...
 
class  Handle
 Base class for wrapping any handle. More...
 
class  Matrix
 Represents a square matrix used for describing N-qubit gates. More...
 
class  Measurement
 Class representation of the measurement result for a single qubit. More...
 
class  MeasurementSet
 Represents a set of measurements. More...
 
class  Plugin
 Plugin definition class. More...
 
class  PluginConfiguration
 Generic class for plugin configurations. More...
 
class  PluginConfigurationBuilder
 Builder class used to construct plugin configurations. More...
 
class  PluginJoinHandle
 Class wrapper for plugin join handles. More...
 
class  PluginProcessConfiguration
 Wrapper class for plugin process configurations. More...
 
class  PluginState
 Wrapper for DQCsim's internal plugin state within the context of downstream-synchronous plugin callbacks. More...
 
class  PluginThreadConfiguration
 Wrapper class for local plugin thread configurations. More...
 
class  QubitRef
 Represents a qubit. More...
 
class  QubitSet
 Represents an ordered set of qubit references. More...
 
class  RunningPluginState
 Wrapper for DQCsim's internal plugin state within the context of the run callback in a frontend. More...
 
class  Simulation
 Wrapper class for a running simulation. More...
 
class  SimulationConfiguration
 Wrapper class for configuring a simulation. More...
 
class  UpstreamPluginState
 Wrapper for DQCsim's internal plugin state within the context of upstream-synchronous plugin callbacks (that is, the modify_measurement callback). More...
 

Typedefs

using HandleIndex = raw::dqcs_handle_t
 C++-styled type name for raw::dqcs_handle_t. More...
 
using QubitIndex = raw::dqcs_qubit_t
 C++-styled type name for raw::dqcs_qubit_t. More...
 
using Cycle = raw::dqcs_cycle_t
 C++-styled type name for raw::dqcs_cycle_t. More...
 
using complex = std::complex< double >
 Typedef for the complex numbers used within the gate matrices.
 

Enumerations

enum  HandleType {
  HandleType::ArbData = 100, HandleType::ArbCmd = 101, HandleType::ArbCmdQueue = 102, HandleType::QubitSet = 103,
  HandleType::Gate = 104, HandleType::Measurement = 105, HandleType::MeasurementSet = 106, HandleType::Matrix = 107,
  HandleType::GateMap = 108, HandleType::FrontendProcessConfig = 200, HandleType::OperatorProcessConfig = 201, HandleType::BackendProcessConfig = 203,
  HandleType::FrontendThreadConfig = 204, HandleType::OperatorThreadConfig = 205, HandleType::BackendThreadConfig = 206, HandleType::SimulationConfig = 207,
  HandleType::Simulation = 208, HandleType::FrontendDefinition = 300, HandleType::OperatorDefinition = 301, HandleType::BackendDefinition = 302,
  HandleType::PluginJoinHandle = 303
}
 Represents the type of a raw handle. More...
 
enum  Loglevel {
  Loglevel::Off = 0, Loglevel::Fatal = 1, Loglevel::Error = 2, Loglevel::Warn = 3,
  Loglevel::Note = 4, Loglevel::Info = 5, Loglevel::Debug = 6, Loglevel::Trace = 7,
  Loglevel::Pass = 8
}
 Represents the loglevel of a message, a loglevel filter level, or one of the possible actions to take when a message is received from a plugin through stdout or stderr. More...
 
enum  MeasurementValue { MeasurementValue::Zero = 0, MeasurementValue::One = 1, MeasurementValue::Undefined = 2 }
 Represents the result of a qubit measurement. More...
 
enum  PathStyle { PathStyle::Keep = 0, PathStyle::Relative = 1, PathStyle::Absolute = 2 }
 Represents the possible options for dealing with paths when writing a reproduction file. More...
 
enum  PluginType { PluginType::Frontend = 0, PluginType::Operator = 1, PluginType::Backend = 2 }
 Enumeration of the three types of plugins. More...
 
enum  GateType { GateType::Unitary = 1, GateType::Measurement = 2, GateType::Prep = 3, GateType::Custom = 4 }
 Enumeration of gate types supported by DQCsim. More...
 
enum  PauliBasis { PauliBasis::X = 1, PauliBasis::Y = 2, PauliBasis::Z = 3 }
 Enumeration of Pauli bases. More...
 
enum  PredefinedGate {
  PredefinedGate::I = 100, PredefinedGate::X = 101, PredefinedGate::Y = 102, PredefinedGate::Z = 103,
  PredefinedGate::H = 104, PredefinedGate::S = 105, PredefinedGate::S_DAG = 106, PredefinedGate::T = 107,
  PredefinedGate::T_DAG = 108, PredefinedGate::RX_90 = 109, PredefinedGate::RX_M90 = 110, PredefinedGate::RX_180 = 111,
  PredefinedGate::RY_90 = 112, PredefinedGate::RY_M90 = 113, PredefinedGate::RY_180 = 114, PredefinedGate::RZ_90 = 115,
  PredefinedGate::RZ_M90 = 116, PredefinedGate::RZ_180 = 117, PredefinedGate::RX = 150, PredefinedGate::RY = 151,
  PredefinedGate::RZ = 152, PredefinedGate::PhaseK = 153, PredefinedGate::Phase = 154, PredefinedGate::U1 = 190,
  PredefinedGate::R = 191, PredefinedGate::Swap = 200, PredefinedGate::SqSwap = 201, PredefinedGate::U2 = 290,
  PredefinedGate::U3 = 390
}
 Enumeration of unitary gates defined by DQCsim. More...
 

Functions

void check (raw::dqcs_return_t code)
 Checks a dqcs_return_t return value; if failure, throws a runtime error with DQCsim's error message. More...
 
bool check (raw::dqcs_bool_return_t code)
 Checks a dqcs_bool_return_t return value; if failure, throws a runtime error with DQCsim's error message. More...
 
unsigned long long check (unsigned long long handle)
 Checks a dqcs_handle_t or dqcs_qubit_t return value; if failure, throws a runtime error with DQCsim's error message. More...
 
Cycle check (Cycle cycle)
 Checks a dqcs_cycle_t return value; if failure, throws a runtime error with DQCsim's error message. More...
 
size_t check (ssize_t size)
 Checks a size return value; if failure, throws a runtime error with DQCsim's error message. More...
 
double check (double value)
 Checks a double return value from dqcs_pcfg_*_timeout_get(); if failure, throws a runtime error with DQCsim's error message. More...
 
raw::dqcs_handle_type_t to_raw (HandleType type) noexcept
 Converts a HandleType to its raw C enum. More...
 
HandleType check (raw::dqcs_handle_type_t type)
 Checks a dqcs_handle_type_t return value and converts it to its C++ enum representation; if failure, throws a runtime error with DQCsim's error message. More...
 
raw::dqcs_loglevel_t to_raw (Loglevel loglevel) noexcept
 Converts a Loglevel to its raw C enum. More...
 
Loglevel check (raw::dqcs_loglevel_t loglevel)
 Checks a dqcs_loglevel_t return value and converts it to its C++ enum representation; if failure, throws a runtime error with DQCsim's error message. More...
 
raw::dqcs_measurement_t to_raw (MeasurementValue measurement) noexcept
 Converts a MeasurementValue to its raw C enum. More...
 
MeasurementValue check (raw::dqcs_measurement_t measurement)
 Checks a dqcs_measurement_t return value and converts it to its C++ enum representation; if failure, throws a runtime error with DQCsim's error message. More...
 
raw::dqcs_path_style_t to_raw (PathStyle style) noexcept
 Converts a PathStyle to its raw C enum. More...
 
PathStyle check (raw::dqcs_path_style_t style)
 Checks a dqcs_path_style_t return value and converts it to its C++ enum representation; if failure, throws a runtime error with DQCsim's error message. More...
 
raw::dqcs_plugin_type_t to_raw (PluginType type) noexcept
 Converts a PluginType to its raw C enum. More...
 
PluginType check (raw::dqcs_plugin_type_t type)
 Checks a dqcs_plugin_type_t return value and converts it to its C++ enum representation; if failure, throws a runtime error with DQCsim's error message. More...
 
raw::dqcs_gate_type_t to_raw (GateType type) noexcept
 Converts a GateType to its raw C enum. More...
 
GateType check (raw::dqcs_gate_type_t type)
 Checks a dqcs_gate_type_t return value and converts it to its C++ enum representation; if failure, throws a runtime error with DQCsim's error message. More...
 
raw::dqcs_basis_t to_raw (PauliBasis type) noexcept
 Converts a PauliBasis to its raw C enum. More...
 
PauliBasis check (raw::dqcs_basis_t type)
 Checks a dqcs_basis_t return value and converts it to its C++ enum representation; if failure, throws a runtime error with DQCsim's error message. More...
 
raw::dqcs_predefined_gate_t to_raw (PredefinedGate type) noexcept
 Converts a PredefinedGate to its raw C enum. More...
 
PredefinedGate check (raw::dqcs_predefined_gate_t type)
 Checks a dqcs_predefined_gate_t return value and converts it to its C++ enum representation; if failure, throws a runtime error with DQCsim's error message. More...
 
template<typename T >
T * check (T *pointer)
 Checks a pointer return value; if failure, throws a runtime error with DQCsim's error message. More...
 
template<typename... Args>
void log (wrap::Loglevel level, const std::string &module, const std::string &file, unsigned int line_nr, const std::string &format, Args... args) noexcept
 Shim around the dqcs_log_format C API using std::string for the strings. More...
 
bool log_raw (wrap::Loglevel level, const std::string &module, const std::string &file, unsigned int line_nr, const std::string &message) noexcept
 Shim around the dqcs_log_raw C API using std::string for the strings. More...
 
QubitRef operator""_q (unsigned long long int qubit)
 Literal operator for qubits, so for instance 15_q returns qubit 15.
 
PluginConfigurationBuilder Frontend (const std::string &name="") noexcept
 Shorthand for constructing a frontend plugin configuration builder. More...
 
PluginConfigurationBuilder Operator (const std::string &name="") noexcept
 Shorthand for constructing an operator plugin configuration builder. More...
 
PluginConfigurationBuilder Backend (const std::string &name="") noexcept
 Shorthand for constructing a backend plugin configuration builder. More...
 

Detailed Description

Namespace containing thin wrapper objects around the handles exposed by the raw C interface.

The symbols in this namespace fully wrap those provided by the raw C API. The following things are abstracted away.

Typedef Documentation

◆ HandleIndex

C++-styled type name for raw::dqcs_handle_t.

This integer type is used to represent C API handles internally. You normally shouldn't encounter this type.

Note
DQCsim starts counting handles from 1. Handle 0 is reserved for signaling errors in the C API.

Definition at line 95 of file dqcsim.

◆ QubitIndex

C++-styled type name for raw::dqcs_qubit_t.

This integer type is used to represent qubit indices. You can do math on this type if you like, though this normally doesn't bear any significance. Most of the time you'll be using QubitRef instead, which prevents such (usually) meaningless operations.

Note
DQCsim starts counting qubits from index 1. Index 0 is reserved for signaling errors in the C API.

Definition at line 108 of file dqcsim.

◆ Cycle

C++-styled type name for raw::dqcs_cycle_t.

This integer type is used to represent simulation cycles.

Definition at line 115 of file dqcsim.

Enumeration Type Documentation

◆ HandleType

Represents the type of a raw handle.

This wraps raw::handle_type_t, not including the invalid option (since we use exceptions to communicate failure).

Enumerator
ArbData 

Indicates that a handle is an ArbData.

ArbCmd 

Indicates that a handle is an ArbCmd.

ArbCmdQueue 

Indicates that a handle is an ArbCmdQueue.

QubitSet 

Indicates that a handle is a QubitSet.

Gate 

Indicates that a handle is a Gate.

Measurement 

Indicates that a handle is a Measurement.

MeasurementSet 

Indicates that a handle is a MeasurementSet.

Matrix 

Indicates that a handle is a Matrix.

GateMap 

Indicates that a handle is a GateMap.

FrontendProcessConfig 

Indicates that a handle is a PluginProcessConfiguration for a frontend plugin.

OperatorProcessConfig 

Indicates that a handle is a PluginProcessConfiguration for an operator plugin.

BackendProcessConfig 

Indicates that a handle is a PluginProcessConfiguration for a backend plugin.

FrontendThreadConfig 

Indicates that a handle is a PluginThreadConfiguration for a frontend plugin.

OperatorThreadConfig 

Indicates that a handle is a PluginThreadConfiguration for an operator plugin.

BackendThreadConfig 

Indicates that a handle is a PluginThreadConfiguration for a backend plugin.

SimulationConfig 

Indicates that a handle is a SimulationConfiguration.

Simulation 

Indicates that a handle is a Simulation.

FrontendDefinition 

Indicates that a handle is a frontend Plugin.

OperatorDefinition 

Indicates that a handle is an operator Plugin.

BackendDefinition 

Indicates that a handle is a backend Plugin.

PluginJoinHandle 

Indicates that a handle is a PluginJoinHandle.

Definition at line 214 of file dqcsim.

◆ Loglevel

Represents the loglevel of a message, a loglevel filter level, or one of the possible actions to take when a message is received from a plugin through stdout or stderr.

This wraps raw::dqcs_loglevel_t, not including the invalid option (since we use exceptions to communicate failure).

Enumerator
Off 

In the context of a filter, turns logging off.

Fatal 

This loglevel is to be used for reporting a fatal error, resulting from the owner of the logger getting into an illegal state from which it cannot recover.

Such problems are also reported to the API caller if applicable.

Error 

This loglevel is to be used for reporting or propagating a non-fatal error caused by the API caller doing something wrong.

Such problems are also reported to the API caller if applicable.

Warn 

This loglevel is to be used for reporting that a called API/function is telling us we did something wrong (that we weren't expecting), but we can recover.

For instance, for a failed connection attempt to something that really should not be failing, we can still retry (and eventually report critical or error if a retry counter overflows). Since we're still trying to rectify things at this point, such problems are NOT reported to the API/function caller via Result::Err.

Note 

This loglevel is to be used for reporting information specifically requested by the user/API caller, such as the result of an API function requested through the command line, or an explicitly captured stdout/stderr stream.

Info 

This loglevel is to be used for reporting information NOT specifically requested by the user/API caller, such as a plugin starting up or shutting down.

Debug 

This loglevel is to be used for reporting debugging information useful for debugging the user of the API provided by the logged instance.

Trace 

This loglevel is to be used for reporting debugging information useful for debugging the internals of the logged instance.

Such messages would normally only be generated by debug builds, to prevent them from impacting performance under normal circumstances.

Pass 

This is intended to be used when configuring the stdout/stderr capture mode for a plugin process.

Selecting it will prevent the stream from being captured; it will just be the same stream as DQCsim's own stdout/stderr. When used as the loglevel for a message, the message itself is sent to stderr instead of passing into DQCsim's log system. Using this for loglevel filters leads to undefined behavior.

Definition at line 407 of file dqcsim.

◆ MeasurementValue

Represents the result of a qubit measurement.

This wraps raw::dqcs_measurement_t, not including the invalid option (since we use exceptions to communicate failure).

Enumerator
Zero 

Qubit measurement returned zero.

One 

Qubit measurement returned one.

Undefined 

This value can be used by backends to indicate that the qubit state was collapsed as part of the measurement process, but the value is unknown for some reason.

Definition at line 534 of file dqcsim.

◆ PathStyle

Represents the possible options for dealing with paths when writing a reproduction file.

This wraps raw::dqcs_path_style_t, not including the invalid option (since we use exceptions to communicate failure).

Enumerator
Keep 

Specifies that paths should be saved the same way they were specified on the command line.

Relative 

Specifies that all paths should be saved relative to DQCsim's working directory.

Absolute 

Specifies that all paths should be saved canonically, i.e.

relative to the root directory.

Definition at line 597 of file dqcsim.

◆ PluginType

Enumeration of the three types of plugins.

This wraps raw::dqcs_plugin_type_t, not including the invalid option (since we use exceptions to communicate failure).

Enumerator
Frontend 

Frontend plugin.

Operator 

Operator plugin.

Backend 

Backend plugin.

Definition at line 660 of file dqcsim.

◆ GateType

Enumeration of gate types supported by DQCsim.

This wraps raw::dqcs_gate_type_t, not including the invalid option (since we use exceptions to communicate failure).

Enumerator
Unitary 

Unitary gates have one or more target qubits, zero or more control qubits, and a unitary matrix, sized for the number of target qubits.

The semantics are that the unitary matrix expanded by the number of control qubits is applied to the qubits.

The data field may add pragma-like hints to the gate, for instance to represent the line number in the source file that generated the gate, error modelling information, and so on. This data may be silently ignored.

Measurement 

Measurement gates have one or more measured qubits and a 2x2 unitary matrix representing the basis.

The semantics are:

  • the hermetian of the matrix is applied to each individual qubit;
  • each individual qubit is measured in the Z basis;
  • the matrix is applied to each individual qubit;
  • the results of the measurement are propagated upstream.

This allows any measurement basis to be used.

The data field may add pragma-like hints to the gate, for instance to represent the line number in the source file that generated the gate, error modelling information, and so on. This data may be silently ignored.

Prep 

Prep gates have one or more target qubits and a 2x2 unitary matrix representing the basis.

The semantics are:

  • each qubit is initialized to |0>;
  • the matrix is applied to each individual qubit.

This allows any initial state to be used.

The data field may add pragma-like hints to the gate, for instance to represent the line number in the source file that generated the gate, error modelling information, and so on. This data may be silently ignored.

Custom 

Custom gates perform a user-defined mixed quantum-classical operation, identified by a name.

They can have zero or more target, control, and measured qubits, of which only the target and control sets must be mutually exclusive. They also have an optional matrix of arbitrary size.

The semantics are:

  • if the name is not recognized, an error is reported;
  • a user-defined operation is performed based on the name, qubits, matrix, and data arguments;
  • exactly one measurement result is reported upstream for exactly the qubits in the measures set.

Definition at line 720 of file dqcsim.

◆ PauliBasis

Enumeration of Pauli bases.

This wraps raw::dqcs_basis_t, not including the invalid option (since we use exceptions to communicate failure).

Enumerator

The X basis.

\[ \psi_X = \frac{1}{\sqrt{2}} \begin{bmatrix} 1 & -1 \\ 1 & 1 \end{bmatrix} \]

The Y basis.

\[ \psi_Y = \frac{1}{\sqrt{2}} \begin{bmatrix} 1 & i \\ i & 1 \end{bmatrix} \]

The Z basis.

\[ \psi_Z = \begin{bmatrix} 1 & 0 \\ 0 & 1 \end{bmatrix} \]

Definition at line 836 of file dqcsim.

◆ PredefinedGate

Enumeration of unitary gates defined by DQCsim.

This wraps raw::dqcs_predefined_gate_t, not including the invalid option (since we use exceptions to communicate failure).

Enumerator

The identity gate for a single qubit.

\[ I = \sigma_0 = \begin{bmatrix} 1 & 0 \\ 0 & 1 \end{bmatrix} \]

The Pauli X matrix.

\[ X = \sigma_1 = \begin{bmatrix} 0 & 1 \\ 1 & 0 \end{bmatrix} \]

The Pauli Y matrix.

\[ Y = \sigma_2 = \begin{bmatrix} 0 & -i \\ i & 0 \end{bmatrix} \]

The Pauli Z matrix.

\[ Z = \sigma_3 = \begin{bmatrix} 1 & 0 \\ 0 & -1 \end{bmatrix} \]

The hadamard gate matrix.

That is, a 180-degree Y rotation, followed by a 90-degree X rotation.

\[ H = \frac{1}{\sqrt{2}} \begin{bmatrix} 1 & 1 \\ 1 & -1 \end{bmatrix} \]

The S matrix, also known as a 90 degree Z rotation.

\[ S = \begin{bmatrix} 1 & 0 \\ 0 & i \end{bmatrix} \]

S_DAG 

The S-dagger matrix, also known as a negative 90 degree Z rotation.

\[ S^\dagger = \begin{bmatrix} 1 & 0 \\ 0 & -i \end{bmatrix} \]

The T matrix, also known as a 45 degree Z rotation.

\[ T = \begin{bmatrix} 1 & 0 \\ 0 & e^{i\frac{\pi}{4}} \end{bmatrix} \]

T_DAG 

The T-dagger matrix, also known as a negative 45 degree Z rotation.

\[ T^\dagger = \begin{bmatrix} 1 & 0 \\ 0 & e^{-i\frac{\pi}{4}} \end{bmatrix} \]

RX_90 

Rx(90°) gate.

\[ R_x\left(\frac{\pi}{2}\right) = \frac{1}{\sqrt{2}} \begin{bmatrix} 1 & -i \\ -i & 1 \end{bmatrix} \]

RX_M90 

Rx(-90°) gate.

\[ R_x\left(-\frac{\pi}{2}\right) = \frac{1}{\sqrt{2}} \begin{bmatrix} 1 & i \\ i & 1 \end{bmatrix} \]

RX_180 

Rx(180°) gate.

\[ R_x(\pi) = \begin{bmatrix} 0 & -i \\ -i & 0 \end{bmatrix} \]

This matrix is equivalent to the Pauli X gate, but differs in global phase. Note that this difference is significant when it is used as a submatrix for a controlled gate.

RY_90 

Ry(90°) gate.

\[ R_y\left(\frac{\pi}{2}\right) = \frac{1}{\sqrt{2}} \begin{bmatrix} 1 & -1 \\ 1 & 1 \end{bmatrix} \]

RY_M90 

Ry(-90°) gate.

\[ R_y\left(\frac{\pi}{2}\right) = \frac{1}{\sqrt{2}} \begin{bmatrix} 1 & 1 \\ -1 & 1 \end{bmatrix} \]

RY_180 

Ry(180°) gate.

\[ R_y(\pi) = \begin{bmatrix} 0 & -1 \\ 1 & 0 \end{bmatrix} \]

This matrix is equivalent to the Pauli Y gate, but differs in global phase. Note that this difference is significant when it is used as a submatrix for a controlled gate.

RZ_90 

Rz(90°) gate.

\[ R_z\left(\frac{\pi}{2}\right) = \frac{1}{\sqrt{2}} \begin{bmatrix} 1-i & 0 \\ 0 & 1+i \end{bmatrix} \]

This matrix is equivalent to the S gate, but differs in global phase. Note that this difference is significant when it is used as a submatrix for a controlled gate.

RZ_M90 

Rz(-90°) gate.

\[ R_z\left(-\frac{\pi}{2}\right) = \frac{1}{\sqrt{2}} \begin{bmatrix} 1+i & 0 \\ 0 & 1-i \end{bmatrix} \]

This matrix is equivalent to the S-dagger gate, but differs in global phase. Note that this difference is significant when it is used as a submatrix for a controlled gate.

RZ_180 

Rz(180°) gate.

\[ R_z(\pi) = \begin{bmatrix} -i & 0 \\ 0 & i \end{bmatrix} \]

This matrix is equivalent to the Pauli Z gate, but differs in global phase. Note that this difference is significant when it is used as a submatrix for a controlled gate.

RX 

The matrix for an arbitrary X rotation.

\[ R_x(\theta) = \begin{bmatrix} \cos{\frac{\theta}{2}} & -i\sin{\frac{\theta}{2}} \\ -i\sin{\frac{\theta}{2}} & \cos{\frac{\theta}{2}} \end{bmatrix} \]

θ is specified or returned through the first binary string argument of the parameterization ArbData object. It is represented as a little-endian double floating point value, specified in radians.

RY 

The matrix for an arbitrary Y rotation.

\[ R_y(\theta) = \begin{bmatrix} \cos{\frac{\theta}{2}} & -\sin{\frac{\theta}{2}} \\ \sin{\frac{\theta}{2}} & \cos{\frac{\theta}{2}} \end{bmatrix} \]

θ is specified or returned through the first binary string argument of the parameterization ArbData object. It is represented as a little-endian double floating point value, specified in radians.

RZ 

The matrix for an arbitrary Z rotation.

\[ R_z(\theta) = \begin{bmatrix} e^{-i\frac{\theta}{2}} & 0 \\ 0 & e^{i\frac{\theta}{2}} \end{bmatrix} \]

θ is specified or returned through the first binary string argument of the parameterization ArbData object. It is represented as a little-endian double floating point value, specified in radians.

PhaseK 

The matrix for a Z rotation with angle π/2^k.

\[ \textit{PhaseK}(k) = \textit{Phase}\left(\frac{\pi}{2^k}\right) = \begin{bmatrix} 1 & 0 \\ 0 & e^{i\pi / 2^k} \end{bmatrix} \]

k is specified or returned through the first binary string argument of the parameterization ArbData object. It is represented as a little-endian unsigned 64-bit integer.

Phase 

The matrix for an arbitrary Z rotation.

\[ \textit{Phase}(\theta) = \begin{bmatrix} 1 & 0 \\ 0 & e^{i\theta} \end{bmatrix} \]

θ is specified or returned through the first binary string argument of the parameterization ArbData object. It is represented as a little-endian double floating point value, specified in radians.

This matrix is equivalent to the Rz gate, but differs in global phase. Note that this difference is significant when it is used as a submatrix for a controlled gate. Specifically, controlled phase gates use the phase as specified by this gate, whereas Rz follows the usual algebraic notation.

U1 

Any single-qubit unitary gate, parameterized as a full unitary matrix.

The full matrix is specified or returned through the first binary string argument of the parameterization ArbData object. It is represented as an array of little-endian double floating point values, structured as real/imag pairs, with the pairs in row-major order.

Arbitrary rotation matrix.

\[ R(\theta, \phi, \lambda) = \begin{bmatrix} \cos{\frac{\theta}{2}} & -\sin{\frac{\theta}{2}} e^{i\lambda} \\ \sin{\frac{\theta}{2}} e^{i\phi} & \cos{\frac{\theta}{2}} e^{i\phi + i\lambda} \end{bmatrix} \]

This is equivalent to the following:

\[ R(\theta, \phi, \lambda) = \textit{Phase}(\phi) \cdot R_y(\theta) \cdot \textit{Phase}(\lambda) \]

The rotation order and phase is taken from Qiskit's U3 gate. Ignoring global phase, any unitary single-qubit gate can be represented with this notation.

θ, φ, and λ are specified or returned through the first three binary string arguments of the parameterization ArbData object. They are represented as little-endian double floating point values, specified in radians.

Swap 

The swap gate matrix.

\[ \textit{SWAP} = \begin{bmatrix} 1 & 0 & 0 & 0 \\ 0 & 0 & 1 & 0 \\ 0 & 1 & 0 & 0 \\ 0 & 0 & 0 & 1 \end{bmatrix} \]

SqSwap 

The square-root of a swap gate matrix.

\[ \sqrt{\textit{SWAP}} = \begin{bmatrix} 1 & 0 & 0 & 0 \\ 0 & \frac{i+1}{2} & \frac{i-1}{2} & 0 \\ 0 & \frac{i-1}{2} & \frac{i+1}{2} & 0 \\ 0 & 0 & 0 & 1 \end{bmatrix} \]

U2 

Any two-qubit unitary gate, parameterized as a full unitary matrix.

The full matrix is specified or returned through the first binary string argument of the parameterization ArbData object. It is represented as an array of little-endian double floating point values, structured as real/imag pairs, with the pairs in row-major order.

U3 

Any three-qubit unitary gate, parameterized as a full unitary matrix.

The full matrix is specified or returned through the first binary string argument of the parameterization ArbData object. It is represented as an array of little-endian double floating point values, structured as real/imag pairs, with the pairs in row-major order.

Definition at line 917 of file dqcsim.

Function Documentation

◆ check() [1/15]

void dqcsim::wrap::check ( raw::dqcs_return_t  code)
inline

Checks a dqcs_return_t return value; if failure, throws a runtime error with DQCsim's error message.

Parameters
codeThe raw function return code.
Exceptions
std::runtime_errorWhen the return code indicated failure.

Definition at line 124 of file dqcsim.

◆ check() [2/15]

bool dqcsim::wrap::check ( raw::dqcs_bool_return_t  code)
inline

Checks a dqcs_bool_return_t return value; if failure, throws a runtime error with DQCsim's error message.

Parameters
codeThe raw function return code.
Returns
The wrapped boolean.
Exceptions
std::runtime_errorWhen the return code indicated failure.

Definition at line 138 of file dqcsim.

◆ check() [3/15]

unsigned long long dqcsim::wrap::check ( unsigned long long  handle)
inline

Checks a dqcs_handle_t or dqcs_qubit_t return value; if failure, throws a runtime error with DQCsim's error message.

Parameters
handleThe raw function return code.
Returns
The wrapped handle or qubit index.
Exceptions
std::runtime_errorWhen the return code indicated failure.

Definition at line 156 of file dqcsim.

◆ check() [4/15]

Cycle dqcsim::wrap::check ( Cycle  cycle)
inline

Checks a dqcs_cycle_t return value; if failure, throws a runtime error with DQCsim's error message.

Parameters
cycleThe raw function return code.
Returns
The wrapped cycle count.
Exceptions
std::runtime_errorWhen the return code indicated failure.

Definition at line 171 of file dqcsim.

◆ check() [5/15]

size_t dqcsim::wrap::check ( ssize_t  size)
inline

Checks a size return value; if failure, throws a runtime error with DQCsim's error message.

Parameters
sizeThe raw function return code.
Returns
The wrapped size.
Exceptions
std::runtime_errorWhen the return code indicated failure.

Definition at line 186 of file dqcsim.

◆ check() [6/15]

double dqcsim::wrap::check ( double  value)
inline

Checks a double return value from dqcs_pcfg_*_timeout_get(); if failure, throws a runtime error with DQCsim's error message.

Parameters
valueThe raw function return code.
Returns
The wrapped double.
Exceptions
std::runtime_errorWhen the return code indicated failure.

Definition at line 201 of file dqcsim.

◆ to_raw() [1/8]

raw::dqcs_handle_type_t dqcsim::wrap::to_raw ( HandleType  type)
inlinenoexcept

Converts a HandleType to its raw C enum.

Parameters
typeThe C++ handle type to convert.
Returns
The raw handle type.

Definition at line 334 of file dqcsim.

◆ check() [7/15]

HandleType dqcsim::wrap::check ( raw::dqcs_handle_type_t  type)
inline

Checks a dqcs_handle_type_t return value and converts it to its C++ enum representation; if failure, throws a runtime error with DQCsim's error message.

Parameters
typeThe raw function return code.
Returns
The wrapped handle type.
Exceptions
std::runtime_errorWhen the return code indicated failure.

Definition at line 371 of file dqcsim.

◆ to_raw() [2/8]

raw::dqcs_loglevel_t dqcsim::wrap::to_raw ( Loglevel  loglevel)
inlinenoexcept

Converts a Loglevel to its raw C enum.

Parameters
loglevelThe C++ loglevel to convert.
Returns
The raw loglevel.

Definition at line 487 of file dqcsim.

◆ check() [8/15]

Loglevel dqcsim::wrap::check ( raw::dqcs_loglevel_t  loglevel)
inline

Checks a dqcs_loglevel_t return value and converts it to its C++ enum representation; if failure, throws a runtime error with DQCsim's error message.

Parameters
loglevelThe raw function return code.
Returns
The wrapped loglevel.
Exceptions
std::runtime_errorWhen the return code indicated failure.

Definition at line 512 of file dqcsim.

◆ to_raw() [3/8]

raw::dqcs_measurement_t dqcsim::wrap::to_raw ( MeasurementValue  measurement)
inlinenoexcept

Converts a MeasurementValue to its raw C enum.

Parameters
measurementThe C++ measurement value to convert.
Returns
The raw measurement value.

Definition at line 561 of file dqcsim.

◆ check() [9/15]

MeasurementValue dqcsim::wrap::check ( raw::dqcs_measurement_t  measurement)
inline

Checks a dqcs_measurement_t return value and converts it to its C++ enum representation; if failure, throws a runtime error with DQCsim's error message.

Parameters
measurementThe raw function return code.
Returns
The wrapped measurement value.
Exceptions
std::runtime_errorWhen the return code indicated failure.

Definition at line 580 of file dqcsim.

◆ to_raw() [4/8]

raw::dqcs_path_style_t dqcsim::wrap::to_raw ( PathStyle  style)
inlinenoexcept

Converts a PathStyle to its raw C enum.

Parameters
styleThe C++ path style to convert.
Returns
The raw path style.

Definition at line 625 of file dqcsim.

◆ check() [10/15]

PathStyle dqcsim::wrap::check ( raw::dqcs_path_style_t  style)
inline

Checks a dqcs_path_style_t return value and converts it to its C++ enum representation; if failure, throws a runtime error with DQCsim's error message.

Parameters
styleThe raw function return code.
Returns
The wrapped path style.
Exceptions
std::runtime_errorWhen the return code indicated failure.

Definition at line 644 of file dqcsim.

◆ to_raw() [5/8]

raw::dqcs_plugin_type_t dqcsim::wrap::to_raw ( PluginType  type)
inlinenoexcept

Converts a PluginType to its raw C enum.

Parameters
typeThe C++ plugin type to convert.
Returns
The raw plugin type.

Definition at line 685 of file dqcsim.

◆ check() [11/15]

PluginType dqcsim::wrap::check ( raw::dqcs_plugin_type_t  type)
inline

Checks a dqcs_plugin_type_t return value and converts it to its C++ enum representation; if failure, throws a runtime error with DQCsim's error message.

Parameters
typeThe raw function return code.
Returns
The wrapped plugin type.
Exceptions
std::runtime_errorWhen the return code indicated failure.

Definition at line 704 of file dqcsim.

◆ to_raw() [6/8]

raw::dqcs_gate_type_t dqcsim::wrap::to_raw ( GateType  type)
inlinenoexcept

Converts a GateType to its raw C enum.

Parameters
typeThe C++ gate type to convert.
Returns
The raw gate type.

Definition at line 799 of file dqcsim.

◆ check() [12/15]

GateType dqcsim::wrap::check ( raw::dqcs_gate_type_t  type)
inline

Checks a dqcs_gate_type_t return value and converts it to its C++ enum representation; if failure, throws a runtime error with DQCsim's error message.

Parameters
typeThe raw function return code.
Returns
The wrapped gate type.
Exceptions
std::runtime_errorWhen the return code indicated failure.

Definition at line 819 of file dqcsim.

◆ to_raw() [7/8]

raw::dqcs_basis_t dqcsim::wrap::to_raw ( PauliBasis  type)
inlinenoexcept

Converts a PauliBasis to its raw C enum.

Parameters
typeThe C++ basis enum variant to convert.
Returns
The raw basis enum variant.

Definition at line 882 of file dqcsim.

◆ check() [13/15]

PauliBasis dqcsim::wrap::check ( raw::dqcs_basis_t  type)
inline

Checks a dqcs_basis_t return value and converts it to its C++ enum representation; if failure, throws a runtime error with DQCsim's error message.

Parameters
typeThe raw function return code.
Returns
The wrapped basis enum variant.
Exceptions
std::runtime_errorWhen the return code indicated failure.

Definition at line 901 of file dqcsim.

◆ to_raw() [8/8]

raw::dqcs_predefined_gate_t dqcsim::wrap::to_raw ( PredefinedGate  type)
inlinenoexcept

Converts a PredefinedGate to its raw C enum.

Parameters
typeThe C++ predefined gate to convert.
Returns
The raw predefined gate type.

Definition at line 1335 of file dqcsim.

◆ check() [14/15]

PredefinedGate dqcsim::wrap::check ( raw::dqcs_predefined_gate_t  type)
inline

Checks a dqcs_predefined_gate_t return value and converts it to its C++ enum representation; if failure, throws a runtime error with DQCsim's error message.

Parameters
typeThe raw function return code.
Returns
The wrapped predefined gate type.
Exceptions
std::runtime_errorWhen the return code indicated failure.

Definition at line 1380 of file dqcsim.

◆ check() [15/15]

template<typename T >
T* dqcsim::wrap::check ( T *  pointer)
inline

Checks a pointer return value; if failure, throws a runtime error with DQCsim's error message.

Parameters
pointerThe raw function return code.
Returns
The non-null pointer.
Exceptions
std::runtime_errorWhen the return code indicated failure.

Definition at line 1425 of file dqcsim.

◆ log()

template<typename... Args>
void dqcsim::wrap::log ( wrap::Loglevel  level,
const std::string &  module,
const std::string &  file,
unsigned int  line_nr,
const std::string &  format,
Args...  args 
)
inlinenoexcept

Shim around the dqcs_log_format C API using std::string for the strings.

Note
The printf format arguments are passed directly into a C-only printf-like function. Therefore, you must use the c_str() function if you want to format std::string variables.

If logging through DQCsim's conventional channels fails, this function simply outputs to stderr directly. Therefore, it cannot fail.

To avoid having to fill out module, file, and line_nr manually, you can use the DQCSIM_LOG macro (or its loglevel-specific friends). If you define DQCSIM_SHORT_LOGGING_MACROS before including <dqcsim>, you can also use the LOG shorthand (or its loglevel-specific friends).

Parameters
levelThe severity level of the message.
moduleThe "module" sending the message. This is unused by the C++ macros.
fileThe source file for the code sending the message (you can use __FILE__ for this).
line_nrThe line number within the source file of the code sending the message (you can use __LINE__ for this).
formatThe printf-style format string for the log message.
argsThe arguments for the printf-style format string.

Definition at line 1459 of file dqcsim.

◆ log_raw()

bool dqcsim::wrap::log_raw ( wrap::Loglevel  level,
const std::string &  module,
const std::string &  file,
unsigned int  line_nr,
const std::string &  message 
)
inlinenoexcept

Shim around the dqcs_log_raw C API using std::string for the strings.

To avoid having to fill out module, file, and line_nr manually, you can use the DQCSIM_LOG macro (or its loglevel-specific friends). If you define DQCSIM_SHORT_LOGGING_MACROS before including <dqcsim>, you can also use the LOG shorthand (or its loglevel-specific friends).

Parameters
levelThe severity level of the message.
moduleThe "module" sending the message. This is unused by the C++ macros.
fileThe source file for the code sending the message (you can use __FILE__ for this).
line_nrThe line number within the source file of the code sending the message (you can use __LINE__ for this).
messageThe log message.
Returns
Whether logging succeeded.

Definition at line 1495 of file dqcsim.

◆ Frontend()

PluginConfigurationBuilder dqcsim::wrap::Frontend ( const std::string &  name = "")
inlinenoexcept

Shorthand for constructing a frontend plugin configuration builder.

Parameters
nameAn optional name for the plugin. See PluginConfigurationBuilder::with_name().
Returns
A PluginConfigurationBuilder for a frontend plugin with the given name.

Definition at line 9430 of file dqcsim.

◆ Operator()

PluginConfigurationBuilder dqcsim::wrap::Operator ( const std::string &  name = "")
inlinenoexcept

Shorthand for constructing an operator plugin configuration builder.

Parameters
nameAn optional name for the plugin. See PluginConfigurationBuilder::with_name().
Returns
A PluginConfigurationBuilder for an operator plugin with the given name.

Definition at line 9442 of file dqcsim.

◆ Backend()

PluginConfigurationBuilder dqcsim::wrap::Backend ( const std::string &  name = "")
inlinenoexcept

Shorthand for constructing a backend plugin configuration builder.

Parameters
nameAn optional name for the plugin. See PluginConfigurationBuilder::with_name().
Returns
A PluginConfigurationBuilder for a backend plugin with the given name.

Definition at line 9454 of file dqcsim.