Skip to content

Add quantum phase estimation in the list of algorithms #276

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

Merged
merged 8 commits into from
May 3, 2025

Conversation

rochisha0
Copy link
Contributor

@rochisha0 rochisha0 commented Apr 12, 2025

Adding quantum phase estimation in the list of algorithms. Issue #264

@rochisha0
Copy link
Contributor Author

@BoxiLi is there a controlled U operator in QuTiP?

@BoxiLi
Copy link
Member

BoxiLi commented Apr 12, 2025

You can define a controlled gate object and add the object

class ControlledGate(Gate):
def __init__(
self, controls, targets, control_value, target_gate, **kwargs
):
super().__init__(
controls=controls,
targets=targets,
control_value=control_value,
target_gate=target_gate,
**kwargs,
)
self.controls = (
[controls] if not isinstance(controls, list) else controls
)
self.control_value = control_value
self.target_gate = target_gate
self.kwargs = kwargs
# In the circuit plot, only the target gate is shown.
# The control has its own symbol.
self.latex_str = target_gate(
targets=self.targets, **self.kwargs
).latex_str
def get_compact_qobj(self):

@rochisha0 rochisha0 marked this pull request as ready for review April 19, 2025 15:38
@rochisha0
Copy link
Contributor Author

@BoxiLi this is ready for review

Copy link
Member

@BoxiLi BoxiLi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks pretty good! Thanks a lot!

You can run black on qpe.py and test_qpe.py to clean the style. Codeclimate may have some additional complain such as trailing white space. You don't have to clean all of the code climate issues, if some of them become too tedious or irrelevant to the changes.

@BoxiLi
Copy link
Member

BoxiLi commented May 2, 2025

There are some inconsistencies in the last change. Should be easy fix, other than that I believe this is ready to be merged.

@rochisha0
Copy link
Contributor Author

Done @BoxiLi !

@BoxiLi BoxiLi merged commit a6d68ca into qutip:master May 3, 2025
13 checks passed
@BoxiLi
Copy link
Member

BoxiLi commented May 3, 2025

Thanks! @rochisha0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants