Projective measurement with projectors $ P_m=\vert m\rangle\langle m\vert$

Note: Measurement has not yet been implemented for a mixed state. It works only for a pure state kept as a vector.

An available type of observable for a measurement in this software is currently only the type: $ M=\sum_mmP_m$ with $ P_m=\vert m\rangle\langle m\vert=
\vert x_ax_bx_c...\rangle\langle x_ax_bx_c...\vert$ where $ x_ax_bx_c...$ is a number written by using binary numbers ( $ x_i\in\{0,1\}$) and $ \vert x_ax_bx_c...\rangle$ are computational basis vectors of qubits whose labels are specified by a user.

  1. To specify the binary values to be measured (measurement result) (0 or 1) for measured qubits, use the command:
    M (bit labels, $ x_a~~x_b~~x_c~~... $);
    * The ``bit labels'' is a string in the style of ``1-6'' (qubit 1 to qubit 6) and/or ``1 3 5'' (qubit 1, 3, and 5). $ x_a~~x_b~~...$ is the string of the binary values to be measured for the qubits of ``bit labels''. You may type like this:
    M (1-8, 1 0 0 1 0 1 1 1);
    The qubits that are not measured will properly transit to the state after the measurement.
    Example for the read-line mode:
     > init 0 0;
     > H(1); CN(1,2);
     > showb;
    0.707107|00> + 0.707107|11>
     > M(1,0);
     > showb;
  2. When you do not specify the result of measurement, the measured qubits result in 0 or 1 with the corresponding probabilities. Such a transition is controlled by a random seed that is produced from the current local time of a computer. For an example, you may try the above example with the line
    instead of M(1,0);.