DQCsim
Public Member Functions | Static Public Member Functions | List of all members
dqcsim::wrap::Gate Class Reference

Represents any kind of gate with qubits bound to it. More...

Inheritance diagram for dqcsim::wrap::Gate:
dqcsim::wrap::Arb dqcsim::wrap::Handle

Public Member Functions

 Gate (HandleIndex handle) noexcept
 Wraps the given Gate handle. More...
 
 Gate (const Gate &)=delete
 
void operator= (const Gate &)=delete
 
 Gate (Gate &&)=default
 Default move constructor.
 
Gateoperator= (Gate &&)=default
 Default move assignment.
 
GateType get_type () const
 Returns the type of this gate. More...
 
QubitSet get_targets () const
 Returns a new qubit reference set with the target qubits for this gate. More...
 
bool has_targets () const
 Returns whether this gate has target qubits. More...
 
QubitSet get_controls () const
 Returns a new qubit reference set with the control qubits for this gate. More...
 
bool has_controls () const
 Returns whether this gate has control qubits. More...
 
QubitSet get_measures () const
 Returns a new qubit reference set with the measurement qubits for this gate. More...
 
bool has_measures () const
 Returns whether this gate has measurement qubits. More...
 
Matrix get_matrix () const
 Returns the matrix that belongs to this gate. More...
 
bool has_matrix () const
 Returns whether this gate has a matrix. More...
 
std::string get_name () const
 Returns the name of a custom gate. More...
 
bool has_name () const
 Returns whether this gate has a name. More...
 
Gatewith_json_string (const std::string &json)
 Sets the arbitrary JSON data to the given serialized JSON string (builder pattern). More...
 
Gatewith_cbor_string (const std::string &cbor)
 Sets the arbitrary JSON data to the given serialized CBOR string (builder pattern). More...
 
template<class JSON >
Gatewith_json (const JSON &json)
 Sets the arbitrary JSON data to the given JSON object from nlohmann::json (builder pattern). More...
 
Gatewith_arg_string (const std::string &data)
 Pushes a (binary) string to the back of the arbitrary argument list (builder pattern). More...
 
template<typename T >
Gatewith_arg (const T &data)
 Pushes a value of type T to the back of the arbitrary argument list (builder pattern). More...
 
- Public Member Functions inherited from dqcsim::wrap::Arb
 Arb (HandleIndex handle) noexcept
 Wraps the given arb handle. More...
 
std::string get_arb_json_string () const
 Returns the current arbitrary JSON data as a serialized JSON string. More...
 
void set_arb_json_string (const std::string &json)
 Sets the arbitrary JSON data to the given serialized JSON string. More...
 
std::string get_arb_cbor_string () const
 Returns the current arbitrary JSON data as a serialized CBOR string. More...
 
void set_arb_cbor_string (const std::string &cbor)
 Sets the arbitrary JSON data to the given serialized CBOR string. More...
 
template<class JSON >
JSON get_arb_json () const
 Returns the current arbitrary JSON data as a JSON object from nlohmann::json. More...
 
template<class JSON >
void set_arb_json (const JSON &json)
 Sets the arbitrary JSON data to the given JSON object from nlohmann::json. More...
 
std::string get_arb_arg_string (ssize_t index) const
 Returns the arbitrary argument at the given index as a (binary) string. More...
 
template<typename T >
get_arb_arg_as (ssize_t index) const
 Returns the arbitrary argument at the given index as the given type. More...
 
template<typename T >
void set_arb_arg_strings (const T &strings)
 Sets the arbitrary argument list to the given iterable of std::strings. More...
 
void set_arb_arg_string (ssize_t index, const std::string &data)
 Sets the arbitrary argument at the given index to a (binary) string. More...
 
template<typename T >
void set_arb_arg (ssize_t index, const T &data)
 Sets the arbitrary argument at the given index to a value of type T. More...
 
void push_arb_arg_string (const std::string &data)
 Pushes a (binary) string to the back of the arbitrary argument list. More...
 
template<typename T >
void push_arb_arg (const T &data)
 Pushes a value of type T to the back of the arbitrary argument list. More...
 
std::string pop_arb_arg_string ()
 Pops from the back of the arbitrary argument list as a (binary) string. More...
 
template<typename T >
pop_arb_arg_as () const
 Pops from the back of the arbitrary argument list as a value of type T. More...
 
void insert_arb_arg_string (ssize_t index, const std::string &data)
 Inserts an arbitrary argument at the given index using a (binary) string. More...
 
template<typename T >
void insert_arb_arg (ssize_t index, const T &data)
 Inserts an arbitrary argument at the given index using a value of type T. More...
 
void remove_arb_arg (ssize_t index)
 Removes the arbitrary argument at the given index. More...
 
size_t get_arb_arg_count () const
 Returns the number of arbitrary arguments. More...
 
void clear_arb_args ()
 Clears the arbitrary argument list. More...
 
void set_arb (const Arb &src)
 Assigns all arb data from the given arb to this one. More...
 
- Public Member Functions inherited from dqcsim::wrap::Handle
 Handle () noexcept
 Constructs an empty wrapper. More...
 
 Handle (HandleIndex handle) noexcept
 Wraps the given raw handle. More...
 
