Qiita Teams that are logged in
You are not logged in to any team

Log in to Qiita Team
Community
OrganizationAdvent CalendarQiitadon (β)
Service
Qiita JobsQiita ZineQiita Blog
0
Help us understand the problem. What is going on with this article?
@skiing_LAL10

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

More than 1 year has passed since last update.

結論

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を操作するかには無関係.

0
Help us understand the problem. What is going on with this article?
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
skiing_LAL10
初心者です.

Comments

No comments
Sign up for free and join this conversation.
Sign Up
If you already have a Qiita account Login
0
Help us understand the problem. What is going on with this article?