4

I am trying to implement the Quantum HHL algorithm on QISKit package of IBM on Python. I have tried searching the documentation for a method to initialize a qubit to a certain value and to create a new unitary gate with specified values.

In the documentation, I found this, which is the class of a Quantum Gate. I tried to make a new instance of this class but I couldn't because not much documentation has been done about the arguments to be passed while initializing the instance of the class.

kenorb
  • 155,785
  • 88
  • 678
  • 743

1 Answers1

4

As of QISKit v0.4.9, the u3() function parametrizes an arbitrary single-qubit unitary gate U(θ, φ, λ) (for details, see formula (2)). Obviously, you can use the u3() function to set a qubit to any value.

For example, this is how you can implement the X-gate and apply it to some qubit qr[0] via the U3-gate:

u3(theta=math.pi, phi=0, lam=0, q=qr[0])
Alexander Pozdneev
  • 1,289
  • 1
  • 13
  • 31
  • Is there a way to create generic n Qubit gates ? – Parth Jatakia Feb 19 '18 at 08:31
  • @ParthJatakia, if you want to run on the real hardware, you would need to manually decompose your particular unitary matrix into a sequence of the *CNOT*- and *U3*-gates. Then, you might want to keep it as your own extension (see [github](https://github.com/QISKit/qiskit-sdk-py/tree/master/qiskit/extensions/standard) for how it is done for the standard gates). – Alexander Pozdneev Feb 19 '18 at 12:15