Skip to content

Commit

Permalink
Add support for more operations.
Browse files Browse the repository at this point in the history
  • Loading branch information
cqc-alec committed Nov 14, 2024
1 parent e0be2a1 commit bba9d6d
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions pytket/pytket/circuit/decompose_classical.py
Original file line number Diff line number Diff line change
Expand Up @@ -338,16 +338,32 @@ def decompose_expr(self, expr: ClExpr, out_var: Variable | None) -> Variable:
match op:
case ClOp.BitAnd:
self.circ.add_c_and(*terms, out_var, **self.kwargs)
case ClOp.BitNot:
self.circ.add_c_not(*terms, out_var, **self.kwargs)
case ClOp.BitOne:
self.circ.add_c_setbits([True], [out_var], **self.kwargs)
case ClOp.BitOr:
self.circ.add_c_or(*terms, out_var, **self.kwargs)
case ClOp.BitXor:
self.circ.add_c_xor(*terms, out_var, **self.kwargs)
case ClOp.BitZero:
self.circ.add_c_setbits([False], [out_var], **self.kwargs)
case ClOp.RegAnd:
self.circ.add_c_and_to_registers(*terms, out_var, **self.kwargs)
case ClOp.RegNot:
self.circ.add_c_not_to_registers(*terms, out_var, **self.kwargs)
case ClOp.RegOne:
self.circ.add_c_setbits(
[True] * out_var.size, out_var.to_list(), **self.kwargs
)
case ClOp.RegOr:
self.circ.add_c_or_to_registers(*terms, out_var, **self.kwargs)
case ClOp.RegXor:
self.circ.add_c_xor_to_registers(*terms, out_var, **self.kwargs)
case ClOp.RegZero:
self.circ.add_c_setbits(
[False] * out_var.size, out_var.to_list(), **self.kwargs
)
case _:
raise DecomposeClassicalError(
f"{op} cannot be decomposed to TKET primitives."
Expand Down

0 comments on commit bba9d6d

Please sign in to comment.