Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: ToffoliBox encoding #28

Merged
merged 2 commits into from
Feb 26, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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>,
aborgna-q marked this conversation as resolved.
Show resolved Hide resolved
},
}

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
Loading