2

If I have an arbitrary non-unitary matrix of say $$ U = \begin{pmatrix} 1.5 & 0 & 0 & 0 \\ 0 & 0 & 0 & 1.6 \\ 0 & 0 & 1 & 0 \\ 0 & 1 & 0 & 0 \\ \end{pmatrix}, $$

is it possible to decompose it into gates implementable in qiskit?

If so, how? If not, why not?

Is is possible to have any arbitrary non-unitary matrix as an input and get the corresponding gates that implement this arbitrary matrix?

Mithrandir24601
  • 3,796
  • 3
  • 24
  • 45
Monica
  • 311
  • 2
  • 6

1 Answers1

1

As far as I know there is no way to implement non-unitary gates in Qiskit. The only non-unitary operations that Qiskit accepts are instructions. Have a look in the section "Non unitary operations" at the end of this tutorial.

However, if you do have an arbitrary unitary matrix, you can apply it to your quantum circuit directly with the qc.unitary() attribute. Have a look at the following code snippet, which I took from this this page.

from qiskit import QuantumCircuit
matrix = [[0, 0, 0, 1],
          [0, 0, 1, 0],
          [1, 0, 0, 0],
          [0, 1, 0, 0]]
circuit = QuantumCircuit(2)
circuit.unitary(matrix, [0, 1])