mimiqcircuits.classical.and_operation¶
Classes
|
Bitwise AND of classical bits, written to a classical bit. |
- class And(N=3)[source]¶
Bases:
AbstractClassicalBitwise AND of classical bits, written to a classical bit.
And(N)acts onNbits: the first is the destination and the otherN - 1are the inputs. The destination is set to 1 only if all inputs are 1. The destination may also be one of the inputs, which updates it in place.- Parameters:
N (int) – Total number of bits, destination included. At least 3; defaults to 3.
- Raises:
ValueError – If
Nis less than 3.
Examples
>>> from mimiqcircuits import * >>> # placeholders show the destination ?0 and the inputs >>> And() c[?0] = c[?1] & c[?2] >>> And(8) c[?0] = & @ c[?1:?7] >>> # c[0] = c[2] & c[3] >>> 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]
- __init__(N=3)[source]¶
Create an And on
Nbits: one destination andN - 1inputs.- Raises:
ValueError – If
Nis less than 3.