mimiqcircuits.classical¶
Classical operations and utilities.
- class mimiqcircuits.classical.SetBit0[source]¶
Bases:
AbstractClassicalSetBit0 operation.
Classical operation that sets a classical bit to 0. 0 → 0 and 1 → 0.
Examples
>>> from mimiqcircuits import * >>> not_op = SetBit0() >>> not_op.name 'set0' >>> c = Circuit() >>> c.push(SetBit0(), 1) 2-bit circuit with 1 instruction: └── c[1] = 0
- class mimiqcircuits.classical.SetBit1[source]¶
Bases:
AbstractClassicalSetBit1 operation.
Classical operation that sets a classical bit to 1. 0 → 1 and 1 → 1.
Examples
>>> from mimiqcircuits import * >>> not_op = SetBit1() >>> not_op.name 'set1' >>> c = Circuit() >>> c.push(SetBit1(), 1) 2-bit circuit with 1 instruction: └── c[1] = 1
- class mimiqcircuits.classical.Not[source]¶
Bases:
AbstractClassicalNot operation.
Represents a NOT operation that can be added to quantum circuits. Classical operation that flips a classical bit: 0 → 1 and 1 → 0.
Examples
>>> from mimiqcircuits import * >>> not_op = Not() >>> not_op.name '!' >>> c = Circuit() >>> c.push(Not(), 1) 2-bit circuit with 1 instruction: └── c[1] = !c[1]
- class mimiqcircuits.classical.And(N=3)[source]¶
Bases:
AbstractClassicalComputes the bitwise AND of N-1 classical bits and stores the result in the first given bit.
Examples
>>> from mimiqcircuits import * >>> And() c[?0] = c[?1] & c[?2] >>> And(8) c[?0] = & @ c[?1:?7] >>> c = Circuit() >>> c.push(And(), 0, 2, 3) 4-bit circuit with 1 instruction: └── c[0] = c[2] & c[3] >>> c = Circuit() >>> c.push(And(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(And(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]
- class mimiqcircuits.classical.Or(N=3)[source]¶
Bases:
AbstractClassicalComputes the bitwise OR of N-1 classical bits and stores the result in the first given bit.
Examples
>>> from mimiqcircuits import * >>> Or() c[?0] = c[?1] | c[?2] >>> Or(8) c[?0] = | @ c[?1:?7] >>> c = Circuit() >>> c.push(Or(), 0, 2, 3) 4-bit circuit with 1 instruction: └── c[0] = c[2] | c[3] >>> c = Circuit() >>> c.push(Or(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(Or(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]
- class mimiqcircuits.classical.Xor(N=3)[source]¶
Bases:
AbstractClassicalComputes 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]
- class mimiqcircuits.classical.ParityCheck(N=3)[source]¶
Bases:
AbstractClassicalPerforms 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]
Modules