Skip to content

Commit

Permalink
feat: ToffoliBox encoding
Browse files Browse the repository at this point in the history
  • Loading branch information
aborgna-q committed Feb 23, 2024
1 parent c1f6767 commit 8c69cb2
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 0 deletions.
21 changes: 21 additions & 0 deletions src/circuit_json.rs
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,17 @@ pub enum OpBox {
#[serde(default = "default_impl_diag")]
impl_diag: bool,
},
/// An operation that constructs a circuit to implement the specified
/// permutation of classical basis states.
ToffoliBox {
id: BoxID,
/// The classical basis state permutation.
permutation: Permutation,
strat: ToffoliBoxSynthStrat,
#[serde(skip_serializing_if = "Option::is_none")]
#[serde(default)]
rotation_axis: Option<OpType>,
},
}

fn default_impl_diag() -> bool {
Expand Down Expand Up @@ -280,3 +291,13 @@ impl<P> Operation<P> {
}
}
}

/// Strategies for synthesising ToffoliBoxes.
#[derive(Deserialize, Serialize, Clone, Debug, PartialEq)]
#[non_exhaustive]
pub enum ToffoliBoxSynthStrat {
/// Use multiplexors to perform parallel swaps on hypercubes.
Matching,
/// Use CnX gates to perform transpositions.
Cycle,
}
3 changes: 3 additions & 0 deletions src/optype.rs
Original file line number Diff line number Diff line change
Expand Up @@ -418,6 +418,9 @@ pub enum OpType {

/// See \ref MultiplexedU2Box
MultiplexedU2Box,

/// See \ref ToffoliBox
ToffoliBox,
}

#[cfg(feature = "pyo3")]
Expand Down

0 comments on commit 8c69cb2

Please sign in to comment.