Parser support for halved parameters. #193
Merged
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.
Summary
This pull request extends the OpenQASM parser and code generator to support halved parameters.
Related Issues
This pull request should resolve issue #190.
Details
To parse gates with halved parameters, the following three changes are made to
QasmParser
.p[i]
is used in a context where parameters are not halved, then the parameter is scaled by2
. Formally, it is replaced byp[i] + p[i]
.1/2
.To print gates with halved parameters,
to_qasm_style_string
now scales constant halved parameters by a factor of2
.Evidently, these changes increase the complexity of symbolic parameter parsing. For this reason, the symbolic parameter parsing code has been factored out into its own method
ParamParser::parse_symb_param
. While testing these changes, it was noted thatParamParser::parse_symb_param
did not support negative parameters, which is also resolved in this pull request.Note
The current circuit generator does not support symbolic parameters. This pull request does not introduce this feature. However, an error message was added to indicate when a symbolic parameter could possibly get discarded.