Change of parameters of Gates in quantumCircuit does not take effect

2 ビュー (過去 30 日間)
James Cai
James Cai 2023 年 6 月 23 日
回答済み: Christine Tobler 2023 年 6 月 30 日
This question concerns MATLAB Support Package for Quantum Computing.
As shown below:
C1=quantumCircuit(ryGate(1,0.5*pi))
C2=C1;
isequal(simulate(C1),simulate(C2))
ans =
logical
1
C2.Gates.Angles=0.25*pi;
isequal(simulate(C1),simulate(C2))
ans =
logical
1
The first comparison should return true, while the second should not.
Any comments?

採用された回答

Christine Tobler
Christine Tobler 2023 年 6 月 30 日
This is a bug, thank you for reporting it. As a workaround while waiting for this to be addressed, pleaseconstruct a new gate instead of assigning to the angles:
C2.Gates.Angles = 0.25*pi;
use
C2.Gates = ryGate(1, 0.25*pi);

その他の回答 (1 件)

Satwik
Satwik 2023 年 6 月 26 日
Hi James,
I understand that you are using Quantum computing package's function ryGate to create a y axis rotation gate and when you change the angle of one of the gates you expect the gates to differ but they remain the same.
When you change the angle of the Gates it does not affects the QuantumState of the gate which is what you are comparing when you do simulate(C1).
C1 is a :
quantumCircuit with properties:
NumQubits: 1
Gates: [1×1 quantum.gate.SimpleGate]
Name: ""
whereas simulate(C1) is a :
QuantumState with properties:
BasisStates: [2×1 string]
Amplitudes: [2×1 double]
NumQubits: 1
And QuantumState only depends on the NumQubits of QuantumCircuit, not on the Gates.
So if you do isequal(C1,C2) after changing the angle it will return false. But if you want to change the QuantumState i.e. simulate() you need to change NumQubits.
Please look into the below code for reference.
C2.NumQubits = 2;
isequal(simulate(C1),simulate(C2)); % Will return false
Hope this helps!

カテゴリ

Help Center および File ExchangeGate-Based Quantum Computing についてさらに検索

製品


リリース

R2023a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by