You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I want to apply Hadamard Rotation operaton to each element in each row, H*X
julia> for rows in 1:3
for cols in 1:2^3
setindex!(H, rows, cols) = sHadamard(1)*H[[rows], [cols]]
end
end
I get wrong output, no change!
julia> H
+ X_X_ZYZY
+ X_YZX_YZ
+ XZ_Y_YXZ
Expected Output
Z_Z_XYXY
Z_YXZ_YX
ZX_Y_YZX
There seems to be a problem with setindex! Because H operation is applied correctly as shown in the output
julia> for rows in 1:3
for cols in 1:2^3
println(sHadamard(1)*Hⱼ[[rows], [cols]] )
end
end
+ Z
+ _
+ Z
+ _
+ X
- Y
+ X
- Y
+ Z
+ _
- Y
+ X
+ Z
+ _
- Y
+ X
+ Z
+ X
+ _
- Y
+ _
- Y
+ Z
+ X
The problem either lies in the assignment ( setindex!(H, rows, cols)) or in setindex! Please feel free to assign an better name to the issue.
The text was updated successfully, but these errors were encountered:
Fe-r-oz
changed the title
Correct set_index(Stabilizer_Tableau, rows, rols)
Correct set_index(Stabilizer_Tableau, rows, cols)
Jun 6, 2024
I think there is some conceptual confusion here. A gate is supposed to be applied to the tableau (state) as a whole, not row-by-row. Thus I am not sure what setindex!(H, rows, cols) = sHadamard(1)*H[[rows], [cols]] is supposed to do.
If one wants to apply a gate, they should just do apply!(state, sHadamard(qubit_index)) (which is also non-allocating, unlike this loop).
If the Hadamard needs to be applied to all qubits, it would looks something like:
for q_i in 1:nqubits(state)
apply!(state, sHadamard(q_i))
end
There is a bit of a misuse of julia syntax here, which is a separate problem. If you want to set an index, you should write:
Suppose
I want to apply Hadamard Rotation operaton to each element in each row, H*X
Expected Output
There seems to be a problem with
setindex!
Because H operation is applied correctly as shown in the outputThe problem either lies in the assignment
( setindex!(H, rows, cols))
or insetindex!
Please feel free to assign an better name to the issue.The text was updated successfully, but these errors were encountered: