2916 lines
163 KiB
Plaintext
2916 lines
163 KiB
Plaintext
---
|
||
title: GroverOperator (v0.26)
|
||
description: API reference for qiskit.circuit.library.GroverOperator in qiskit v0.26
|
||
in_page_toc_min_heading_level: 1
|
||
python_api_type: class
|
||
python_api_name: qiskit.circuit.library.GroverOperator
|
||
---
|
||
|
||
<span id="qiskit-circuit-library-groveroperator" />
|
||
|
||
# qiskit.circuit.library.GroverOperator
|
||
|
||
<Class id="qiskit.circuit.library.GroverOperator" isDedicatedPage={true} github="https://github.com/qiskit/qiskit/tree/stable/0.17/qiskit/circuit/library/grover_operator.py" signature="GroverOperator(oracle, state_preparation=None, zero_reflection=None, reflection_qubits=None, insert_barriers=False, mcx_mode='noancilla', name='Q')" modifiers="class">
|
||
The Grover operator.
|
||
|
||
Grover’s search algorithm \[1, 2] consists of repeated applications of the so-called Grover operator used to amplify the amplitudes of the desired output states. This operator, $\mathcal{Q}$, consists of the phase oracle, $\mathcal{S}_f$, zero phase-shift or zero reflection, $\mathcal{S}_0$, and an input state preparation $\mathcal{A}$:
|
||
|
||
$$
|
||
\mathcal{Q} = \mathcal{A} \mathcal{S}_0 \mathcal{A}^\dagger \mathcal{S}_f
|
||
$$
|
||
|
||
In the standard Grover search we have $\mathcal{A} = H^{\otimes n}$:
|
||
|
||
$$
|
||
\mathcal{Q} = H^{\otimes n} \mathcal{S}_0 H^{\otimes n} \mathcal{S}_f
|
||
= D \mathcal{S_f}
|
||
$$
|
||
|
||
The operation $D = H^{\otimes n} \mathcal{S}_0 H^{\otimes n}$ is also referred to as diffusion operator. In this formulation we can see that Grover’s operator consists of two steps: first, the phase oracle multiplies the good states by -1 (with $\mathcal{S}_f$) and then the whole state is reflected around the mean (with $D$).
|
||
|
||
This class allows setting a different state preparation, as in quantum amplitude amplification (a generalization of Grover’s algorithm), $\mathcal{A}$ might not be a layer of Hardamard gates \[3].
|
||
|
||
The action of the phase oracle $\mathcal{S}_f$ is defined as
|
||
|
||
$$
|
||
\mathcal{S}_f: |x\rangle \mapsto (-1)^{f(x)}|x\rangle
|
||
$$
|
||
|
||
where $f(x) = 1$ if $x$ is a good state and 0 otherwise. To highlight the fact that this oracle flips the phase of the good states and does not flip the state of a result qubit, we call $\mathcal{S}_f$ a phase oracle.
|
||
|
||
Note that you can easily construct a phase oracle from a bitflip oracle by sandwiching the controlled X gate on the result qubit by a X and H gate. For instance
|
||
|
||
```python
|
||
Bitflip oracle Phaseflip oracle
|
||
q_0: ──■── q_0: ────────────■────────────
|
||
┌─┴─┐ ┌───┐┌───┐┌─┴─┐┌───┐┌───┐
|
||
out: ┤ X ├ out: ┤ X ├┤ H ├┤ X ├┤ H ├┤ X ├
|
||
└───┘ └───┘└───┘└───┘└───┘└───┘
|
||
```
|
||
|
||
There is some flexibility in defining the oracle and $\mathcal{A}$ operator. Before the Grover operator is applied in Grover’s algorithm, the qubits are first prepared with one application of the $\mathcal{A}$ operator (or Hadamard gates in the standard formulation). Thus, we always have operation of the form $\mathcal{A} \mathcal{S}_f \mathcal{A}^\dagger$. Therefore it is possible to move bitflip logic into $\mathcal{A}$ and leaving the oracle only to do phaseflips via Z gates based on the bitflips. One possible use-case for this are oracles that do not uncompute the state qubits.
|
||
|
||
The zero reflection $\mathcal{S}_0$ is usually defined as
|
||
|
||
$$
|
||
\mathcal{S}_0 = 2 |0\rangle^{\otimes n} \langle 0|^{\otimes n} - \mathbb{I}_n
|
||
$$
|
||
|
||
where $\mathbb{I}_n$ is the identity on $n$ qubits. By default, this class implements the negative version $2 |0\rangle^{\otimes n} \langle 0|^{\otimes n} - \mathbb{I}_n$, since this can simply be implemented with a multi-controlled Z sandwiched by X gates on the target qubit and the introduced global phase does not matter for Grover’s algorithm.
|
||
|
||
**Examples**
|
||
|
||
```python
|
||
>>> from qiskit.circuit import QuantumCircuit
|
||
>>> from qiskit.circuit.library import GroverOperator
|
||
>>> oracle = QuantumCircuit(2)
|
||
>>> oracle.z(0) # good state = first qubit is |1>
|
||
>>> grover_op = GroverOperator(oracle, insert_barriers=True)
|
||
>>> grover_op.draw()
|
||
┌───┐ ░ ┌───┐ ░ ┌───┐ ┌───┐ ░ ┌───┐
|
||
state_0: ┤ Z ├─░─┤ H ├─░─┤ X ├───────■──┤ X ├──────░─┤ H ├
|
||
└───┘ ░ ├───┤ ░ ├───┤┌───┐┌─┴─┐├───┤┌───┐ ░ ├───┤
|
||
state_1: ──────░─┤ H ├─░─┤ X ├┤ H ├┤ X ├┤ H ├┤ X ├─░─┤ H ├
|
||
░ └───┘ ░ └───┘└───┘└───┘└───┘└───┘ ░ └───┘
|
||
```
|
||
|
||
```python
|
||
>>> oracle = QuantumCircuit(1)
|
||
>>> oracle.z(0) # the qubit state |1> is the good state
|
||
>>> state_preparation = QuantumCircuit(1)
|
||
>>> state_preparation.ry(0.2, 0) # non-uniform state preparation
|
||
>>> grover_op = GroverOperator(oracle, state_preparation)
|
||
>>> grover_op.draw()
|
||
┌───┐┌──────────┐┌───┐┌───┐┌───┐┌─────────┐
|
||
state_0: ┤ Z ├┤ RY(-0.2) ├┤ X ├┤ Z ├┤ X ├┤ RY(0.2) ├
|
||
└───┘└──────────┘└───┘└───┘└───┘└─────────┘
|
||
```
|
||
|
||
```python
|
||
>>> oracle = QuantumCircuit(4)
|
||
>>> oracle.z(3)
|
||
>>> reflection_qubits = [0, 3]
|
||
>>> state_preparation = QuantumCircuit(4)
|
||
>>> state_preparation.cry(0.1, 0, 3)
|
||
>>> state_preparation.ry(0.5, 3)
|
||
>>> grover_op = GroverOperator(oracle, state_preparation,
|
||
... reflection_qubits=reflection_qubits)
|
||
>>> grover_op.draw()
|
||
┌───┐ ┌───┐
|
||
state_0: ──────────────────────■──────┤ X ├───────■──┤ X ├──────────■────────────────
|
||
│ └───┘ │ └───┘ │
|
||
state_1: ──────────────────────┼──────────────────┼─────────────────┼────────────────
|
||
│ │ │
|
||
state_2: ──────────────────────┼──────────────────┼─────────────────┼────────────────
|
||
┌───┐┌──────────┐┌────┴─────┐┌───┐┌───┐┌─┴─┐┌───┐┌───┐┌────┴────┐┌─────────┐
|
||
state_3: ┤ Z ├┤ RY(-0.5) ├┤ RY(-0.1) ├┤ X ├┤ H ├┤ X ├┤ H ├┤ X ├┤ RY(0.1) ├┤ RY(0.5) ├
|
||
└───┘└──────────┘└──────────┘└───┘└───┘└───┘└───┘└───┘└─────────┘└─────────┘
|
||
```
|
||
|
||
```python
|
||
>>> mark_state = Statevector.from_label('011')
|
||
>>> diffuse_operator = 2 * DensityMatrix.from_label('000') - Operator.from_label('III')
|
||
>>> grover_op = GroverOperator(oracle=mark_state, zero_reflection=diffuse_operator)
|
||
>>> grover_op.draw(fold=70)
|
||
┌─────────────────┐ ┌───┐ »
|
||
state_0: ┤0 ├──────┤ H ├──────────────────────────»
|
||
│ │┌─────┴───┴─────┐ ┌───┐ »
|
||
state_1: ┤1 UCRZ(0,pi,0,0) ├┤0 ├─────┤ H ├──────────»
|
||
│ ││ UCRZ(pi/2,0) │┌────┴───┴────┐┌───┐»
|
||
state_2: ┤2 ├┤1 ├┤ UCRZ(-pi/4) ├┤ H ├»
|
||
└─────────────────┘└───────────────┘└─────────────┘└───┘»
|
||
« ┌─────────────────┐ ┌───┐
|
||
«state_0: ┤0 ├──────┤ H ├─────────────────────────
|
||
« │ │┌─────┴───┴─────┐ ┌───┐
|
||
«state_1: ┤1 UCRZ(pi,0,0,0) ├┤0 ├────┤ H ├──────────
|
||
« │ ││ UCRZ(pi/2,0) │┌───┴───┴────┐┌───┐
|
||
«state_2: ┤2 ├┤1 ├┤ UCRZ(pi/4) ├┤ H ├
|
||
« └─────────────────┘└───────────────┘└────────────┘└───┘
|
||
```
|
||
|
||
**References**
|
||
|
||
**\[1]: L. K. Grover (1996), A fast quantum mechanical algorithm for database search,**
|
||
|
||
[arXiv:quant-ph/9605043](https://arxiv.org/abs/quant-ph/9605043).
|
||
|
||
**\[2]: I. Chuang & M. Nielsen, Quantum Computation and Quantum Information,**
|
||
|
||
Cambridge: Cambridge University Press, 2000. Chapter 6.1.2.
|
||
|
||
**\[3]: Brassard, G., Hoyer, P., Mosca, M., & Tapp, A. (2000).**
|
||
|
||
Quantum Amplitude Amplification and Estimation. [arXiv:quant-ph/0005055](http://arxiv.org/abs/quant-ph/0005055).
|
||
|
||
**Parameters**
|
||
|
||
* **oracle** (`Union`\[`QuantumCircuit`, `Statevector`]) – The phase oracle implementing a reflection about the bad state. Note that this is not a bitflip oracle, see the docstring for more information.
|
||
* **state\_preparation** (`Optional`\[`QuantumCircuit`]) – The operator preparing the good and bad state. For Grover’s algorithm, this is a n-qubit Hadamard gate and for amplitude amplification or estimation the operator $\mathcal{A}$.
|
||
* **zero\_reflection** (`Union`\[`QuantumCircuit`, `DensityMatrix`, `Operator`, `None`]) – The reflection about the zero state, $\mathcal{S}_0$.
|
||
* **reflection\_qubits** (`Optional`\[`List`\[`int`]]) – Qubits on which the zero reflection acts on.
|
||
* **insert\_barriers** (`bool`) – Whether barriers should be inserted between the reflections and A.
|
||
* **mcx\_mode** (`str`) – The mode to use for building the default zero reflection.
|
||
* **name** (`str`) – The name of the circuit.
|
||
|
||
### \_\_init\_\_
|
||
|
||
<Function id="qiskit.circuit.library.GroverOperator.__init__" signature="__init__(oracle, state_preparation=None, zero_reflection=None, reflection_qubits=None, insert_barriers=False, mcx_mode='noancilla', name='Q')">
|
||
**Parameters**
|
||
|
||
* **oracle** (`Union`\[`QuantumCircuit`, `Statevector`]) – The phase oracle implementing a reflection about the bad state. Note that this is not a bitflip oracle, see the docstring for more information.
|
||
* **state\_preparation** (`Optional`\[`QuantumCircuit`]) – The operator preparing the good and bad state. For Grover’s algorithm, this is a n-qubit Hadamard gate and for amplitude amplification or estimation the operator $\mathcal{A}$.
|
||
* **zero\_reflection** (`Union`\[`QuantumCircuit`, `DensityMatrix`, `Operator`, `None`]) – The reflection about the zero state, $\mathcal{S}_0$.
|
||
* **reflection\_qubits** (`Optional`\[`List`\[`int`]]) – Qubits on which the zero reflection acts on.
|
||
* **insert\_barriers** (`bool`) – Whether barriers should be inserted between the reflections and A.
|
||
* **mcx\_mode** (`str`) – The mode to use for building the default zero reflection.
|
||
* **name** (`str`) – The name of the circuit.
|
||
</Function>
|
||
|
||
## Methods
|
||
|
||
| | |
|
||
| ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------- |
|
||
| [`__init__`](#qiskit.circuit.library.GroverOperator.__init__ "qiskit.circuit.library.GroverOperator.__init__")(oracle\[, state\_preparation, …]) | **type oracle**`Union`\[`QuantumCircuit`, `Statevector`] |
|
||
| [`add_bits`](#qiskit.circuit.library.GroverOperator.add_bits "qiskit.circuit.library.GroverOperator.add_bits")(bits) | Add Bits to the circuit. |
|
||
| [`add_calibration`](#qiskit.circuit.library.GroverOperator.add_calibration "qiskit.circuit.library.GroverOperator.add_calibration")(gate, qubits, schedule\[, params]) | Register a low-level, custom pulse definition for the given gate. |
|
||
| [`add_register`](#qiskit.circuit.library.GroverOperator.add_register "qiskit.circuit.library.GroverOperator.add_register")(\*regs) | Add registers. |
|
||
| [`append`](#qiskit.circuit.library.GroverOperator.append "qiskit.circuit.library.GroverOperator.append")(instruction\[, qargs, cargs]) | Append one or more instructions to the end of the circuit, modifying the circuit in place. |
|
||
| [`assign_parameters`](#qiskit.circuit.library.GroverOperator.assign_parameters "qiskit.circuit.library.GroverOperator.assign_parameters")(parameters\[, inplace, …]) | Assign parameters to new parameters or values. |
|
||
| [`barrier`](#qiskit.circuit.library.GroverOperator.barrier "qiskit.circuit.library.GroverOperator.barrier")(\*qargs) | Apply `Barrier`. |
|
||
| [`bind_parameters`](#qiskit.circuit.library.GroverOperator.bind_parameters "qiskit.circuit.library.GroverOperator.bind_parameters")(values\[, value\_dict]) | Assign numeric parameters to values yielding a new circuit. |
|
||
| [`cast`](#qiskit.circuit.library.GroverOperator.cast "qiskit.circuit.library.GroverOperator.cast")(value, \_type) | Best effort to cast value to type. |
|
||
| [`cbit_argument_conversion`](#qiskit.circuit.library.GroverOperator.cbit_argument_conversion "qiskit.circuit.library.GroverOperator.cbit_argument_conversion")(clbit\_representation) | Converts several classical bit representations (such as indexes, range, etc.) into a list of classical bits. |
|
||
| [`ccx`](#qiskit.circuit.library.GroverOperator.ccx "qiskit.circuit.library.GroverOperator.ccx")(control\_qubit1, control\_qubit2, target\_qubit) | Apply [`CCXGate`](qiskit.circuit.library.CCXGate "qiskit.circuit.library.CCXGate"). |
|
||
| [`ch`](#qiskit.circuit.library.GroverOperator.ch "qiskit.circuit.library.GroverOperator.ch")(control\_qubit, target\_qubit\[, label, …]) | Apply [`CHGate`](qiskit.circuit.library.CHGate "qiskit.circuit.library.CHGate"). |
|
||
| [`cls_instances`](#qiskit.circuit.library.GroverOperator.cls_instances "qiskit.circuit.library.GroverOperator.cls_instances")() | Return the current number of instances of this class, useful for auto naming. |
|
||
| [`cls_prefix`](#qiskit.circuit.library.GroverOperator.cls_prefix "qiskit.circuit.library.GroverOperator.cls_prefix")() | Return the prefix to use for auto naming. |
|
||
| [`cnot`](#qiskit.circuit.library.GroverOperator.cnot "qiskit.circuit.library.GroverOperator.cnot")(control\_qubit, target\_qubit\[, label, …]) | Apply [`CXGate`](qiskit.circuit.library.CXGate "qiskit.circuit.library.CXGate"). |
|
||
| [`combine`](#qiskit.circuit.library.GroverOperator.combine "qiskit.circuit.library.GroverOperator.combine")(rhs) | DEPRECATED - Returns rhs appended to self if self contains compatible registers. |
|
||
| [`compose`](#qiskit.circuit.library.GroverOperator.compose "qiskit.circuit.library.GroverOperator.compose")(other\[, qubits, clbits, front, inplace]) | Compose circuit with `other` circuit or instruction, optionally permuting wires. |
|
||
| [`control`](#qiskit.circuit.library.GroverOperator.control "qiskit.circuit.library.GroverOperator.control")(\[num\_ctrl\_qubits, label, ctrl\_state]) | Control this circuit on `num_ctrl_qubits` qubits. |
|
||
| [`copy`](#qiskit.circuit.library.GroverOperator.copy "qiskit.circuit.library.GroverOperator.copy")(\[name]) | Copy the circuit. |
|
||
| [`count_ops`](#qiskit.circuit.library.GroverOperator.count_ops "qiskit.circuit.library.GroverOperator.count_ops")() | Count each operation kind in the circuit. |
|
||
| [`cp`](#qiskit.circuit.library.GroverOperator.cp "qiskit.circuit.library.GroverOperator.cp")(theta, control\_qubit, target\_qubit\[, …]) | Apply [`CPhaseGate`](qiskit.circuit.library.CPhaseGate "qiskit.circuit.library.CPhaseGate"). |
|
||
| [`crx`](#qiskit.circuit.library.GroverOperator.crx "qiskit.circuit.library.GroverOperator.crx")(theta, control\_qubit, target\_qubit\[, …]) | Apply [`CRXGate`](qiskit.circuit.library.CRXGate "qiskit.circuit.library.CRXGate"). |
|
||
| [`cry`](#qiskit.circuit.library.GroverOperator.cry "qiskit.circuit.library.GroverOperator.cry")(theta, control\_qubit, target\_qubit\[, …]) | Apply [`CRYGate`](qiskit.circuit.library.CRYGate "qiskit.circuit.library.CRYGate"). |
|
||
| [`crz`](#qiskit.circuit.library.GroverOperator.crz "qiskit.circuit.library.GroverOperator.crz")(theta, control\_qubit, target\_qubit\[, …]) | Apply [`CRZGate`](qiskit.circuit.library.CRZGate "qiskit.circuit.library.CRZGate"). |
|
||
| [`cswap`](#qiskit.circuit.library.GroverOperator.cswap "qiskit.circuit.library.GroverOperator.cswap")(control\_qubit, target\_qubit1, …\[, …]) | Apply [`CSwapGate`](qiskit.circuit.library.CSwapGate "qiskit.circuit.library.CSwapGate"). |
|
||
| [`csx`](#qiskit.circuit.library.GroverOperator.csx "qiskit.circuit.library.GroverOperator.csx")(control\_qubit, target\_qubit\[, label, …]) | Apply [`CSXGate`](qiskit.circuit.library.CSXGate "qiskit.circuit.library.CSXGate"). |
|
||
| [`cu`](#qiskit.circuit.library.GroverOperator.cu "qiskit.circuit.library.GroverOperator.cu")(theta, phi, lam, gamma, control\_qubit, …) | Apply [`CUGate`](qiskit.circuit.library.CUGate "qiskit.circuit.library.CUGate"). |
|
||
| [`cu1`](#qiskit.circuit.library.GroverOperator.cu1 "qiskit.circuit.library.GroverOperator.cu1")(theta, control\_qubit, target\_qubit\[, …]) | Apply [`CU1Gate`](qiskit.circuit.library.CU1Gate "qiskit.circuit.library.CU1Gate"). |
|
||
| [`cu3`](#qiskit.circuit.library.GroverOperator.cu3 "qiskit.circuit.library.GroverOperator.cu3")(theta, phi, lam, control\_qubit, target\_qubit) | Apply [`CU3Gate`](qiskit.circuit.library.CU3Gate "qiskit.circuit.library.CU3Gate"). |
|
||
| [`cx`](#qiskit.circuit.library.GroverOperator.cx "qiskit.circuit.library.GroverOperator.cx")(control\_qubit, target\_qubit\[, label, …]) | Apply [`CXGate`](qiskit.circuit.library.CXGate "qiskit.circuit.library.CXGate"). |
|
||
| [`cy`](#qiskit.circuit.library.GroverOperator.cy "qiskit.circuit.library.GroverOperator.cy")(control\_qubit, target\_qubit\[, label, …]) | Apply [`CYGate`](qiskit.circuit.library.CYGate "qiskit.circuit.library.CYGate"). |
|
||
| [`cz`](#qiskit.circuit.library.GroverOperator.cz "qiskit.circuit.library.GroverOperator.cz")(control\_qubit, target\_qubit\[, label, …]) | Apply [`CZGate`](qiskit.circuit.library.CZGate "qiskit.circuit.library.CZGate"). |
|
||
| [`dcx`](#qiskit.circuit.library.GroverOperator.dcx "qiskit.circuit.library.GroverOperator.dcx")(qubit1, qubit2) | Apply [`DCXGate`](qiskit.circuit.library.DCXGate "qiskit.circuit.library.DCXGate"). |
|
||
| [`decompose`](#qiskit.circuit.library.GroverOperator.decompose "qiskit.circuit.library.GroverOperator.decompose")() | Call a decomposition pass on this circuit, to decompose one level (shallow decompose). |
|
||
| [`delay`](#qiskit.circuit.library.GroverOperator.delay "qiskit.circuit.library.GroverOperator.delay")(duration\[, qarg, unit]) | Apply [`Delay`](qiskit.circuit.Delay "qiskit.circuit.Delay"). |
|
||
| [`depth`](#qiskit.circuit.library.GroverOperator.depth "qiskit.circuit.library.GroverOperator.depth")() | Return circuit depth (i.e., length of critical path). |
|
||
| [`diagonal`](#qiskit.circuit.library.GroverOperator.diagonal "qiskit.circuit.library.GroverOperator.diagonal")(diag, qubit) | Attach a diagonal gate to a circuit. |
|
||
| [`draw`](#qiskit.circuit.library.GroverOperator.draw "qiskit.circuit.library.GroverOperator.draw")(\[output, scale, filename, style, …]) | Draw the quantum circuit. |
|
||
| [`ecr`](#qiskit.circuit.library.GroverOperator.ecr "qiskit.circuit.library.GroverOperator.ecr")(qubit1, qubit2) | Apply [`ECRGate`](qiskit.circuit.library.ECRGate "qiskit.circuit.library.ECRGate"). |
|
||
| [`extend`](#qiskit.circuit.library.GroverOperator.extend "qiskit.circuit.library.GroverOperator.extend")(rhs) | DEPRECATED - Append QuantumCircuit to the RHS if it contains compatible registers. |
|
||
| [`fredkin`](#qiskit.circuit.library.GroverOperator.fredkin "qiskit.circuit.library.GroverOperator.fredkin")(control\_qubit, target\_qubit1, …) | Apply [`CSwapGate`](qiskit.circuit.library.CSwapGate "qiskit.circuit.library.CSwapGate"). |
|
||
| [`from_qasm_file`](#qiskit.circuit.library.GroverOperator.from_qasm_file "qiskit.circuit.library.GroverOperator.from_qasm_file")(path) | Take in a QASM file and generate a QuantumCircuit object. |
|
||
| [`from_qasm_str`](#qiskit.circuit.library.GroverOperator.from_qasm_str "qiskit.circuit.library.GroverOperator.from_qasm_str")(qasm\_str) | Take in a QASM string and generate a QuantumCircuit object. |
|
||
| [`h`](#qiskit.circuit.library.GroverOperator.h "qiskit.circuit.library.GroverOperator.h")(qubit) | Apply [`HGate`](qiskit.circuit.library.HGate "qiskit.circuit.library.HGate"). |
|
||
| [`hamiltonian`](#qiskit.circuit.library.GroverOperator.hamiltonian "qiskit.circuit.library.GroverOperator.hamiltonian")(operator, time, qubits\[, label]) | Apply hamiltonian evolution to qubits. |
|
||
| [`has_register`](#qiskit.circuit.library.GroverOperator.has_register "qiskit.circuit.library.GroverOperator.has_register")(register) | Test if this circuit has the register r. |
|
||
| [`i`](#qiskit.circuit.library.GroverOperator.i "qiskit.circuit.library.GroverOperator.i")(qubit) | Apply [`IGate`](qiskit.circuit.library.IGate "qiskit.circuit.library.IGate"). |
|
||
| [`id`](#qiskit.circuit.library.GroverOperator.id "qiskit.circuit.library.GroverOperator.id")(qubit) | Apply [`IGate`](qiskit.circuit.library.IGate "qiskit.circuit.library.IGate"). |
|
||
| [`initialize`](#qiskit.circuit.library.GroverOperator.initialize "qiskit.circuit.library.GroverOperator.initialize")(params\[, qubits]) | Initialize qubits in a specific state. |
|
||
| [`inverse`](#qiskit.circuit.library.GroverOperator.inverse "qiskit.circuit.library.GroverOperator.inverse")() | Invert (take adjoint of) this circuit. |
|
||
| [`iso`](#qiskit.circuit.library.GroverOperator.iso "qiskit.circuit.library.GroverOperator.iso")(isometry, q\_input, q\_ancillas\_for\_output) | Attach an arbitrary isometry from m to n qubits to a circuit. |
|
||
| [`isometry`](#qiskit.circuit.library.GroverOperator.isometry "qiskit.circuit.library.GroverOperator.isometry")(isometry, q\_input, …\[, …]) | Attach an arbitrary isometry from m to n qubits to a circuit. |
|
||
| [`iswap`](#qiskit.circuit.library.GroverOperator.iswap "qiskit.circuit.library.GroverOperator.iswap")(qubit1, qubit2) | Apply [`iSwapGate`](qiskit.circuit.library.iSwapGate "qiskit.circuit.library.iSwapGate"). |
|
||
| [`mcp`](#qiskit.circuit.library.GroverOperator.mcp "qiskit.circuit.library.GroverOperator.mcp")(lam, control\_qubits, target\_qubit) | Apply [`MCPhaseGate`](qiskit.circuit.library.MCPhaseGate "qiskit.circuit.library.MCPhaseGate"). |
|
||
| [`mcrx`](#qiskit.circuit.library.GroverOperator.mcrx "qiskit.circuit.library.GroverOperator.mcrx")(theta, q\_controls, q\_target\[, …]) | Apply Multiple-Controlled X rotation gate |
|
||
| [`mcry`](#qiskit.circuit.library.GroverOperator.mcry "qiskit.circuit.library.GroverOperator.mcry")(theta, q\_controls, q\_target\[, …]) | Apply Multiple-Controlled Y rotation gate |
|
||
| [`mcrz`](#qiskit.circuit.library.GroverOperator.mcrz "qiskit.circuit.library.GroverOperator.mcrz")(lam, q\_controls, q\_target\[, …]) | Apply Multiple-Controlled Z rotation gate |
|
||
| [`mct`](#qiskit.circuit.library.GroverOperator.mct "qiskit.circuit.library.GroverOperator.mct")(control\_qubits, target\_qubit\[, …]) | Apply [`MCXGate`](qiskit.circuit.library.MCXGate "qiskit.circuit.library.MCXGate"). |
|
||
| [`mcu1`](#qiskit.circuit.library.GroverOperator.mcu1 "qiskit.circuit.library.GroverOperator.mcu1")(lam, control\_qubits, target\_qubit) | Apply `MCU1Gate`. |
|
||
| [`mcx`](#qiskit.circuit.library.GroverOperator.mcx "qiskit.circuit.library.GroverOperator.mcx")(control\_qubits, target\_qubit\[, …]) | Apply [`MCXGate`](qiskit.circuit.library.MCXGate "qiskit.circuit.library.MCXGate"). |
|
||
| [`measure`](#qiskit.circuit.library.GroverOperator.measure "qiskit.circuit.library.GroverOperator.measure")(qubit, cbit) | Measure quantum bit into classical bit (tuples). |
|
||
| [`measure_active`](#qiskit.circuit.library.GroverOperator.measure_active "qiskit.circuit.library.GroverOperator.measure_active")(\[inplace]) | Adds measurement to all non-idle qubits. |
|
||
| [`measure_all`](#qiskit.circuit.library.GroverOperator.measure_all "qiskit.circuit.library.GroverOperator.measure_all")(\[inplace]) | Adds measurement to all qubits. |
|
||
| [`ms`](#qiskit.circuit.library.GroverOperator.ms "qiskit.circuit.library.GroverOperator.ms")(theta, qubits) | Apply [`MSGate`](qiskit.circuit.library.MSGate "qiskit.circuit.library.MSGate"). |
|
||
| [`num_connected_components`](#qiskit.circuit.library.GroverOperator.num_connected_components "qiskit.circuit.library.GroverOperator.num_connected_components")(\[unitary\_only]) | How many non-entangled subcircuits can the circuit be factored to. |
|
||
| [`num_nonlocal_gates`](#qiskit.circuit.library.GroverOperator.num_nonlocal_gates "qiskit.circuit.library.GroverOperator.num_nonlocal_gates")() | Return number of non-local gates (i.e. |
|
||
| [`num_tensor_factors`](#qiskit.circuit.library.GroverOperator.num_tensor_factors "qiskit.circuit.library.GroverOperator.num_tensor_factors")() | Computes the number of tensor factors in the unitary (quantum) part of the circuit only. |
|
||
| [`num_unitary_factors`](#qiskit.circuit.library.GroverOperator.num_unitary_factors "qiskit.circuit.library.GroverOperator.num_unitary_factors")() | Computes the number of tensor factors in the unitary (quantum) part of the circuit only. |
|
||
| [`p`](#qiskit.circuit.library.GroverOperator.p "qiskit.circuit.library.GroverOperator.p")(theta, qubit) | Apply [`PhaseGate`](qiskit.circuit.library.PhaseGate "qiskit.circuit.library.PhaseGate"). |
|
||
| [`pauli`](#qiskit.circuit.library.GroverOperator.pauli "qiskit.circuit.library.GroverOperator.pauli")(pauli\_string, qubits) | Apply `PauliGate`. |
|
||
| [`power`](#qiskit.circuit.library.GroverOperator.power "qiskit.circuit.library.GroverOperator.power")(power\[, matrix\_power]) | Raise this circuit to the power of `power`. |
|
||
| [`qasm`](#qiskit.circuit.library.GroverOperator.qasm "qiskit.circuit.library.GroverOperator.qasm")(\[formatted, filename]) | Return OpenQASM string. |
|
||
| [`qbit_argument_conversion`](#qiskit.circuit.library.GroverOperator.qbit_argument_conversion "qiskit.circuit.library.GroverOperator.qbit_argument_conversion")(qubit\_representation) | Converts several qubit representations (such as indexes, range, etc.) into a list of qubits. |
|
||
| [`qubit_duration`](#qiskit.circuit.library.GroverOperator.qubit_duration "qiskit.circuit.library.GroverOperator.qubit_duration")(\*qubits) | Return the duration between the start and stop time of the first and last instructions, excluding delays, over the supplied qubits. |
|
||
| [`qubit_start_time`](#qiskit.circuit.library.GroverOperator.qubit_start_time "qiskit.circuit.library.GroverOperator.qubit_start_time")(\*qubits) | Return the start time of the first instruction, excluding delays, over the supplied qubits. |
|
||
| [`qubit_stop_time`](#qiskit.circuit.library.GroverOperator.qubit_stop_time "qiskit.circuit.library.GroverOperator.qubit_stop_time")(\*qubits) | Return the stop time of the last instruction, excluding delays, over the supplied qubits. |
|
||
| [`r`](#qiskit.circuit.library.GroverOperator.r "qiskit.circuit.library.GroverOperator.r")(theta, phi, qubit) | Apply [`RGate`](qiskit.circuit.library.RGate "qiskit.circuit.library.RGate"). |
|
||
| [`rcccx`](#qiskit.circuit.library.GroverOperator.rcccx "qiskit.circuit.library.GroverOperator.rcccx")(control\_qubit1, control\_qubit2, …) | Apply [`RC3XGate`](qiskit.circuit.library.RC3XGate "qiskit.circuit.library.RC3XGate"). |
|
||
| [`rccx`](#qiskit.circuit.library.GroverOperator.rccx "qiskit.circuit.library.GroverOperator.rccx")(control\_qubit1, control\_qubit2, …) | Apply [`RCCXGate`](qiskit.circuit.library.RCCXGate "qiskit.circuit.library.RCCXGate"). |
|
||
| [`remove_final_measurements`](#qiskit.circuit.library.GroverOperator.remove_final_measurements "qiskit.circuit.library.GroverOperator.remove_final_measurements")(\[inplace]) | Removes final measurement on all qubits if they are present. |
|
||
| [`repeat`](#qiskit.circuit.library.GroverOperator.repeat "qiskit.circuit.library.GroverOperator.repeat")(reps) | Repeat this circuit `reps` times. |
|
||
| [`reset`](#qiskit.circuit.library.GroverOperator.reset "qiskit.circuit.library.GroverOperator.reset")(qubit) | Reset q. |
|
||
| [`reverse_bits`](#qiskit.circuit.library.GroverOperator.reverse_bits "qiskit.circuit.library.GroverOperator.reverse_bits")() | Return a circuit with the opposite order of wires. |
|
||
| [`reverse_ops`](#qiskit.circuit.library.GroverOperator.reverse_ops "qiskit.circuit.library.GroverOperator.reverse_ops")() | Reverse the circuit by reversing the order of instructions. |
|
||
| [`rv`](#qiskit.circuit.library.GroverOperator.rv "qiskit.circuit.library.GroverOperator.rv")(vx, vy, vz, qubit) | Apply [`RVGate`](qiskit.circuit.library.RVGate "qiskit.circuit.library.RVGate"). |
|
||
| [`rx`](#qiskit.circuit.library.GroverOperator.rx "qiskit.circuit.library.GroverOperator.rx")(theta, qubit\[, label]) | Apply [`RXGate`](qiskit.circuit.library.RXGate "qiskit.circuit.library.RXGate"). |
|
||
| [`rxx`](#qiskit.circuit.library.GroverOperator.rxx "qiskit.circuit.library.GroverOperator.rxx")(theta, qubit1, qubit2) | Apply [`RXXGate`](qiskit.circuit.library.RXXGate "qiskit.circuit.library.RXXGate"). |
|
||
| [`ry`](#qiskit.circuit.library.GroverOperator.ry "qiskit.circuit.library.GroverOperator.ry")(theta, qubit\[, label]) | Apply [`RYGate`](qiskit.circuit.library.RYGate "qiskit.circuit.library.RYGate"). |
|
||
| [`ryy`](#qiskit.circuit.library.GroverOperator.ryy "qiskit.circuit.library.GroverOperator.ryy")(theta, qubit1, qubit2) | Apply [`RYYGate`](qiskit.circuit.library.RYYGate "qiskit.circuit.library.RYYGate"). |
|
||
| [`rz`](#qiskit.circuit.library.GroverOperator.rz "qiskit.circuit.library.GroverOperator.rz")(phi, qubit) | Apply [`RZGate`](qiskit.circuit.library.RZGate "qiskit.circuit.library.RZGate"). |
|
||
| [`rzx`](#qiskit.circuit.library.GroverOperator.rzx "qiskit.circuit.library.GroverOperator.rzx")(theta, qubit1, qubit2) | Apply [`RZXGate`](qiskit.circuit.library.RZXGate "qiskit.circuit.library.RZXGate"). |
|
||
| [`rzz`](#qiskit.circuit.library.GroverOperator.rzz "qiskit.circuit.library.GroverOperator.rzz")(theta, qubit1, qubit2) | Apply [`RZZGate`](qiskit.circuit.library.RZZGate "qiskit.circuit.library.RZZGate"). |
|
||
| [`s`](#qiskit.circuit.library.GroverOperator.s "qiskit.circuit.library.GroverOperator.s")(qubit) | Apply [`SGate`](qiskit.circuit.library.SGate "qiskit.circuit.library.SGate"). |
|
||
| [`save_amplitudes`](#qiskit.circuit.library.GroverOperator.save_amplitudes "qiskit.circuit.library.GroverOperator.save_amplitudes")(params\[, label, pershot, …]) | Save complex statevector amplitudes. |
|
||
| [`save_amplitudes_squared`](#qiskit.circuit.library.GroverOperator.save_amplitudes_squared "qiskit.circuit.library.GroverOperator.save_amplitudes_squared")(params\[, label, …]) | Save squared statevector amplitudes (probabilities). |
|
||
| [`save_density_matrix`](#qiskit.circuit.library.GroverOperator.save_density_matrix "qiskit.circuit.library.GroverOperator.save_density_matrix")(\[qubits, label, …]) | Save the current simulator quantum state as a density matrix. |
|
||
| [`save_expectation_value`](#qiskit.circuit.library.GroverOperator.save_expectation_value "qiskit.circuit.library.GroverOperator.save_expectation_value")(operator, qubits\[, …]) | Save the expectation value of a Hermitian operator. |
|
||
| [`save_expectation_value_variance`](#qiskit.circuit.library.GroverOperator.save_expectation_value_variance "qiskit.circuit.library.GroverOperator.save_expectation_value_variance")(operator, qubits) | Save the expectation value of a Hermitian operator. |
|
||
| [`save_matrix_product_state`](#qiskit.circuit.library.GroverOperator.save_matrix_product_state "qiskit.circuit.library.GroverOperator.save_matrix_product_state")(\[label, pershot, …]) | Save the current simulator quantum state as a matrix product state. |
|
||
| [`save_probabilities`](#qiskit.circuit.library.GroverOperator.save_probabilities "qiskit.circuit.library.GroverOperator.save_probabilities")(\[qubits, label, …]) | Save measurement outcome probabilities vector. |
|
||
| [`save_probabilities_dict`](#qiskit.circuit.library.GroverOperator.save_probabilities_dict "qiskit.circuit.library.GroverOperator.save_probabilities_dict")(\[qubits, label, …]) | Save measurement outcome probabilities vector. |
|
||
| [`save_stabilizer`](#qiskit.circuit.library.GroverOperator.save_stabilizer "qiskit.circuit.library.GroverOperator.save_stabilizer")(\[label, pershot, conditional]) | Save the current stabilizer simulator quantum state as a Clifford. |
|
||
| [`save_state`](#qiskit.circuit.library.GroverOperator.save_state "qiskit.circuit.library.GroverOperator.save_state")(\[label, pershot, conditional]) | Save the current simulator quantum state. |
|
||
| [`save_statevector`](#qiskit.circuit.library.GroverOperator.save_statevector "qiskit.circuit.library.GroverOperator.save_statevector")(\[label, pershot, conditional]) | Save the current simulator quantum state as a statevector. |
|
||
| [`save_statevector_dict`](#qiskit.circuit.library.GroverOperator.save_statevector_dict "qiskit.circuit.library.GroverOperator.save_statevector_dict")(\[label, pershot, …]) | Save the current simulator quantum state as a statevector as a dict. |
|
||
| [`save_superop`](#qiskit.circuit.library.GroverOperator.save_superop "qiskit.circuit.library.GroverOperator.save_superop")(\[label, pershot]) | Save the current state of the superop simulator. |
|
||
| [`save_unitary`](#qiskit.circuit.library.GroverOperator.save_unitary "qiskit.circuit.library.GroverOperator.save_unitary")(\[label, pershot]) | Save the current state of the unitary simulator. |
|
||
| [`sdg`](#qiskit.circuit.library.GroverOperator.sdg "qiskit.circuit.library.GroverOperator.sdg")(qubit) | Apply [`SdgGate`](qiskit.circuit.library.SdgGate "qiskit.circuit.library.SdgGate"). |
|
||
| [`set_density_matrix`](#qiskit.circuit.library.GroverOperator.set_density_matrix "qiskit.circuit.library.GroverOperator.set_density_matrix")(state) | Set the density matrix state of the simulator. |
|
||
| [`set_matrix_product_state`](#qiskit.circuit.library.GroverOperator.set_matrix_product_state "qiskit.circuit.library.GroverOperator.set_matrix_product_state")(state) | Set the matrix product state of the simulator. |
|
||
| [`set_stabilizer`](#qiskit.circuit.library.GroverOperator.set_stabilizer "qiskit.circuit.library.GroverOperator.set_stabilizer")(state) | Set the Clifford stabilizer state of the simulator. |
|
||
| [`set_statevector`](#qiskit.circuit.library.GroverOperator.set_statevector "qiskit.circuit.library.GroverOperator.set_statevector")(state) | Set the statevector state of the simulator. |
|
||
| [`set_superop`](#qiskit.circuit.library.GroverOperator.set_superop "qiskit.circuit.library.GroverOperator.set_superop")(state) | Set the superop state of the simulator. |
|
||
| [`set_unitary`](#qiskit.circuit.library.GroverOperator.set_unitary "qiskit.circuit.library.GroverOperator.set_unitary")(state) | Set the state state of the simulator. |
|
||
| [`size`](#qiskit.circuit.library.GroverOperator.size "qiskit.circuit.library.GroverOperator.size")() | Returns total number of gate operations in circuit. |
|
||
| [`snapshot`](#qiskit.circuit.library.GroverOperator.snapshot "qiskit.circuit.library.GroverOperator.snapshot")(label\[, snapshot\_type, qubits, params]) | Take a statevector snapshot of the internal simulator representation. |
|
||
| [`snapshot_density_matrix`](#qiskit.circuit.library.GroverOperator.snapshot_density_matrix "qiskit.circuit.library.GroverOperator.snapshot_density_matrix")(label\[, qubits]) | Take a density matrix snapshot of simulator state. |
|
||
| [`snapshot_expectation_value`](#qiskit.circuit.library.GroverOperator.snapshot_expectation_value "qiskit.circuit.library.GroverOperator.snapshot_expectation_value")(label, op, qubits) | Take a snapshot of expectation value \<O> of an Operator. |
|
||
| [`snapshot_probabilities`](#qiskit.circuit.library.GroverOperator.snapshot_probabilities "qiskit.circuit.library.GroverOperator.snapshot_probabilities")(label, qubits\[, variance]) | Take a probability snapshot of the simulator state. |
|
||
| [`snapshot_stabilizer`](#qiskit.circuit.library.GroverOperator.snapshot_stabilizer "qiskit.circuit.library.GroverOperator.snapshot_stabilizer")(label) | Take a stabilizer snapshot of the simulator state. |
|
||
| [`snapshot_statevector`](#qiskit.circuit.library.GroverOperator.snapshot_statevector "qiskit.circuit.library.GroverOperator.snapshot_statevector")(label) | Take a statevector snapshot of the simulator state. |
|
||
| [`squ`](#qiskit.circuit.library.GroverOperator.squ "qiskit.circuit.library.GroverOperator.squ")(unitary\_matrix, qubit\[, mode, …]) | Decompose an arbitrary 2\*2 unitary into three rotation gates. |
|
||
| [`swap`](#qiskit.circuit.library.GroverOperator.swap "qiskit.circuit.library.GroverOperator.swap")(qubit1, qubit2) | Apply [`SwapGate`](qiskit.circuit.library.SwapGate "qiskit.circuit.library.SwapGate"). |
|
||
| [`sx`](#qiskit.circuit.library.GroverOperator.sx "qiskit.circuit.library.GroverOperator.sx")(qubit) | Apply [`SXGate`](qiskit.circuit.library.SXGate "qiskit.circuit.library.SXGate"). |
|
||
| [`sxdg`](#qiskit.circuit.library.GroverOperator.sxdg "qiskit.circuit.library.GroverOperator.sxdg")(qubit) | Apply [`SXdgGate`](qiskit.circuit.library.SXdgGate "qiskit.circuit.library.SXdgGate"). |
|
||
| [`t`](#qiskit.circuit.library.GroverOperator.t "qiskit.circuit.library.GroverOperator.t")(qubit) | Apply [`TGate`](qiskit.circuit.library.TGate "qiskit.circuit.library.TGate"). |
|
||
| [`tdg`](#qiskit.circuit.library.GroverOperator.tdg "qiskit.circuit.library.GroverOperator.tdg")(qubit) | Apply [`TdgGate`](qiskit.circuit.library.TdgGate "qiskit.circuit.library.TdgGate"). |
|
||
| [`tensor`](#qiskit.circuit.library.GroverOperator.tensor "qiskit.circuit.library.GroverOperator.tensor")(other\[, inplace]) | Tensor `self` with `other`. |
|
||
| [`to_gate`](#qiskit.circuit.library.GroverOperator.to_gate "qiskit.circuit.library.GroverOperator.to_gate")(\[parameter\_map, label]) | Create a Gate out of this circuit. |
|
||
| [`to_instruction`](#qiskit.circuit.library.GroverOperator.to_instruction "qiskit.circuit.library.GroverOperator.to_instruction")(\[parameter\_map]) | Create an Instruction out of this circuit. |
|
||
| [`toffoli`](#qiskit.circuit.library.GroverOperator.toffoli "qiskit.circuit.library.GroverOperator.toffoli")(control\_qubit1, control\_qubit2, …) | Apply [`CCXGate`](qiskit.circuit.library.CCXGate "qiskit.circuit.library.CCXGate"). |
|
||
| [`u`](#qiskit.circuit.library.GroverOperator.u "qiskit.circuit.library.GroverOperator.u")(theta, phi, lam, qubit) | Apply [`UGate`](qiskit.circuit.library.UGate "qiskit.circuit.library.UGate"). |
|
||
| [`u1`](#qiskit.circuit.library.GroverOperator.u1 "qiskit.circuit.library.GroverOperator.u1")(theta, qubit) | Apply [`U1Gate`](qiskit.circuit.library.U1Gate "qiskit.circuit.library.U1Gate"). |
|
||
| [`u2`](#qiskit.circuit.library.GroverOperator.u2 "qiskit.circuit.library.GroverOperator.u2")(phi, lam, qubit) | Apply [`U2Gate`](qiskit.circuit.library.U2Gate "qiskit.circuit.library.U2Gate"). |
|
||
| [`u3`](#qiskit.circuit.library.GroverOperator.u3 "qiskit.circuit.library.GroverOperator.u3")(theta, phi, lam, qubit) | Apply [`U3Gate`](qiskit.circuit.library.U3Gate "qiskit.circuit.library.U3Gate"). |
|
||
| [`uc`](#qiskit.circuit.library.GroverOperator.uc "qiskit.circuit.library.GroverOperator.uc")(gate\_list, q\_controls, q\_target\[, …]) | Attach a uniformly controlled gates (also called multiplexed gates) to a circuit. |
|
||
| [`ucrx`](#qiskit.circuit.library.GroverOperator.ucrx "qiskit.circuit.library.GroverOperator.ucrx")(angle\_list, q\_controls, q\_target) | Attach a uniformly controlled (also called multiplexed) Rx rotation gate to a circuit. |
|
||
| [`ucry`](#qiskit.circuit.library.GroverOperator.ucry "qiskit.circuit.library.GroverOperator.ucry")(angle\_list, q\_controls, q\_target) | Attach a uniformly controlled (also called multiplexed) Ry rotation gate to a circuit. |
|
||
| [`ucrz`](#qiskit.circuit.library.GroverOperator.ucrz "qiskit.circuit.library.GroverOperator.ucrz")(angle\_list, q\_controls, q\_target) | Attach a uniformly controlled (also called multiplexed gates) Rz rotation gate to a circuit. |
|
||
| [`unitary`](#qiskit.circuit.library.GroverOperator.unitary "qiskit.circuit.library.GroverOperator.unitary")(obj, qubits\[, label]) | Apply unitary gate to q. |
|
||
| [`width`](#qiskit.circuit.library.GroverOperator.width "qiskit.circuit.library.GroverOperator.width")() | Return number of qubits plus clbits in circuit. |
|
||
| [`x`](#qiskit.circuit.library.GroverOperator.x "qiskit.circuit.library.GroverOperator.x")(qubit\[, label]) | Apply [`XGate`](qiskit.circuit.library.XGate "qiskit.circuit.library.XGate"). |
|
||
| [`y`](#qiskit.circuit.library.GroverOperator.y "qiskit.circuit.library.GroverOperator.y")(qubit) | Apply [`YGate`](qiskit.circuit.library.YGate "qiskit.circuit.library.YGate"). |
|
||
| [`z`](#qiskit.circuit.library.GroverOperator.z "qiskit.circuit.library.GroverOperator.z")(qubit) | Apply [`ZGate`](qiskit.circuit.library.ZGate "qiskit.circuit.library.ZGate"). |
|
||
|
||
## Attributes
|
||
|
||
| | |
|
||
| ----------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------- |
|
||
| [`ancillas`](#qiskit.circuit.library.GroverOperator.ancillas "qiskit.circuit.library.GroverOperator.ancillas") | Returns a list of ancilla bits in the order that the registers were added. |
|
||
| [`calibrations`](#qiskit.circuit.library.GroverOperator.calibrations "qiskit.circuit.library.GroverOperator.calibrations") | Return calibration dictionary. |
|
||
| [`clbits`](#qiskit.circuit.library.GroverOperator.clbits "qiskit.circuit.library.GroverOperator.clbits") | Returns a list of classical bits in the order that the registers were added. |
|
||
| [`data`](#qiskit.circuit.library.GroverOperator.data "qiskit.circuit.library.GroverOperator.data") | Return the circuit data (instructions and context). |
|
||
| `extension_lib` | |
|
||
| [`global_phase`](#qiskit.circuit.library.GroverOperator.global_phase "qiskit.circuit.library.GroverOperator.global_phase") | Return the global phase of the circuit in radians. |
|
||
| `header` | |
|
||
| `instances` | |
|
||
| [`metadata`](#qiskit.circuit.library.GroverOperator.metadata "qiskit.circuit.library.GroverOperator.metadata") | The user provided metadata associated with the circuit |
|
||
| [`num_ancillas`](#qiskit.circuit.library.GroverOperator.num_ancillas "qiskit.circuit.library.GroverOperator.num_ancillas") | Return the number of ancilla qubits. |
|
||
| [`num_clbits`](#qiskit.circuit.library.GroverOperator.num_clbits "qiskit.circuit.library.GroverOperator.num_clbits") | Return number of classical bits. |
|
||
| [`num_parameters`](#qiskit.circuit.library.GroverOperator.num_parameters "qiskit.circuit.library.GroverOperator.num_parameters") | Convenience function to get the number of parameter objects in the circuit. |
|
||
| [`num_qubits`](#qiskit.circuit.library.GroverOperator.num_qubits "qiskit.circuit.library.GroverOperator.num_qubits") | Return number of qubits. |
|
||
| [`oracle`](#qiskit.circuit.library.GroverOperator.oracle "qiskit.circuit.library.GroverOperator.oracle") | The oracle implementing a reflection about the bad state. |
|
||
| [`parameters`](#qiskit.circuit.library.GroverOperator.parameters "qiskit.circuit.library.GroverOperator.parameters") | Convenience function to get the parameters defined in the parameter table. |
|
||
| `prefix` | |
|
||
| [`qubits`](#qiskit.circuit.library.GroverOperator.qubits "qiskit.circuit.library.GroverOperator.qubits") | Returns a list of quantum bits in the order that the registers were added. |
|
||
| [`reflection_qubits`](#qiskit.circuit.library.GroverOperator.reflection_qubits "qiskit.circuit.library.GroverOperator.reflection_qubits") | Reflection qubits, on which S0 is applied (if S0 is not user-specified). |
|
||
| [`state_preparation`](#qiskit.circuit.library.GroverOperator.state_preparation "qiskit.circuit.library.GroverOperator.state_preparation") | The subcircuit implementing the A operator or Hadamards. |
|
||
| [`zero_reflection`](#qiskit.circuit.library.GroverOperator.zero_reflection "qiskit.circuit.library.GroverOperator.zero_reflection") | The subcircuit implementing the reflection about 0. |
|
||
|
||
### add\_bits
|
||
|
||
<Function id="qiskit.circuit.library.GroverOperator.add_bits" signature="add_bits(bits)">
|
||
Add Bits to the circuit.
|
||
</Function>
|
||
|
||
### add\_calibration
|
||
|
||
<Function id="qiskit.circuit.library.GroverOperator.add_calibration" signature="add_calibration(gate, qubits, schedule, params=None)">
|
||
Register a low-level, custom pulse definition for the given gate.
|
||
|
||
**Parameters**
|
||
|
||
* **gate** (*Union\[*[*Gate*](qiskit.circuit.Gate "qiskit.circuit.Gate")*, str]*) – Gate information.
|
||
* **qubits** (*Union\[int, Tuple\[int]]*) – List of qubits to be measured.
|
||
* **schedule** ([*Schedule*](qiskit.pulse.Schedule "qiskit.pulse.Schedule")) – Schedule information.
|
||
* **params** (*Optional\[List\[Union\[float,* [*Parameter*](qiskit.circuit.Parameter "qiskit.circuit.Parameter")*]]]*) – A list of parameters.
|
||
|
||
**Raises**
|
||
|
||
**Exception** – if the gate is of type string and params is None.
|
||
</Function>
|
||
|
||
### add\_register
|
||
|
||
<Function id="qiskit.circuit.library.GroverOperator.add_register" signature="add_register(*regs)">
|
||
Add registers.
|
||
</Function>
|
||
|
||
### ancillas
|
||
|
||
<Attribute id="qiskit.circuit.library.GroverOperator.ancillas">
|
||
Returns a list of ancilla bits in the order that the registers were added.
|
||
</Attribute>
|
||
|
||
### append
|
||
|
||
<Function id="qiskit.circuit.library.GroverOperator.append" signature="append(instruction, qargs=None, cargs=None)">
|
||
Append one or more instructions to the end of the circuit, modifying the circuit in place. Expands qargs and cargs.
|
||
|
||
**Parameters**
|
||
|
||
* **instruction** ([*qiskit.circuit.Instruction*](qiskit.circuit.Instruction "qiskit.circuit.Instruction")) – Instruction instance to append
|
||
* **qargs** (*list(argument)*) – qubits to attach instruction to
|
||
* **cargs** (*list(argument)*) – clbits to attach instruction to
|
||
|
||
**Returns**
|
||
|
||
a handle to the instruction that was just added
|
||
|
||
**Return type**
|
||
|
||
[qiskit.circuit.Instruction](qiskit.circuit.Instruction "qiskit.circuit.Instruction")
|
||
|
||
**Raises**
|
||
|
||
* **CircuitError** – if object passed is a subclass of Instruction
|
||
* **CircuitError** – if object passed is neither subclass nor an instance of Instruction
|
||
</Function>
|
||
|
||
### assign\_parameters
|
||
|
||
<Function id="qiskit.circuit.library.GroverOperator.assign_parameters" signature="assign_parameters(parameters, inplace=False, param_dict=None)">
|
||
Assign parameters to new parameters or values.
|
||
|
||
The keys of the parameter dictionary must be Parameter instances in the current circuit. The values of the dictionary can either be numeric values or new parameter objects. The values can be assigned to the current circuit object or to a copy of it.
|
||
|
||
**Parameters**
|
||
|
||
* **parameters** (*dict or iterable*) – Either a dictionary or iterable specifying the new parameter values. If a dict, it specifies the mapping from `current_parameter` to `new_parameter`, where `new_parameter` can be a new parameter object or a numeric value. If an iterable, the elements are assigned to the existing parameters in the order they were inserted. You can call `QuantumCircuit.parameters` to check this order.
|
||
* **inplace** (*bool*) – If False, a copy of the circuit with the bound parameters is returned. If True the circuit instance itself is modified.
|
||
* **param\_dict** (*dict*) – Deprecated, use `parameters` instead.
|
||
|
||
**Raises**
|
||
|
||
* **CircuitError** – If parameters is a dict and contains parameters not present in the circuit.
|
||
* **ValueError** – If parameters is a list/array and the length mismatches the number of free parameters in the circuit.
|
||
|
||
**Returns**
|
||
|
||
A copy of the circuit with bound parameters, if `inplace` is True, otherwise None.
|
||
|
||
**Return type**
|
||
|
||
Optional([QuantumCircuit](qiskit.circuit.QuantumCircuit "qiskit.circuit.QuantumCircuit"))
|
||
|
||
**Examples**
|
||
|
||
Create a parameterized circuit and assign the parameters in-place.
|
||
|
||
```python
|
||
from qiskit.circuit import QuantumCircuit, Parameter
|
||
|
||
circuit = QuantumCircuit(2)
|
||
params = [Parameter('A'), Parameter('B'), Parameter('C')]
|
||
circuit.ry(params[0], 0)
|
||
circuit.crx(params[1], 0, 1)
|
||
|
||
print('Original circuit:')
|
||
print(circuit.draw())
|
||
|
||
circuit.assign_parameters({params[0]: params[2]}, inplace=True)
|
||
|
||
print('Assigned in-place:')
|
||
print(circuit.draw())
|
||
```
|
||
|
||
```
|
||
Original circuit:
|
||
┌───────┐
|
||
q_0: ┤ RY(A) ├────■────
|
||
└───────┘┌───┴───┐
|
||
q_1: ─────────┤ RX(B) ├
|
||
└───────┘
|
||
Assigned in-place:
|
||
┌───────┐
|
||
q_0: ┤ RY(C) ├────■────
|
||
└───────┘┌───┴───┐
|
||
q_1: ─────────┤ RX(B) ├
|
||
└───────┘
|
||
```
|
||
|
||
Bind the values out-of-place and get a copy of the original circuit.
|
||
|
||
```python
|
||
from qiskit.circuit import QuantumCircuit, ParameterVector
|
||
|
||
circuit = QuantumCircuit(2)
|
||
params = ParameterVector('P', 2)
|
||
circuit.ry(params[0], 0)
|
||
circuit.crx(params[1], 0, 1)
|
||
|
||
bound_circuit = circuit.assign_parameters({params[0]: 1, params[1]: 2})
|
||
print('Bound circuit:')
|
||
print(bound_circuit.draw())
|
||
|
||
print('The original circuit is unchanged:')
|
||
print(circuit.draw())
|
||
```
|
||
|
||
```
|
||
Bound circuit:
|
||
┌───────┐
|
||
q_0: ┤ RY(1) ├────■────
|
||
└───────┘┌───┴───┐
|
||
q_1: ─────────┤ RX(2) ├
|
||
└───────┘
|
||
The original circuit is unchanged:
|
||
┌──────────┐
|
||
q_0: ┤ RY(P[0]) ├─────■──────
|
||
└──────────┘┌────┴─────┐
|
||
q_1: ────────────┤ RX(P[1]) ├
|
||
└──────────┘
|
||
```
|
||
</Function>
|
||
|
||
### barrier
|
||
|
||
<Function id="qiskit.circuit.library.GroverOperator.barrier" signature="barrier(*qargs)">
|
||
Apply `Barrier`. If qargs is None, applies to all.
|
||
</Function>
|
||
|
||
### bind\_parameters
|
||
|
||
<Function id="qiskit.circuit.library.GroverOperator.bind_parameters" signature="bind_parameters(values, value_dict=None)">
|
||
Assign numeric parameters to values yielding a new circuit.
|
||
|
||
To assign new Parameter objects or bind the values in-place, without yielding a new circuit, use the [`assign_parameters()`](#qiskit.circuit.library.GroverOperator.assign_parameters "qiskit.circuit.library.GroverOperator.assign_parameters") method.
|
||
|
||
**Parameters**
|
||
|
||
* **values** (*dict or iterable*) – \{parameter: value, …} or \[value1, value2, …]
|
||
* **value\_dict** (*dict*) – Deprecated, use `values` instead.
|
||
|
||
**Raises**
|
||
|
||
* **CircuitError** – If values is a dict and contains parameters not present in the circuit.
|
||
* **TypeError** – If values contains a ParameterExpression.
|
||
|
||
**Returns**
|
||
|
||
copy of self with assignment substitution.
|
||
|
||
**Return type**
|
||
|
||
[QuantumCircuit](qiskit.circuit.QuantumCircuit "qiskit.circuit.QuantumCircuit")
|
||
</Function>
|
||
|
||
### calibrations
|
||
|
||
<Attribute id="qiskit.circuit.library.GroverOperator.calibrations">
|
||
Return calibration dictionary.
|
||
|
||
**The custom pulse definition of a given gate is of the form**
|
||
|
||
\{‘gate\_name’: \{(qubits, params): schedule}}
|
||
</Attribute>
|
||
|
||
### cast
|
||
|
||
<Function id="qiskit.circuit.library.GroverOperator.cast" signature="cast(value, _type)" modifiers="static">
|
||
Best effort to cast value to type. Otherwise, returns the value.
|
||
</Function>
|
||
|
||
### cbit\_argument\_conversion
|
||
|
||
<Function id="qiskit.circuit.library.GroverOperator.cbit_argument_conversion" signature="cbit_argument_conversion(clbit_representation)">
|
||
Converts several classical bit representations (such as indexes, range, etc.) into a list of classical bits.
|
||
|
||
**Parameters**
|
||
|
||
**clbit\_representation** (*Object*) – representation to expand
|
||
|
||
**Returns**
|
||
|
||
Where each tuple is a classical bit.
|
||
|
||
**Return type**
|
||
|
||
List(tuple)
|
||
</Function>
|
||
|
||
### ccx
|
||
|
||
<Function id="qiskit.circuit.library.GroverOperator.ccx" signature="ccx(control_qubit1, control_qubit2, target_qubit)">
|
||
Apply [`CCXGate`](qiskit.circuit.library.CCXGate "qiskit.circuit.library.CCXGate").
|
||
</Function>
|
||
|
||
### ch
|
||
|
||
<Function id="qiskit.circuit.library.GroverOperator.ch" signature="ch(control_qubit, target_qubit, label=None, ctrl_state=None)">
|
||
Apply [`CHGate`](qiskit.circuit.library.CHGate "qiskit.circuit.library.CHGate").
|
||
</Function>
|
||
|
||
### clbits
|
||
|
||
<Attribute id="qiskit.circuit.library.GroverOperator.clbits">
|
||
Returns a list of classical bits in the order that the registers were added.
|
||
</Attribute>
|
||
|
||
### cls\_instances
|
||
|
||
<Function id="qiskit.circuit.library.GroverOperator.cls_instances" signature="cls_instances()" modifiers="classmethod">
|
||
Return the current number of instances of this class, useful for auto naming.
|
||
</Function>
|
||
|
||
### cls\_prefix
|
||
|
||
<Function id="qiskit.circuit.library.GroverOperator.cls_prefix" signature="cls_prefix()" modifiers="classmethod">
|
||
Return the prefix to use for auto naming.
|
||
</Function>
|
||
|
||
### cnot
|
||
|
||
<Function id="qiskit.circuit.library.GroverOperator.cnot" signature="cnot(control_qubit, target_qubit, label=None, ctrl_state=None)">
|
||
Apply [`CXGate`](qiskit.circuit.library.CXGate "qiskit.circuit.library.CXGate").
|
||
</Function>
|
||
|
||
### combine
|
||
|
||
<Function id="qiskit.circuit.library.GroverOperator.combine" signature="combine(rhs)">
|
||
DEPRECATED - Returns rhs appended to self if self contains compatible registers.
|
||
|
||
Two circuits are compatible if they contain the same registers or if they contain different registers with unique names. The returned circuit will contain all unique registers between both circuits.
|
||
|
||
Return self + rhs as a new object.
|
||
|
||
**Parameters**
|
||
|
||
**rhs** ([*QuantumCircuit*](qiskit.circuit.QuantumCircuit "qiskit.circuit.QuantumCircuit")) – The quantum circuit to append to the right hand side.
|
||
|
||
**Returns**
|
||
|
||
Returns a new QuantumCircuit object
|
||
|
||
**Return type**
|
||
|
||
[QuantumCircuit](qiskit.circuit.QuantumCircuit "qiskit.circuit.QuantumCircuit")
|
||
|
||
**Raises**
|
||
|
||
**QiskitError** – if the rhs circuit is not compatible
|
||
</Function>
|
||
|
||
### compose
|
||
|
||
<Function id="qiskit.circuit.library.GroverOperator.compose" signature="compose(other, qubits=None, clbits=None, front=False, inplace=False)">
|
||
Compose circuit with `other` circuit or instruction, optionally permuting wires.
|
||
|
||
`other` can be narrower or of equal width to `self`.
|
||
|
||
**Parameters**
|
||
|
||
* **other** ([*qiskit.circuit.Instruction*](qiskit.circuit.Instruction "qiskit.circuit.Instruction") *or*[*QuantumCircuit*](qiskit.circuit.QuantumCircuit "qiskit.circuit.QuantumCircuit") *or BaseOperator*) – (sub)circuit to compose onto self.
|
||
* **qubits** (*list\[Qubit|int]*) – qubits of self to compose onto.
|
||
* **clbits** (*list\[Clbit|int]*) – clbits of self to compose onto.
|
||
* **front** (*bool*) – If True, front composition will be performed (not implemented yet).
|
||
* **inplace** (*bool*) – If True, modify the object. Otherwise return composed circuit.
|
||
|
||
**Returns**
|
||
|
||
the composed circuit (returns None if inplace==True).
|
||
|
||
**Return type**
|
||
|
||
[QuantumCircuit](qiskit.circuit.QuantumCircuit "qiskit.circuit.QuantumCircuit")
|
||
|
||
**Raises**
|
||
|
||
* **CircuitError** – if composing on the front.
|
||
* **QiskitError** – if `other` is wider or there are duplicate edge mappings.
|
||
|
||
Examples:
|
||
|
||
```python
|
||
lhs.compose(rhs, qubits=[3, 2], inplace=True)
|
||
|
||
.. parsed-literal::
|
||
|
||
┌───┐ ┌─────┐ ┌───┐
|
||
lqr_1_0: ───┤ H ├─── rqr_0: ──■──┤ Tdg ├ lqr_1_0: ───┤ H ├───────────────
|
||
├───┤ ┌─┴─┐└─────┘ ├───┤
|
||
lqr_1_1: ───┤ X ├─── rqr_1: ┤ X ├─────── lqr_1_1: ───┤ X ├───────────────
|
||
┌──┴───┴──┐ └───┘ ┌──┴───┴──┐┌───┐
|
||
lqr_1_2: ┤ U1(0.1) ├ + = lqr_1_2: ┤ U1(0.1) ├┤ X ├───────
|
||
└─────────┘ └─────────┘└─┬─┘┌─────┐
|
||
lqr_2_0: ─────■───── lqr_2_0: ─────■───────■──┤ Tdg ├
|
||
┌─┴─┐ ┌─┴─┐ └─────┘
|
||
lqr_2_1: ───┤ X ├─── lqr_2_1: ───┤ X ├───────────────
|
||
└───┘ └───┘
|
||
lcr_0: 0 ═══════════ lcr_0: 0 ═══════════════════════
|
||
|
||
lcr_1: 0 ═══════════ lcr_1: 0 ═══════════════════════
|
||
```
|
||
</Function>
|
||
|
||
### control
|
||
|
||
<Function id="qiskit.circuit.library.GroverOperator.control" signature="control(num_ctrl_qubits=1, label=None, ctrl_state=None)">
|
||
Control this circuit on `num_ctrl_qubits` qubits.
|
||
|
||
**Parameters**
|
||
|
||
* **num\_ctrl\_qubits** (*int*) – The number of control qubits.
|
||
* **label** (*str*) – An optional label to give the controlled operation for visualization.
|
||
* **ctrl\_state** (*str or int*) – The control state in decimal or as a bitstring (e.g. ‘111’). If None, use `2**num_ctrl_qubits - 1`.
|
||
|
||
**Returns**
|
||
|
||
The controlled version of this circuit.
|
||
|
||
**Return type**
|
||
|
||
[QuantumCircuit](qiskit.circuit.QuantumCircuit "qiskit.circuit.QuantumCircuit")
|
||
|
||
**Raises**
|
||
|
||
**CircuitError** – If the circuit contains a non-unitary operation and cannot be controlled.
|
||
</Function>
|
||
|
||
### copy
|
||
|
||
<Function id="qiskit.circuit.library.GroverOperator.copy" signature="copy(name=None)">
|
||
Copy the circuit.
|
||
|
||
**Parameters**
|
||
|
||
**name** (*str*) – name to be given to the copied circuit. If None, then the name stays the same
|
||
|
||
**Returns**
|
||
|
||
a deepcopy of the current circuit, with the specified name
|
||
|
||
**Return type**
|
||
|
||
[QuantumCircuit](qiskit.circuit.QuantumCircuit "qiskit.circuit.QuantumCircuit")
|
||
</Function>
|
||
|
||
### count\_ops
|
||
|
||
<Function id="qiskit.circuit.library.GroverOperator.count_ops" signature="count_ops()">
|
||
Count each operation kind in the circuit.
|
||
|
||
**Returns**
|
||
|
||
a breakdown of how many operations of each kind, sorted by amount.
|
||
|
||
**Return type**
|
||
|
||
OrderedDict
|
||
</Function>
|
||
|
||
### cp
|
||
|
||
<Function id="qiskit.circuit.library.GroverOperator.cp" signature="cp(theta, control_qubit, target_qubit, label=None, ctrl_state=None)">
|
||
Apply [`CPhaseGate`](qiskit.circuit.library.CPhaseGate "qiskit.circuit.library.CPhaseGate").
|
||
</Function>
|
||
|
||
### crx
|
||
|
||
<Function id="qiskit.circuit.library.GroverOperator.crx" signature="crx(theta, control_qubit, target_qubit, label=None, ctrl_state=None)">
|
||
Apply [`CRXGate`](qiskit.circuit.library.CRXGate "qiskit.circuit.library.CRXGate").
|
||
</Function>
|
||
|
||
### cry
|
||
|
||
<Function id="qiskit.circuit.library.GroverOperator.cry" signature="cry(theta, control_qubit, target_qubit, label=None, ctrl_state=None)">
|
||
Apply [`CRYGate`](qiskit.circuit.library.CRYGate "qiskit.circuit.library.CRYGate").
|
||
</Function>
|
||
|
||
### crz
|
||
|
||
<Function id="qiskit.circuit.library.GroverOperator.crz" signature="crz(theta, control_qubit, target_qubit, label=None, ctrl_state=None)">
|
||
Apply [`CRZGate`](qiskit.circuit.library.CRZGate "qiskit.circuit.library.CRZGate").
|
||
</Function>
|
||
|
||
### cswap
|
||
|
||
<Function id="qiskit.circuit.library.GroverOperator.cswap" signature="cswap(control_qubit, target_qubit1, target_qubit2, label=None, ctrl_state=None)">
|
||
Apply [`CSwapGate`](qiskit.circuit.library.CSwapGate "qiskit.circuit.library.CSwapGate").
|
||
</Function>
|
||
|
||
### csx
|
||
|
||
<Function id="qiskit.circuit.library.GroverOperator.csx" signature="csx(control_qubit, target_qubit, label=None, ctrl_state=None)">
|
||
Apply [`CSXGate`](qiskit.circuit.library.CSXGate "qiskit.circuit.library.CSXGate").
|
||
</Function>
|
||
|
||
### cu
|
||
|
||
<Function id="qiskit.circuit.library.GroverOperator.cu" signature="cu(theta, phi, lam, gamma, control_qubit, target_qubit, label=None, ctrl_state=None)">
|
||
Apply [`CUGate`](qiskit.circuit.library.CUGate "qiskit.circuit.library.CUGate").
|
||
</Function>
|
||
|
||
### cu1
|
||
|
||
<Function id="qiskit.circuit.library.GroverOperator.cu1" signature="cu1(theta, control_qubit, target_qubit, label=None, ctrl_state=None)">
|
||
Apply [`CU1Gate`](qiskit.circuit.library.CU1Gate "qiskit.circuit.library.CU1Gate").
|
||
</Function>
|
||
|
||
### cu3
|
||
|
||
<Function id="qiskit.circuit.library.GroverOperator.cu3" signature="cu3(theta, phi, lam, control_qubit, target_qubit, label=None, ctrl_state=None)">
|
||
Apply [`CU3Gate`](qiskit.circuit.library.CU3Gate "qiskit.circuit.library.CU3Gate").
|
||
</Function>
|
||
|
||
### cx
|
||
|
||
<Function id="qiskit.circuit.library.GroverOperator.cx" signature="cx(control_qubit, target_qubit, label=None, ctrl_state=None)">
|
||
Apply [`CXGate`](qiskit.circuit.library.CXGate "qiskit.circuit.library.CXGate").
|
||
</Function>
|
||
|
||
### cy
|
||
|
||
<Function id="qiskit.circuit.library.GroverOperator.cy" signature="cy(control_qubit, target_qubit, label=None, ctrl_state=None)">
|
||
Apply [`CYGate`](qiskit.circuit.library.CYGate "qiskit.circuit.library.CYGate").
|
||
</Function>
|
||
|
||
### cz
|
||
|
||
<Function id="qiskit.circuit.library.GroverOperator.cz" signature="cz(control_qubit, target_qubit, label=None, ctrl_state=None)">
|
||
Apply [`CZGate`](qiskit.circuit.library.CZGate "qiskit.circuit.library.CZGate").
|
||
</Function>
|
||
|
||
### data
|
||
|
||
<Attribute id="qiskit.circuit.library.GroverOperator.data">
|
||
Return the circuit data (instructions and context).
|
||
|
||
**Returns**
|
||
|
||
a list-like object containing the tuples for the circuit’s data.
|
||
|
||
Each tuple is in the format `(instruction, qargs, cargs)`, where instruction is an Instruction (or subclass) object, qargs is a list of Qubit objects, and cargs is a list of Clbit objects.
|
||
|
||
**Return type**
|
||
|
||
QuantumCircuitData
|
||
</Attribute>
|
||
|
||
### dcx
|
||
|
||
<Function id="qiskit.circuit.library.GroverOperator.dcx" signature="dcx(qubit1, qubit2)">
|
||
Apply [`DCXGate`](qiskit.circuit.library.DCXGate "qiskit.circuit.library.DCXGate").
|
||
</Function>
|
||
|
||
### decompose
|
||
|
||
<Function id="qiskit.circuit.library.GroverOperator.decompose" signature="decompose()">
|
||
Call a decomposition pass on this circuit, to decompose one level (shallow decompose).
|
||
|
||
**Returns**
|
||
|
||
a circuit one level decomposed
|
||
|
||
**Return type**
|
||
|
||
[QuantumCircuit](qiskit.circuit.QuantumCircuit "qiskit.circuit.QuantumCircuit")
|
||
</Function>
|
||
|
||
### delay
|
||
|
||
<Function id="qiskit.circuit.library.GroverOperator.delay" signature="delay(duration, qarg=None, unit='dt')">
|
||
Apply [`Delay`](qiskit.circuit.Delay "qiskit.circuit.Delay"). If qarg is None, applies to all qubits. When applying to multiple qubits, delays with the same duration will be created.
|
||
|
||
**Parameters**
|
||
|
||
* **duration** (*int or float*) – duration of the delay.
|
||
* **qarg** (*Object*) – qubit argument to apply this delay.
|
||
* **unit** (*str*) – unit of the duration. Supported units: ‘s’, ‘ms’, ‘us’, ‘ns’, ‘ps’, ‘dt’. Default is `dt`, i.e. integer time unit depending on the target backend.
|
||
|
||
**Returns**
|
||
|
||
the attached delay instruction.
|
||
|
||
**Return type**
|
||
|
||
qiskit.Instruction
|
||
|
||
**Raises**
|
||
|
||
**CircuitError** – if arguments have bad format.
|
||
</Function>
|
||
|
||
### depth
|
||
|
||
<Function id="qiskit.circuit.library.GroverOperator.depth" signature="depth()">
|
||
Return circuit depth (i.e., length of critical path). This does not include compiler or simulator directives such as ‘barrier’ or ‘snapshot’.
|
||
|
||
**Returns**
|
||
|
||
Depth of circuit.
|
||
|
||
**Return type**
|
||
|
||
int
|
||
|
||
**Notes**
|
||
|
||
The circuit depth and the DAG depth need not be the same.
|
||
</Function>
|
||
|
||
### diagonal
|
||
|
||
<Function id="qiskit.circuit.library.GroverOperator.diagonal" signature="diagonal(diag, qubit)">
|
||
Attach a diagonal gate to a circuit.
|
||
|
||
The decomposition is based on Theorem 7 given in “Synthesis of Quantum Logic Circuits” by Shende et al. ([https://arxiv.org/pdf/quant-ph/0406176.pdf](https://arxiv.org/pdf/quant-ph/0406176.pdf)).
|
||
|
||
**Parameters**
|
||
|
||
* **diag** (*list*) – list of the 2^k diagonal entries (for a diagonal gate on k qubits). Must contain at least two entries
|
||
* **qubit** (*QuantumRegister|list*) – list of k qubits the diagonal is acting on (the order of the qubits specifies the computational basis in which the diagonal gate is provided: the first element in diag acts on the state where all the qubits in q are in the state 0, the second entry acts on the state where all the qubits q\[1],…,q\[k-1] are in the state zero and q\[0] is in the state 1, and so on)
|
||
|
||
**Returns**
|
||
|
||
the diagonal gate which was attached to the circuit.
|
||
|
||
**Return type**
|
||
|
||
[QuantumCircuit](qiskit.circuit.QuantumCircuit "qiskit.circuit.QuantumCircuit")
|
||
|
||
**Raises**
|
||
|
||
**QiskitError** – if the list of the diagonal entries or the qubit list is in bad format; if the number of diagonal entries is not 2^k, where k denotes the number of qubits
|
||
</Function>
|
||
|
||
### draw
|
||
|
||
<Function id="qiskit.circuit.library.GroverOperator.draw" signature="draw(output=None, scale=None, filename=None, style=None, interactive=False, plot_barriers=True, reverse_bits=False, justify=None, vertical_compression='medium', idle_wires=True, with_layout=True, fold=None, ax=None, initial_state=False, cregbundle=True)">
|
||
Draw the quantum circuit. Use the output parameter to choose the drawing format:
|
||
|
||
**text**: ASCII art TextDrawing that can be printed in the console.
|
||
|
||
**matplotlib**: images with color rendered purely in Python.
|
||
|
||
**latex**: high-quality images compiled via latex.
|
||
|
||
**latex\_source**: raw uncompiled latex output.
|
||
|
||
**Parameters**
|
||
|
||
* **output** (*str*) – select the output method to use for drawing the circuit. Valid choices are `text`, `mpl`, `latex`, `latex_source`. By default the text drawer is used unless the user config file (usually `~/.qiskit/settings.conf`) has an alternative backend set as the default. For example, `circuit_drawer = latex`. If the output kwarg is set, that backend will always be used over the default in the user config file.
|
||
* **scale** (*float*) – scale of image to draw (shrink if \< 1.0). Only used by the mpl, latex and latex\_source outputs. Defaults to 1.0.
|
||
* **filename** (*str*) – file path to save image to. Defaults to None.
|
||
* **style** (*dict or str*) – dictionary of style or file name of style json file. This option is only used by the mpl output type. If style is a str, it is used as the path to a json file which contains a style dict. The file will be opened, parsed, and then any style elements in the dict will replace the default values in the input dict. A file to be loaded must end in `.json`, but the name entered here can omit `.json`. For example, `style='iqx.json'` or `style='iqx'`. If style is a dict and the `'name'` key is set, that name will be used to load a json file, followed by loading the other items in the style dict. For example, `style={'name': 'iqx'}`. If style is not a str and name is not a key in the style dict, then the default value from the user config file (usually `~/.qiskit/settings.conf`) will be used, for example, `circuit_mpl_style = iqx`. If none of these are set, the default style will be used. The search path for style json files can be specified in the user config, for example, `circuit_mpl_style_path = /home/user/styles:/home/user`. See: [`DefaultStyle`](qiskit.visualization.qcstyle.DefaultStyle "qiskit.visualization.qcstyle.DefaultStyle") for more information on the contents.
|
||
* **interactive** (*bool*) – when set to true, show the circuit in a new window (for mpl this depends on the matplotlib backend being used supporting this). Note when used with either the text or the latex\_source output type this has no effect and will be silently ignored. Defaults to False.
|
||
* **reverse\_bits** (*bool*) – when set to True, reverse the bit order inside registers for the output visualization. Defaults to False.
|
||
* **plot\_barriers** (*bool*) – enable/disable drawing barriers in the output circuit. Defaults to True.
|
||
* **justify** (*string*) – options are `left`, `right` or `none`. If anything else is supplied, it defaults to left justified. It refers to where gates should be placed in the output circuit if there is an option. `none` results in each gate being placed in its own column.
|
||
* **vertical\_compression** (*string*) – `high`, `medium` or `low`. It merges the lines generated by the text output so the drawing will take less vertical room. Default is `medium`. Only used by the text output, will be silently ignored otherwise.
|
||
* **idle\_wires** (*bool*) – include idle wires (wires with no circuit elements) in output visualization. Default is True.
|
||
* **with\_layout** (*bool*) – include layout information, with labels on the physical layout. Default is True.
|
||
* **fold** (*int*) – sets pagination. It can be disabled using -1. In text, sets the length of the lines. This is useful when the drawing does not fit in the console. If None (default), it will try to guess the console width using `shutil.get_terminal_size()`. However, if running in jupyter, the default line length is set to 80 characters. In mpl, it is the number of (visual) layers before folding. Default is 25.
|
||
* **ax** (*matplotlib.axes.Axes*) – Only used by the mpl backend. An optional Axes object to be used for the visualization output. If none is specified, a new matplotlib Figure will be created and used. Additionally, if specified there will be no returned Figure since it is redundant.
|
||
* **initial\_state** (*bool*) – optional. Adds `|0>` in the beginning of the wire. Default is False.
|
||
* **cregbundle** (*bool*) – optional. If set True, bundle classical registers. Default is True.
|
||
|
||
**Returns**
|
||
|
||
`TextDrawing` or `matplotlib.figure` or `PIL.Image` or `str`:
|
||
|
||
* **TextDrawing (output=’text’)**
|
||
|
||
A drawing that can be printed as ascii art.
|
||
|
||
* **matplotlib.figure.Figure (output=’mpl’)**
|
||
|
||
A matplotlib figure object for the circuit diagram.
|
||
|
||
* **PIL.Image (output=’latex’)**
|
||
|
||
An in-memory representation of the image of the circuit diagram.
|
||
|
||
* **str (output=’latex\_source’)**
|
||
|
||
The LaTeX source code for visualizing the circuit diagram.
|
||
|
||
**Raises**
|
||
|
||
* [**VisualizationError**](qiskit.visualization.VisualizationError "qiskit.visualization.VisualizationError") – when an invalid output method is selected
|
||
* **ImportError** – when the output methods requires non-installed libraries.
|
||
|
||
**Example**
|
||
|
||
```python
|
||
from qiskit import QuantumRegister, ClassicalRegister, QuantumCircuit
|
||
from qiskit.tools.visualization import circuit_drawer
|
||
q = QuantumRegister(1)
|
||
c = ClassicalRegister(1)
|
||
qc = QuantumCircuit(q, c)
|
||
qc.h(q)
|
||
qc.measure(q, c)
|
||
qc.draw(output='mpl', style={'backgroundcolor': '#EEEEEE'})
|
||
```
|
||
|
||
![../\_images/qiskit.circuit.library.GroverOperator\_2\_0.png](/images/api/qiskit/0.26/qiskit.circuit.library.GroverOperator_2_0.png)
|
||
</Function>
|
||
|
||
### ecr
|
||
|
||
<Function id="qiskit.circuit.library.GroverOperator.ecr" signature="ecr(qubit1, qubit2)">
|
||
Apply [`ECRGate`](qiskit.circuit.library.ECRGate "qiskit.circuit.library.ECRGate").
|
||
</Function>
|
||
|
||
### extend
|
||
|
||
<Function id="qiskit.circuit.library.GroverOperator.extend" signature="extend(rhs)">
|
||
DEPRECATED - Append QuantumCircuit to the RHS if it contains compatible registers.
|
||
|
||
Two circuits are compatible if they contain the same registers or if they contain different registers with unique names. The returned circuit will contain all unique registers between both circuits.
|
||
|
||
Modify and return self.
|
||
|
||
**Parameters**
|
||
|
||
**rhs** ([*QuantumCircuit*](qiskit.circuit.QuantumCircuit "qiskit.circuit.QuantumCircuit")) – The quantum circuit to append to the right hand side.
|
||
|
||
**Returns**
|
||
|
||
Returns this QuantumCircuit object (which has been modified)
|
||
|
||
**Return type**
|
||
|
||
[QuantumCircuit](qiskit.circuit.QuantumCircuit "qiskit.circuit.QuantumCircuit")
|
||
|
||
**Raises**
|
||
|
||
**QiskitError** – if the rhs circuit is not compatible
|
||
</Function>
|
||
|
||
### fredkin
|
||
|
||
<Function id="qiskit.circuit.library.GroverOperator.fredkin" signature="fredkin(control_qubit, target_qubit1, target_qubit2)">
|
||
Apply [`CSwapGate`](qiskit.circuit.library.CSwapGate "qiskit.circuit.library.CSwapGate").
|
||
</Function>
|
||
|
||
### from\_qasm\_file
|
||
|
||
<Function id="qiskit.circuit.library.GroverOperator.from_qasm_file" signature="from_qasm_file(path)" modifiers="static">
|
||
Take in a QASM file and generate a QuantumCircuit object.
|
||
|
||
**Parameters**
|
||
|
||
**path** (*str*) – Path to the file for a QASM program
|
||
|
||
**Returns**
|
||
|
||
The QuantumCircuit object for the input QASM
|
||
|
||
**Return type**
|
||
|
||
[QuantumCircuit](qiskit.circuit.QuantumCircuit "qiskit.circuit.QuantumCircuit")
|
||
</Function>
|
||
|
||
### from\_qasm\_str
|
||
|
||
<Function id="qiskit.circuit.library.GroverOperator.from_qasm_str" signature="from_qasm_str(qasm_str)" modifiers="static">
|
||
Take in a QASM string and generate a QuantumCircuit object.
|
||
|
||
**Parameters**
|
||
|
||
**qasm\_str** (*str*) – A QASM program string
|
||
|
||
**Returns**
|
||
|
||
The QuantumCircuit object for the input QASM
|
||
|
||
**Return type**
|
||
|
||
[QuantumCircuit](qiskit.circuit.QuantumCircuit "qiskit.circuit.QuantumCircuit")
|
||
</Function>
|
||
|
||
### global\_phase
|
||
|
||
<Attribute id="qiskit.circuit.library.GroverOperator.global_phase">
|
||
Return the global phase of the circuit in radians.
|
||
</Attribute>
|
||
|
||
### h
|
||
|
||
<Function id="qiskit.circuit.library.GroverOperator.h" signature="h(qubit)">
|
||
Apply [`HGate`](qiskit.circuit.library.HGate "qiskit.circuit.library.HGate").
|
||
</Function>
|
||
|
||
### hamiltonian
|
||
|
||
<Function id="qiskit.circuit.library.GroverOperator.hamiltonian" signature="hamiltonian(operator, time, qubits, label=None)">
|
||
Apply hamiltonian evolution to qubits.
|
||
</Function>
|
||
|
||
### has\_register
|
||
|
||
<Function id="qiskit.circuit.library.GroverOperator.has_register" signature="has_register(register)">
|
||
Test if this circuit has the register r.
|
||
|
||
**Parameters**
|
||
|
||
**register** (*Register*) – a quantum or classical register.
|
||
|
||
**Returns**
|
||
|
||
True if the register is contained in this circuit.
|
||
|
||
**Return type**
|
||
|
||
bool
|
||
</Function>
|
||
|
||
### i
|
||
|
||
<Function id="qiskit.circuit.library.GroverOperator.i" signature="i(qubit)">
|
||
Apply [`IGate`](qiskit.circuit.library.IGate "qiskit.circuit.library.IGate").
|
||
</Function>
|
||
|
||
### id
|
||
|
||
<Function id="qiskit.circuit.library.GroverOperator.id" signature="id(qubit)">
|
||
Apply [`IGate`](qiskit.circuit.library.IGate "qiskit.circuit.library.IGate").
|
||
</Function>
|
||
|
||
### initialize
|
||
|
||
<Function id="qiskit.circuit.library.GroverOperator.initialize" signature="initialize(params, qubits=None)">
|
||
Initialize qubits in a specific state.
|
||
|
||
Qubit initialization is done by first resetting the qubits to $|0\rangle$ followed by an state preparing unitary. Both these steps are included in the Initialize instruction.
|
||
|
||
**Parameters**
|
||
|
||
* **params** (*str or list or int*) –
|
||
|
||
* **str: labels of basis states of the Pauli eigenstates Z, X, Y. See**
|
||
|
||
`from_label()`. Notice the order of the labels is reversed with respect to the qubit index to be applied to. Example label ‘01’ initializes the qubit zero to |1> and the qubit one to |0>.
|
||
|
||
* list: vector of complex amplitudes to initialize to.
|
||
|
||
* **int: an integer that is used as a bitmap indicating which qubits to initialize**
|
||
|
||
to |1>. Example: setting params to 5 would initialize qubit 0 and qubit 2 to |1> and qubit 1 to |0>.
|
||
|
||
* **qubits** ([*QuantumRegister*](qiskit.circuit.QuantumRegister "qiskit.circuit.QuantumRegister") *or int*) –
|
||
|
||
* QuantumRegister: A list of qubits to be initialized \[Default: None].
|
||
* int: Index of qubit to initialized \[Default: None].
|
||
|
||
**Returns**
|
||
|
||
a handle to the instruction that was just initialized
|
||
|
||
**Return type**
|
||
|
||
[qiskit.circuit.Instruction](qiskit.circuit.Instruction "qiskit.circuit.Instruction")
|
||
|
||
**Examples**
|
||
|
||
Prepare a qubit in the state $(|0\rangle - |1\rangle) / \sqrt{2}$.
|
||
|
||
```python
|
||
import numpy as np
|
||
from qiskit import QuantumCircuit
|
||
|
||
circuit = QuantumCircuit(1)
|
||
circuit.initialize([1/np.sqrt(2), -1/np.sqrt(2)], 0)
|
||
circuit.draw()
|
||
```
|
||
|
||
```python
|
||
┌──────────────────────────────┐
|
||
q_0: ┤ initialize(0.70711,-0.70711) ├
|
||
└──────────────────────────────┘
|
||
```
|
||
|
||
**output:**
|
||
|
||
┌──────────────────────────────┐
|
||
|
||
**q\_0: ┤ initialize(0.70711,-0.70711) ├**
|
||
|
||
└──────────────────────────────┘
|
||
|
||
Initialize from a string two qubits in the state |10>. The order of the labels is reversed with respect to qubit index. More information about labels for basis states are in `from_label()`.
|
||
|
||
```python
|
||
import numpy as np
|
||
from qiskit import QuantumCircuit
|
||
|
||
circuit = QuantumCircuit(2)
|
||
circuit.initialize('01', circuit.qubits)
|
||
circuit.draw()
|
||
```
|
||
|
||
```python
|
||
┌──────────────────┐
|
||
q_0: ┤0 ├
|
||
│ initialize(0,1) │
|
||
q_1: ┤1 ├
|
||
└──────────────────┘
|
||
```
|
||
|
||
**output:**
|
||
|
||
┌──────────────────┐
|
||
|
||
**q\_0: ┤0 ├**
|
||
|
||
│ initialize(0,1) │
|
||
|
||
**q\_1: ┤1 ├**
|
||
|
||
└──────────────────┘
|
||
|
||
Initialize two qubits from an array of complex amplitudes .. jupyter-execute:
|
||
|
||
```python
|
||
import numpy as np
|
||
from qiskit import QuantumCircuit
|
||
|
||
circuit = QuantumCircuit(2)
|
||
circuit.initialize([0, 1/np.sqrt(2), -1.j/np.sqrt(2), 0], circuit.qubits)
|
||
circuit.draw()
|
||
```
|
||
|
||
**output:**
|
||
|
||
┌────────────────────────────────────┐
|
||
|
||
**q\_0: ┤0 ├**
|
||
|
||
│ initialize(0,0.70711,-0.70711j,0) │
|
||
|
||
**q\_1: ┤1 ├**
|
||
|
||
└────────────────────────────────────┘
|
||
</Function>
|
||
|
||
### inverse
|
||
|
||
<Function id="qiskit.circuit.library.GroverOperator.inverse" signature="inverse()">
|
||
Invert (take adjoint of) this circuit.
|
||
|
||
This is done by recursively inverting all gates.
|
||
|
||
**Returns**
|
||
|
||
the inverted circuit
|
||
|
||
**Return type**
|
||
|
||
[QuantumCircuit](qiskit.circuit.QuantumCircuit "qiskit.circuit.QuantumCircuit")
|
||
|
||
**Raises**
|
||
|
||
**CircuitError** – if the circuit cannot be inverted.
|
||
|
||
**Examples**
|
||
|
||
**input:**
|
||
|
||
┌───┐
|
||
|
||
**q\_0: ┤ H ├─────■──────**
|
||
|
||
└───┘┌────┴─────┐
|
||
|
||
**q\_1: ─────┤ RX(1.57) ├**
|
||
|
||
└──────────┘
|
||
|
||
**output:**
|
||
|
||
┌───┐
|
||
|
||
**q\_0: ──────■──────┤ H ├**
|
||
|
||
┌─────┴─────┐└───┘
|
||
|
||
**q\_1: ┤ RX(-1.57) ├─────**
|
||
|
||
└───────────┘
|
||
</Function>
|
||
|
||
### iso
|
||
|
||
<Function id="qiskit.circuit.library.GroverOperator.iso" signature="iso(isometry, q_input, q_ancillas_for_output, q_ancillas_zero=None, q_ancillas_dirty=None)">
|
||
Attach an arbitrary isometry from m to n qubits to a circuit. In particular, this allows to attach arbitrary unitaries on n qubits (m=n) or to prepare any state on n qubits (m=0). The decomposition used here was introduced by Iten et al. in [https://arxiv.org/abs/1501.06911](https://arxiv.org/abs/1501.06911).
|
||
|
||
**Parameters**
|
||
|
||
* **isometry** (*ndarray*) – an isometry from m to n qubits, i.e., a (complex) ndarray of dimension 2^n×2^m with orthonormal columns (given in the computational basis specified by the order of the ancillas and the input qubits, where the ancillas are considered to be more significant than the input qubits.).
|
||
* **q\_input** (*QuantumRegister|list\[*[*Qubit*](qiskit.circuit.Qubit "qiskit.circuit.Qubit")*]*) – list of m qubits where the input to the isometry is fed in (empty list for state preparation).
|
||
* **q\_ancillas\_for\_output** (*QuantumRegister|list\[*[*Qubit*](qiskit.circuit.Qubit "qiskit.circuit.Qubit")*]*) – list of n-m ancilla qubits that are used for the output of the isometry and which are assumed to start in the zero state. The qubits are listed with increasing significance.
|
||
* **q\_ancillas\_zero** (*QuantumRegister|list\[*[*Qubit*](qiskit.circuit.Qubit "qiskit.circuit.Qubit")*]*) – list of ancilla qubits which are assumed to start in the zero state. Default is q\_ancillas\_zero = None.
|
||
* **q\_ancillas\_dirty** (*QuantumRegister|list\[*[*Qubit*](qiskit.circuit.Qubit "qiskit.circuit.Qubit")*]*) – list of ancilla qubits which can start in an arbitrary state. Default is q\_ancillas\_dirty = None.
|
||
|
||
**Returns**
|
||
|
||
the isometry is attached to the quantum circuit.
|
||
|
||
**Return type**
|
||
|
||
[QuantumCircuit](qiskit.circuit.QuantumCircuit "qiskit.circuit.QuantumCircuit")
|
||
|
||
**Raises**
|
||
|
||
**QiskitError** – if the array is not an isometry of the correct size corresponding to the provided number of qubits.
|
||
</Function>
|
||
|
||
### isometry
|
||
|
||
<Function id="qiskit.circuit.library.GroverOperator.isometry" signature="isometry(isometry, q_input, q_ancillas_for_output, q_ancillas_zero=None, q_ancillas_dirty=None)">
|
||
Attach an arbitrary isometry from m to n qubits to a circuit. In particular, this allows to attach arbitrary unitaries on n qubits (m=n) or to prepare any state on n qubits (m=0). The decomposition used here was introduced by Iten et al. in [https://arxiv.org/abs/1501.06911](https://arxiv.org/abs/1501.06911).
|
||
|
||
**Parameters**
|
||
|
||
* **isometry** (*ndarray*) – an isometry from m to n qubits, i.e., a (complex) ndarray of dimension 2^n×2^m with orthonormal columns (given in the computational basis specified by the order of the ancillas and the input qubits, where the ancillas are considered to be more significant than the input qubits.).
|
||
* **q\_input** (*QuantumRegister|list\[*[*Qubit*](qiskit.circuit.Qubit "qiskit.circuit.Qubit")*]*) – list of m qubits where the input to the isometry is fed in (empty list for state preparation).
|
||
* **q\_ancillas\_for\_output** (*QuantumRegister|list\[*[*Qubit*](qiskit.circuit.Qubit "qiskit.circuit.Qubit")*]*) – list of n-m ancilla qubits that are used for the output of the isometry and which are assumed to start in the zero state. The qubits are listed with increasing significance.
|
||
* **q\_ancillas\_zero** (*QuantumRegister|list\[*[*Qubit*](qiskit.circuit.Qubit "qiskit.circuit.Qubit")*]*) – list of ancilla qubits which are assumed to start in the zero state. Default is q\_ancillas\_zero = None.
|
||
* **q\_ancillas\_dirty** (*QuantumRegister|list\[*[*Qubit*](qiskit.circuit.Qubit "qiskit.circuit.Qubit")*]*) – list of ancilla qubits which can start in an arbitrary state. Default is q\_ancillas\_dirty = None.
|
||
|
||
**Returns**
|
||
|
||
the isometry is attached to the quantum circuit.
|
||
|
||
**Return type**
|
||
|
||
[QuantumCircuit](qiskit.circuit.QuantumCircuit "qiskit.circuit.QuantumCircuit")
|
||
|
||
**Raises**
|
||
|
||
**QiskitError** – if the array is not an isometry of the correct size corresponding to the provided number of qubits.
|
||
</Function>
|
||
|
||
### iswap
|
||
|
||
<Function id="qiskit.circuit.library.GroverOperator.iswap" signature="iswap(qubit1, qubit2)">
|
||
Apply [`iSwapGate`](qiskit.circuit.library.iSwapGate "qiskit.circuit.library.iSwapGate").
|
||
</Function>
|
||
|
||
### mcp
|
||
|
||
<Function id="qiskit.circuit.library.GroverOperator.mcp" signature="mcp(lam, control_qubits, target_qubit)">
|
||
Apply [`MCPhaseGate`](qiskit.circuit.library.MCPhaseGate "qiskit.circuit.library.MCPhaseGate").
|
||
</Function>
|
||
|
||
### mcrx
|
||
|
||
<Function id="qiskit.circuit.library.GroverOperator.mcrx" signature="mcrx(theta, q_controls, q_target, use_basis_gates=False)">
|
||
Apply Multiple-Controlled X rotation gate
|
||
|
||
**Parameters**
|
||
|
||
* **self** ([*QuantumCircuit*](qiskit.circuit.QuantumCircuit "qiskit.circuit.QuantumCircuit")) – The QuantumCircuit object to apply the mcrx gate on.
|
||
* **theta** (*float*) – angle theta
|
||
* **q\_controls** (*list(*[*Qubit*](qiskit.circuit.Qubit "qiskit.circuit.Qubit")*)*) – The list of control qubits
|
||
* **q\_target** ([*Qubit*](qiskit.circuit.Qubit "qiskit.circuit.Qubit")) – The target qubit
|
||
* **use\_basis\_gates** (*bool*) – use p, u, cx
|
||
|
||
**Raises**
|
||
|
||
**QiskitError** – parameter errors
|
||
</Function>
|
||
|
||
### mcry
|
||
|
||
<Function id="qiskit.circuit.library.GroverOperator.mcry" signature="mcry(theta, q_controls, q_target, q_ancillae=None, mode=None, use_basis_gates=False)">
|
||
Apply Multiple-Controlled Y rotation gate
|
||
|
||
**Parameters**
|
||
|
||
* **self** ([*QuantumCircuit*](qiskit.circuit.QuantumCircuit "qiskit.circuit.QuantumCircuit")) – The QuantumCircuit object to apply the mcry gate on.
|
||
* **theta** (*float*) – angle theta
|
||
* **q\_controls** (*list(*[*Qubit*](qiskit.circuit.Qubit "qiskit.circuit.Qubit")*)*) – The list of control qubits
|
||
* **q\_target** ([*Qubit*](qiskit.circuit.Qubit "qiskit.circuit.Qubit")) – The target qubit
|
||
* **q\_ancillae** ([*QuantumRegister*](qiskit.circuit.QuantumRegister "qiskit.circuit.QuantumRegister") *or tuple(*[*QuantumRegister*](qiskit.circuit.QuantumRegister "qiskit.circuit.QuantumRegister")*, int)*) – The list of ancillary qubits.
|
||
* **mode** (*string*) – The implementation mode to use
|
||
* **use\_basis\_gates** (*bool*) – use p, u, cx
|
||
|
||
**Raises**
|
||
|
||
**QiskitError** – parameter errors
|
||
</Function>
|
||
|
||
### mcrz
|
||
|
||
<Function id="qiskit.circuit.library.GroverOperator.mcrz" signature="mcrz(lam, q_controls, q_target, use_basis_gates=False)">
|
||
Apply Multiple-Controlled Z rotation gate
|
||
|
||
**Parameters**
|
||
|
||
* **self** ([*QuantumCircuit*](qiskit.circuit.QuantumCircuit "qiskit.circuit.QuantumCircuit")) – The QuantumCircuit object to apply the mcrz gate on.
|
||
* **lam** (*float*) – angle lambda
|
||
* **q\_controls** (*list(*[*Qubit*](qiskit.circuit.Qubit "qiskit.circuit.Qubit")*)*) – The list of control qubits
|
||
* **q\_target** ([*Qubit*](qiskit.circuit.Qubit "qiskit.circuit.Qubit")) – The target qubit
|
||
* **use\_basis\_gates** (*bool*) – use p, u, cx
|
||
|
||
**Raises**
|
||
|
||
**QiskitError** – parameter errors
|
||
</Function>
|
||
|
||
### mct
|
||
|
||
<Function id="qiskit.circuit.library.GroverOperator.mct" signature="mct(control_qubits, target_qubit, ancilla_qubits=None, mode='noancilla')">
|
||
Apply [`MCXGate`](qiskit.circuit.library.MCXGate "qiskit.circuit.library.MCXGate").
|
||
</Function>
|
||
|
||
### mcu1
|
||
|
||
<Function id="qiskit.circuit.library.GroverOperator.mcu1" signature="mcu1(lam, control_qubits, target_qubit)">
|
||
Apply `MCU1Gate`.
|
||
</Function>
|
||
|
||
### mcx
|
||
|
||
<Function id="qiskit.circuit.library.GroverOperator.mcx" signature="mcx(control_qubits, target_qubit, ancilla_qubits=None, mode='noancilla')">
|
||
Apply [`MCXGate`](qiskit.circuit.library.MCXGate "qiskit.circuit.library.MCXGate").
|
||
|
||
The multi-cX gate can be implemented using different techniques, which use different numbers of ancilla qubits and have varying circuit depth. These modes are: - ‘noancilla’: Requires 0 ancilla qubits. - ‘recursion’: Requires 1 ancilla qubit if more than 4 controls are used, otherwise 0. - ‘v-chain’: Requires 2 less ancillas than the number of control qubits. - ‘v-chain-dirty’: Same as for the clean ancillas (but the circuit will be longer).
|
||
</Function>
|
||
|
||
### measure
|
||
|
||
<Function id="qiskit.circuit.library.GroverOperator.measure" signature="measure(qubit, cbit)">
|
||
Measure quantum bit into classical bit (tuples).
|
||
|
||
**Parameters**
|
||
|
||
* **qubit** (*QuantumRegister|list|tuple*) – quantum register
|
||
* **cbit** (*ClassicalRegister|list|tuple*) – classical register
|
||
|
||
**Returns**
|
||
|
||
the attached measure instruction.
|
||
|
||
**Return type**
|
||
|
||
qiskit.Instruction
|
||
|
||
**Raises**
|
||
|
||
**CircuitError** – if qubit is not in this circuit or bad format; if cbit is not in this circuit or not creg.
|
||
</Function>
|
||
|
||
### measure\_active
|
||
|
||
<Function id="qiskit.circuit.library.GroverOperator.measure_active" signature="measure_active(inplace=True)">
|
||
Adds measurement to all non-idle qubits. Creates a new ClassicalRegister with a size equal to the number of non-idle qubits being measured.
|
||
|
||
Returns a new circuit with measurements if inplace=False.
|
||
|
||
**Parameters**
|
||
|
||
**inplace** (*bool*) – All measurements inplace or return new circuit.
|
||
|
||
**Returns**
|
||
|
||
Returns circuit with measurements when inplace = False.
|
||
|
||
**Return type**
|
||
|
||
[QuantumCircuit](qiskit.circuit.QuantumCircuit "qiskit.circuit.QuantumCircuit")
|
||
</Function>
|
||
|
||
### measure\_all
|
||
|
||
<Function id="qiskit.circuit.library.GroverOperator.measure_all" signature="measure_all(inplace=True)">
|
||
Adds measurement to all qubits. Creates a new ClassicalRegister with a size equal to the number of qubits being measured.
|
||
|
||
Returns a new circuit with measurements if inplace=False.
|
||
|
||
**Parameters**
|
||
|
||
**inplace** (*bool*) – All measurements inplace or return new circuit.
|
||
|
||
**Returns**
|
||
|
||
Returns circuit with measurements when inplace = False.
|
||
|
||
**Return type**
|
||
|
||
[QuantumCircuit](qiskit.circuit.QuantumCircuit "qiskit.circuit.QuantumCircuit")
|
||
</Function>
|
||
|
||
### metadata
|
||
|
||
<Attribute id="qiskit.circuit.library.GroverOperator.metadata">
|
||
The user provided metadata associated with the circuit
|
||
|
||
The metadata for the circuit is a user provided `dict` of metadata for the circuit. It will not be used to influence the execution or operation of the circuit, but it is expected to be passed between all transforms of the circuit (ie transpilation) and that providers will associate any circuit metadata with the results it returns from execution of that circuit.
|
||
</Attribute>
|
||
|
||
### ms
|
||
|
||
<Function id="qiskit.circuit.library.GroverOperator.ms" signature="ms(theta, qubits)">
|
||
Apply [`MSGate`](qiskit.circuit.library.MSGate "qiskit.circuit.library.MSGate").
|
||
</Function>
|
||
|
||
### num\_ancillas
|
||
|
||
<Attribute id="qiskit.circuit.library.GroverOperator.num_ancillas">
|
||
Return the number of ancilla qubits.
|
||
</Attribute>
|
||
|
||
### num\_clbits
|
||
|
||
<Attribute id="qiskit.circuit.library.GroverOperator.num_clbits">
|
||
Return number of classical bits.
|
||
</Attribute>
|
||
|
||
### num\_connected\_components
|
||
|
||
<Function id="qiskit.circuit.library.GroverOperator.num_connected_components" signature="num_connected_components(unitary_only=False)">
|
||
How many non-entangled subcircuits can the circuit be factored to.
|
||
|
||
**Parameters**
|
||
|
||
**unitary\_only** (*bool*) – Compute only unitary part of graph.
|
||
|
||
**Returns**
|
||
|
||
Number of connected components in circuit.
|
||
|
||
**Return type**
|
||
|
||
int
|
||
</Function>
|
||
|
||
### num\_nonlocal\_gates
|
||
|
||
<Function id="qiskit.circuit.library.GroverOperator.num_nonlocal_gates" signature="num_nonlocal_gates()">
|
||
Return number of non-local gates (i.e. involving 2+ qubits).
|
||
|
||
Conditional nonlocal gates are also included.
|
||
</Function>
|
||
|
||
### num\_parameters
|
||
|
||
<Attribute id="qiskit.circuit.library.GroverOperator.num_parameters">
|
||
Convenience function to get the number of parameter objects in the circuit.
|
||
</Attribute>
|
||
|
||
### num\_qubits
|
||
|
||
<Attribute id="qiskit.circuit.library.GroverOperator.num_qubits">
|
||
Return number of qubits.
|
||
</Attribute>
|
||
|
||
### num\_tensor\_factors
|
||
|
||
<Function id="qiskit.circuit.library.GroverOperator.num_tensor_factors" signature="num_tensor_factors()">
|
||
Computes the number of tensor factors in the unitary (quantum) part of the circuit only.
|
||
|
||
**Notes**
|
||
|
||
This is here for backwards compatibility, and will be removed in a future release of Qiskit. You should call num\_unitary\_factors instead.
|
||
</Function>
|
||
|
||
### num\_unitary\_factors
|
||
|
||
<Function id="qiskit.circuit.library.GroverOperator.num_unitary_factors" signature="num_unitary_factors()">
|
||
Computes the number of tensor factors in the unitary (quantum) part of the circuit only.
|
||
</Function>
|
||
|
||
### oracle
|
||
|
||
<Attribute id="qiskit.circuit.library.GroverOperator.oracle">
|
||
The oracle implementing a reflection about the bad state.
|
||
</Attribute>
|
||
|
||
### p
|
||
|
||
<Function id="qiskit.circuit.library.GroverOperator.p" signature="p(theta, qubit)">
|
||
Apply [`PhaseGate`](qiskit.circuit.library.PhaseGate "qiskit.circuit.library.PhaseGate").
|
||
</Function>
|
||
|
||
### parameters
|
||
|
||
<Attribute id="qiskit.circuit.library.GroverOperator.parameters">
|
||
Convenience function to get the parameters defined in the parameter table.
|
||
</Attribute>
|
||
|
||
### pauli
|
||
|
||
<Function id="qiskit.circuit.library.GroverOperator.pauli" signature="pauli(pauli_string, qubits)">
|
||
Apply `PauliGate`.
|
||
</Function>
|
||
|
||
### power
|
||
|
||
<Function id="qiskit.circuit.library.GroverOperator.power" signature="power(power, matrix_power=False)">
|
||
Raise this circuit to the power of `power`.
|
||
|
||
If `power` is a positive integer and `matrix_power` is `False`, this implementation defaults to calling `repeat`. Otherwise, if the circuit is unitary, the matrix is computed to calculate the matrix power.
|
||
|
||
**Parameters**
|
||
|
||
* **power** (*int*) – The power to raise this circuit to.
|
||
* **matrix\_power** (*bool*) – If True, the circuit is converted to a matrix and then the matrix power is computed. If False, and `power` is a positive integer, the implementation defaults to `repeat`.
|
||
|
||
**Raises**
|
||
|
||
**CircuitError** – If the circuit needs to be converted to a gate but it is not unitary.
|
||
|
||
**Returns**
|
||
|
||
A circuit implementing this circuit raised to the power of `power`.
|
||
|
||
**Return type**
|
||
|
||
[QuantumCircuit](qiskit.circuit.QuantumCircuit "qiskit.circuit.QuantumCircuit")
|
||
</Function>
|
||
|
||
### qasm
|
||
|
||
<Function id="qiskit.circuit.library.GroverOperator.qasm" signature="qasm(formatted=False, filename=None)">
|
||
Return OpenQASM string.
|
||
|
||
**Parameters**
|
||
|
||
* **formatted** (*bool*) – Return formatted Qasm string.
|
||
* **filename** (*str*) – Save Qasm to file with name ‘filename’.
|
||
|
||
**Returns**
|
||
|
||
If formatted=False.
|
||
|
||
**Return type**
|
||
|
||
str
|
||
|
||
**Raises**
|
||
|
||
* **ImportError** – If pygments is not installed and `formatted` is `True`.
|
||
* [**QasmError**](qiskit.qasm.QasmError "qiskit.qasm.QasmError") – If circuit has free parameters.
|
||
</Function>
|
||
|
||
### qbit\_argument\_conversion
|
||
|
||
<Function id="qiskit.circuit.library.GroverOperator.qbit_argument_conversion" signature="qbit_argument_conversion(qubit_representation)">
|
||
Converts several qubit representations (such as indexes, range, etc.) into a list of qubits.
|
||
|
||
**Parameters**
|
||
|
||
**qubit\_representation** (*Object*) – representation to expand
|
||
|
||
**Returns**
|
||
|
||
Where each tuple is a qubit.
|
||
|
||
**Return type**
|
||
|
||
List(tuple)
|
||
</Function>
|
||
|
||
### qubit\_duration
|
||
|
||
<Function id="qiskit.circuit.library.GroverOperator.qubit_duration" signature="qubit_duration(*qubits)">
|
||
Return the duration between the start and stop time of the first and last instructions, excluding delays, over the supplied qubits. Its time unit is `self.unit`.
|
||
|
||
**Parameters**
|
||
|
||
**\*qubits** – Qubits within `self` to include.
|
||
|
||
**Return type**
|
||
|
||
`Union`\[`int`, `float`]
|
||
|
||
**Returns**
|
||
|
||
Return the duration between the first start and last stop time of non-delay instructions
|
||
</Function>
|
||
|
||
### qubit\_start\_time
|
||
|
||
<Function id="qiskit.circuit.library.GroverOperator.qubit_start_time" signature="qubit_start_time(*qubits)">
|
||
Return the start time of the first instruction, excluding delays, over the supplied qubits. Its time unit is `self.unit`.
|
||
|
||
Return 0 if there are no instructions over qubits
|
||
|
||
**Parameters**
|
||
|
||
* **\*qubits** – Qubits within `self` to include. Integers are allowed for qubits, indicating
|
||
* **of self.qubits.** (*indices*) –
|
||
|
||
**Return type**
|
||
|
||
`Union`\[`int`, `float`]
|
||
|
||
**Returns**
|
||
|
||
Return the start time of the first instruction, excluding delays, over the qubits
|
||
|
||
**Raises**
|
||
|
||
**CircuitError** – if `self` is a not-yet scheduled circuit.
|
||
</Function>
|
||
|
||
### qubit\_stop\_time
|
||
|
||
<Function id="qiskit.circuit.library.GroverOperator.qubit_stop_time" signature="qubit_stop_time(*qubits)">
|
||
Return the stop time of the last instruction, excluding delays, over the supplied qubits. Its time unit is `self.unit`.
|
||
|
||
Return 0 if there are no instructions over qubits
|
||
|
||
**Parameters**
|
||
|
||
* **\*qubits** – Qubits within `self` to include. Integers are allowed for qubits, indicating
|
||
* **of self.qubits.** (*indices*) –
|
||
|
||
**Return type**
|
||
|
||
`Union`\[`int`, `float`]
|
||
|
||
**Returns**
|
||
|
||
Return the stop time of the last instruction, excluding delays, over the qubits
|
||
|
||
**Raises**
|
||
|
||
**CircuitError** – if `self` is a not-yet scheduled circuit.
|
||
</Function>
|
||
|
||
### qubits
|
||
|
||
<Attribute id="qiskit.circuit.library.GroverOperator.qubits">
|
||
Returns a list of quantum bits in the order that the registers were added.
|
||
</Attribute>
|
||
|
||
### r
|
||
|
||
<Function id="qiskit.circuit.library.GroverOperator.r" signature="r(theta, phi, qubit)">
|
||
Apply [`RGate`](qiskit.circuit.library.RGate "qiskit.circuit.library.RGate").
|
||
</Function>
|
||
|
||
### rcccx
|
||
|
||
<Function id="qiskit.circuit.library.GroverOperator.rcccx" signature="rcccx(control_qubit1, control_qubit2, control_qubit3, target_qubit)">
|
||
Apply [`RC3XGate`](qiskit.circuit.library.RC3XGate "qiskit.circuit.library.RC3XGate").
|
||
</Function>
|
||
|
||
### rccx
|
||
|
||
<Function id="qiskit.circuit.library.GroverOperator.rccx" signature="rccx(control_qubit1, control_qubit2, target_qubit)">
|
||
Apply [`RCCXGate`](qiskit.circuit.library.RCCXGate "qiskit.circuit.library.RCCXGate").
|
||
</Function>
|
||
|
||
### reflection\_qubits
|
||
|
||
<Attribute id="qiskit.circuit.library.GroverOperator.reflection_qubits">
|
||
Reflection qubits, on which S0 is applied (if S0 is not user-specified).
|
||
</Attribute>
|
||
|
||
### remove\_final\_measurements
|
||
|
||
<Function id="qiskit.circuit.library.GroverOperator.remove_final_measurements" signature="remove_final_measurements(inplace=True)">
|
||
Removes final measurement on all qubits if they are present. Deletes the ClassicalRegister that was used to store the values from these measurements if it is idle.
|
||
|
||
Returns a new circuit without measurements if inplace=False.
|
||
|
||
**Parameters**
|
||
|
||
**inplace** (*bool*) – All measurements removed inplace or return new circuit.
|
||
|
||
**Returns**
|
||
|
||
Returns circuit with measurements removed when inplace = False.
|
||
|
||
**Return type**
|
||
|
||
[QuantumCircuit](qiskit.circuit.QuantumCircuit "qiskit.circuit.QuantumCircuit")
|
||
</Function>
|
||
|
||
### repeat
|
||
|
||
<Function id="qiskit.circuit.library.GroverOperator.repeat" signature="repeat(reps)">
|
||
Repeat this circuit `reps` times.
|
||
|
||
**Parameters**
|
||
|
||
**reps** (*int*) – How often this circuit should be repeated.
|
||
|
||
**Returns**
|
||
|
||
A circuit containing `reps` repetitions of this circuit.
|
||
|
||
**Return type**
|
||
|
||
[QuantumCircuit](qiskit.circuit.QuantumCircuit "qiskit.circuit.QuantumCircuit")
|
||
</Function>
|
||
|
||
### reset
|
||
|
||
<Function id="qiskit.circuit.library.GroverOperator.reset" signature="reset(qubit)">
|
||
Reset q.
|
||
</Function>
|
||
|
||
### reverse\_bits
|
||
|
||
<Function id="qiskit.circuit.library.GroverOperator.reverse_bits" signature="reverse_bits()">
|
||
Return a circuit with the opposite order of wires.
|
||
|
||
The circuit is “vertically” flipped. If a circuit is defined over multiple registers, the resulting circuit will have the same registers but with their order flipped.
|
||
|
||
This method is useful for converting a circuit written in little-endian convention to the big-endian equivalent, and vice versa.
|
||
|
||
**Returns**
|
||
|
||
the circuit with reversed bit order.
|
||
|
||
**Return type**
|
||
|
||
[QuantumCircuit](qiskit.circuit.QuantumCircuit "qiskit.circuit.QuantumCircuit")
|
||
|
||
**Examples**
|
||
|
||
**input:**
|
||
|
||
┌───┐
|
||
|
||
**q\_0: ┤ H ├─────■──────**
|
||
|
||
└───┘┌────┴─────┐
|
||
|
||
**q\_1: ─────┤ RX(1.57) ├**
|
||
|
||
└──────────┘
|
||
|
||
**output:**
|
||
|
||
┌──────────┐
|
||
|
||
**q\_0: ─────┤ RX(1.57) ├**
|
||
|
||
┌───┐└────┬─────┘
|
||
|
||
**q\_1: ┤ H ├─────■──────**
|
||
|
||
└───┘
|
||
</Function>
|
||
|
||
### reverse\_ops
|
||
|
||
<Function id="qiskit.circuit.library.GroverOperator.reverse_ops" signature="reverse_ops()">
|
||
Reverse the circuit by reversing the order of instructions.
|
||
|
||
This is done by recursively reversing all instructions. It does not invert (adjoint) any gate.
|
||
|
||
**Returns**
|
||
|
||
the reversed circuit.
|
||
|
||
**Return type**
|
||
|
||
[QuantumCircuit](qiskit.circuit.QuantumCircuit "qiskit.circuit.QuantumCircuit")
|
||
|
||
**Examples**
|
||
|
||
**input:**
|
||
|
||
┌───┐
|
||
|
||
**q\_0: ┤ H ├─────■──────**
|
||
|
||
└───┘┌────┴─────┐
|
||
|
||
**q\_1: ─────┤ RX(1.57) ├**
|
||
|
||
└──────────┘
|
||
|
||
**output:**
|
||
|
||
┌───┐
|
||
|
||
**q\_0: ─────■──────┤ H ├**
|
||
|
||
┌────┴─────┐└───┘
|
||
|
||
**q\_1: ┤ RX(1.57) ├─────**
|
||
|
||
└──────────┘
|
||
</Function>
|
||
|
||
### rv
|
||
|
||
<Function id="qiskit.circuit.library.GroverOperator.rv" signature="rv(vx, vy, vz, qubit)">
|
||
Apply [`RVGate`](qiskit.circuit.library.RVGate "qiskit.circuit.library.RVGate").
|
||
</Function>
|
||
|
||
### rx
|
||
|
||
<Function id="qiskit.circuit.library.GroverOperator.rx" signature="rx(theta, qubit, label=None)">
|
||
Apply [`RXGate`](qiskit.circuit.library.RXGate "qiskit.circuit.library.RXGate").
|
||
</Function>
|
||
|
||
### rxx
|
||
|
||
<Function id="qiskit.circuit.library.GroverOperator.rxx" signature="rxx(theta, qubit1, qubit2)">
|
||
Apply [`RXXGate`](qiskit.circuit.library.RXXGate "qiskit.circuit.library.RXXGate").
|
||
</Function>
|
||
|
||
### ry
|
||
|
||
<Function id="qiskit.circuit.library.GroverOperator.ry" signature="ry(theta, qubit, label=None)">
|
||
Apply [`RYGate`](qiskit.circuit.library.RYGate "qiskit.circuit.library.RYGate").
|
||
</Function>
|
||
|
||
### ryy
|
||
|
||
<Function id="qiskit.circuit.library.GroverOperator.ryy" signature="ryy(theta, qubit1, qubit2)">
|
||
Apply [`RYYGate`](qiskit.circuit.library.RYYGate "qiskit.circuit.library.RYYGate").
|
||
</Function>
|
||
|
||
### rz
|
||
|
||
<Function id="qiskit.circuit.library.GroverOperator.rz" signature="rz(phi, qubit)">
|
||
Apply [`RZGate`](qiskit.circuit.library.RZGate "qiskit.circuit.library.RZGate").
|
||
</Function>
|
||
|
||
### rzx
|
||
|
||
<Function id="qiskit.circuit.library.GroverOperator.rzx" signature="rzx(theta, qubit1, qubit2)">
|
||
Apply [`RZXGate`](qiskit.circuit.library.RZXGate "qiskit.circuit.library.RZXGate").
|
||
</Function>
|
||
|
||
### rzz
|
||
|
||
<Function id="qiskit.circuit.library.GroverOperator.rzz" signature="rzz(theta, qubit1, qubit2)">
|
||
Apply [`RZZGate`](qiskit.circuit.library.RZZGate "qiskit.circuit.library.RZZGate").
|
||
</Function>
|
||
|
||
### s
|
||
|
||
<Function id="qiskit.circuit.library.GroverOperator.s" signature="s(qubit)">
|
||
Apply [`SGate`](qiskit.circuit.library.SGate "qiskit.circuit.library.SGate").
|
||
</Function>
|
||
|
||
### save\_amplitudes
|
||
|
||
<Function id="qiskit.circuit.library.GroverOperator.save_amplitudes" signature="save_amplitudes(params, label='amplitudes', pershot=False, conditional=False)">
|
||
Save complex statevector amplitudes.
|
||
|
||
**Parameters**
|
||
|
||
* **params** (*List\[int] or List\[str]*) – the basis states to return amplitudes for.
|
||
* **label** (*str*) – the key for retrieving saved data from results.
|
||
* **pershot** (*bool*) – if True save a list of amplitudes vectors for each shot of the simulation rather than the a single amplitude vector \[Default: False].
|
||
* **conditional** (*bool*) – if True save the amplitudes vector conditional on the current classical register values \[Default: False].
|
||
|
||
**Returns**
|
||
|
||
with attached instruction.
|
||
|
||
**Return type**
|
||
|
||
[QuantumCircuit](qiskit.circuit.QuantumCircuit "qiskit.circuit.QuantumCircuit")
|
||
|
||
**Raises**
|
||
|
||
**ExtensionError** – if params is invalid for the specified number of qubits.
|
||
</Function>
|
||
|
||
### save\_amplitudes\_squared
|
||
|
||
<Function id="qiskit.circuit.library.GroverOperator.save_amplitudes_squared" signature="save_amplitudes_squared(params, label='amplitudes_squared', unnormalized=False, pershot=False, conditional=False)">
|
||
Save squared statevector amplitudes (probabilities).
|
||
|
||
**Parameters**
|
||
|
||
* **params** (*List\[int] or List\[str]*) – the basis states to return amplitudes for.
|
||
* **label** (*str*) – the key for retrieving saved data from results.
|
||
* **unnormalized** (*bool*) – If True return save the unnormalized accumulated probabilities over all shots \[Default: False].
|
||
* **pershot** (*bool*) – if True save a list of probability vectors for each shot of the simulation rather than the a single amplitude vector \[Default: False].
|
||
* **conditional** (*bool*) – if True save the probability vector conditional on the current classical register values \[Default: False].
|
||
|
||
**Returns**
|
||
|
||
with attached instruction.
|
||
|
||
**Return type**
|
||
|
||
[QuantumCircuit](qiskit.circuit.QuantumCircuit "qiskit.circuit.QuantumCircuit")
|
||
|
||
**Raises**
|
||
|
||
**ExtensionError** – if params is invalid for the specified number of qubits.
|
||
</Function>
|
||
|
||
### save\_density\_matrix
|
||
|
||
<Function id="qiskit.circuit.library.GroverOperator.save_density_matrix" signature="save_density_matrix(qubits=None, label='density_matrix', unnormalized=False, pershot=False, conditional=False)">
|
||
Save the current simulator quantum state as a density matrix.
|
||
|
||
**Parameters**
|
||
|
||
* **qubits** (*list or None*) – the qubits to save reduced density matrix on. If None the full density matrix of qubits will be saved \[Default: None].
|
||
* **label** (*str*) – the key for retrieving saved data from results.
|
||
* **unnormalized** (*bool*) – If True return save the unnormalized accumulated or conditional accumulated density matrix over all shots \[Default: False].
|
||
* **pershot** (*bool*) – if True save a list of density matrices for each shot of the simulation rather than the average over all shots \[Default: False].
|
||
* **conditional** (*bool*) – if True save the average or pershot data conditional on the current classical register values \[Default: False].
|
||
|
||
**Returns**
|
||
|
||
with attached instruction.
|
||
|
||
**Return type**
|
||
|
||
[QuantumCircuit](qiskit.circuit.QuantumCircuit "qiskit.circuit.QuantumCircuit")
|
||
</Function>
|
||
|
||
### save\_expectation\_value
|
||
|
||
<Function id="qiskit.circuit.library.GroverOperator.save_expectation_value" signature="save_expectation_value(operator, qubits, label='expectation_value', unnormalized=False, pershot=False, conditional=False)">
|
||
Save the expectation value of a Hermitian operator.
|
||
|
||
**Parameters**
|
||
|
||
* **operator** ([*Pauli*](qiskit.quantum_info.Pauli "qiskit.quantum_info.Pauli") *or*[*SparsePauliOp*](qiskit.quantum_info.SparsePauliOp "qiskit.quantum_info.SparsePauliOp") *or*[*Operator*](qiskit.quantum_info.Operator "qiskit.quantum_info.Operator")) – a Hermitian operator.
|
||
* **qubits** (*list*) – circuit qubits to apply instruction.
|
||
* **label** (*str*) – the key for retrieving saved data from results.
|
||
* **unnormalized** (*bool*) – If True return save the unnormalized accumulated or conditional accumulated expectation value over all shot \[Default: False].
|
||
* **pershot** (*bool*) – if True save a list of expectation values for each shot of the simulation rather than the average over all shots \[Default: False].
|
||
* **conditional** (*bool*) – if True save the average or pershot data conditional on the current classical register values \[Default: False].
|
||
|
||
**Returns**
|
||
|
||
with attached instruction.
|
||
|
||
**Return type**
|
||
|
||
[QuantumCircuit](qiskit.circuit.QuantumCircuit "qiskit.circuit.QuantumCircuit")
|
||
|
||
**Raises**
|
||
|
||
**ExtensionError** – if the input operator is invalid or not Hermitian.
|
||
|
||
<Admonition title="Note" type="note">
|
||
This method appends a `SaveExpectationValue` instruction to the quantum circuit.
|
||
</Admonition>
|
||
</Function>
|
||
|
||
### save\_expectation\_value\_variance
|
||
|
||
<Function id="qiskit.circuit.library.GroverOperator.save_expectation_value_variance" signature="save_expectation_value_variance(operator, qubits, label='expectation_value_variance', unnormalized=False, pershot=False, conditional=False)">
|
||
Save the expectation value of a Hermitian operator.
|
||
|
||
**Parameters**
|
||
|
||
* **operator** ([*Pauli*](qiskit.quantum_info.Pauli "qiskit.quantum_info.Pauli") *or*[*SparsePauliOp*](qiskit.quantum_info.SparsePauliOp "qiskit.quantum_info.SparsePauliOp") *or*[*Operator*](qiskit.quantum_info.Operator "qiskit.quantum_info.Operator")) – a Hermitian operator.
|
||
* **qubits** (*list*) – circuit qubits to apply instruction.
|
||
* **label** (*str*) – the key for retrieving saved data from results.
|
||
* **unnormalized** (*bool*) – If True return save the unnormalized accumulated or conditional accumulated expectation value and variance over all shot \[Default: False].
|
||
* **pershot** (*bool*) – if True save a list of expectation values and variances for each shot of the simulation rather than the average over all shots \[Default: False].
|
||
* **conditional** (*bool*) – if True save the data conditional on the current classical register values \[Default: False].
|
||
|
||
**Returns**
|
||
|
||
with attached instruction.
|
||
|
||
**Return type**
|
||
|
||
[QuantumCircuit](qiskit.circuit.QuantumCircuit "qiskit.circuit.QuantumCircuit")
|
||
|
||
**Raises**
|
||
|
||
**ExtensionError** – if the input operator is invalid or not Hermitian.
|
||
|
||
<Admonition title="Note" type="note">
|
||
This method appends a `SaveExpectationValueVariance` instruction to the quantum circuit.
|
||
</Admonition>
|
||
</Function>
|
||
|
||
### save\_matrix\_product\_state
|
||
|
||
<Function id="qiskit.circuit.library.GroverOperator.save_matrix_product_state" signature="save_matrix_product_state(label='matrix_product_state', pershot=False, conditional=False)">
|
||
Save the current simulator quantum state as a matrix product state.
|
||
|
||
**Parameters**
|
||
|
||
* **label** (*str*) – the key for retrieving saved data from results.
|
||
* **pershot** (*bool*) – if True save the mps for each shot of the simulation \[Default: False].
|
||
* **conditional** (*bool*) – if True save pershot data conditional on the current classical register values \[Default: False].
|
||
|
||
**Returns**
|
||
|
||
with attached instruction.
|
||
|
||
**Return type**
|
||
|
||
[QuantumCircuit](qiskit.circuit.QuantumCircuit "qiskit.circuit.QuantumCircuit")
|
||
</Function>
|
||
|
||
### save\_probabilities
|
||
|
||
<Function id="qiskit.circuit.library.GroverOperator.save_probabilities" signature="save_probabilities(qubits=None, label='probabilities', unnormalized=False, pershot=False, conditional=False)">
|
||
Save measurement outcome probabilities vector.
|
||
|
||
**Parameters**
|
||
|
||
* **qubits** (*list or None*) – the qubits to apply snapshot to. If None all qubits will be snapshot \[Default: None].
|
||
* **label** (*str*) – the key for retrieving saved data from results.
|
||
* **unnormalized** (*bool*) – If True return save the unnormalized accumulated probabilities over all shots \[Default: False].
|
||
* **pershot** (*bool*) – if True save a list of probabilities for each shot of the simulation rather than the average over all shots \[Default: False].
|
||
* **conditional** (*bool*) – if True save the probabilities data conditional on the current classical register values \[Default: False].
|
||
|
||
**Returns**
|
||
|
||
with attached instruction.
|
||
|
||
**Return type**
|
||
|
||
[QuantumCircuit](qiskit.circuit.QuantumCircuit "qiskit.circuit.QuantumCircuit")
|
||
</Function>
|
||
|
||
### save\_probabilities\_dict
|
||
|
||
<Function id="qiskit.circuit.library.GroverOperator.save_probabilities_dict" signature="save_probabilities_dict(qubits=None, label='probabilities', unnormalized=False, pershot=False, conditional=False)">
|
||
Save measurement outcome probabilities vector.
|
||
|
||
**Parameters**
|
||
|
||
* **qubits** (*list or None*) – the qubits to apply snapshot to. If None all qubits will be snapshot \[Default: None].
|
||
* **label** (*str*) – the key for retrieving saved data from results.
|
||
* **unnormalized** (*bool*) – If True return save the unnormalized accumulated probabilities over all shots \[Default: False].
|
||
* **pershot** (*bool*) – if True save a list of probabilities for each shot of the simulation rather than the average over all shots \[Default: False].
|
||
* **conditional** (*bool*) – if True save the probabilities data conditional on the current classical register values \[Default: False].
|
||
|
||
**Returns**
|
||
|
||
with attached instruction.
|
||
|
||
**Return type**
|
||
|
||
[QuantumCircuit](qiskit.circuit.QuantumCircuit "qiskit.circuit.QuantumCircuit")
|
||
</Function>
|
||
|
||
### save\_stabilizer
|
||
|
||
<Function id="qiskit.circuit.library.GroverOperator.save_stabilizer" signature="save_stabilizer(label='stabilizer', pershot=False, conditional=False)">
|
||
Save the current stabilizer simulator quantum state as a Clifford.
|
||
|
||
**Parameters**
|
||
|
||
* **label** (*str*) – the key for retrieving saved data from results.
|
||
* **pershot** (*bool*) – if True save a list of Cliffords for each shot of the simulation \[Default: False].
|
||
* **conditional** (*bool*) – if True save pershot data conditional on the current classical register values \[Default: False].
|
||
|
||
**Returns**
|
||
|
||
with attached instruction.
|
||
|
||
**Return type**
|
||
|
||
[QuantumCircuit](qiskit.circuit.QuantumCircuit "qiskit.circuit.QuantumCircuit")
|
||
|
||
<Admonition title="Note" type="note">
|
||
This instruction is always defined across all qubits in a circuit.
|
||
</Admonition>
|
||
</Function>
|
||
|
||
### save\_state
|
||
|
||
<Function id="qiskit.circuit.library.GroverOperator.save_state" signature="save_state(label=None, pershot=False, conditional=False)">
|
||
Save the current simulator quantum state.
|
||
|
||
**Parameters**
|
||
|
||
* **label** (*str or None*) – Optional, the key for retrieving saved data from results. If None the key will be the state type of the simulator.
|
||
* **pershot** (*bool*) – if True save a list of statevectors for each shot of the simulation \[Default: False].
|
||
* **conditional** (*bool*) – if True save pershot data conditional on the current classical register values \[Default: False].
|
||
|
||
**Returns**
|
||
|
||
with attached instruction.
|
||
|
||
**Return type**
|
||
|
||
[QuantumCircuit](qiskit.circuit.QuantumCircuit "qiskit.circuit.QuantumCircuit")
|
||
</Function>
|
||
|
||
### save\_statevector
|
||
|
||
<Function id="qiskit.circuit.library.GroverOperator.save_statevector" signature="save_statevector(label='statevector', pershot=False, conditional=False)">
|
||
Save the current simulator quantum state as a statevector.
|
||
|
||
**Parameters**
|
||
|
||
* **pershot** (*bool*) – if True save a list of statevectors for each shot of the simulation \[Default: False].
|
||
* **label** (*str*) – the key for retrieving saved data from results.
|
||
* **conditional** (*bool*) – if True save pershot data conditional on the current classical register values \[Default: False].
|
||
|
||
**Returns**
|
||
|
||
with attached instruction.
|
||
|
||
**Return type**
|
||
|
||
[QuantumCircuit](qiskit.circuit.QuantumCircuit "qiskit.circuit.QuantumCircuit")
|
||
|
||
<Admonition title="Note" type="note">
|
||
This instruction is always defined across all qubits in a circuit.
|
||
</Admonition>
|
||
</Function>
|
||
|
||
### save\_statevector\_dict
|
||
|
||
<Function id="qiskit.circuit.library.GroverOperator.save_statevector_dict" signature="save_statevector_dict(label='statevector', pershot=False, conditional=False)">
|
||
Save the current simulator quantum state as a statevector as a dict.
|
||
|
||
**Parameters**
|
||
|
||
* **label** (*str*) – the key for retrieving saved data from results.
|
||
* **pershot** (*bool*) – if True save a list of statevectors for each shot of the simulation \[Default: False].
|
||
* **conditional** (*bool*) – if True save pershot data conditional on the current classical register values \[Default: False].
|
||
|
||
**Returns**
|
||
|
||
with attached instruction.
|
||
|
||
**Return type**
|
||
|
||
[QuantumCircuit](qiskit.circuit.QuantumCircuit "qiskit.circuit.QuantumCircuit")
|
||
|
||
<Admonition title="Note" type="note">
|
||
This instruction is always defined across all qubits in a circuit.
|
||
</Admonition>
|
||
</Function>
|
||
|
||
### save\_superop
|
||
|
||
<Function id="qiskit.circuit.library.GroverOperator.save_superop" signature="save_superop(label='superop', pershot=False)">
|
||
Save the current state of the superop simulator.
|
||
|
||
**Parameters**
|
||
|
||
* **label** (*str*) – the key for retrieving saved data from results.
|
||
* **pershot** (*bool*) – if True save a list of SuperOp matrices for each shot of the simulation \[Default: False].
|
||
|
||
**Returns**
|
||
|
||
with attached instruction.
|
||
|
||
**Return type**
|
||
|
||
[QuantumCircuit](qiskit.circuit.QuantumCircuit "qiskit.circuit.QuantumCircuit")
|
||
|
||
<Admonition title="Note" type="note">
|
||
This instruction is always defined across all qubits in a circuit.
|
||
</Admonition>
|
||
</Function>
|
||
|
||
### save\_unitary
|
||
|
||
<Function id="qiskit.circuit.library.GroverOperator.save_unitary" signature="save_unitary(label='unitary', pershot=False)">
|
||
Save the current state of the unitary simulator.
|
||
|
||
**Parameters**
|
||
|
||
* **label** (*str*) – the key for retrieving saved data from results.
|
||
* **pershot** (*bool*) – if True save a list of unitaries for each shot of the simulation \[Default: False].
|
||
|
||
**Returns**
|
||
|
||
with attached instruction.
|
||
|
||
**Return type**
|
||
|
||
[QuantumCircuit](qiskit.circuit.QuantumCircuit "qiskit.circuit.QuantumCircuit")
|
||
|
||
<Admonition title="Note" type="note">
|
||
This instruction is always defined across all qubits in a circuit.
|
||
</Admonition>
|
||
</Function>
|
||
|
||
### sdg
|
||
|
||
<Function id="qiskit.circuit.library.GroverOperator.sdg" signature="sdg(qubit)">
|
||
Apply [`SdgGate`](qiskit.circuit.library.SdgGate "qiskit.circuit.library.SdgGate").
|
||
</Function>
|
||
|
||
### set\_density\_matrix
|
||
|
||
<Function id="qiskit.circuit.library.GroverOperator.set_density_matrix" signature="set_density_matrix(state)">
|
||
Set the density matrix state of the simulator.
|
||
|
||
**Parameters**
|
||
|
||
**state** ([*DensityMatrix*](qiskit.quantum_info.DensityMatrix "qiskit.quantum_info.DensityMatrix")) – a density matrix.
|
||
|
||
**Returns**
|
||
|
||
with attached instruction.
|
||
|
||
**Return type**
|
||
|
||
[QuantumCircuit](qiskit.circuit.QuantumCircuit "qiskit.circuit.QuantumCircuit")
|
||
|
||
**Raises**
|
||
|
||
**ExtensionError** – If the density matrix is the incorrect size for the current circuit.
|
||
</Function>
|
||
|
||
### set\_matrix\_product\_state
|
||
|
||
<Function id="qiskit.circuit.library.GroverOperator.set_matrix_product_state" signature="set_matrix_product_state(state)">
|
||
Set the matrix product state of the simulator.
|
||
|
||
**Parameters**
|
||
|
||
**state** (*Tuple\[List\[Tuple\[np.array\[complex\_t]]]], List\[List\[float]]*) – A matrix\_product\_state.
|
||
|
||
**Returns**
|
||
|
||
with attached instruction.
|
||
|
||
**Return type**
|
||
|
||
[QuantumCircuit](qiskit.circuit.QuantumCircuit "qiskit.circuit.QuantumCircuit")
|
||
|
||
**Raises**
|
||
|
||
**ExtensionError** – If the structure of the state is incorrect
|
||
</Function>
|
||
|
||
### set\_stabilizer
|
||
|
||
<Function id="qiskit.circuit.library.GroverOperator.set_stabilizer" signature="set_stabilizer(state)">
|
||
Set the Clifford stabilizer state of the simulator.
|
||
|
||
**Parameters**
|
||
|
||
**state** ([*Clifford*](qiskit.quantum_info.Clifford "qiskit.quantum_info.Clifford")) – A clifford operator.
|
||
|
||
**Returns**
|
||
|
||
with attached instruction.
|
||
|
||
**Return type**
|
||
|
||
[QuantumCircuit](qiskit.circuit.QuantumCircuit "qiskit.circuit.QuantumCircuit")
|
||
|
||
**Raises**
|
||
|
||
**ExtensionError** – If the state is the incorrect size for the current circuit.
|
||
</Function>
|
||
|
||
### set\_statevector
|
||
|
||
<Function id="qiskit.circuit.library.GroverOperator.set_statevector" signature="set_statevector(state)">
|
||
Set the statevector state of the simulator.
|
||
|
||
**Parameters**
|
||
|
||
**state** ([*Statevector*](qiskit.quantum_info.Statevector "qiskit.quantum_info.Statevector")) – A state matrix.
|
||
|
||
**Returns**
|
||
|
||
with attached instruction.
|
||
|
||
**Return type**
|
||
|
||
[QuantumCircuit](qiskit.circuit.QuantumCircuit "qiskit.circuit.QuantumCircuit")
|
||
|
||
**Raises**
|
||
|
||
**ExtensionError** – If the state is the incorrect size for the current circuit.
|
||
</Function>
|
||
|
||
### set\_superop
|
||
|
||
<Function id="qiskit.circuit.library.GroverOperator.set_superop" signature="set_superop(state)">
|
||
Set the superop state of the simulator.
|
||
|
||
**Parameters**
|
||
|
||
**state** (*QuantumChannel*) – A CPTP quantum channel.
|
||
|
||
**Returns**
|
||
|
||
with attached instruction.
|
||
|
||
**Return type**
|
||
|
||
[QuantumCircuit](qiskit.circuit.QuantumCircuit "qiskit.circuit.QuantumCircuit")
|
||
|
||
**Raises**
|
||
|
||
* **ExtensionError** – If the state is the incorrect size for the current circuit.
|
||
* **ExtensionError** – if the input QuantumChannel is not CPTP.
|
||
</Function>
|
||
|
||
### set\_unitary
|
||
|
||
<Function id="qiskit.circuit.library.GroverOperator.set_unitary" signature="set_unitary(state)">
|
||
Set the state state of the simulator.
|
||
|
||
**Parameters**
|
||
|
||
**state** ([*Operator*](qiskit.quantum_info.Operator "qiskit.quantum_info.Operator")) – A state matrix.
|
||
|
||
**Returns**
|
||
|
||
with attached instruction.
|
||
|
||
**Return type**
|
||
|
||
[QuantumCircuit](qiskit.circuit.QuantumCircuit "qiskit.circuit.QuantumCircuit")
|
||
|
||
**Raises**
|
||
|
||
* **ExtensionError** – If the state is the incorrect size for the current circuit.
|
||
* **ExtensionError** – if the input matrix is not unitary.
|
||
</Function>
|
||
|
||
### size
|
||
|
||
<Function id="qiskit.circuit.library.GroverOperator.size" signature="size()">
|
||
Returns total number of gate operations in circuit.
|
||
|
||
**Returns**
|
||
|
||
Total number of gate operations.
|
||
|
||
**Return type**
|
||
|
||
int
|
||
</Function>
|
||
|
||
### snapshot
|
||
|
||
<Function id="qiskit.circuit.library.GroverOperator.snapshot" signature="snapshot(label, snapshot_type='statevector', qubits=None, params=None)">
|
||
Take a statevector snapshot of the internal simulator representation. Works on all qubits, and prevents reordering (like barrier). :param label: a snapshot label to report the result :type label: str :param snapshot\_type: the type of the snapshot. :type snapshot\_type: str :param qubits: the qubits to apply snapshot to \[Default: None]. :type qubits: list or None :param params: the parameters for snapshot\_type \[Default: None]. :type params: list or None
|
||
|
||
**Returns**
|
||
|
||
with attached command
|
||
|
||
**Return type**
|
||
|
||
[QuantumCircuit](qiskit.circuit.QuantumCircuit "qiskit.circuit.QuantumCircuit")
|
||
|
||
**Raises**
|
||
|
||
**ExtensionError** – malformed command
|
||
</Function>
|
||
|
||
### snapshot\_density\_matrix
|
||
|
||
<Function id="qiskit.circuit.library.GroverOperator.snapshot_density_matrix" signature="snapshot_density_matrix(label, qubits=None)">
|
||
Take a density matrix snapshot of simulator state.
|
||
|
||
**Parameters**
|
||
|
||
* **label** (*str*) – a snapshot label to report the result
|
||
* **qubits** (*list or None*) – the qubits to apply snapshot to. If None all qubits will be snapshot \[Default: None].
|
||
|
||
**Returns**
|
||
|
||
with attached instruction.
|
||
|
||
**Return type**
|
||
|
||
[QuantumCircuit](qiskit.circuit.QuantumCircuit "qiskit.circuit.QuantumCircuit")
|
||
|
||
**Raises**
|
||
|
||
**ExtensionError** – if snapshot is invalid.
|
||
|
||
<Admonition title="Note" type="note">
|
||
This method will be deprecated after the qiskit-aer 0.8 release. It has been superseded by the [`qiskit.providers.aer.library.save_density_matrix()`](qiskit.providers.aer.library.save_density_matrix "qiskit.providers.aer.library.save_density_matrix") circuit method.
|
||
</Admonition>
|
||
</Function>
|
||
|
||
### snapshot\_expectation\_value
|
||
|
||
<Function id="qiskit.circuit.library.GroverOperator.snapshot_expectation_value" signature="snapshot_expectation_value(label, op, qubits, single_shot=False, variance=False)">
|
||
Take a snapshot of expectation value \<O> of an Operator.
|
||
|
||
**Parameters**
|
||
|
||
* **label** (*str*) – a snapshot label to report the result
|
||
* **op** ([*Operator*](qiskit.quantum_info.Operator "qiskit.quantum_info.Operator")) – operator to snapshot
|
||
* **qubits** (*list*) – the qubits to snapshot.
|
||
* **single\_shot** (*bool*) – return list for each shot rather than average \[Default: False]
|
||
* **variance** (*bool*) – compute variance of values \[Default: False]
|
||
|
||
**Returns**
|
||
|
||
with attached instruction.
|
||
|
||
**Return type**
|
||
|
||
[QuantumCircuit](qiskit.circuit.QuantumCircuit "qiskit.circuit.QuantumCircuit")
|
||
|
||
**Raises**
|
||
|
||
**ExtensionError** – if snapshot is invalid.
|
||
|
||
<Admonition title="Note" type="note">
|
||
This method will be deprecated after the qiskit-aer 0.8 release. It has been superseded by the [`qiskit.providers.aer.library.save_expectation_value()`](qiskit.providers.aer.library.save_expectation_value "qiskit.providers.aer.library.save_expectation_value") and [`qiskit.providers.aer.library.save_expectation_value_variance()`](qiskit.providers.aer.library.save_expectation_value_variance "qiskit.providers.aer.library.save_expectation_value_variance") circuit methods.
|
||
</Admonition>
|
||
</Function>
|
||
|
||
### snapshot\_probabilities
|
||
|
||
<Function id="qiskit.circuit.library.GroverOperator.snapshot_probabilities" signature="snapshot_probabilities(label, qubits, variance=False)">
|
||
Take a probability snapshot of the simulator state.
|
||
|
||
**Parameters**
|
||
|
||
* **label** (*str*) – a snapshot label to report the result
|
||
* **qubits** (*list*) – the qubits to snapshot.
|
||
* **variance** (*bool*) – compute variance of probabilities \[Default: False]
|
||
|
||
**Returns**
|
||
|
||
with attached instruction.
|
||
|
||
**Return type**
|
||
|
||
[QuantumCircuit](qiskit.circuit.QuantumCircuit "qiskit.circuit.QuantumCircuit")
|
||
|
||
**Raises**
|
||
|
||
**ExtensionError** – if snapshot is invalid.
|
||
|
||
<Admonition title="Note" type="note">
|
||
This method will be deprecated after the qiskit-aer 0.8 release. It has been superseded by the [`qiskit.providers.aer.library.save_probabilities()`](qiskit.providers.aer.library.save_probabilities "qiskit.providers.aer.library.save_probabilities") and [`qiskit.providers.aer.library.save_probabilities_dict()`](qiskit.providers.aer.library.save_probabilities_dict "qiskit.providers.aer.library.save_probabilities_dict") circuit methods.
|
||
</Admonition>
|
||
</Function>
|
||
|
||
### snapshot\_stabilizer
|
||
|
||
<Function id="qiskit.circuit.library.GroverOperator.snapshot_stabilizer" signature="snapshot_stabilizer(label)">
|
||
Take a stabilizer snapshot of the simulator state.
|
||
|
||
**Parameters**
|
||
|
||
**label** (*str*) – a snapshot label to report the result.
|
||
|
||
**Returns**
|
||
|
||
with attached instruction.
|
||
|
||
**Return type**
|
||
|
||
[QuantumCircuit](qiskit.circuit.QuantumCircuit "qiskit.circuit.QuantumCircuit")
|
||
|
||
**Raises**
|
||
|
||
**ExtensionError** – if snapshot is invalid.
|
||
|
||
**Additional Information:**
|
||
|
||
This snapshot is always performed on all qubits in a circuit. The number of qubits parameter specifies the size of the instruction as a barrier and should be set to the number of qubits in the circuit.
|
||
|
||
<Admonition title="Note" type="note">
|
||
This method will be deprecated after the qiskit-aer 0.8 release. It has been superseded by the [`qiskit.providers.aer.library.save_stabilizer()`](qiskit.providers.aer.library.save_stabilizer "qiskit.providers.aer.library.save_stabilizer") circuit method.
|
||
</Admonition>
|
||
</Function>
|
||
|
||
### snapshot\_statevector
|
||
|
||
<Function id="qiskit.circuit.library.GroverOperator.snapshot_statevector" signature="snapshot_statevector(label)">
|
||
Take a statevector snapshot of the simulator state.
|
||
|
||
**Parameters**
|
||
|
||
**label** (*str*) – a snapshot label to report the result.
|
||
|
||
**Returns**
|
||
|
||
with attached instruction.
|
||
|
||
**Return type**
|
||
|
||
[QuantumCircuit](qiskit.circuit.QuantumCircuit "qiskit.circuit.QuantumCircuit")
|
||
|
||
**Raises**
|
||
|
||
**ExtensionError** – if snapshot is invalid.
|
||
|
||
**Additional Information:**
|
||
|
||
This snapshot is always performed on all qubits in a circuit. The number of qubits parameter specifies the size of the instruction as a barrier and should be set to the number of qubits in the circuit.
|
||
|
||
<Admonition title="Note" type="note">
|
||
This method will be deprecated after the qiskit-aer 0.8 release. It has been superseded by the [`qiskit.providers.aer.library.save_statevector()`](qiskit.providers.aer.library.save_statevector "qiskit.providers.aer.library.save_statevector") circuit method.
|
||
</Admonition>
|
||
</Function>
|
||
|
||
### squ
|
||
|
||
<Function id="qiskit.circuit.library.GroverOperator.squ" signature="squ(unitary_matrix, qubit, mode='ZYZ', up_to_diagonal=False, *, u=None)">
|
||
Decompose an arbitrary 2\*2 unitary into three rotation gates.
|
||
|
||
Note that the decomposition is up to a global phase shift. (This is a well known decomposition, which can be found for example in Nielsen and Chuang’s book “Quantum computation and quantum information”.)
|
||
|
||
**Parameters**
|
||
|
||
* **unitary\_matrix** (*ndarray*) – 2\*2 unitary (given as a (complex) ndarray).
|
||
* **qubit** (*QuantumRegister | Qubit*) – The qubit which the gate is acting on.
|
||
* **mode** (*string*) – determines the used decomposition by providing the rotation axes. The allowed modes are: “ZYZ” (default)
|
||
* **up\_to\_diagonal** (*bool*) – if set to True, the single-qubit unitary is decomposed up to a diagonal matrix, i.e. a unitary u’ is implemented such that there exists a 2\*2 diagonal gate d with u = d.dot(u’)
|
||
* **u** (*ndarray*) – Deprecated, use `unitary_matrix` instead.
|
||
|
||
**Returns**
|
||
|
||
The single-qubit unitary instruction attached to the circuit.
|
||
|
||
**Return type**
|
||
|
||
[InstructionSet](qiskit.circuit.InstructionSet "qiskit.circuit.InstructionSet")
|
||
|
||
**Raises**
|
||
|
||
**QiskitError** – if the format is wrong; if the array u is not unitary
|
||
</Function>
|
||
|
||
### state\_preparation
|
||
|
||
<Attribute id="qiskit.circuit.library.GroverOperator.state_preparation">
|
||
The subcircuit implementing the A operator or Hadamards.
|
||
|
||
**Return type**
|
||
|
||
`QuantumCircuit`
|
||
</Attribute>
|
||
|
||
### swap
|
||
|
||
<Function id="qiskit.circuit.library.GroverOperator.swap" signature="swap(qubit1, qubit2)">
|
||
Apply [`SwapGate`](qiskit.circuit.library.SwapGate "qiskit.circuit.library.SwapGate").
|
||
</Function>
|
||
|
||
### sx
|
||
|
||
<Function id="qiskit.circuit.library.GroverOperator.sx" signature="sx(qubit)">
|
||
Apply [`SXGate`](qiskit.circuit.library.SXGate "qiskit.circuit.library.SXGate").
|
||
</Function>
|
||
|
||
### sxdg
|
||
|
||
<Function id="qiskit.circuit.library.GroverOperator.sxdg" signature="sxdg(qubit)">
|
||
Apply [`SXdgGate`](qiskit.circuit.library.SXdgGate "qiskit.circuit.library.SXdgGate").
|
||
</Function>
|
||
|
||
### t
|
||
|
||
<Function id="qiskit.circuit.library.GroverOperator.t" signature="t(qubit)">
|
||
Apply [`TGate`](qiskit.circuit.library.TGate "qiskit.circuit.library.TGate").
|
||
</Function>
|
||
|
||
### tdg
|
||
|
||
<Function id="qiskit.circuit.library.GroverOperator.tdg" signature="tdg(qubit)">
|
||
Apply [`TdgGate`](qiskit.circuit.library.TdgGate "qiskit.circuit.library.TdgGate").
|
||
</Function>
|
||
|
||
### tensor
|
||
|
||
<Function id="qiskit.circuit.library.GroverOperator.tensor" signature="tensor(other, inplace=False)">
|
||
Tensor `self` with `other`.
|
||
|
||
Remember that in the little-endian convention the leftmost operation will be at the bottom of the circuit. See also [the docs](/guides/bit-ordering) for more information.
|
||
|
||
```python
|
||
┌────────┐ ┌─────┐ ┌─────┐
|
||
q_0: ┤ bottom ├ ⊗ q_0: ┤ top ├ = q_0: ─┤ top ├──
|
||
└────────┘ └─────┘ ┌┴─────┴─┐
|
||
q_1: ┤ bottom ├
|
||
└────────┘
|
||
```
|
||
|
||
**Parameters**
|
||
|
||
* **other** ([*QuantumCircuit*](qiskit.circuit.QuantumCircuit "qiskit.circuit.QuantumCircuit")) – The other circuit to tensor this circuit with.
|
||
* **inplace** (*bool*) – If True, modify the object. Otherwise return composed circuit.
|
||
|
||
**Examples**
|
||
|
||
```python
|
||
from qiskit import QuantumCircuit
|
||
top = QuantumCircuit(1)
|
||
top.x(0);
|
||
bottom = QuantumCircuit(2)
|
||
bottom.cry(0.2, 0, 1);
|
||
tensored = bottom.tensor(top)
|
||
print(tensored.draw())
|
||
```
|
||
|
||
```
|
||
┌───┐
|
||
q_0: ───┤ X ├───
|
||
└───┘
|
||
q_1: ─────■─────
|
||
┌────┴────┐
|
||
q_2: ┤ RY(0.2) ├
|
||
└─────────┘
|
||
```
|
||
|
||
**Returns**
|
||
|
||
The tensored circuit (returns None if inplace==True).
|
||
|
||
**Return type**
|
||
|
||
[QuantumCircuit](qiskit.circuit.QuantumCircuit "qiskit.circuit.QuantumCircuit")
|
||
</Function>
|
||
|
||
### to\_gate
|
||
|
||
<Function id="qiskit.circuit.library.GroverOperator.to_gate" signature="to_gate(parameter_map=None, label=None)">
|
||
Create a Gate out of this circuit.
|
||
|
||
**Parameters**
|
||
|
||
* **parameter\_map** (*dict*) – For parameterized circuits, a mapping from parameters in the circuit to parameters to be used in the gate. If None, existing circuit parameters will also parameterize the gate.
|
||
* **label** (*str*) – Optional gate label.
|
||
|
||
**Returns**
|
||
|
||
a composite gate encapsulating this circuit (can be decomposed back)
|
||
|
||
**Return type**
|
||
|
||
[Gate](qiskit.circuit.Gate "qiskit.circuit.Gate")
|
||
</Function>
|
||
|
||
### to\_instruction
|
||
|
||
<Function id="qiskit.circuit.library.GroverOperator.to_instruction" signature="to_instruction(parameter_map=None)">
|
||
Create an Instruction out of this circuit.
|
||
|
||
**Parameters**
|
||
|
||
**parameter\_map** (*dict*) – For parameterized circuits, a mapping from parameters in the circuit to parameters to be used in the instruction. If None, existing circuit parameters will also parameterize the instruction.
|
||
|
||
**Returns**
|
||
|
||
a composite instruction encapsulating this circuit (can be decomposed back)
|
||
|
||
**Return type**
|
||
|
||
[qiskit.circuit.Instruction](qiskit.circuit.Instruction "qiskit.circuit.Instruction")
|
||
</Function>
|
||
|
||
### toffoli
|
||
|
||
<Function id="qiskit.circuit.library.GroverOperator.toffoli" signature="toffoli(control_qubit1, control_qubit2, target_qubit)">
|
||
Apply [`CCXGate`](qiskit.circuit.library.CCXGate "qiskit.circuit.library.CCXGate").
|
||
</Function>
|
||
|
||
### u
|
||
|
||
<Function id="qiskit.circuit.library.GroverOperator.u" signature="u(theta, phi, lam, qubit)">
|
||
Apply [`UGate`](qiskit.circuit.library.UGate "qiskit.circuit.library.UGate").
|
||
</Function>
|
||
|
||
### u1
|
||
|
||
<Function id="qiskit.circuit.library.GroverOperator.u1" signature="u1(theta, qubit)">
|
||
Apply [`U1Gate`](qiskit.circuit.library.U1Gate "qiskit.circuit.library.U1Gate").
|
||
</Function>
|
||
|
||
### u2
|
||
|
||
<Function id="qiskit.circuit.library.GroverOperator.u2" signature="u2(phi, lam, qubit)">
|
||
Apply [`U2Gate`](qiskit.circuit.library.U2Gate "qiskit.circuit.library.U2Gate").
|
||
</Function>
|
||
|
||
### u3
|
||
|
||
<Function id="qiskit.circuit.library.GroverOperator.u3" signature="u3(theta, phi, lam, qubit)">
|
||
Apply [`U3Gate`](qiskit.circuit.library.U3Gate "qiskit.circuit.library.U3Gate").
|
||
</Function>
|
||
|
||
### uc
|
||
|
||
<Function id="qiskit.circuit.library.GroverOperator.uc" signature="uc(gate_list, q_controls, q_target, up_to_diagonal=False)">
|
||
Attach a uniformly controlled gates (also called multiplexed gates) to a circuit.
|
||
|
||
The decomposition was introduced by Bergholm et al. in [https://arxiv.org/pdf/quant-ph/0410066.pdf](https://arxiv.org/pdf/quant-ph/0410066.pdf).
|
||
|
||
**Parameters**
|
||
|
||
* **gate\_list** (*list\[ndarray]*) – list of two qubit unitaries \[U\_0,…,U\_\{2^k-1}], where each single-qubit unitary U\_i is a given as a 2\*2 array
|
||
* **q\_controls** (*QuantumRegister|list\[(*[*QuantumRegister*](qiskit.circuit.QuantumRegister "qiskit.circuit.QuantumRegister")*,int)]*) – list of k control qubits. The qubits are ordered according to their significance in the computational basis. For example if q\_controls=\[q\[1],q\[2]] (with q = QuantumRegister(2)), the unitary U\_0 is performed if q\[1] and q\[2] are in the state zero, U\_1 is performed if q\[2] is in the state zero and q\[1] is in the state one, and so on
|
||
* **q\_target** (*QuantumRegister|(*[*QuantumRegister*](qiskit.circuit.QuantumRegister "qiskit.circuit.QuantumRegister")*,int)*) – target qubit, where we act on with the single-qubit gates.
|
||
* **up\_to\_diagonal** (*bool*) – If set to True, the uniformly controlled gate is decomposed up to a diagonal gate, i.e. a unitary u’ is implemented such that there exists a diagonal gate d with u = d.dot(u’), where the unitary u describes the uniformly controlled gate
|
||
|
||
**Returns**
|
||
|
||
the uniformly controlled gate is attached to the circuit.
|
||
|
||
**Return type**
|
||
|
||
[QuantumCircuit](qiskit.circuit.QuantumCircuit "qiskit.circuit.QuantumCircuit")
|
||
|
||
**Raises**
|
||
|
||
**QiskitError** – if the list number of control qubits does not correspond to the provided number of single-qubit unitaries; if an input is of the wrong type
|
||
</Function>
|
||
|
||
### ucrx
|
||
|
||
<Function id="qiskit.circuit.library.GroverOperator.ucrx" signature="ucrx(angle_list, q_controls, q_target)">
|
||
Attach a uniformly controlled (also called multiplexed) Rx rotation gate to a circuit.
|
||
|
||
The decomposition is base on [https://arxiv.org/pdf/quant-ph/0406176.pdf](https://arxiv.org/pdf/quant-ph/0406176.pdf) by Shende et al.
|
||
|
||
**Parameters**
|
||
|
||
* **angle\_list** (*list*) – list of (real) rotation angles $[a_0,...,a_{2^k-1}]$
|
||
* **q\_controls** (*QuantumRegister|list*) – list of k control qubits (or empty list if no controls). The control qubits are ordered according to their significance in increasing order: For example if `q_controls=[q[0],q[1]]` (with `q = QuantumRegister(2)`), the rotation `Rx(a_0)` is performed if `q[0]` and `q[1]` are in the state zero, the rotation `Rx(a_1)` is performed if `q[0]` is in the state one and `q[1]` is in the state zero, and so on
|
||
* **q\_target** (*QuantumRegister|Qubit*) – target qubit, where we act on with the single-qubit rotation gates
|
||
|
||
**Returns**
|
||
|
||
the uniformly controlled rotation gate is attached to the circuit.
|
||
|
||
**Return type**
|
||
|
||
[QuantumCircuit](qiskit.circuit.QuantumCircuit "qiskit.circuit.QuantumCircuit")
|
||
|
||
**Raises**
|
||
|
||
**QiskitError** – if the list number of control qubits does not correspond to the provided number of single-qubit unitaries; if an input is of the wrong type
|
||
</Function>
|
||
|
||
### ucry
|
||
|
||
<Function id="qiskit.circuit.library.GroverOperator.ucry" signature="ucry(angle_list, q_controls, q_target)">
|
||
Attach a uniformly controlled (also called multiplexed) Ry rotation gate to a circuit.
|
||
|
||
The decomposition is base on [https://arxiv.org/pdf/quant-ph/0406176.pdf](https://arxiv.org/pdf/quant-ph/0406176.pdf) by Shende et al.
|
||
|
||
**Parameters**
|
||
|
||
* **angle\_list** (*list\[numbers*) – list of (real) rotation angles $[a_0,...,a_{2^k-1}]$
|
||
* **q\_controls** (*QuantumRegister|list\[*[*Qubit*](qiskit.circuit.Qubit "qiskit.circuit.Qubit")*]*) – list of k control qubits (or empty list if no controls). The control qubits are ordered according to their significance in increasing order: For example if `q_controls=[q[0],q[1]]` (with `q = QuantumRegister(2)`), the rotation `Ry(a_0)` is performed if `q[0]` and `q[1]` are in the state zero, the rotation `Ry(a_1)` is performed if `q[0]` is in the state one and `q[1]` is in the state zero, and so on
|
||
* **q\_target** (*QuantumRegister|Qubit*) – target qubit, where we act on with the single-qubit rotation gates
|
||
|
||
**Returns**
|
||
|
||
the uniformly controlled rotation gate is attached to the circuit.
|
||
|
||
**Return type**
|
||
|
||
[QuantumCircuit](qiskit.circuit.QuantumCircuit "qiskit.circuit.QuantumCircuit")
|
||
|
||
**Raises**
|
||
|
||
**QiskitError** – if the list number of control qubits does not correspond to the provided number of single-qubit unitaries; if an input is of the wrong type
|
||
</Function>
|
||
|
||
### ucrz
|
||
|
||
<Function id="qiskit.circuit.library.GroverOperator.ucrz" signature="ucrz(angle_list, q_controls, q_target)">
|
||
Attach a uniformly controlled (also called multiplexed gates) Rz rotation gate to a circuit.
|
||
|
||
The decomposition is base on [https://arxiv.org/pdf/quant-ph/0406176.pdf](https://arxiv.org/pdf/quant-ph/0406176.pdf) by Shende et al.
|
||
|
||
**Parameters**
|
||
|
||
* **angle\_list** (*list\[numbers*) – list of (real) rotation angles \[a\_0,…,a\_\{2^k-1}]
|
||
* **q\_controls** (*QuantumRegister|list\[*[*Qubit*](qiskit.circuit.Qubit "qiskit.circuit.Qubit")*]*) – list of k control qubits (or empty list if no controls). The control qubits are ordered according to their significance in increasing order: For example if q\_controls=\[q\[1],q\[2]] (with q = QuantumRegister(2)), the rotation Rz(a\_0)is performed if q\[1] and q\[2] are in the state zero, the rotation Rz(a\_1) is performed if q\[1] is in the state one and q\[2] is in the state zero, and so on
|
||
* **q\_target** (*QuantumRegister|Qubit*) – target qubit, where we act on with the single-qubit rotation gates
|
||
|
||
**Returns**
|
||
|
||
the uniformly controlled rotation gate is attached to the circuit.
|
||
|
||
**Return type**
|
||
|
||
[QuantumCircuit](qiskit.circuit.QuantumCircuit "qiskit.circuit.QuantumCircuit")
|
||
|
||
**Raises**
|
||
|
||
**QiskitError** – if the list number of control qubits does not correspond to the provided number of single-qubit unitaries; if an input is of the wrong type
|
||
</Function>
|
||
|
||
### unitary
|
||
|
||
<Function id="qiskit.circuit.library.GroverOperator.unitary" signature="unitary(obj, qubits, label=None)">
|
||
Apply unitary gate to q.
|
||
</Function>
|
||
|
||
### width
|
||
|
||
<Function id="qiskit.circuit.library.GroverOperator.width" signature="width()">
|
||
Return number of qubits plus clbits in circuit.
|
||
|
||
**Returns**
|
||
|
||
Width of circuit.
|
||
|
||
**Return type**
|
||
|
||
int
|
||
</Function>
|
||
|
||
### x
|
||
|
||
<Function id="qiskit.circuit.library.GroverOperator.x" signature="x(qubit, label=None)">
|
||
Apply [`XGate`](qiskit.circuit.library.XGate "qiskit.circuit.library.XGate").
|
||
</Function>
|
||
|
||
### y
|
||
|
||
<Function id="qiskit.circuit.library.GroverOperator.y" signature="y(qubit)">
|
||
Apply [`YGate`](qiskit.circuit.library.YGate "qiskit.circuit.library.YGate").
|
||
</Function>
|
||
|
||
### z
|
||
|
||
<Function id="qiskit.circuit.library.GroverOperator.z" signature="z(qubit)">
|
||
Apply [`ZGate`](qiskit.circuit.library.ZGate "qiskit.circuit.library.ZGate").
|
||
</Function>
|
||
|
||
### zero\_reflection
|
||
|
||
<Attribute id="qiskit.circuit.library.GroverOperator.zero_reflection">
|
||
The subcircuit implementing the reflection about 0.
|
||
|
||
**Return type**
|
||
|
||
`QuantumCircuit`
|
||
</Attribute>
|
||
</Class>
|
||
|