1
$\begingroup$

Hello I am using measure density matrix function like that:

for i in range (10):
    measurement_result = cirq.measure_density_matrix(state,indices=[0, 1, 2])
    print("measurement",measurement_result)

And my results are like that:

enter image description here

As you can see, I have ([0, 0, 0], array([[0.36107099-0.36107099j, 0. +0.j , and I want to extract first part [0, 0, 0] (the qubit part) and then I will count how many [0, 0, 0] , [0, 0, 1] [0, 1, 0] … But I could not extract the first part of array. How can I get the first part [0, 0, 0] ? Thanks ...

$\endgroup$

1 Answer 1

1
$\begingroup$

This is more of a basic python usage question. You want

first_part = measurement_result[0] or first_part, second_part = measurement_result.

$\endgroup$
2
  • $\begingroup$ Can I ask one more question to you regarding the mostly python part? cirq.kron(cirq.unitary(cirq.rz(a)),cirq.unitary(cirq.rz(b)),cirq.unitary(cirq.rz(a)))I have this line and I also write this line for all possible combination of a and b. I mean I have to write also cirq.kron(cirq.unitary(cirq.rz(a)),cirq.unitary(cirq.rz(a)),cirq.unitary(cirq.rz(a))) and also cirq.kron(cirq.unitary(cirq.rz(b)),cirq.unitary(cirq.rz(b)),cirq.unitary(cirq.rz(b))) and also cirq.kron(cirq.unitary(cirq.rz(a)),cirq.unitary(cirq.rz(b)),cirq.unitary(cirq.rz(b))) … all possible combination for a b. @Craig Gidney $\endgroup$
    – quest
    Nov 2, 2020 at 18:46
  • $\begingroup$ Do you have an idea for that @craig-gidney $\endgroup$
    – quest
    Nov 4, 2020 at 22:30

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.