dakk / qlasskit

A python-to-quantum compiler
https://dakk.github.io/qlasskit/
Apache License 2.0
56 stars 11 forks source link

Pow operator #23

Closed dakk closed 4 months ago

dakk commented 6 months ago

Implement the ast.Pow operator () between a variable and an integer constant. Since a n == a a ... * a, we implement this operator with a rewriting rule in ast2ast.

The rewriting rule should be placed in the class AstRewriter (https://github.com/dakk/qlasskit/blob/master/qlasskit/ast2ast.py#L137), overriding the method visit_Pow, and rewriting the pow as multiplications.

Please read CONTRIBUTING.md before contributing.

Youngcius commented 4 months ago

I would like to try to solve this issue @dakk Could you assign that to me

dakk commented 4 months ago

@Youngcius according to rules, an Issue is assigned to a contributor if contributor's PR gets successfully approved by the maintainer. I'm sorry for the confusion.

Youngcius commented 4 months ago

I see! Thanks for your info

dakk commented 4 months ago

@tomv42 thank you for the contribution, I merged the pull request after I made just a tiny edit, by using Qtype.fill instead of pad_operand (https://github.com/dakk/qlasskit/commit/d8b299efc40205cc1f6a75a39b9cc192fcc092d0).

Please comment this issue so I'm able to assign it to you.

tomv42 commented 4 months ago

@dakk Thanks for merging the pull request! I enjoyed working on it and found the project very interesting.

dakk commented 4 months ago

Great to hear that, if you will encounter a situation where qlasskit could be useful, please suggest or use it!

If you want, there are other open issues for the unitary hack: https://unitaryhack.dev/projects/qlasskit/