majority_gate(a: int, b: int, c: int, in_x_basis: bool = False) → pyquil.quil.Program¶
The majority gate.
Computes (a * b) xor (a * c) xor (b * c) where * is multiplication mod 2.
The default option is to compute this in the computational (aka Z) basis. If in_x_basis is true then the computation is instead in the X basis, i.e. CNOT is replaced by CNOT_X_basis and CCNOT is replaced by CCNOT_X_basis
See [CDKM96] reference in ripple_carry_adder.adder() docstring
- a – qubit label
- b – qubit label
- c – qubit label
- in_x_basis – if true, the returned program performs the equivalent logic in the X basis.
program which results in (c xor a) on the c line, (b xor a) on the b line, and the output (majority of the inputs) on the a line.