CHGate

class CHGate(label=None, ctrl_state=None)[source]

Controlled-Hadamard gate.

Applies a Hadamard on the target qubit if the control is in the \(|1\rangle\) state.

Circuit symbol:

q_0: ──■──

┌─┴─┐

q_1: ┤ H ├

└───┘

Matrix Representation:

\[\begin{split}CH\ q_0, q_1 = I \otimes |0\rangle\langle 0| + H \otimes |1\rangle\langle 1| = \begin{pmatrix} 1 & 0 & 0 & 0 \\ 0 & \frac{1}{\sqrt{2}} & 0 & \frac{1}{\sqrt{2}} \\ 0 & 0 & 1 & 0 \\ 0 & \frac{1}{\sqrt{2}} & 0 & -\frac{1}{\sqrt{2}} \end{pmatrix}\end{split}\]

Note

In Qiskit’s convention, higher qubit indices are more significant (little endian convention). In many textbooks, controlled gates are presented with the assumption of more significant qubits as control, which in our case would be q_1. Thus a textbook matrix for this gate will be:

     ┌───┐
q_0: ┤ H ├
     └─┬─┘
q_1: ──■──
\[\begin{split}CH\ q_1, q_0 = |0\rangle\langle 0| \otimes I + |1\rangle\langle 1| \otimes H = \frac{1}{\sqrt{2}} \begin{pmatrix} 1 & 0 & 0 & 0 \\ 0 & 1 & 0 & 0 \\ 0 & 0 & 1 & 1 \\ 0 & 0 & 1 & -1 \end{pmatrix}\end{split}\]

Create new CH gate.

Attributes

CHGate.ctrl_state

Return the control state of the gate as a decimal integer.

CHGate.decompositions

Get the decompositions of the instruction from the SessionEquivalenceLibrary.

CHGate.definition

Return definition in terms of other basic gates.

CHGate.label

Return gate label

CHGate.num_ctrl_qubits

Get number of control qubits.

CHGate.params

return instruction params.

Methods

CHGate.add_decomposition(decomposition)

Add a decomposition of the instruction to the SessionEquivalenceLibrary.

CHGate.assemble()

Assemble a QasmQobjInstruction

CHGate.broadcast_arguments(qargs, cargs)

Validation and handling of the arguments and its relationship.

CHGate.c_if(classical, val)

Add classical condition on register classical and value val.

CHGate.control([num_ctrl_qubits, label, …])

Return controlled version of gate.

CHGate.copy([name])

Copy of the instruction.

CHGate.inverse()

Return inverted CH gate (itself).

CHGate.is_parameterized()

Return True .IFF.

CHGate.mirror()

DEPRECATED: use instruction.reverse_ops().

CHGate.power(exponent)

Creates a unitary gate as gate^exponent.

CHGate.qasm()

Return a default OpenQASM string for the instruction.

CHGate.repeat(n)

Creates an instruction with gate repeated n amount of times.

CHGate.reverse_ops()

For a composite instruction, reverse the order of sub-instructions.

CHGate.to_matrix()

Return a numpy.array for the CH gate.