View source on GitHub |
Checksum code for either even or odd Hamming weight.
openfermion.transforms.checksum_code(
n_modes: int, odd: Union[int, bool]
) -> openfermion.ops.BinaryCode
The Hamming weight is defined such that it yields the total occupation number for a given basis state. A Checksum code with odd weight will encode all states with odd occupation number. This code saves one qubit: n_qubits = n_modes - 1.
Args | |
---|---|
n_modes
|
int
number of modes |
odd
|
int or bool
1 (True) or 0 (False), if odd, we encode all states with odd Hamming weight |
Returns (BinaryCode): The checksum BinaryCode