# Decomposition of an arbitrary gate using given matrix in Qiskit

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?

• 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). Feb 15, 2020 at 9: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. Feb 16, 2020 at 18:53
• See answer to the original in: quantumcomputing.stackexchange.com/questions/4975/… Feb 16, 2020 at 23:46
• 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. Feb 17, 2020 at 10:33

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