Make the Scalar class compatible with symbolic phases #355
+123
−40
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Please merge after #354
This PR modifies scalar.py to support symbolic phases. As such, it removes any explicit calculation of the complex scalar outside the dedicated
to_number
method.The main change is due to the
add_spider_pair
method. The scalar added by this method is1 + e^(i pi p1) + e^(i pi p2) - e^(i pi (p1+p2))
where p1 and p2 are phases of the two spiders. In the case when p1 and p2 are both non-clifford, there is no way of writing this scalar usingscalar.phase
andscalar.phase_node
. So we introduce a new variablescalar.sum_of_phases
which represents the term(c1*exp(i*phase1) + ... + cn*exp(i*phaseN))
as a dictionary mapping phase->coeffecient. Rest of the changes are in support of adding thesum_of_phases
variable.