virtual ~Handle () noexcept
 Delete the handle and its wrapper.
 
void free ()
 Explicitly delete the handle, allowing errors to be caught. More...
 
bool is_valid () const noexcept
 Returns whether this wrapper (still) contains a valid handle. More...
 
HandleIndex get_handle () const noexcept
 Returns the raw handle without relinquishing ownership. More...
 
HandleIndex take_handle () noexcept
 Returns the raw handle and relinquishes ownership. More...
 
 Handle (const Handle &)=delete
 
void operator= (const Handle &)=delete
 
 Handle (Handle &&src)
 Move constructor; simply moves ownership of the handle from the source object to the constructed object. More...
 
Handleoperator= (Handle &&src)
 Move constructor; simply moves ownership of the handle from the source object to the assignment target. More...
 
std::string dump () const
 Returns a string containing a debug dump of the handle. More...
 
HandleType type () const
 Returns the type of this handle. More...
 

Static Public Member Functions

static Gate predefined (PredefinedGate gate, QubitSet &&qubits, ArbData &&parameters)
 Constructs a new predefined gate. More...
 
static Gate predefined (PredefinedGate gate, const QubitSet &qubits, const ArbData &parameters)
 Constructs a new predefined gate. More...
 
static Gate predefined (PredefinedGate gate, QubitSet &&qubits)
 Constructs a new non-parameterized predefined gate. More...
 
static Gate predefined (PredefinedGate gate, const QubitSet &qubits)
 Constructs a new non-parameterized predefined gate. More...
 
static Gate unitary (QubitSet &&targets, const Matrix &matrix)
 Constructs a new custom unitary gate. More...
 
static Gate unitary (const QubitSet &targets, const Matrix &matrix)
 Constructs a new custom unitary gate. More...
 
static Gate unitary (QubitSet &&targets, QubitSet &&controls, const Matrix &matrix)
 Constructs a new custom unitary gate with control qubits. More...
 
static Gate unitary (const QubitSet &targets, const QubitSet &controls, const Matrix &matrix)
 Constructs a new custom unitary gate with control qubits. More...
 
static Gate measure (QubitSet &&measures)
 Constructs a new Z-axis measurement gate. More...
 
static Gate measure (const QubitSet &measures)
 Constructs a new Z-axis measurement gate. More...
 
static Gate measure (QubitSet &&measures, PauliBasis basis)
 Constructs a new measurement gate, measuring in the given Pauli basis. More...
 
static Gate measure (const QubitSet &measures, PauliBasis basis)
 Constructs a new measurement gate, measuring in the given Pauli basis. More...
 
static Gate measure (QubitSet &&measures, Matrix &&basis)
 Constructs a new measurement gate, measuring in the given custom basis. More...
 
static Gate measure (const QubitSet &measures, const Matrix &basis)
 Constructs a new measurement gate, measuring in the given custom basis. More...
 
static Gate prep (QubitSet &&targets)
 Constructs a new Z-axis prep gate, putting the qubits in the |0> state. More...
 
static Gate prep (const QubitSet &targets)
 Constructs a new Z-axis prep gate, putting the qubits in the |0> state. More...
 
static Gate prep (QubitSet &&targets, PauliBasis basis)
 Constructs a new prep gate, putting the qubits in the base state for the given Pauli basis. More...
 
static Gate prep (const QubitSet &targets, PauliBasis basis)
 Constructs a new prep gate, putting the qubits in the base state for the given Pauli basis. More...
 
static Gate prep (QubitSet &&targets, Matrix &&basis)
 Constructs a new prep gate for a custom initial state. More...
 
static Gate prep (const QubitSet &targets, const Matrix &basis)
 Constructs a new prep gate for a custom initial state. More...
 
static Gate custom (const std::string &name, QubitSet &&targets, QubitSet &&controls, QubitSet &&measures, const Matrix &matrix)
 Constructs a new custom gate with target qubits, control qubits, measured qubits, and a matrix. More...
 
static Gate custom (const std::string &name, const QubitSet &targets, const QubitSet &controls, const QubitSet &measures, const Matrix &matrix)
 Constructs a new custom gate with target qubits, control qubits, measured qubits, and a matrix. More...
 
static Gate custom (const std::string &name, QubitSet &&targets, QubitSet &&controls, QubitSet &&measures)
 Constructs a new custom gate with target qubits, control qubits, and measured qubits. More...
 
static Gate custom (const std::string &name, const QubitSet &targets, const QubitSet &controls, const QubitSet &measures)
 Constructs a new custom gate with target qubits, control qubits, and measured qubits. More...
 
static Gate custom (const std::string &name, QubitSet &&targets, QubitSet &&controls, const Matrix &matrix)
 Constructs a new custom gate with target qubits, control qubits, and a matrix. More...
 
static Gate custom (const std::string &name, const QubitSet &targets, const QubitSet &controls, const Matrix &matrix)
 Constructs a new custom gate with target qubits, control qubits, and a matrix. More...
 
static Gate custom (const std::string &name, QubitSet &&targets, QubitSet &&controls)
 Constructs a new custom gate with target qubits and control qubits. More...
 
