Open king-p3nguin opened 2 months ago
In this code I can see it is ok,
circuit = random_circuit(num_qubits, depth, seed=seed)
circuit2 = circuit.reverse_bits()
circuit.save_density_matrix()
print(get_density_matrix(circuit))
circuit2.save_density_matrix()
print(get_density_matrix(circuit2))
output:
DensityMatrix([[0.35+0.j , 0. +0.477j, 0. +0.j , 0. +0.j ],
[0. -0.477j, 0.65+0.j , 0. +0.j , 0. +0.j ],
[0. +0.j , 0. +0.j , 0. +0.j , 0. +0.j ],
[0. +0.j , 0. +0.j , 0. +0.j , 0. +0.j ]],
dims=(2, 2))
DensityMatrix([[0.35+0.j , 0. +0.j , 0. +0.477j, 0. +0.j ],
[0. +0.j , 0. +0.j , 0. +0.j , 0. +0.j ],
[0. -0.477j, 0. +0.j , 0.65+0.j , 0. +0.j ],
[0. +0.j , 0. +0.j , 0. +0.j , 0. +0.j ]],
dims=(2, 2))
maybe reverse_bits() do not copy the circuit correctly
Informations
What is the current behavior?
QuantumCircuit.reverse_bits()
affects the bit order in the state vector but not the density matrixSteps to reproduce the problem
Output:
What is the expected behavior?
The effect of
QuantumCircuit.reverse_bits()
on the result should be consistent (should be unified to either have no effect on the order of bits in bothStatevector
andDensityMatrix
, or to have an effect).