mimiqcircuits.classical.paritycheck

Classes

ParityCheck([N])

Performs a parity check on N-1 classical bits and stores the result in the first bit.

class mimiqcircuits.classical.paritycheck.ParityCheck(N=3)[source]

Bases: AbstractClassical

Performs a parity check on N-1 classical bits and stores the result in the first bit.

It computes the sum modulo 2 of the inputs.

Examples

>>> from mimiqcircuits import *
>>> ParityCheck()
c[?0] = ⨊ c[?1, ?2]
>>> ParityCheck(5)
c[?0] = ⨊ c[?1, ?2, ?3, ?4]
>>> c = Circuit()
>>> c.push(ParityCheck(), 0, 2, 3)
4-bit circuit with 1 instruction:
└── c[0] = ⨊ c[2, 3]

>>> c = Circuit()
>>> c.push(ParityCheck(5), 0, 1, 2, 3, 4)
5-bit circuit with 1 instruction:
└── c[0] = ⨊ c[1, 2, 3, 4]
__init__(N=3)[source]

Initializes a ParityCheck operation.

Parameters:

N – The total number of classical bits (1 destination + N-1 inputs). Must be 3 or greater. Defaults to 3.

iswrapper()[source]
__repr__()[source]

Returns the string representation of the operation with placeholders.

__str__()[source]

Returns the simple string name of the operation.

format_with_targets(qubits, bits, zvars)[source]

Formats the operation with its specific target bits.