set_representation
Method of Qbit.
set_representation(integer value) -> Qbit
Sets the integer representation of the Qbit.
This method makes use of the binary expansion of an integer to set the value of the qubits that appear in the product state. For example, the integer 0B1100 leads to the product state |0011>. Note that the bit values appear in reverse order in the Qbit object. The number of significant bits of the integer must not exceed the number of sites on which the Qbit object has support. For example Qbit(2).set_representation(0B1100) yields an error because the Qbit object has size 2, but 0B1100 requires 4 bits.
Parameters
- value: The integer whose binary expansion is used to set the states of the qubits in the product state.
Example
Qbit(4).set_representation(0B1100) // Returns (1 + 0i)|0011>
// Qbit(2).set_representation(0B1100) //Error "The integer 0B1100 requires 4 bits, which exceeds the number of sites 2 of the Qbit object."