static Gate custom (const std::string &name, const QubitSet &targets, const QubitSet &controls)
 Constructs a new custom gate with target qubits and control qubits. More...
 
static Gate custom (const std::string &name, QubitSet &&targets, const Matrix &matrix)
 Constructs a new custom gate with target qubits and a matrix. More...
 
static Gate custom (const std::string &name, const QubitSet &targets, const Matrix &matrix)
 Constructs a new custom gate with target qubits and a matrix. More...
 
static Gate custom (const std::string &name, QubitSet &&targets)
 Constructs a new custom gate with only target qubits. More...
 
static Gate custom (const std::string &name, const QubitSet &targets)
 Constructs a new custom gate with only target qubits. More...
 
static Gate custom (const std::string &name)
 Constructs a new custom gate without qubit operands. More...
 

Additional Inherited Members

- Protected Attributes inherited from dqcsim::wrap::Handle
HandleIndex handle
 The wrapped handle.
 

Detailed Description

Represents any kind of gate with qubits bound to it.

DQCsim currently knows three kinds of gates: unitary gates, Z-axis measurement gates, and custom gates. These are constructed with the unitary, measurement, and custom constructors respectively. Briefly put:

Refer to the constructor overloads for more information.

Gates may have arbitrary data attached to them. This is particularly useful for custom gates, but non-custom gates can also have such data to augment their behavior. The difference in that case is that custom gates must be rejected by downstream plugins that don't support them, while the arbitrary dats for augmented unitary and measurement gates may be ignored. To construct a gate with arbitrary data, use one of the constructor overloads followed by the ArbData builder pattern functions, for instance:

"foobar", // name
QubitSet().with(1_q) // target
).with_json_string("{\"hello\": \"world\"}")
.with_arg<int>(33)
.with_arg_string("I'm a string!");

Definition at line 3552 of file dqcsim.

Constructor & Destructor Documentation

◆ Gate()

dqcsim::wrap::Gate::Gate ( HandleIndex  handle)
inlinenoexcept

Wraps the given Gate handle.

Note
This constructor does not verify that the handle is actually valid.
Parameters
handleThe raw handle to wrap.

Definition at line 3563 of file dqcsim.

Member Function Documentation

◆ predefined() [1/4]

static Gate dqcsim::wrap::Gate::predefined ( PredefinedGate  gate,
QubitSet &&  qubits,
ArbData &&  parameters 
)
inlinestatic

Constructs a new predefined gate.

Parameters
gateThe type of gate to construct.
qubitsThe qubits that the gate should operate on. This should be at least the number of qubits required by the gate type; any additional qubits added on the left-hand side will serve as control qubits for a controlled gate using the specified gate matrix as its non-controlled submatrix.
parametersAn ArbData object containing the parameterization data for the predefined gate, if it requires parameters. Refer to the docs for PredefinedGate for more info. Any additional data in the ArbData object will be added to the gate's ArbData attachment.
Returns
The requested unitary gate.
Exceptions
std::runtime_errorWhen construction of the new handle failed for some reason.

Definition at line 3597 of file dqcsim.

◆ predefined() [2/4]

static Gate dqcsim::wrap::Gate::predefined ( PredefinedGate  gate,
const QubitSet qubits,
const ArbData parameters 
)
inlinestatic

Constructs a new predefined gate.

Parameters
gateThe type of gate to construct.
qubitsThe qubits that the gate should operate on. This should be at least the number of qubits required by the gate type; any additional qubits added on the left-hand side will serve as control qubits for a controlled gate using the specified gate matrix as its non-controlled submatrix.
parametersAn ArbData object containing the parameterization data for the predefined gate, if it requires parameters. Refer to the docs for PredefinedGate for more info. Any additional data in the ArbData object will be added to the gate's ArbData attachment.
Returns
The requested unitary gate.
Exceptions
std::runtime_errorWhen construction of the new handle failed for some reason.

Definition at line 3622 of file dqcsim.

◆ predefined() [3/4]

static Gate dqcsim::wrap::Gate::predefined ( PredefinedGate  gate,
QubitSet &&  qubits 
)
inlinestatic

Constructs a new non-parameterized predefined gate.

Parameters
gateThe type of gate to construct.
qubitsThe qubits that the gate should operate on. This should be at least the number of qubits required by the gate type; any additional qubits added on the left-hand side will serve as control qubits for a controlled gate using the specified gate matrix as its non-controlled submatrix.
Returns
The requested unitary gate.
Exceptions
std::runtime_errorWhen construction of the new handle failed for some reason.

Definition at line 3639 of file dqcsim.

◆ predefined() [4/4]

static Gate dqcsim::wrap::Gate::predefined ( PredefinedGate  gate,
const QubitSet qubits 
)
inlinestatic

Constructs a new non-parameterized predefined gate.

Parameters
gateThe type of gate to construct.
qubitsThe qubits that the gate should operate on. This should be at least the number of qubits required by the gate type; any additional qubits added on the left-hand side will serve as control qubits for a controlled gate using the specified gate matrix as its non-controlled submatrix.
Returns
The requested unitary gate.
Exceptions
std::runtime_errorWhen construction of the new handle failed for some reason.

