Say I have a string representing the operations of a quantum circuit. I want to have the unitary operator representing it. Is there a tool for doing so in Python or else?
You can use Python with Qiskit. Say your string representation is written using OpenQASM syntax.
qasm = """ OPENQASM 2.0; include "qelib1.inc"; qreg q; h q; t q; cx q, q; """
You can build a circuit out of this and simulate it on a unitary simulator:
import qiskit as qk import numpy as np circuit = qk.load_qasm_string(qasm) result = qk.execute(circuit, 'local_unitary_simulator').result() print(np.round(result.get_unitary(), 1))
[[ 0.7+0.j 0.7-0.j 0. +0.j 0. +0.j ] [ 0. +0.j 0. +0.j 0.5+0.5j -0.5-0.5j] [ 0. +0.j 0. +0.j 0.5+0.5j 0.5+0.5j] [ 0.7+0.j -0.7+0.j 0. +0.j 0. +0.j ]]
Normally, quantum simulators ask you to specify a starting state, for example, all qubits initially in state $|0\rangle$, and then they give you the final state after that initial state evolves through all of the SEO (sequence of elementary operations). This is performed in my software Qubiter by the class SEO_simulator.
However, a well designed simulator package should also multiply the SEO and give you the unitary matrix it represents. This is done in Qubiter by the class
I have described the features of Qubiter in some of my other answers; it is my own code.