BQSKit / bqskit

Berkeley Quantum Synthesis Toolkit
Other
106 stars 31 forks source link

Add missing `get_inverse` definitions #227

Open edyounis opened 4 months ago

edyounis commented 4 months ago

Many gates throughout the library are missing get_inverse and get_inverse_params definitions.

These functions are called when inverting an Operation. This is used to find the inverse of a circuit using natural gate definitions rather than a bunch of DaggerGate wrappers. This allows users to print qasm output easily after inverting a circuit without much manual intervention.

Take a look at the U3Gate for a complete example. The inverse is the same gate but with different parameters. So the get_inverse function returns the same gate (U3Gate), and the get_inverse_params returns the inverted parameters.

There is a catch-all implementation for all gates that defaults to the DaggerGate wrapper, and in many cases, this is not necessary. We should implement these functions for all gates in the library that have simple inverses.

Youngcius commented 1 month ago

@edyounis would you like to be assigned to this issue? I am glad to try to solve it.

edyounis commented 1 month ago

Hey I realized I only should have assigned this once completed.

Youngcius commented 1 month ago

Alright. I made a pull request "add feature get_inverse" just now that might need your review.