QuantumBFS / Yao.jl

Extensible, Efficient Quantum Algorithm Design for Humans.
https://yaoquantum.org
Other
918 stars 119 forks source link

Added similar(::DensityMatrix) #452

Closed jlbosse closed 1 year ago

jlbosse commented 1 year ago

The title says it all. I also checked that #416 and #408 don't add similar(::DensityMatrix)

codecov[bot] commented 1 year ago

Codecov Report

Base: 88.31% // Head: 88.27% // Decreases project coverage by -0.03% :warning:

Coverage data is based on head (b4205bb) compared to base (a88f5e0). Patch coverage: 100.00% of modified lines in pull request are covered.

Additional details and impacted files ```diff @@ Coverage Diff @@ ## master #452 +/- ## ========================================== - Coverage 88.31% 88.27% -0.04% ========================================== Files 76 76 Lines 4765 4766 +1 ========================================== - Hits 4208 4207 -1 - Misses 557 559 +2 ``` | [Impacted Files](https://codecov.io/gh/QuantumBFS/Yao.jl/pull/452?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=QuantumBFS) | Coverage Δ | | |---|---|---| | [lib/YaoArrayRegister/src/density\_matrix.jl](https://codecov.io/gh/QuantumBFS/Yao.jl/pull/452?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=QuantumBFS#diff-bGliL1lhb0FycmF5UmVnaXN0ZXIvc3JjL2RlbnNpdHlfbWF0cml4Lmps) | `98.48% <100.00%> (+0.02%)` | :arrow_up: | | [lib/YaoBlocks/src/treeutils/load.jl](https://codecov.io/gh/QuantumBFS/Yao.jl/pull/452?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=QuantumBFS#diff-bGliL1lhb0Jsb2Nrcy9zcmMvdHJlZXV0aWxzL2xvYWQuamw=) | `80.32% <0.00%> (-1.64%)` | :arrow_down: | Help us with your feedback. Take ten seconds to tell us [how you rate us](https://about.codecov.io/nps?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=QuantumBFS). Have a feature suggestion? [Share it here.](https://app.codecov.io/gh/feedback/?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=QuantumBFS)

:umbrella: View full report at Codecov.
:loudspeaker: Do you have feedback about the report comment? Let us know in this issue.

Roger-luo commented 1 year ago

LGTM

jlbosse commented 1 year ago

I have code where I need a "scratch" register to store a temporary state. I was allocating creating this scratch register using scratch = similar(register) and when I wanted to run a density matrix simulation (with noise channels added to the circuit) instead of a noiseless state vector simulation it was complaining about the lack of similar(::DensityMatrix)

Or more generally: It would be great that any code that can be run with a ArrayReg can just as well be run with a DensityMatrix for noisy simulations.