Skip to content

Commit

Permalink
feat: add CZ op
Browse files Browse the repository at this point in the history
  • Loading branch information
ss2165 committed Sep 7, 2023
1 parent ef0ed54 commit 65659d0
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
2 changes: 2 additions & 0 deletions src/json/op.rs
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,7 @@ impl From<&JsonOp> for OpType {
JsonOpType::PhasedX => T2Op::PhasedX.into(),
JsonOpType::ZZMax => T2Op::ZZMax.into(),
JsonOpType::ZZPhase => T2Op::ZZPhase.into(),
JsonOpType::CZ => T2Op::CZ.into(),
JsonOpType::noop => LeafOp::Noop { ty: QB_T }.into(),
_ => LeafOp::CustomOp(Box::new(json_op.as_opaque_op())).into(),
}
Expand Down Expand Up @@ -219,6 +220,7 @@ impl TryFrom<&OpType> for JsonOp {
T2Op::PhasedX => JsonOpType::PhasedX,
T2Op::ZZMax => JsonOpType::ZZMax,
T2Op::ZZPhase => JsonOpType::ZZPhase,
T2Op::CZ => JsonOpType::CZ,
_ => return Err(err()),
}
} else if let LeafOp::CustomOp(b) = leaf {
Expand Down
5 changes: 3 additions & 2 deletions src/ops.rs
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ pub enum T2Op {
RxF64,
PhasedX,
ZZPhase,
CZ,
TK1,
}
#[derive(Clone, Copy, Debug, Serialize, Deserialize, EnumIter, Display, PartialEq, PartialOrd)]
Expand Down Expand Up @@ -121,7 +122,7 @@ impl SimpleOpEnum for T2Op {
let two_qb_row = type_row![QB_T, QB_T];
match self {
H | T | S | X | Y | Z | Tdg | Sdg => FunctionType::new(one_qb_row.clone(), one_qb_row),
CX | ZZMax => FunctionType::new(two_qb_row.clone(), two_qb_row),
CX | ZZMax | CZ => FunctionType::new(two_qb_row.clone(), two_qb_row),
ZZPhase => FunctionType::new(type_row![QB_T, QB_T, FLOAT64_TYPE], two_qb_row),
Measure => FunctionType::new(one_qb_row, type_row![QB_T, BOOL_T]),
RzF64 | RxF64 => FunctionType::new(type_row![QB_T, FLOAT64_TYPE], one_qb_row),
Expand Down Expand Up @@ -168,7 +169,7 @@ impl T2Op {
X | RxF64 => vec![(0, Pauli::X)],
T | Z | S | Tdg | Sdg | RzF64 | Measure => vec![(0, Pauli::Z)],
CX => vec![(0, Pauli::Z), (1, Pauli::X)],
ZZMax | ZZPhase => vec![(0, Pauli::Z), (1, Pauli::Z)],
ZZMax | ZZPhase | CZ => vec![(0, Pauli::Z), (1, Pauli::Z)],
// by default, no commutation
_ => vec![],
}
Expand Down

0 comments on commit 65659d0

Please sign in to comment.