Help us understand the problem. What is going on with this article?

Qiskit 回路のDepthを知りたいとき

結論

qc.depth()でOK

参考

qiskit.circuit.quantumcircuit moduledepth()の関数がある.

他にもappend()など,便利な関数が色々ある.

使用例

IBM Quantum Experience上で実行した.

まずはimport

%matplotlib inline
# Importing standard Qiskit libraries and configuring account
from qiskit import QuantumCircuit, execute, Aer, IBMQ
from qiskit.compiler import transpile, assemble
from qiskit.tools.jupyter import *
from qiskit.visualization import *
# Loading your IBM Q account(s)
provider = IBMQ.load_account()

from qiskit import *

回路の作成

q = QuantumRegister(3)
c = ClassicalRegister(3)
qc = QuantumCircuit(q, c)
#.draw()で回路を表示
qc.draw()

ScreenShot 2020-02-20 11.50.33.png

.depth()でDepthを測定すると

qc.depth()
>>> 0

まだ何もつけていないので0になる.

回路にHadamard gateを2つ作用させる.

qc.h(q[0])
qc.h(q[0])
qc.draw()

ScreenShot 2020-02-20 11.53.19.png

qc.depth()
>>> 2

正しい結果が得られる.

3つのqubitに同時にHadamard gateを作用させると

q = QuantumRegister(3)
c = ClassicalRegister(3)
qc = QuantumCircuit(q, c)
qc.h(q[0])
qc.h(q[1])
qc.h(q[2])
qc.draw()

ScreenShot 2020-02-20 11.56.01.png

qc.depth()
>>> 1

depthは,一回の操作でいくつのqubitを操作するかには無関係.

Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
Comments
No comments
Sign up for free and join this conversation.
If you already have a Qiita account
Why do not you register as a user and use Qiita more conveniently?
You need to log in to use this function. Qiita can be used more conveniently after logging in.
You seem to be reading articles frequently this month. Qiita can be used more conveniently after logging in.
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
ユーザーは見つかりませんでした