openfermion.transforms.checksum_code

Checksum code for either even or odd Hamming weight.

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.

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