Definition at line 3660 of file dqcsim.

◆ unitary() [1/4]

static Gate dqcsim::wrap::Gate::unitary ( QubitSet &&  targets,
const Matrix matrix 
)
inlinestatic

Constructs a new custom unitary gate.

Parameters
targetsA qubit reference set with the target qubits.
matrixThe matrix to be applied to the target qubits. It must be appropriately sized for the number of target qubits (2^n by 2^n).
Returns
The requested unitary gate.
Exceptions
std::runtime_errorWhen construction of the new handle failed for some reason.

Definition at line 3674 of file dqcsim.

◆ unitary() [2/4]

static Gate dqcsim::wrap::Gate::unitary ( const QubitSet targets,
const Matrix matrix 
)
inlinestatic

Constructs a new custom unitary gate.

Parameters
targetsA qubit reference set with the target qubits, passed by copy.
matrixThe matrix to be applied to the target qubits. It must be appropriately sized for the number of target qubits (2^n by 2^n).
Returns
The requested unitary gate.
Exceptions
std::runtime_errorWhen construction of the new handle failed for some reason.

Definition at line 3693 of file dqcsim.

◆ unitary() [3/4]

static Gate dqcsim::wrap::Gate::unitary ( QubitSet &&  targets,
QubitSet &&  controls,
const Matrix matrix 
)
inlinestatic

Constructs a new custom unitary gate with control qubits.

Parameters
targetsA qubit reference set with the target qubits.
controlsA qubit reference set with the target qubits. The control qubits are not represented in the matrix; the backend will supplement it as needed. The targets and controls qubit sets must be disjoint.
matrixThe matrix to be applied to the target qubits. It must be appropriately sized for the number of target qubits (2^n by 2^n).
Returns
The requested unitary gate.
Exceptions
std::runtime_errorWhen construction of the new handle failed for some reason.

Definition at line 3711 of file dqcsim.

◆ unitary() [4/4]

static Gate dqcsim::wrap::Gate::unitary ( const QubitSet targets,
const QubitSet controls,
const Matrix matrix 
)
inlinestatic

Constructs a new custom unitary gate with control qubits.

Parameters
targetsA qubit reference set with the target qubits, passed by copy.
controlsA qubit reference set with the target qubits, passed by copy. The control qubits are not represented in the matrix; the backend will supplement it as needed. The targets and controls qubit sets must be disjoint.
matrixThe matrix to be applied to the target qubits. It must be appropriately sized for the number of target qubits (2^n by 2^n).
Returns
The requested unitary gate.
Exceptions
std::runtime_errorWhen construction of the new handle failed for some reason.

Definition at line 3734 of file dqcsim.

◆ measure() [1/6]

static Gate dqcsim::wrap::Gate::measure ( QubitSet &&  measures)
inlinestatic

Constructs a new Z-axis measurement gate.

Parameters
measuresA qubit reference set with the to-be-measured qubits. The measurement results can be queried from PluginState after the gate is executed. Any previous measurement results for those qubits will be overridden.
Returns
The requested measurement gate.
Exceptions
std::runtime_errorWhen construction of the new handle failed for some reason.

Definition at line 3749 of file dqcsim.

◆ measure() [2/6]

static Gate dqcsim::wrap::Gate::measure ( const QubitSet measures)
inlinestatic

Constructs a new Z-axis measurement gate.

Parameters
measuresA qubit reference set with the to-be-measured qubits, passed by copy. The measurement results can be queried from PluginState after the gate is executed. Any previous measurement results for those qubits will be overridden.
Returns
The requested measurement gate.
Exceptions
std::runtime_errorWhen construction of the new handle failed for some reason.

Definition at line 3764 of file dqcsim.

◆ measure() [3/6]

static Gate dqcsim::wrap::Gate::measure ( QubitSet &&  measures,
PauliBasis  basis 
)
inlinestatic

Constructs a new measurement gate, measuring in the given Pauli basis.

Parameters
measuresA qubit reference set with the to-be-measured qubits. The measurement results can be queried from PluginState after the gate is executed. Any previous measurement results for those qubits will be overridden.
basisThe measurement basis.
Returns
The requested measurement gate.
Exceptions
std::runtime_errorWhen construction of the new handle failed for some reason.

Definition at line 3780 of file dqcsim.

◆ measure() [4/6]

static Gate dqcsim::wrap::Gate::measure ( const QubitSet measures,
PauliBasis  basis 
)
inlinestatic

Constructs a new measurement gate, measuring in the given Pauli basis.

Parameters
measuresA qubit reference set with the to-be-measured qubits, passed by copy. The measurement results can be queried from PluginState after the gate is executed. Any previous measurement results for those qubits will be overridden.
basisThe measurement basis.
Returns
The requested measurement gate.
Exceptions
std::runtime_errorWhen construction of the new handle failed for some reason.

Definition at line 3796 of file dqcsim.

◆ measure() [5/6]

static Gate dqcsim::wrap::Gate::measure ( QubitSet &&  measures,
Matrix &&  basis 
)
inlinestatic

