#[repr(C)]pub struct CNativeGateSet {
pub translate: fn(gate_json: *const c_char, target: usize, native_gate_json: &mut *const c_char) -> i32,
pub cnot: fn(control: usize, target: usize, native_gate_json: &mut *const c_char) -> i32,
}Expand description
FFI-compatible function-pointer table for translating abstract gates into backend-native instructions.
The compiler calls these callbacks during the decomposition and routing passes to convert high-level gate representations into the instruction set understood by the target hardware or simulator.
Construct a CNativeGateSet value on the C side, fill in all function
pointers, then pass it to ket_quantum_execution_batch. Passing NULL
instead uses identity translation (no decomposition).
All callbacks must return 0 on success or a non-zero libket error code on
failure.
Fields§
§translate: fn(gate_json: *const c_char, target: usize, native_gate_json: &mut *const c_char) -> i32Translate a single-qubit gate (given as a 2×2 unitary matrix) into native gate instructions.
gate_json is a null-terminated JSON string encoding the gate as a
flat 2×2 complex matrix [[re,im,re,im],[re,im,re,im]]. target is
the target qubit index. On success *native_gate_json is set to a
heap-allocated null-terminated JSON string encoding the native gate
sequence. Returns 0 on success.
cnot: fn(control: usize, target: usize, native_gate_json: &mut *const c_char) -> i32Produce the native gate sequence that implements a CNOT between two qubits.
The first argument is the control qubit index and the second is the
target qubit index. On success *native_gate_json is set to a
heap-allocated null-terminated JSON string encoding the native CNOT
decomposition. Returns 0 on success.
Trait Implementations§
Source§impl Clone for CNativeGateSet
impl Clone for CNativeGateSet
Source§fn clone(&self) -> CNativeGateSet
fn clone(&self) -> CNativeGateSet
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for CNativeGateSet
impl Debug for CNativeGateSet
Auto Trait Implementations§
impl Freeze for CNativeGateSet
impl RefUnwindSafe for CNativeGateSet
impl Send for CNativeGateSet
impl Sync for CNativeGateSet
impl Unpin for CNativeGateSet
impl UnsafeUnpin for CNativeGateSet
impl UnwindSafe for CNativeGateSet
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more