#[repr(C)]pub struct CBatchExecution {
pub sample: fn(gates_json: *const c_char, qubits_to_sample: *const usize, qubits_to_sample_len: usize, shots: usize, sample_json: &mut *const c_char) -> i32,
pub exp_value: fn(gates_json: *const c_char, hamiltonian_list_json: *const c_char, result: *mut f64) -> i32,
pub sample_native: fn(gates_json: *const c_char, qubits_to_sample: *const usize, qubits_to_sample_len: usize, shots: usize, sample_json: &mut *const c_char) -> i32,
pub exp_value_native: fn(gates_json: *const c_char, hamiltonian_list_json: *const c_char, result: *mut f64) -> i32,
pub gradient: fn(gates_json: *const c_char, hamiltonian_list_json: *const c_char, exp_result: &mut f64, grad_json: &mut *const c_char) -> i32,
}Expand description
FFI-compatible function-pointer table for a batch execution backend.
In batch mode the entire compiled circuit is serialized and handed to the
backend in a single call when ket_process_execute is invoked, rather than
dispatching gate-by-gate.
Construct a CBatchExecution value on the C side, fill in all function
pointers, then call ket_quantum_execution_batch to create the
corresponding QuantumExecution variant.
All callbacks must return 0 on success or a non-zero libket error code on
failure.
Fields§
§sample: fn(gates_json: *const c_char, qubits_to_sample: *const usize, qubits_to_sample_len: usize, shots: usize, sample_json: &mut *const c_char) -> i32§exp_value: fn(gates_json: *const c_char, hamiltonian_list_json: *const c_char, result: *mut f64) -> i32§sample_native: fn(gates_json: *const c_char, qubits_to_sample: *const usize, qubits_to_sample_len: usize, shots: usize, sample_json: &mut *const c_char) -> i32§exp_value_native: fn(gates_json: *const c_char, hamiltonian_list_json: *const c_char, result: *mut f64) -> i32§gradient: fn(gates_json: *const c_char, hamiltonian_list_json: *const c_char, exp_result: &mut f64, grad_json: &mut *const c_char) -> i32Trait Implementations§
Source§impl BatchExecution for CBatchExecution
impl BatchExecution for CBatchExecution
Source§fn sample(
&self,
gates: &[GateInstruction],
qubits_to_sample: &[usize],
shots: usize,
) -> Result<SampleData, KetError>
fn sample( &self, gates: &[GateInstruction], qubits_to_sample: &[usize], shots: usize, ) -> Result<SampleData, KetError>
Executes
gates and samples the state of qubits_to_sample over
shots shots, receiving gates in the Libket IR format. Read moreSource§fn exp_value(
&self,
gates: &[GateInstruction],
hamiltonian_list: &[Hamiltonian],
) -> Result<Vec<f64>, KetError>
fn exp_value( &self, gates: &[GateInstruction], hamiltonian_list: &[Hamiltonian], ) -> Result<Vec<f64>, KetError>
Executes
gates and computes the expectation value of each Hamiltonian
in hamiltonian_list, receiving gates in the Libket IR format. Read moreSource§fn sample_native(
&self,
gates: &[NativeGate],
qubits_to_sample: &[usize],
shots: usize,
) -> Result<SampleData, KetError>
fn sample_native( &self, gates: &[NativeGate], qubits_to_sample: &[usize], shots: usize, ) -> Result<SampleData, KetError>
Executes
gates and samples the state of qubits_to_sample over
shots shots, receiving pre-translated native gates. Read moreSource§fn exp_value_native(
&self,
gates: &[NativeGate],
hamiltonian_list: &[Hamiltonian],
) -> Result<Vec<f64>, KetError>
fn exp_value_native( &self, gates: &[NativeGate], hamiltonian_list: &[Hamiltonian], ) -> Result<Vec<f64>, KetError>
Executes
gates and computes the expectation value of each Hamiltonian
in hamiltonian_list, receiving pre-translated native gates. Read moreSource§impl Clone for CBatchExecution
impl Clone for CBatchExecution
Source§fn clone(&self) -> CBatchExecution
fn clone(&self) -> CBatchExecution
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreAuto Trait Implementations§
impl Freeze for CBatchExecution
impl RefUnwindSafe for CBatchExecution
impl Send for CBatchExecution
impl Sync for CBatchExecution
impl Unpin for CBatchExecution
impl UnsafeUnpin for CBatchExecution
impl UnwindSafe for CBatchExecution
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
Mutably borrows from an owned value. Read more
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>
Converts
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>
Converts
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