Constructs a new measurement gate, measuring in the given custom basis.

Parameters
measuresA qubit reference set with the to-be-measured qubits. The measurement results can be queried from PluginState after the gate is executed. Any previous measurement results for those qubits will be overridden.
basisThe measurement basis, represented as a 2x2 matrix defining the rotation from the Z basis to the desired basis.
Returns
The requested measurement gate.
Exceptions
std::runtime_errorWhen construction of the new handle failed for some reason.

Definition at line 3813 of file dqcsim.

◆ measure() [6/6]

static Gate dqcsim::wrap::Gate::measure ( const QubitSet measures,
const Matrix basis 
)
inlinestatic

Constructs a new measurement gate, measuring in the given custom basis.

Parameters
measuresA qubit reference set with the to-be-measured qubits, passed by copy. The measurement results can be queried from PluginState after the gate is executed. Any previous measurement results for those qubits will be overridden.
basisThe measurement basis, represented as a 2x2 matrix defining the rotation from the Z basis to the desired basis.
Returns
The requested measurement gate.
Exceptions
std::runtime_errorWhen construction of the new handle failed for some reason.

Definition at line 3830 of file dqcsim.

◆ prep() [1/6]

static Gate dqcsim::wrap::Gate::prep ( QubitSet &&  targets)
inlinestatic

Constructs a new Z-axis prep gate, putting the qubits in the |0> state.

Parameters
targetsA qubit reference set with the to-be-prepared qubits.
Returns
The requested prep gate.
Exceptions
std::runtime_errorWhen construction of the new handle failed for some reason.

Definition at line 3842 of file dqcsim.

◆ prep() [2/6]

static Gate dqcsim::wrap::Gate::prep ( const QubitSet targets)
inlinestatic

Constructs a new Z-axis prep gate, putting the qubits in the |0> state.

Parameters
targetsA qubit reference set with the to-be-prepared qubits.
Returns
The requested prep gate.
Exceptions
std::runtime_errorWhen construction of the new handle failed for some reason.

Definition at line 3854 of file dqcsim.

◆ prep() [3/6]

static Gate dqcsim::wrap::Gate::prep ( QubitSet &&  targets,
PauliBasis  basis 
)
inlinestatic

Constructs a new prep gate, putting the qubits in the base state for the given Pauli basis.

Parameters
targetsA qubit reference set with the to-be-prepared qubits.
basisThe basis.
Returns
The requested prep gate.
Exceptions
std::runtime_errorWhen construction of the new handle failed for some reason.

Definition at line 3868 of file dqcsim.

◆ prep() [4/6]

static Gate dqcsim::wrap::Gate::prep ( const QubitSet targets,
PauliBasis  basis 
)
inlinestatic

Constructs a new prep gate, putting the qubits in the base state for the given Pauli basis.

Parameters
targetsA qubit reference set with the to-be-prepared qubits.
basisThe basis.
Returns
The requested prep gate.
Exceptions
std::runtime_errorWhen construction of the new handle failed for some reason.

Definition at line 3882 of file dqcsim.

◆ prep() [5/6]

static Gate dqcsim::wrap::Gate::prep ( QubitSet &&  targets,
Matrix &&  basis 
)
inlinestatic

Constructs a new prep gate for a custom initial state.

Parameters
targetsA qubit reference set with the to-be-prepared qubits.
basisThe basis, represented as a 2x2 matrix defining the rotation to be applied after initializing the qubits to |0>.
Returns
The requested prep gate.
Exceptions
std::runtime_errorWhen construction of the new handle failed for some reason.

Definition at line 3896 of file dqcsim.

◆ prep() [6/6]

static Gate dqcsim::wrap::Gate::prep ( const QubitSet targets,
const Matrix basis 
)
inlinestatic

Constructs a new prep gate for a custom initial state.

Parameters
targetsA qubit reference set with the to-be-prepared qubits.
basisThe basis, represented as a 2x2 matrix defining the rotation to be applied after initializing the qubits to |0>.
Returns
The requested prep gate.
Exceptions
std::runtime_errorWhen construction of the new handle failed for some reason.

Definition at line 3910 of file dqcsim.

◆ custom() [1/13]

static Gate dqcsim::wrap::Gate::custom ( const std::string &  name,
QubitSet &&  targets,
QubitSet &&  controls,
QubitSet &&  measures,
const Matrix matrix 
)
inlinestatic

Constructs a new custom gate with target qubits, control qubits, measured qubits, and a matrix.

Parameters
nameA name identifying the custom gate. Which gates are available is determined by the backend.
targetsA qubit reference set with the target qubits.
controlsA qubit reference set with the target qubits. The control qubits are not represented in the matrix; the backend will supplement it as needed. The targets and controls qubit sets must be disjoint.
measuresA qubit reference set with to-be-measured qubits. The measurement results can be queried from PluginState after the gate is executed. Any previous measurement results for those qubits will be overridden.
matrixThe matrix to be applied to the target qubits. It must be appropriately sized for the number of target qubits (2^n by 2^n).
Returns
The requested custom gate.
Exceptions
std::runtime_errorWhen construction of the new handle failed for some reason.

Definition at line 3937 of file dqcsim.

