Package com.quantum4j.core.gates
Class ThreeQubitGate
java.lang.Object
com.quantum4j.core.gates.ThreeQubitGate
- All Implemented Interfaces:
Gate
- Direct Known Subclasses:
CCXGate,StandardGates.CCXGate
Abstract base class for three-qubit gates.
A three-qubit gate is represented by an 8×8 complex matrix in the local basis:
|q0 q1 q2⟩ = |000⟩, |001⟩, ..., |111⟩
where q0, q1, q2 are exactly the three qubit indices passed to
apply(StateVector, int, int, int) in that order.
This avoids internal reordering and preserves correct semantics for
asymmetric gates like CCX (Toffoli) where the position of controls and
target matters.-
Field Summary
Fields -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedThreeQubitGate(Complex[][] matrix) Construct a three-qubit gate with the given 8×8 matrix. -
Method Summary
Modifier and TypeMethodDescriptionvoidapply(StateVector state, int q0, int q1, int q2) Apply this gate to qubits (q0, q1, q2) in that logical order.intarity()Get the arity (number of qubits) this gate acts upon.
-
Field Details
-
matrix
8×8 unitary matrix in local ordering |q0 q1 q2⟩.
-
-
Constructor Details
-
ThreeQubitGate
Construct a three-qubit gate with the given 8×8 matrix.- Parameters:
matrix- an 8×8 complex matrix
-
-
Method Details
-
arity
public int arity()Description copied from interface:GateGet the arity (number of qubits) this gate acts upon. -
apply
Apply this gate to qubits (q0, q1, q2) in that logical order. Local basis index mapping: local index k = (b0 << 2) | (b1 << 1) | b2 where b0, b1, b2 are the bits of (q0, q1, q2) respectively.
-