[][src]Function qip::measurement_ops::soft_measure

pub fn soft_measure<P: Precision>(
    n: u64,
    indices: &[u64],
    input: &[Complex<P>],
    input_offset: Option<u64>,
    multithread: bool
) -> u64

Sample a measurement from a state input. b Sample from qubits at indices and return bits as u64 in order given by indices. See measure_prob for details.

Keep in mind that qubits are big-endian to match kron product standards. |abc> means q0=a, q1=b, q2=c

Examples

use qip::state_ops::from_reals;
use qip::measurement_ops::soft_measure;

// Make the state |10>, index 0 is always |1> and index 1 is always |0>
let input = from_reals(&[0.0, 0.0, 1.0, 0.0]);

let m = soft_measure(2, &[0], &input, None, false);
assert_eq!(m, 1);
let m = soft_measure(2, &[1], &input, None, false);
assert_eq!(m, 0);