◆ custom() [2/13]

static Gate dqcsim::wrap::Gate::custom ( const std::string &  name,
const QubitSet targets,
const QubitSet controls,
const QubitSet measures,
const Matrix matrix 
)
inlinestatic

Constructs a new custom gate with target qubits, control qubits, measured qubits, and a matrix.

Parameters
nameA name identifying the custom gate. Which gates are available is determined by the backend.
targetsA qubit reference set with the target qubits, passed by copy.
controlsA qubit reference set with the target qubits, passed by copy. The control qubits are not represented in the matrix; the backend will supplement it as needed. The targets and controls qubit sets must be disjoint.
measuresA qubit reference set with to-be-measured qubits, passed by copy. The measurement results can be queried from PluginState after the gate is executed. Any previous measurement results for those qubits will be overridden.
matrixThe matrix to be applied to the target qubits. It must be appropriately sized for the number of target qubits (2^n by 2^n).
Returns
The requested custom gate.
Exceptions
std::runtime_errorWhen construction of the new handle failed for some reason.

Definition at line 3975 of file dqcsim.

◆ custom() [3/13]

static Gate dqcsim::wrap::Gate::custom ( const std::string &  name,
QubitSet &&  targets,
QubitSet &&  controls,
QubitSet &&  measures 
)
inlinestatic

Constructs a new custom gate with target qubits, control qubits, and measured qubits.

Parameters
nameA name identifying the custom gate. Which gates are available is determined by the backend.
targetsA qubit reference set with the target qubits.
controlsA qubit reference set with the target qubits. The targets and controls qubit sets must be disjoint.
measuresA qubit reference set with to-be-measured qubits. The measurement results can be queried from PluginState after the gate is executed. Any previous measurement results for those qubits will be overridden.
Returns
The requested custom gate.
Exceptions
std::runtime_errorWhen construction of the new handle failed for some reason.

Definition at line 4008 of file dqcsim.

◆ custom() [4/13]

static Gate dqcsim::wrap::Gate::custom ( const std::string &  name,
const QubitSet targets,
const QubitSet controls,
const QubitSet measures 
)
inlinestatic

Constructs a new custom gate with target qubits, control qubits, and measured qubits.

Parameters
nameA name identifying the custom gate. Which gates are available is determined by the backend.
targetsA qubit reference set with the target qubits, passed by copy.
controlsA qubit reference set with the target qubits, passed by copy. The targets and controls qubit sets must be disjoint.
measuresA qubit reference set with to-be-measured qubits, passed by copy. The measurement results can be queried from PluginState after the gate is executed. Any previous measurement results for those qubits will be overridden.
Returns
The requested custom gate.
Exceptions
std::runtime_errorWhen construction of the new handle failed for some reason.

Definition at line 4041 of file dqcsim.

◆ custom() [5/13]

static Gate dqcsim::wrap::Gate::custom ( const std::string &  name,
QubitSet &&  targets,
QubitSet &&  controls,
const Matrix matrix 
)
inlinestatic

Constructs a new custom gate with target qubits, control qubits, and a matrix.

Parameters
nameA name identifying the custom gate. Which gates are available is determined by the backend.
targetsA qubit reference set with the target qubits.
controlsA qubit reference set with the target qubits. The control qubits are not represented in the matrix; the backend will supplement it as needed. The targets and controls qubit sets must be disjoint.
matrixThe matrix to be applied to the target qubits. It must be appropriately sized for the number of target qubits (2^n by 2^n).
Returns
The requested custom gate.
Exceptions
std::runtime_errorWhen construction of the new handle failed for some reason.

Definition at line 4072 of file dqcsim.

◆ custom() [6/13]

static Gate dqcsim::wrap::Gate::custom ( const std::string &  name,
const QubitSet targets,
const QubitSet controls,
const Matrix matrix 
)
inlinestatic

Constructs a new custom gate with target qubits, control qubits, and a matrix.

Parameters
nameA name identifying the custom gate. Which gates are available is determined by the backend.
targetsA qubit reference set with the target qubits, passed by copy.
controlsA qubit reference set with the target qubits, passed by copy. The control qubits are not represented in the matrix; the backend will supplement it as needed. The targets and controls qubit sets must be disjoint.
matrixThe matrix to be applied to the target qubits. It must be appropriately sized for the number of target qubits (2^n by 2^n).
Returns
The requested custom gate.
Exceptions
std::runtime_errorWhen construction of the new handle failed for some reason.

Definition at line 4105 of file dqcsim.

◆ custom() [7/13]

static Gate dqcsim::wrap::Gate::custom ( const std::string &  name,
QubitSet &&  targets,
QubitSet &&  controls 
)
inlinestatic

Constructs a new custom gate with target qubits and control qubits.

Parameters
nameA name identifying the custom gate. Which gates are available is determined by the backend.
targetsA qubit reference set with the target qubits.
controlsA qubit reference set with the target qubits. The targets and controls qubit sets must be disjoint.
Returns
The requested custom gate.
Exceptions
std::runtime_errorWhen construction of the new handle failed for some reason.

Definition at line 4131 of file dqcsim.

◆ custom() [8/13]

static Gate dqcsim::wrap::Gate::custom ( const std::string &  name,
const QubitSet targets,
const QubitSet controls 
)
inlinestatic

Constructs a new custom gate with target qubits and control qubits.

Parameters
nameA name identifying the custom gate. Which gates are available is determined by the backend.
targetsA qubit reference set with the target qubits, passed by copy.
controlsA qubit reference set with the target qubits, passed by copy. The targets and controls qubit sets must be disjoint.
Returns
The requested custom gate.
Exceptions
std::runtime_errorWhen construction of the new handle failed for some reason.

Definition at line 4158 of file dqcsim.

◆ custom() [9/13]

static Gate dqcsim::wrap::Gate::custom ( const std::string &  name,
QubitSet &&  targets,
const Matrix matrix 
)
inlinestatic

Constructs a new custom gate with target qubits and a matrix.

Parameters
nameA name identifying the custom gate. Which gates are available is determined by the backend.
targetsA qubit reference set with the target qubits.
matrixThe matrix to be applied to the target qubits. It must be appropriately sized for the number of target qubits (2^n by 2^n).
Returns
The requested custom gate.
Exceptions
std::runtime_errorWhen construction of the new handle failed for some reason.

Definition at line 4182 of file dqcsim.

◆ custom() [10/13]

static Gate dqcsim::wrap::Gate::custom ( const std::string &  name,
const QubitSet targets,
const Matrix matrix 
)
inlinestatic

Constructs a new custom gate with target qubits and a matrix.

Parameters
nameA name identifying the custom gate. Which gates are available is determined by the backend.
targetsA qubit reference set with the target qubits, passed by copy.
matrixThe matrix to be applied to the target qubits. It must be appropriately sized for the number of target qubits (2^n by 2^n).
Returns
The requested custom gate.
Exceptions
std::runtime_errorWhen construction of the new handle failed for some reason.

Definition at line 4209 of file dqcsim.

◆ custom() [11/13]

static Gate dqcsim::wrap::Gate::custom ( const std::string &  name,
QubitSet &&  targets 
)
inlinestatic

Constructs a new custom gate with only target qubits.

Parameters
nameA name identifying the custom gate. Which gates are available is determined by the backend.
targetsA qubit reference set with the target qubits.
Returns
The requested custom gate.
Exceptions
std::runtime_errorWhen construction of the new handle failed for some reason.

Definition at line 4231 of file dqcsim.

◆ custom() [12/13]

static Gate dqcsim::wrap::Gate::custom ( const std::string &  name,
const QubitSet targets 
)
inlinestatic

Constructs a new custom gate with only target qubits.

Parameters
nameA name identifying the custom gate. Which gates are available is determined by the backend.
targetsA qubit reference set with the target qubits, passed by copy.
Returns
The requested custom gate.
Exceptions
std::runtime_errorWhen construction of the new handle failed for some reason.

Definition at line 4255 of file dqcsim.

◆ custom() [13/13]

static Gate dqcsim::wrap::Gate::custom ( const std::string &  name)
inlinestatic

Constructs a new custom gate without qubit operands.

Parameters
nameA name identifying the custom gate. Which gates are available is determined by the backend.
Returns
The requested custom gate.
Exceptions
std::runtime_errorWhen construction of the new handle failed for some reason.

Definition at line 4274 of file dqcsim.

◆ get_type()

GateType dqcsim::wrap::Gate::get_type ( ) const
inline

Returns the type of this gate.

Returns
The gate type.
Exceptions
std::runtime_errorWhen the current handle is invalid.

Definition at line 4292 of file dqcsim.

◆ get_targets()

QubitSet dqcsim::wrap::Gate::get_targets ( ) const
inline

Returns a new qubit reference set with the target qubits for this gate.

Returns
A new qubit reference set with the target qubits for this gate.
Exceptions
std::runtime_errorWhen construction of the new qubit set (handle) failed for some reason or the current handle is invalid.

Definition at line 4303 of file dqcsim.

◆ has_targets()

bool dqcsim::wrap::Gate::has_targets ( ) const
inline

Returns whether this gate has target qubits.

Returns
Whether this gate has target qubits.
Exceptions
std::runtime_errorWhen the current handle is invalid.

Definition at line 4313 of file dqcsim.

◆ get_controls()

QubitSet dqcsim::wrap::Gate::get_controls ( ) const
inline

Returns a new qubit reference set with the control qubits for this gate.

Returns
A new qubit reference set with the control qubits for this gate.
Exceptions
std::runtime_errorWhen construction of the new qubit set (handle) failed for some reason or the current handle is invalid.

Definition at line 4324 of file dqcsim.

◆ has_controls()

bool dqcsim::wrap::Gate::has_controls ( ) const
inline

Returns whether this gate has control qubits.

Returns
Whether this gate has control qubits.
Exceptions
std::runtime_errorWhen the current handle is invalid.

Definition at line 4334 of file dqcsim.

◆ get_measures()

QubitSet dqcsim::wrap::Gate::get_measures ( ) const
inline

Returns a new qubit reference set with the measurement qubits for this gate.

