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.
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Implement RGate in Rust #12662
Implement RGate in Rust #12662
Changes from 1 commit
2a064bd
a034be5
7eef0f3
49c8dcd
043133f
07fec37
bff9fef
File filter
Filter by extension
Conversations
Jump to
There are no files selected for viewing
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this could be more readable if we used helper functions like
multiply_param
, and maybe add one for adding a scalar to a parameter in the same fashion. But I am fine merging the implementation as-is and beautifying it later.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My first iteration did not fit with the helper function, nor one for
add
. But it's changed a lot since I last tried. I'll revisit it; readability and encapsulation is important.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I did something similar to your suggest in
49c8dcd
(#12662). This factors out cloning aParam
. This is only used once now, but can be used whenever aParam
needs to be cloned. I find the code much more readable at the call point.Regarding factoring out
add_param
: There are pros and cons to doing this. Disadvantages: The branch with-*phi + PI / 2.0
is more readable if it is not nested calls. In fact, this made it slightly easier for me to spot the error-*phi + 1.0
.Another one is that it requires two match statements rather than one, so
-*phi + PI / 2.0
won't be optimized. I'm not sure, but I doubt this will matter in the future for performance.But, I'm on the fence. Currently, the second match arm would be much more readable with your suggestion. I can implement and use
add_param
quickly if you prefer. I'm inclined to do it just to look at it.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Implemented your suggestion in
07fec37
(#12662). I'm not 100% sure there isn't a non-negligible efficiency hit. But I think it's easier to read and will be easier to build on.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see your point, I think we could merge the code as-is and once all Rust standard gates are in place, maybe run the benchmarks with/without
add_param
to see if there is indeed a significant performance hit.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why add the
r
gate to the SKIP_LIST? All others haven't been implemented yet, butr
has an implementation.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good question. I added and removed several times while debugging. I'll recheck.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed in
7eef0f3
(#12662). It failed because the decomposition had an error.