Skip to main content

ket_process_exp_value

Function ket_process_exp_value 

Source
#[unsafe(no_mangle)]
pub extern "C" fn ket_process_exp_value( process: &mut Process, hamiltonian_json: *const c_char, result: &mut f64, some_result: &mut bool, ) -> i32
Expand description

Requests the expectation value computation for a given Hamiltonian (passed as JSON) on a Process.

In live mode, the expectation value is computed immediately: *some_result is set to true and the value is written to *result. In batch mode, the request is recorded for the next ket_process_execute call: *some_result is set to false and *result is left unmodified until execution completes and ket_process_read_exp_value is called.

§Parameters

  • process: The process on which the expectation value is computed.
  • hamiltonian_json: A null-terminated JSON string encoding the Hamiltonian.
  • result: Output: the computed expectation value (valid only when *some_result is true).
  • some_result: Output: set to true if the expectation value was computed immediately (live mode), or false if the request was deferred (batch mode).

§Returns

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