Skip to main content

ket_process_sample

Function ket_process_sample 

Source
#[unsafe(no_mangle)]
pub extern "C" fn ket_process_sample( process: &mut Process, qubits: *const usize, qubits_len: usize, shots: usize, sample_json: &mut *const c_char, ) -> i32
Expand description

Requests a measurement sample of qubits over shots repetitions.

In live mode, the circuit is executed immediately and the result is returned as a heap-allocated JSON string (caller must free with super::ket_string_delete). In batch mode, the request is recorded for the next ket_process_execute call and *sample_json is set to a JSON null string; the actual data becomes available after execution and can be retrieved with ket_process_read_sample.

§Parameters

  • process: The process on which the sample is requested.
  • qubits: Pointer to an array of qubit indices to sample.
  • qubits_len: Number of elements in qubits.
  • shots: Number of repetitions.
  • sample_json: Output: set to a pointer to a heap-allocated null-terminated JSON string (caller must free with super::ket_string_delete).

§Returns

0 on success, non-zero error code on failure.