- class qiskit.circuit.Gate(name, num_qubits, params, label=None)#
Create a new gate.
Get Clbits in condition.
Get the decompositions of the instruction from the SessionEquivalenceLibrary.
Return definition in terms of other basic gates.
Get the duration.
Return instruction label
Return the name.
Return the number of clbits.
Return the number of qubits.
return instruction params.
Get the time unit of duration.
Add a decomposition of the instruction to the SessionEquivalenceLibrary.
Assemble a QasmQobjInstruction
- broadcast_arguments(qargs, cargs)#
Validation and handling of the arguments and its relationship.
cx(q, q); cx(q, q). This method yields the arguments in the right grouping. In the given example:
in: [[q,q], q], outs: [q, q],  [q, q], 
The general broadcasting rules are:
If len(qargs) == 1:
[q, q] -> [q],[q]
If len(qargs) == 2:
[[q, q], [r, r]] -> [q, r], [q, r] [[q], [r, r]] -> [q, r], [q, r] [[q, q], [r]] -> [q, r], [q, r]
If len(qargs) >= 3:
[q, q], [r, r], ...] -> [q, r, ...], [q, r, ...]
- c_if(classical, val)#
Set a classical equality condition on this instruction between the register or cbit
This is a setter method, not an additive one. Calling this multiple times will silently override any previously set condition; it does not stack.
- control(num_ctrl_qubits=1, label=None, ctrl_state=None)#
Return controlled version of gate. See
Controlled version of gate. This default algorithm uses
num_ctrl_qubits-1ancilla qubits so returns a gate of size
num_qubits + 2*num_ctrl_qubits - 1.
- 반환 형식:
- 예외 발생:
QiskitError – unrecognized mode or invalid ctrl_state
Copy of the instruction.
Invert this instruction.
If the instruction is composite (i.e. has a definition), then its definition will be recursively inverted.
Special instructions inheriting from Instruction can implement their own inverse (e.g. T and Tdg, Barrier, etc.)
Return True .IFF. instruction is parameterized else False
Creates a unitary gate as gate^exponent.
Return a default OpenQASM string for the instruction.
Derived instructions may override this to print in a different format (e.g.
measure q -> c;).
버전 0.25.0부터 폐지됨: The method
qiskit.circuit.instruction.Instruction.qasm()is deprecated as of qiskit-terra 0.25.0. It will be removed no earlier than 3 months after the release date. Correct exporting to OpenQASM 2 is the responsibility of a larger exporter; it cannot safely be done on an object-by-object basis without context. No replacement will be provided, because the premise is wrong.
Creates an instruction with gate repeated n amount of times.
For a composite instruction, reverse the order of sub-instructions.
This is done by recursively reversing all sub-instructions. It does not invert any gate.
- a new instruction with
- 반환 형식:
Soft comparison between gates. Their names, number of qubits, and classical bit numbers must match. The number of parameters must match. Each parameter is compared. If one is a ParameterExpression then it is not taken into account.
other (instruction) – other instruction.
are self and other equal up to parameter expressions.
- 반환 형식:
Return a Numpy.array for the gate unitary matrix.
if the Gate subclass has a matrix definition.
- 반환 형식:
- 예외 발생:
CircuitError – If a Gate subclass does not implement this method an exception will be raised when this base class method is called.
Gate parameters should be int, float, or ParameterExpression