Dimension of the gate's matrix, which corresponds to the number of basis states in the Hilbert space it acts upon. For a gate acting on n qubits, the size is 2^n.
This property is computed dynamically from the matrix dimensions, ensuring that the reported size is always consistent with the matrix.
The number of rows (which equals the number of columns) in the gate matrix.
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.
Readonly
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.
Hadamard gate - creates superposition. H = (1/√2) * [1 1; 1 -1]