QuantumBFS / ZXCalculus.jl

An implementation of ZX-calculus in Julia
http://yaoquantum.org/ZXCalculus.jl/dev/
MIT License
48 stars 7 forks source link

ZXW rewrite rules + Differentiation #93

Closed exAClior closed 1 year ago

codecov[bot] commented 1 year ago

Codecov Report

Patch coverage: 79.17% and project coverage change: -0.43% :warning:

Comparison is base (5161a51) 82.88% compared to head (6870623) 82.46%.

Additional details and impacted files ```diff @@ Coverage Diff @@ ## master #93 +/- ## ========================================== - Coverage 82.88% 82.46% -0.43% ========================================== Files 16 17 +1 Lines 2478 2902 +424 ========================================== + Hits 2054 2393 +339 - Misses 424 509 +85 ``` | [Files Changed](https://app.codecov.io/gh/QuantumBFS/ZXCalculus.jl/pull/93?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=QuantumBFS) | Coverage Δ | | |---|---|---| | [src/ZXCalculus.jl](https://app.codecov.io/gh/QuantumBFS/ZXCalculus.jl/pull/93?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=QuantumBFS#diff-c3JjL1pYQ2FsY3VsdXMuamw=) | `100.00% <ø> (ø)` | | | [src/zxw\_diagram.jl](https://app.codecov.io/gh/QuantumBFS/ZXCalculus.jl/pull/93?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=QuantumBFS#diff-c3JjL3p4d19kaWFncmFtLmps) | `86.20% <ø> (ø)` | | | [src/parameter.jl](https://app.codecov.io/gh/QuantumBFS/ZXCalculus.jl/pull/93?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=QuantumBFS#diff-c3JjL3BhcmFtZXRlci5qbA==) | `76.31% <45.45%> (-20.03%)` | :arrow_down: | | [src/zxw\_rules.jl](https://app.codecov.io/gh/QuantumBFS/ZXCalculus.jl/pull/93?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=QuantumBFS#diff-c3JjL3p4d19ydWxlcy5qbA==) | `73.44% <73.44%> (ø)` | | | [src/utils.jl](https://app.codecov.io/gh/QuantumBFS/ZXCalculus.jl/pull/93?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=QuantumBFS#diff-c3JjL3V0aWxzLmps) | `87.05% <94.15%> (+11.28%)` | :arrow_up: | | [src/to\_eincode.jl](https://app.codecov.io/gh/QuantumBFS/ZXCalculus.jl/pull/93?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=QuantumBFS#diff-c3JjL3RvX2VpbmNvZGUuamw=) | `98.85% <100.00%> (+0.07%)` | :arrow_up: |

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

exAClior commented 1 year ago

Hello @ChenZhao44 , could you please take a look at my differentiation implementation while I continue to work on the integration part? I did minimal testing just in case I need to rewrite the entire thing.

exAClior commented 1 year ago

@ChenZhao44 Hi! I fixed and tested everything including differentiation, integration of two sites and four sites, variance calculation. Everything passed! Could you please take a look at it at your convenience? Thanks!

There are a few caveats for future user and future me. 1: If you found yourself missing a $\sqrt{2}$ in value sensitive calculation (derivative or integral), note the X spider used in ZXW Calculus related literature is actually a pink X spider, you need to adjust for $2^{(m+n-2)/2}$ where $m$ and $n$ are the number of in and out legs of the pink X spider 2: The ZXWDiagram representing the integral will be a factor of $1/2$ instead of $1/2\pi$ off from $\int_{0}^{2} \square d\theta$ where $\square$ represents the ZXDiagram calculating expectation value. This is because the spiders we used have rotation angles in units of $\pi$ not radians .

A merge of this PR should close #76 and #16

exAClior commented 1 year ago

Need to fix #97