Expand description
SIMD-accelerated single-qubit gate kernels for state vector simulation.
This module provides a high-level public API for applying individual quantum gates
directly to Vec<Complex64> state vectors. It owns the gather/scatter logic
internally so callers do not need to split amplitudes into separate in_amps0 /
in_amps1 buffers themselves.
Internally the implementations delegate to the existing
crate::optimized_simd SIMD primitives (backed by
scirs2_core::simd_ops::SimdUnifiedOps) for all vector arithmetic, with
a scalar fallback for small state vectors (< 256 amplitudes, i.e. < 8 qubits).
§Usage example
use quantrs2_sim::state_vector_simd::{apply_h_simd, apply_x_simd};
use scirs2_core::Complex64;
let n_qubits = 4usize;
let mut state = vec![Complex64::new(0.0, 0.0); 1 << n_qubits];
state[0] = Complex64::new(1.0, 0.0); // |0000⟩
apply_h_simd(&mut state, 0, n_qubits); // qubit 0 → |+⟩
apply_x_simd(&mut state, 1, n_qubits); // qubit 1 → |1⟩ (CNOT-like)These SIMD kernels are provided as a standalone module and can be called
directly. Integration into the main StateVectorSimulator dispatch already
exists in statevector.rs via apply_single_qubit_gate_simd; this module
adds the named, standalone API surface (see also TODO.md).
Functions§
- apply_
gate_ 2x2_ scalar - Pure-scalar application of a 2×2 unitary
matrixto qubittarget. - apply_
gate_ 2x2_ simd - Apply a generic 2×2 unitary gate to qubit
targetusing SIMD acceleration. - apply_
h_ simd - Apply the Hadamard gate H to qubit
targetusing SIMD. - apply_
rx_ simd - Apply the RX(theta) rotation gate to qubit
targetusing SIMD. - apply_
ry_ simd - Apply the RY(theta) rotation gate to qubit
targetusing SIMD. - apply_
rz_ simd - Apply the RZ(theta) rotation gate to qubit
targetusing SIMD. - apply_
s_ simd - Apply the S (phase) gate to qubit
targetusing SIMD. - apply_
t_ simd - Apply the T gate to qubit
targetusing SIMD. - apply_
x_ simd - Apply the Pauli-X (NOT) gate to qubit
targetusing SIMD. - apply_
y_ simd - Apply the Pauli-Y gate to qubit
targetusing SIMD. - apply_
z_ simd - Apply the Pauli-Z gate to qubit
targetusing SIMD. - simd_
available - Returns
truewhen SIMD acceleration is available at runtime on this CPU.