Qiskit / qiskit

Qiskit is an open-source SDK for working with quantum computers at the level of extended quantum circuits, operators, and primitives.
https://www.ibm.com/quantum/qiskit
Apache License 2.0
5.04k stars 2.32k forks source link

How to get all entries of an array via array to latex, in Qiskit, with precision upto 14 decimal places #7495

Closed MubasharK closed 1 year ago

MubasharK commented 2 years ago

What should we add?

I want to ask two questions as I could not find answer to them on this forum and elsewhere. First, what is a precision of an array representing a quantum state which has been evolved via quantum circuit in Qiskit. Second, the command array to latex does not output all entries of the array instead it displays few entries with ellipses in between them. How can we get complete array with precision up to 14 decimal places (say)? According to my observations, the precision seems to be 5 decimal places. If it is true, then how one can enhance it? Also, I request you to update the output of array to latex in Qiskit so that all elements of the output tuple are explicitly listed.

frankharkins commented 2 years ago

@MubasharK

MubasharK commented 2 years ago

Thank you Frank Harkins! Please see the below file. The output of block 4 and 5 is my concern. With including precision=14 in the command array_to_latex one issue has been resolved. But, not all entries of the output array are explicitly listed. The state (array) is initialized using from qiskit.quantum_info import Statevector state = Statevector.from_int(0, 2**7) state = state.evolve(qc)

draw using latex

state.draw('latex') Multi qubit controlled rotations.pdf

frankharkins commented 2 years ago

Replace:

array_to_latex(state)    -->    array_to_latex(state, max_size=2**7, precision=14)

Looks like the ket convention drawer is ignoring max size, I've added a bug report for this (https://github.com/Qiskit/qiskit-terra/issues/7516). Once fixed, I think you should be able to do state.draw('latex', max_size=2**7) to get what you want.

MubasharK commented 2 years ago

Hello Harkins,

Hope you are well.

The issue (#7516 https://github.com/Qiskit/qiskit-terra/issues/7516) is still open and I am unable to retrieve all the entries using the command state.draw('latex', max_size=2**7). Is there any progress about this?

Best, Mubashar

On Tue, 11 Jan 2022 at 17:46, Frank Harkins @.***> wrote:

Replace:

array_to_latex(state) --> array_to_latex(state, max_size=2**7, precision=14)

Looks like the ket convention drawer is ignoring max size, I've added a bug report for this (#7516 https://github.com/Qiskit/qiskit-terra/issues/7516). Once fixed, I think you should be able to do state.draw('latex', max_size=2**7) to get what you want.

— Reply to this email directly, view it on GitHub https://github.com/Qiskit/qiskit-terra/issues/7495#issuecomment-1009930819, or unsubscribe https://github.com/notifications/unsubscribe-auth/AXGEYE5D5PTGFTC77RH3ZNTUVQRCNANCNFSM5LOFNBLQ . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.

You are receiving this because you were mentioned.Message ID: @.***>

kdk commented 1 year ago

Closing as it looks like this was resolved as part of #7516 . Please feel free to re-open if you're still seeing this issue.