Returns
A new qubit reference set with the measurement qubits for this gate.
Exceptions
std::runtime_errorWhen construction of the new qubit set (handle) failed for some reason or the current handle is invalid.

Definition at line 4347 of file dqcsim.

◆ has_measures()

bool dqcsim::wrap::Gate::has_measures ( ) const
inline

Returns whether this gate has measurement qubits.

Returns
Whether this gate has measurement qubits.
Exceptions
std::runtime_errorWhen the current handle is invalid.

Definition at line 4357 of file dqcsim.

◆ get_matrix()

Matrix dqcsim::wrap::Gate::get_matrix ( ) const
inline

Returns the matrix that belongs to this gate.

Returns
The matrix that belongs to this gate.
Exceptions
std::runtime_errorWhen the current handle is invalid or the gate doesn't have a matrix.

Definition at line 4368 of file dqcsim.

◆ has_matrix()

bool dqcsim::wrap::Gate::has_matrix ( ) const
inline

Returns whether this gate has a matrix.

Returns
Whether this gate has a matrix.
Exceptions
std::runtime_errorWhen the current handle is invalid.

Definition at line 4378 of file dqcsim.

◆ get_name()

std::string dqcsim::wrap::Gate::get_name ( ) const
inline

Returns the name of a custom gate.

Returns
The name of a custom gate.
Exceptions
std::runtime_errorWhen the current handle is invalid.

Definition at line 4388 of file dqcsim.

◆ has_name()

bool dqcsim::wrap::Gate::has_name ( ) const
inline

Returns whether this gate has a name.

Returns
Whether this gate has a name.
Exceptions
std::runtime_errorWhen the current handle is invalid.

Definition at line 4401 of file dqcsim.

◆ with_json_string()

Gate& dqcsim::wrap::Gate::with_json_string ( const std::string &  json)
inline

Sets the arbitrary JSON data to the given serialized JSON string (builder pattern).

Parameters
jsonA string representation of a JSON dictionary object to assign.
Returns
&self, to continue building.
Exceptions
std::runtime_errorWhen the string representation is invalid, or when the current handle is invalid.

Definition at line 4420 of file dqcsim.

◆ with_cbor_string()

Gate& dqcsim::wrap::Gate::with_cbor_string ( const std::string &  cbor)
inline

Sets the arbitrary JSON data to the given serialized CBOR string (builder pattern).

Parameters
cborA JSON object represented as a CBOR binary string.
Returns
&self, to continue building.
Exceptions
std::runtime_errorWhen the CBOR string is invalid, or when the current handle is invalid.

Definition at line 4434 of file dqcsim.

◆ with_json()

template<class JSON >
Gate& dqcsim::wrap::Gate::with_json ( const JSON &  json)
inline

Sets the arbitrary JSON data to the given JSON object from nlohmann::json (builder pattern).

Since that is a header-only library that isn't usually installed system-wide and be using a specific version in your project already, you need to specify the nlohmann::json type as a generic to this function.

Parameters
jsonThe C++ JSON object representation of the object to set.
Returns
&self, to continue building.
Exceptions
std::runtime_errorWhen the current handle is invalid.

Definition at line 4451 of file dqcsim.

◆ with_arg_string()

Gate& dqcsim::wrap::Gate::with_arg_string ( const std::string &  data)
inline

Pushes a (binary) string to the back of the arbitrary argument list (builder pattern).

Parameters
dataThe data for the new argument, represented as a (binary) string.
Returns
&self, to continue building.
Exceptions
std::runtime_errorWhen the current handle is invalid.

Definition at line 4465 of file dqcsim.

◆ with_arg()

template<typename T >
Gate& dqcsim::wrap::Gate::with_arg ( const T &  data)
inline

Pushes a value of type T to the back of the arbitrary argument list (builder pattern).

Warning
Type T must be a primitive value (like an int) or a struct thereof, without pointers or any other "complicated" constructs. DQCsim just copies the bytes over. It is up to you to ensure that that's what you want to happen; unfortunately C++11 does not provide a way to statically ensure that this is the case.
Parameters
dataThe data for the new argument, represented as some C object.
Returns
&self, to continue building.
Exceptions
std::runtime_errorWhen the current handle is invalid.

Definition at line 4485 of file dqcsim.


The documentation for this class was generated from the following file:
dqcsim::wrap::Gate::with_json_string
Gate & with_json_string(const std::string &json)
Sets the arbitrary JSON data to the given serialized JSON string (builder pattern).
Definition: dqcsim:4420
dqcsim::wrap::Gate::with_arg_string
Gate & with_arg_string(const std::string &data)
Pushes a (binary) string to the back of the arbitrary argument list (builder pattern).
Definition: dqcsim:4465
dqcsim::wrap::Gate::custom
static Gate custom(const std::string &name, QubitSet &&targets, QubitSet &&controls, QubitSet &&measures, const Matrix &matrix)
Constructs a new custom gate with target qubits, control qubits, measured qubits, and a matrix.
Definition: dqcsim:3937
dqcsim::wrap::Gate::with_arg
Gate & with_arg(const T &data)
Pushes a value of type T to the back of the arbitrary argument list (builder pattern).
Definition: dqcsim:4485