655 lines
18 KiB
Plaintext
655 lines
18 KiB
Plaintext
---
|
||
title: QkCircuit (dev version)
|
||
description: API reference for QkCircuit in the dev version of qiskit-c
|
||
in_page_toc_min_heading_level: 2
|
||
python_api_type: module
|
||
python_api_name: QkCircuit
|
||
---
|
||
|
||
# QkCircuit
|
||
|
||
```c
|
||
typedef struct QkCircuit QkCircuit
|
||
```
|
||
|
||
The fundamental element of quantum computing is the *quantum circuit*. This is a computational routine that can be run, one shot at a time, on a quantum processing unit (QPU). A circuit will act on a predefined amount of quantum data (in Qiskit, we only directly support qubits) with unitary operations (gates), measurements and resets. In addition, a quantum circuit can contain operations on classical data, including real-time computations and control-flow constructs, which are executed by the controllers of the QPU. The `QkCircuit` struct exposes a low level interface to Qiskit’s quantum circuit data structure and exposes only what is defined in the inner data model of Qiskit. Therefore it is missing some functionality that is available in the higher level Python [`QuantumCircuit`](qiskit-circuit-quantum-circuit#qiskit.circuit.QuantumCircuit "qiskit.circuit.QuantumCircuit") class.
|
||
|
||
Below is an example of a quantum circuit that makes a three-qubit Greenberger–Horne–Zeilinger (GHZ) state defined as:
|
||
|
||
$$
|
||
|\psi\rangle = \left( |000\rangle + |111\rangle \right) / \sqrt{2}
|
||
$$
|
||
|
||
```c
|
||
#include <qiskit.h>
|
||
|
||
// Create a circuit with three qubits and 3 classical bits
|
||
QkCircuit *qc = qk_circuit_new(3, 0);
|
||
// H gate on qubit 0, putting this qubit in a superposition of |0> + |1>.
|
||
qk_circuit_gate(qc, QkGate_H, {0}, NULL);
|
||
// A CX (CNOT) gate on control qubit 0 and target qubit 1 generating a Bell state.
|
||
qk_circuit_gate(qc, QkGate_CX, {0, 1}, NULL);
|
||
// A CX (CNOT) gate on control qubit 0 and target qubit 2 generating a GHZ state.
|
||
qk_circuit_gate(qc, QkGate_CX, {0, 2}, NULL);
|
||
// Free the created circuit.
|
||
qk_circuit_free(qc);
|
||
```
|
||
|
||
The circuit C API currently only supports creating circuits that contain operations defined in Qiskit’s internal Rust data model. Generally this includes only gates in the standard gate library, standard non-unitary operations (currently [`Barrier`](circuit#qiskit.circuit.Barrier "qiskit.circuit.Barrier"), [`Measure`](circuit#qiskit.circuit.Measure "qiskit.circuit.Measure"), [`Reset`](circuit#qiskit.circuit.Reset "qiskit.circuit.Reset"), and [`Delay`](circuit#qiskit.circuit.Delay "qiskit.circuit.Delay")) and [`UnitaryGate`](qiskit-circuit-library-unitary-gate#qiskit.circuit.library.UnitaryGate "qiskit.circuit.library.UnitaryGate"). This functionality will be expanded over time as the Rust data model is expanded to natively support more functionality.
|
||
|
||
## Data Types
|
||
|
||
### QkOpCount
|
||
|
||
<Class id="QkOpCount" signature="struct QkOpCount">
|
||
An individual operation count represented by the operation name and the number of instances in the circuit.
|
||
|
||
#### const char \*name
|
||
|
||
<Attribute id="name">
|
||
A nul terminated string representing the operation name
|
||
</Attribute>
|
||
|
||
#### uintptr\_t count
|
||
|
||
<Attribute id="count">
|
||
The number of instances of this operation in the circuit
|
||
</Attribute>
|
||
</Class>
|
||
|
||
### QkOpCounts
|
||
|
||
<Class id="QkOpCounts" signature="struct QkOpCounts">
|
||
An array of `OpCount` objects representing the total counts of all the operation types in a circuit.
|
||
|
||
#### QkOpCount \*data
|
||
|
||
<Attribute id="data">
|
||
A array of size `len` containing `OpCount` objects for each type of operation in the circuit
|
||
</Attribute>
|
||
|
||
#### uintptr\_t len
|
||
|
||
<Attribute id="len">
|
||
The number of elements in `data`
|
||
</Attribute>
|
||
</Class>
|
||
|
||
### QkCircuitInstruction
|
||
|
||
<Class id="QkCircuitInstruction" signature="struct QkCircuitInstruction">
|
||
A circuit instruction representation.
|
||
|
||
This struct represents the data contained in an individual instruction in a `QkCircuit`. It is not a pointer to the underlying object, but contains a copy of the properties of the instruction for inspection.
|
||
|
||
#### const char \*name
|
||
|
||
<Attribute id="name">
|
||
The instruction name
|
||
</Attribute>
|
||
|
||
#### uint32\_t num\_qubits
|
||
|
||
<Attribute id="num_qubits">
|
||
The number of qubits for this instruction.
|
||
</Attribute>
|
||
|
||
#### uint32\_t \*qubits
|
||
|
||
<Attribute id="qubits">
|
||
A pointer to an array of qubit indices this instruction operates on.
|
||
</Attribute>
|
||
|
||
#### uint32\_t num\_clbits
|
||
|
||
<Attribute id="num_clbits">
|
||
The number of clbits for this instruction.
|
||
</Attribute>
|
||
|
||
#### uint32\_t \*clbits
|
||
|
||
<Attribute id="clbits">
|
||
A pointer to an array of clbit indices this instruction operates on.
|
||
</Attribute>
|
||
|
||
#### uint32\_t num\_params
|
||
|
||
<Attribute id="num_params">
|
||
The number of parameters for this instruction.
|
||
</Attribute>
|
||
|
||
#### double \*params
|
||
|
||
<Attribute id="params">
|
||
A pointer to an array of parameter values for this instruction.
|
||
</Attribute>
|
||
</Class>
|
||
|
||
## Functions
|
||
|
||
### QkDelayUnit
|
||
|
||
<Class id="QkDelayUnit" signature="enum QkDelayUnit">
|
||
Units for circuit delays.
|
||
|
||
*Values:*
|
||
|
||
#### enumerator QkDelayUnit\_S
|
||
|
||
<Attribute id="QkDelayUnit_S">
|
||
Seconds.
|
||
</Attribute>
|
||
|
||
#### enumerator QkDelayUnit\_MS
|
||
|
||
<Attribute id="QkDelayUnit_MS">
|
||
Milliseconds.
|
||
</Attribute>
|
||
|
||
#### enumerator QkDelayUnit\_US
|
||
|
||
<Attribute id="QkDelayUnit_US">
|
||
Microseconds.
|
||
</Attribute>
|
||
|
||
#### enumerator QkDelayUnit\_NS
|
||
|
||
<Attribute id="QkDelayUnit_NS">
|
||
Nanoseconds.
|
||
</Attribute>
|
||
|
||
#### enumerator QkDelayUnit\_PS
|
||
|
||
<Attribute id="QkDelayUnit_PS">
|
||
Picoseconds.
|
||
</Attribute>
|
||
</Class>
|
||
|
||
### qk\_circuit\_new
|
||
|
||
<Function id="qk_circuit_new" signature="QkCircuit *qk_circuit_new(uint32_t num_qubits, uint32_t num_clbits)">
|
||
Construct a new circuit with the given number of qubits and clbits.
|
||
|
||
<span id="group__QkCircuit_1autotoc_md3" />
|
||
|
||
#### Example
|
||
|
||
```c
|
||
QkCircuit *empty = qk_circuit_new(100, 100);
|
||
```
|
||
|
||
**Parameters**
|
||
|
||
* **num\_qubits** – The number of qubits the circuit contains.
|
||
* **num\_clbits** – The number of clbits the circuit contains.
|
||
|
||
**Returns**
|
||
|
||
A pointer to the created circuit.
|
||
</Function>
|
||
|
||
### qk\_circuit\_copy
|
||
|
||
<Function id="qk_circuit_copy" signature="QkCircuit *qk_circuit_copy(const QkCircuit *circuit)">
|
||
Create a copy of a `QkCircuit`.
|
||
|
||
<span id="group__QkCircuit_1autotoc_md4" />
|
||
|
||
#### Example
|
||
|
||
```c
|
||
QkCircuit *qc = qk_circuit_new(100, 100);
|
||
QkCircuit *copy = qk_circuit_copy(qc);
|
||
```
|
||
|
||
<span id="group__QkCircuit_1autotoc_md5" />
|
||
|
||
#### Safety
|
||
|
||
<span id="group__QkCircuit_1autotoc_md5" />
|
||
|
||
Behavior is undefined if `circuit` is not a valid, non-null pointer to a `QkCircuit`.
|
||
|
||
**Parameters**
|
||
|
||
**circuit** – A pointer to the circuit to copy.
|
||
|
||
**Returns**
|
||
|
||
A new pointer to a copy of the input `circuit`.
|
||
</Function>
|
||
|
||
### qk\_circuit\_num\_qubits
|
||
|
||
<Function id="qk_circuit_num_qubits" signature="uint32_t qk_circuit_num_qubits(const QkCircuit *circuit)">
|
||
Get the number of qubits the circuit contains.
|
||
|
||
<span id="group__QkCircuit_1autotoc_md6" />
|
||
|
||
#### Example
|
||
|
||
```c
|
||
QkCircuit *qc = qk_circuit_new(100, 100);
|
||
uint32_t num_qubits = qk_circuit_num_qubits(qc); // num_qubits==100
|
||
```
|
||
|
||
<span id="group__QkCircuit_1autotoc_md7" />
|
||
|
||
#### Safety
|
||
|
||
<span id="group__QkCircuit_1autotoc_md7" />
|
||
|
||
Behavior is undefined if `circuit` is not a valid, non-null pointer to a `QkCircuit`.
|
||
|
||
**Parameters**
|
||
|
||
**circuit** – A pointer to the circuit.
|
||
|
||
**Returns**
|
||
|
||
The number of qubits the circuit is defined on.
|
||
</Function>
|
||
|
||
### qk\_circuit\_num\_clbits
|
||
|
||
<Function id="qk_circuit_num_clbits" signature="uint32_t qk_circuit_num_clbits(const QkCircuit *circuit)">
|
||
Get the number of clbits the circuit contains.
|
||
|
||
<span id="group__QkCircuit_1autotoc_md8" />
|
||
|
||
#### Example
|
||
|
||
```c
|
||
QkCircuit *qc = qk_circuit_new(100, 50);
|
||
uint32_t num_clbits = qk_circuit_num_clbits(qc); // num_clbits==50
|
||
```
|
||
|
||
<span id="group__QkCircuit_1autotoc_md9" />
|
||
|
||
#### Safety
|
||
|
||
<span id="group__QkCircuit_1autotoc_md9" />
|
||
|
||
Behavior is undefined if `circuit` is not a valid, non-null pointer to a `QkCircuit`.
|
||
|
||
**Parameters**
|
||
|
||
**circuit** – A pointer to the circuit.
|
||
|
||
**Returns**
|
||
|
||
The number of qubits the circuit is defined on.
|
||
</Function>
|
||
|
||
### qk\_circuit\_free
|
||
|
||
<Function id="qk_circuit_free" signature="void qk_circuit_free(QkCircuit *circuit)">
|
||
Free the circuit.
|
||
|
||
<span id="group__QkCircuit_1autotoc_md10" />
|
||
|
||
#### Example
|
||
|
||
```c
|
||
QkCircuit *qc = qk_circuit_new(100, 100);
|
||
qk_circuit_free(qc);
|
||
```
|
||
|
||
<span id="group__QkCircuit_1autotoc_md11" />
|
||
|
||
#### Safety
|
||
|
||
<span id="group__QkCircuit_1autotoc_md11" />
|
||
|
||
Behavior is undefined if `circuit` is not either null or a valid pointer to a `QkCircuit`.
|
||
|
||
**Parameters**
|
||
|
||
**circuit** – A pointer to the circuit to free.
|
||
</Function>
|
||
|
||
### qk\_circuit\_gate
|
||
|
||
<Function id="qk_circuit_gate" signature="QkExitCode qk_circuit_gate(QkCircuit *circuit, QkGate gate, const uint32_t *qubits, const double *params)">
|
||
Append a standard gate to the circuit.
|
||
|
||
<span id="group__QkCircuit_1autotoc_md12" />
|
||
|
||
#### Example
|
||
|
||
```c
|
||
QkCircuit *qc = qk_circuit_new(100, 0);
|
||
qk_circuit_gate(qc, QkGate_H, *[0], *[]);
|
||
```
|
||
|
||
<span id="group__QkCircuit_1autotoc_md13" />
|
||
|
||
#### Safety
|
||
|
||
<span id="group__QkCircuit_1autotoc_md13" />
|
||
|
||
The `qubits` and `params` types are expected to be a pointer to an array of `uint32_t` and `double` respectively where the length is matching the expectations for the standard gate. If the array is insufficently long the behavior of this function is undefined as this will read outside the bounds of the array. It can be a null pointer if there are no qubits or params for a given gate. You can check `qk_gate_num_qubits` and `qk_gate_num_params` to determine how many qubits and params are required for a given gate.
|
||
|
||
Behavior is undefined if `circuit` is not a valid, non-null pointer to a `QkCircuit`.
|
||
|
||
**Parameters**
|
||
|
||
* **circuit** – A pointer to the circuit to add the gate to.
|
||
* **gate** – The StandardGate to add to the circuit.
|
||
* **qubits** – The pointer to the array of `uint32_t` qubit indices to add the gate on. This can be a null pointer if there are no qubits for `gate` (e.g. `QkGate_GlobalPhase`)
|
||
* **params** – The pointer to the array of `double` values to use for the gate parameters. This can be a null pointer if there are no parameters for `gate` (e.g. `QkGate_H`).
|
||
</Function>
|
||
|
||
### qk\_gate\_num\_qubits
|
||
|
||
<Function id="qk_gate_num_qubits" signature="uint32_t qk_gate_num_qubits(QkGate gate)">
|
||
Get the number of qubits for a `QkGate`
|
||
|
||
<span id="group__QkCircuit_1autotoc_md14" />
|
||
|
||
#### Example
|
||
|
||
```c
|
||
uint32_t num_qubits = qk_gate_num_qubits(QkGate_CCX);
|
||
```
|
||
|
||
**Parameters**
|
||
|
||
**gate** – The standard gate to get the number of qubits for
|
||
</Function>
|
||
|
||
### qk\_gate\_num\_params
|
||
|
||
<Function id="qk_gate_num_params" signature="uint32_t qk_gate_num_params(QkGate gate)">
|
||
Get the number of params for a `QkGate`
|
||
|
||
<span id="group__QkCircuit_1autotoc_md15" />
|
||
|
||
#### Example
|
||
|
||
```c
|
||
uint32_t num_params = qk_gate_num_params(QkGate_R);
|
||
```
|
||
|
||
**Parameters**
|
||
|
||
**gate** – The standard gate to get the number of qubits for
|
||
</Function>
|
||
|
||
### qk\_circuit\_measure
|
||
|
||
<Function id="qk_circuit_measure" signature="QkExitCode qk_circuit_measure(QkCircuit *circuit, uint32_t qubit, uint32_t clbit)">
|
||
Append a measurement to the circuit
|
||
|
||
<span id="group__QkCircuit_1autotoc_md16" />
|
||
|
||
#### Example
|
||
|
||
```c
|
||
QkCircuit *qc = qk_circuit_new(100, 1);
|
||
qk_circuit_measure(qc, 0, 0);
|
||
```
|
||
|
||
<span id="group__QkCircuit_1autotoc_md17" />
|
||
|
||
#### Safety
|
||
|
||
<span id="group__QkCircuit_1autotoc_md17" />
|
||
|
||
Behavior is undefined if `circuit` is not a valid, non-null pointer to a `QkCircuit`.
|
||
|
||
**Parameters**
|
||
|
||
* **circuit** – A pointer to the circuit to add the measurement to
|
||
* **qubit** – The `uint32_t` for the qubit to measure
|
||
* **clbit** – The `uint32_t` for the clbit to store the measurement outcome in
|
||
</Function>
|
||
|
||
### qk\_circuit\_reset
|
||
|
||
<Function id="qk_circuit_reset" signature="QkExitCode qk_circuit_reset(QkCircuit *circuit, uint32_t qubit)">
|
||
Append a reset to the circuit
|
||
|
||
<span id="group__QkCircuit_1autotoc_md18" />
|
||
|
||
#### Example
|
||
|
||
```c
|
||
QkCircuit *qc = qk_circuit_new(100, 0);
|
||
qk_circuit_reset(qc, 0);
|
||
```
|
||
|
||
<span id="group__QkCircuit_1autotoc_md19" />
|
||
|
||
#### Safety
|
||
|
||
<span id="group__QkCircuit_1autotoc_md19" />
|
||
|
||
Behavior is undefined if `circuit` is not a valid, non-null pointer to a `QkCircuit`.
|
||
|
||
**Parameters**
|
||
|
||
* **circuit** – A pointer to the circuit to add the reset to
|
||
* **qubit** – The `uint32_t` for the qubit to reset
|
||
</Function>
|
||
|
||
### qk\_circuit\_barrier
|
||
|
||
<Function id="qk_circuit_barrier" signature="QkExitCode qk_circuit_barrier(QkCircuit *circuit, uint32_t num_qubits, const uint32_t *qubits)">
|
||
Append a barrier to the circuit
|
||
|
||
<span id="group__QkCircuit_1autotoc_md20" />
|
||
|
||
#### Example
|
||
|
||
```c
|
||
QkCircuit *qc = qk_circuit_new(100, 1);
|
||
uint32_t qubits[5] = {0, 1, 2, 3, 4};
|
||
qk_circuit_barrier(qc, 5, qubits);
|
||
```
|
||
|
||
<span id="group__QkCircuit_1autotoc_md21" />
|
||
|
||
#### Safety
|
||
|
||
<span id="group__QkCircuit_1autotoc_md21" />
|
||
|
||
The length of the array qubits points to must be num\_qubits. If there is a mismatch the behavior is undefined.
|
||
|
||
Behavior is undefined if `circuit` is not a valid, non-null pointer to a `QkCircuit`.
|
||
|
||
**Parameters**
|
||
|
||
* **circuit** – A pointer to the circuit to add the barrier to
|
||
* **num\_qubits** – The number of qubits wide the barrier is
|
||
* **qubits** – The pointer to the array of `uint32_t` qubit indices to add the barrier on.
|
||
</Function>
|
||
|
||
### qk\_circuit\_count\_ops
|
||
|
||
<Function id="qk_circuit_count_ops" signature="QkOpCounts qk_circuit_count_ops(const QkCircuit *circuit)">
|
||
Return a list of string names for instructions in a circuit and their counts.
|
||
|
||
<span id="group__QkCircuit_1autotoc_md22" />
|
||
|
||
#### Example
|
||
|
||
```c
|
||
QkCircuit *qc = qk_circuit_new(100, 0);
|
||
qk_circuit_gate(qc, HGate, *[0], *[]);
|
||
QkOpCounts *counts = qk_circuit_count_ops(qc);
|
||
```
|
||
|
||
<span id="group__QkCircuit_1autotoc_md23" />
|
||
|
||
#### Safety
|
||
|
||
<span id="group__QkCircuit_1autotoc_md23" />
|
||
|
||
Behavior is undefined if `circuit` is not a valid, non-null pointer to a `QkCircuit`.
|
||
|
||
**Parameters**
|
||
|
||
**circuit** – A pointer to the circuit to get the counts for.
|
||
</Function>
|
||
|
||
### qk\_circuit\_num\_instructions
|
||
|
||
<Function id="qk_circuit_num_instructions" signature="uintptr_t qk_circuit_num_instructions(const QkCircuit *circuit)">
|
||
Return the number of instructions in the circuit
|
||
|
||
<span id="group__QkCircuit_1autotoc_md24" />
|
||
|
||
#### Example
|
||
|
||
```c
|
||
QkCircuit *qc = qk_circuit_new(100);
|
||
qk_circuit_gate(qc, QkGate_H, *[0], *[]);
|
||
uintptr_t num_instructions = qk_circuit_num_instructions(qc); // 1
|
||
```
|
||
|
||
<span id="group__QkCircuit_1autotoc_md25" />
|
||
|
||
#### Safety
|
||
|
||
<span id="group__QkCircuit_1autotoc_md25" />
|
||
|
||
Behavior is undefined if `circuit` is not a valid, non-null pointer to a `QkCircuit`.
|
||
|
||
**Parameters**
|
||
|
||
**circuit** – A pointer to the circuit to get the total number of instructions for.
|
||
</Function>
|
||
|
||
### qk\_circuit\_get\_instruction
|
||
|
||
<Function id="qk_circuit_get_instruction" signature="QkCircuitInstruction qk_circuit_get_instruction(const QkCircuit *circuit, uintptr_t index)">
|
||
Return the instruction details for an instruction in the circuit
|
||
|
||
This function is used to get the instruction details for a given instruction in the circuit.
|
||
|
||
<span id="group__QkCircuit_1autotoc_md26" />
|
||
|
||
#### Example
|
||
|
||
```c
|
||
QkCircuit *qc = qk_circuit_new(100);
|
||
qk_circuit_gate(qc, QkGate_H, *[0], *[]);
|
||
QkCircuitInstruction inst = qk_circuit_get_instruction(qc, 0);
|
||
```
|
||
|
||
<span id="group__QkCircuit_1autotoc_md27" />
|
||
|
||
#### Safety
|
||
|
||
<span id="group__QkCircuit_1autotoc_md27" />
|
||
|
||
Behavior is undefined if `circuit` is not a valid, non-null pointer to a `QkCircuit`. The value for `index` must be less than the value returned by `qk_circuit_num_instructions` otherwise this function will panic
|
||
|
||
**Parameters**
|
||
|
||
* **circuit** – A pointer to the circuit to get the instruction details for.
|
||
* **index** – The instruction index to get the instruction details of.
|
||
|
||
**Returns**
|
||
|
||
The instruction details for the specified instructions
|
||
</Function>
|
||
|
||
### qk\_circuit\_instruction\_free
|
||
|
||
<Function id="qk_circuit_instruction_free" signature="void qk_circuit_instruction_free(QkCircuitInstruction inst)">
|
||
Free a circuit instruction object
|
||
|
||
<span id="group__QkCircuit_1autotoc_md28" />
|
||
|
||
#### Safety
|
||
|
||
<span id="group__QkCircuit_1autotoc_md28" />
|
||
|
||
Behavior is undefined if `inst` is not an object returned by `qk_circuit_get_instruction`.
|
||
|
||
**Parameters**
|
||
|
||
**inst** – The instruction to free
|
||
</Function>
|
||
|
||
### qk\_opcounts\_free
|
||
|
||
<Function id="qk_opcounts_free" signature="void qk_opcounts_free(QkOpCounts op_counts)">
|
||
Free a circuit op count list.
|
||
|
||
<span id="group__QkCircuit_1autotoc_md29" />
|
||
|
||
#### Safety
|
||
|
||
<span id="group__QkCircuit_1autotoc_md29" />
|
||
|
||
Behavior is undefined if `op_counts` is not the object returned by `qk_circuit_count_ops`.
|
||
|
||
**Parameters**
|
||
|
||
**op\_counts** – The returned op count list from `qk_circuit_count_ops`.
|
||
</Function>
|
||
|
||
### qk\_circuit\_to\_python
|
||
|
||
<Function id="qk_circuit_to_python" signature="PyObject *qk_circuit_to_python(QkCircuit *circuit)">
|
||
Convert to a Python-space `QuantumCircuit`.
|
||
|
||
This function takes ownership of the pointer and gives it to Python. Using the input `circuit` pointer after it’s passed to this function is undefined behavior. In particular, `qk_circuit_free` should not be called on this pointer anymore.
|
||
|
||
<span id="group__QkCircuit_1autotoc_md30" />
|
||
|
||
#### Safety
|
||
|
||
<span id="group__QkCircuit_1autotoc_md30" />
|
||
|
||
Behavior is undefined if `circuit` is not a valid, non-null pointer to a `QkCircuit`
|
||
|
||
It is assumed that the thread currently executing this function holds the Python GIL. This is required to create the Python object returned by this function.
|
||
|
||
**Parameters**
|
||
|
||
**circuit** – The C-space `QkCircuit` pointer.
|
||
|
||
**Returns**
|
||
|
||
A Python `QuantumCircuit` object.
|
||
</Function>
|
||
|
||
### qk\_circuit\_delay
|
||
|
||
<Function id="qk_circuit_delay" signature="QkExitCode qk_circuit_delay(QkCircuit *circuit, uint32_t qubit, double duration, QkDelayUnit unit)">
|
||
Append a delay instruction to the circuit.
|
||
|
||
<span id="group__QkCircuit_1autotoc_md31" />
|
||
|
||
#### Example
|
||
|
||
```c
|
||
QkCircuit *qc = qk_circuit_new(1, 0);
|
||
qk_circuit_delay(qc, 0, 100.0, QkDelayUnit_NS);
|
||
```
|
||
|
||
<span id="group__QkCircuit_1autotoc_md32" />
|
||
|
||
#### Safety
|
||
|
||
<span id="group__QkCircuit_1autotoc_md32" />
|
||
|
||
Behavior is undefined if `circuit` is not a valid, non-null pointer to a `QkCircuit`.
|
||
|
||
**Parameters**
|
||
|
||
* **circuit** – A pointer to the circuit to add the delay to.
|
||
* **qubit** – The `uint32_t` index of the qubit to apply the delay to.
|
||
* **duration** – The duration of the delay.
|
||
* **unit** – An enum representing the unit of the duration.
|
||
|
||
**Returns**
|
||
|
||
An exit code.
|
||
</Function>
|
||
|