dakk / qlasskit

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

Shift and Add multiplication for constants #36

Closed dakk closed 5 months ago

dakk commented 6 months ago

When we have bin operations with a constant operator, it is sometime possible to do some optimization.

For instance if we want to multiply and diving two numbers, and one operand is a constant, we can achieve it using shift and add multiplication algorithm (https://youtu.be/acUH4lWe2NQ?si=H7GAS241CZuyBe3C&t=880)

We need to refactor the type abastraction in order to have mul (a times b) and mul_c (a times Const), etc; or we can extend mul() to handle different case; or we can call simplify logic directly in operations.

We need a Qtype.is_const #37 to check if a Qtype is constant (only contains False/True).