Skip to content
This repository has been archived by the owner on Dec 18, 2021. It is now read-only.

Print register better #68

Open
GiggleLiu opened this issue Sep 13, 2020 · 2 comments
Open

Print register better #68

GiggleLiu opened this issue Sep 13, 2020 · 2 comments
Labels
enhancement New feature or request

Comments

@GiggleLiu
Copy link
Member

Something like

julia> using BitBasis, Yao
julia> reg = rand_state(3)
ArrayReg{1, Complex{Float64}, Array...}
    active qubits: 3/3
julia> for (amp, b) in zip(state(reg), basis(BitStr64{nqubits(reg)}))
           println("$amp * $b")
       end
-0.3376505759988792 + 0.33325899072397025im * 000 ₍₂₎
0.32054579481565426 + 0.31927725422058706im * 001 ₍₂₎
0.09069334279111192 + 0.013173928388618843im * 010 ₍₂₎
-0.3263247507853093 - 0.07986342841304012im * 011 ₍₂₎
-0.27129613548559606 - 0.09708850865801441im * 100 ₍₂₎
-0.327171716777714 - 0.13959063658977386im * 101 ₍₂₎
0.23149778290317669 - 0.15132920651218748im * 110 ₍₂₎
-0.2859389557190614 + 0.28490459569435167im * 111 ₍₂₎
@GiggleLiu GiggleLiu added the enhancement New feature or request label Sep 13, 2020
@Roger-luo
Copy link
Member

I don't get it, why we need this at all? this won't work for large states and gives you no useful information about the state.

@GiggleLiu
Copy link
Member Author

GiggleLiu commented Sep 13, 2020

We can still print part of the state when the state is large, just as the julia vector printing. It can be implemented in another function, rather than the default show. Sometimes it is convenient.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants