Gets the matrix dimension (2^numQubits) for this multi-qubit gate.
Matrix size: 2^n where n is the number of qubits
Optional
name: stringStatic
onOptional
name: stringStatic
onOptional
name: stringApplies 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.
Multi-Hadamard gate - applies Hadamard gates to specified qubit positions simultaneously.
This gate applies Hadamard transformations to multiple specified qubits in parallel, creating uniform superposition states across selected qubits. It's essential for quantum algorithms that require efficient preparation of superposition states.
For n total qubits and k target positions, creates tensor product: H ⊗ I ⊗ H ⊗ ... (Hadamard on targets, Identity elsewhere)
Matrix Structure: 2^n × 2^n with selective Hadamard transformations Complexity: More efficient than sequential Hadamard applications