Change of parameters of Gates in quantumCircuit does not take effect
3 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
James Cai
am 23 Jun. 2023
Beantwortet: Christine Tobler
am 30 Jun. 2023
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?
0 Kommentare
Akzeptierte Antwort
Christine Tobler
am 30 Jun. 2023
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);
0 Kommentare
Weitere Antworten (1)
Satwik
am 26 Jun. 2023
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!
0 Kommentare
Siehe auch
Kategorien
Mehr zu Gate-Based Quantum Computing finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!