Skip to content

Commit

Permalink
! remove Tk1, add Ry and Toffoli
Browse files Browse the repository at this point in the history
  • Loading branch information
ss2165 committed Sep 3, 2024
1 parent 541c253 commit 1c1e464
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 20 deletions.
3 changes: 2 additions & 1 deletion tket2-py/tket2/ops.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,9 @@ class Tk2Op(Enum):
Measure = auto()
Rz = auto()
Rx = auto()
Ry = auto()
Toffoli = auto()
CZ = auto()
TK1 = auto()
QAlloc = auto()
QFree = auto()
Reset = auto()
Expand Down
29 changes: 12 additions & 17 deletions tket2/src/ops.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,18 +43,19 @@ use crate::extension::REGISTRY;
pub enum Tk2Op {
H,
CX,
CZ,
T,
Tdg,
S,
Sdg,
X,
Y,
Z,
Tdg,
Sdg,
Measure,
Rz,
Rx,
CZ,
TK1,
Ry,
Rz,
Toffoli,
Measure,
QAlloc,
QFree,
Reset,
Expand Down Expand Up @@ -107,18 +108,12 @@ impl MakeOpDef for Tk2Op {
fn signature(&self) -> SignatureFunc {
use Tk2Op::*;
let one_qb_row = type_row![QB_T];
let two_qb_row = type_row![QB_T, QB_T];
match self {
H | T | S | X | Y | Z | Tdg | Sdg | Reset => {
Signature::new(one_qb_row.clone(), one_qb_row)
}
CX | CZ => Signature::new(two_qb_row.clone(), two_qb_row),
H | T | S | X | Y | Z | Tdg | Sdg | Reset => Signature::new_endo(one_qb_row),
CX | CZ => Signature::new_endo(type_row![QB_T; 2]),
Toffoli => Signature::new_endo(type_row![QB_T; 3]),
Measure => Signature::new(one_qb_row, type_row![QB_T, BOOL_T]),
Rz | Rx => Signature::new(type_row![QB_T, FLOAT64_TYPE], one_qb_row),
TK1 => Signature::new(
type_row![QB_T, FLOAT64_TYPE, FLOAT64_TYPE, FLOAT64_TYPE],
one_qb_row,
),
Rz | Rx | Ry => Signature::new(type_row![QB_T, FLOAT64_TYPE], one_qb_row),
QAlloc => Signature::new(type_row![], one_qb_row),
QFree => Signature::new(one_qb_row, type_row![]),
}
Expand Down Expand Up @@ -170,7 +165,7 @@ impl Tk2Op {
pub fn is_quantum(&self) -> bool {
use Tk2Op::*;
match self {
H | CX | T | S | X | Y | Z | Tdg | Sdg | Rz | Rx | CZ | TK1 => true,
H | CX | T | S | X | Y | Z | Tdg | Sdg | Rz | Rx | Toffoli | Ry | CZ => true,
Measure | QAlloc | QFree | Reset => false,
}
}
Expand Down
6 changes: 4 additions & 2 deletions tket2/src/serialize/pytket/op/native.rs
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,8 @@ impl NativeOp {
Tk2Op::Sdg => Tk1OpType::Sdg,
Tk2Op::Rz => Tk1OpType::Rz,
Tk2Op::Rx => Tk1OpType::Rx,
Tk2Op::TK1 => Tk1OpType::TK1,
Tk2Op::Ry => Tk1OpType::Ry,
Tk2Op::Toffoli => Tk1OpType::CCX,
Tk2Op::CZ => Tk1OpType::CZ,
Tk2Op::Reset => Tk1OpType::Reset,
Tk2Op::Measure => Tk1OpType::Measure,
Expand Down Expand Up @@ -92,7 +93,8 @@ impl NativeOp {
Tk1OpType::Sdg => Tk2Op::Sdg.into(),
Tk1OpType::Rz => Tk2Op::Rz.into(),
Tk1OpType::Rx => Tk2Op::Rx.into(),
Tk1OpType::TK1 => Tk2Op::TK1.into(),
Tk1OpType::Ry => Tk2Op::Ry.into(),
Tk1OpType::CCX => Tk2Op::Toffoli.into(),
Tk1OpType::CZ => Tk2Op::CZ.into(),
Tk1OpType::Reset => Tk2Op::Reset.into(),
Tk1OpType::Measure => Tk2Op::Measure.into(),
Expand Down

0 comments on commit 1c1e464

Please sign in to comment.