mimiqcircuits.classical.xor_operation

Classes

Xor([N])

Computes the bitwise XOR of N-1 classical bits and stores the result in the first given bit.

class mimiqcircuits.classical.xor_operation.Xor(N=3)[source]

Bases: AbstractClassical

Computes the bitwise XOR of N-1 classical bits and stores the result in the first given bit.

Examples

>>> from mimiqcircuits import *
>>> Xor()
c[?0] = c[?1] ^ c[?2]
>>> Xor(8)
c[?0] = ^ @ c[?1:?7]
>>> c = Circuit()
>>> c.push(Xor(), 0, 2, 3)
4-bit circuit with 1 instruction:
└── c[0] = c[2] ^ c[3]

>>> c = Circuit()
>>> c.push(Xor(5), 0, 1, 2, 3, 4)
5-bit circuit with 1 instruction:
└── c[0] = c[1] ^ c[2] ^ c[3] ^ c[4]

>>> c = Circuit()
>>> c.push(Xor(8), 0, 1, 2, 3, 4, 5, 6, 7)
8-bit circuit with 1 instruction:
└── c[0] = ^ @ c[1, 2, 3, 4, 5, 6, 7]
__init__(N=3)[source]

Initializes an Xor 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.