TransWikia.com

Cirq - Measure Density Matrix Function Getting First Element

Quantum Computing Asked on April 18, 2021

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 …

One Answer

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

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

Correct answer by Craig Gidney on April 18, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP