qlasskit icon indicating copy to clipboard operation
qlasskit copied to clipboard

Pow operator

Open dakk opened this issue 1 year ago • 0 comments

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.

  • Check that n is an ast.Constant, positive integer
  • If overriding visit_Pow won't work, override visit_BinOp instead and check if the expression is a ast.Pow

Please read CONTRIBUTING.md before contributing.

dakk avatar Mar 16 '24 17:03 dakk