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,687
  • 2
  • 22
  • 43
Monica
  • 311
  • 2
  • 6
  • 1
    Welcome to quantum computing SC. In what way do you want to decompose the matrix? Do you mean to basic quantum gates? What does the matrix represent as it seems it is not unitary (columns are not unit vectors). – Martin Vesely Feb 15 '20 at 09:05
  • I want to decompose any kind of matrix rather than a unitary matrix into elementary gates in Qiskit. Is this possible? Decomposition using KAK decomposition in Qiskit. – Monica Feb 16 '20 at 18:53
  • See answer to the original in: https://quantumcomputing.stackexchange.com/questions/4975/how-do-i-build-a-gate-from-a-matrix-on-qiskit – Yehuda Naveh Feb 16 '20 at 23:46
  • 1
    You should probably edit your question to add more information about what you want to achieve. You cannot decompose non-unitary gates as a sequence of quantum gates (a product of unitary matrices is always unitary). It is possible to "implement" non-unitary gates (and this becomes probabilistic and involved) but you asked for a decomposition, which is different. – Adrien Suau Feb 17 '20 at 10:33
  • The long discussion about this is in response to question 4975 (link added as comment above) – Yehuda Naveh Feb 16 '20 at 23:49
  • Decompose to what? – peterh Feb 19 '20 at 15:59
  • Going from the comments, the question linked in the above comments is virtually irrelevant to this question - the linked question is about decomposing unitary matrices, this is about decomposing non-unitary matrices, which are two totally different questions. While there might be technical arguments/questions about the use of the word 'decompose', this is probably something best addressed in an actual answer or even an [edit] to the question – Mithrandir24601 Feb 19 '20 at 23:34
  • @Monica I've gone ahead and edited your question in a way that hopefully clarifies it to people while still being what you're looking to ask. If it's not quite right, feel free to [edit] further or revert the edit, although it's worth noting that it can't be simply decomposed as a unitary gate could be, so the question of 'how' doesn't really work without first asking 'is it possible?' – Mithrandir24601 Feb 19 '20 at 23:53

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])