Gets the matrix dimension (2^numQubits) for this multi-qubit gate.
Matrix size: 2^n where n is the number of qubits
Creates a new Global Phase gate.
Number of qubits in the system
Phase angle in radians to apply globally
Optional
name: stringOptional custom name for the gate (defaults to 'E')
Gets the phase angle applied by this gate.
Phase angle in radians
Static
fromCreates a GlobalPhaseGate with specified angle.
Number of qubits in the system
Phase angle in radians
Optional
name: stringOptional custom name
New GlobalPhaseGate instance
Static
fromCreates a GlobalPhaseGate with phase as multiple of π.
Number of qubits in the system
Phase as multiple of π (e.g., 0.5 for π/2)
Optional
name: stringOptional custom name
New GlobalPhaseGate instance
Applies this quantum gate to a quantum state.
This is the primary, high-level method for quantum gate application. It transforms pure quantum states represented as state vectors through unitary matrix operations, ensuring proper quantum mechanical evolution.
The method creates a Q5mOperator from the gate's matrix and applies it to the quantum state using the state's apply() method.
This ensures proper quantum mechanical evolution while maintaining
type safety and performance optimizations specific to state vectors.
The complexity of this operation depends on the state's representation
(dense or sparse) but is generally O(2^n)
for an n-qubit gate on an n-qubit state.
The quantum state to be transformed. Its dimension must match the gate's size.
The transformed quantum state after the gate has been applied.
Applies this quantum gate directly to a state vector representation of a quantum state.
This method provides low-level access for direct state vector manipulation, performing the matrix-vector multiplication U|ψ⟩. It is primarily used internally by simulators and for compatibility with legacy code that operates directly on arrays of complex numbers.
This method performs the fundamental quantum gate operation by multiplying
the gate's unitary matrix with the input state vector. It validates that
the state vector has the correct dimension before applying the transformation.
The complexity of this operation is O(N^2)
where N is the size of the state vector.
This is the core mathematical operation underlying all quantum gate applications. The operation preserves fundamental quantum mechanical properties:
The quantum state vector (an array of quantum amplitudes) to transform.
The transformed state vector after gate application.
Returns a string representation of this quantum gate.
The string representation uses the gate's name
property, making it
useful for debugging, logging, circuit visualization, and serialization.
The gate's name as a string.
Protected
numReadonly
nameHuman-readable name of the quantum gate (e.g., "H", "CNOT", "RZ"). This name is used for debugging, logging, and circuit visualization. It should be a concise and descriptive identifier for the gate's operation. Must be implemented by all concrete gate subclasses.
Readonly
matrixUnitary matrix representation of the quantum gate. This matrix defines how the gate transforms quantum states according to the Schrödinger equation's evolution: |ψ'⟩ = U|ψ⟩. The matrix must be square and unitary (U†U = I) to ensure valid, reversible quantum operations that conserve probability. Must be implemented by all concrete gate subclasses.
Global Phase Gate - applies uniform phase e^(iφ) to entire quantum state.
The GlobalPhaseGate multiplies every amplitude in the quantum state by the same phase factor e^(iφ). While global phases are physically unobservable (they don't affect measurement probabilities), they are important for:
Matrix Representation:
where I_n is the n-qubit identity matrix (size 2^n × 2^n).
Effect on State:
All basis state amplitudes are multiplied by the same phase factor.
Applications: