/** * Sparse statevector over BigInt indices. * * State index bit layout: qubit 0 is bit 0 (LSB). Public-facing bitstrings * use the q0-leftmost convention where q0 is the leftmost character. * * Using BigInt eliminates the 32-bit overflow that silently wraps at qubit 30 * when using `1 << 31` in JavaScript. */ import { Complex } from './complex.js'; export type StateVector = Map; /** |0...0⟩ for n qubits. */ export declare const zero: (n: number) => StateVector; /** 2×2 unitary gate matrix: [[a, b], [c, d]]. */ export type Gate2x2 = [[Complex, Complex], [Complex, Complex]]; /** 4×4 unitary gate matrix. Row/column order: |00⟩, |01⟩, |10⟩, |11⟩ (qubit a = MSB). */ export type Gate4x4 = [ [ Complex, Complex, Complex, Complex ], [ Complex, Complex, Complex, Complex ], [ Complex, Complex, Complex, Complex ], [ Complex, Complex, Complex, Complex ] ]; /** * Apply a single-qubit gate to qubit q. * * For each pair of basis states |x₀⟩ (bit q = 0) and |x₁⟩ (bit q = 1): * new[x₀] = a·old[x₀] + b·old[x₁] * new[x₁] = c·old[x₀] + d·old[x₁] */ export declare function applySingle(sv: StateVector, q: number, [[a, b], [c, d]]: Gate2x2): StateVector; /** * Apply a controlled-NOT gate: if control = |1⟩, flip target. */ export declare function applyCNOT(sv: StateVector, control: number, target: number): StateVector; /** * Apply a SWAP gate: exchange qubit a and qubit b. */ export declare function applySWAP(sv: StateVector, a: number, b: number): StateVector; /** * Apply a two-qubit gate to qubits a and b. * * Qubit a is the MSB of the 2-bit local index so the column ordering matches * the standard ket notation: |00⟩, |01⟩, |10⟩, |11⟩ where the first digit is a. */ export declare function applyTwo(sv: StateVector, a: number, b: number, gate: Gate4x4): StateVector; /** * Apply a Toffoli (CCX) gate: flip target if both c1 = |1⟩ and c2 = |1⟩. * Pure permutation — no amplitude arithmetic. */ export declare function applyToffoli(sv: StateVector, c1: number, c2: number, target: number): StateVector; /** * Apply a Fredkin (CSWAP) gate: swap qubits a and b if control = |1⟩. * Pure permutation — no amplitude arithmetic. */ export declare function applyCSwap(sv: StateVector, control: number, a: number, b: number): StateVector; /** * Apply a C-√iSWAP (controlled-SrSwap) gate: if control = |1⟩, apply √iSWAP to qubits a and b. * * √iSWAP matrix in the |00⟩/|01⟩/|10⟩/|11⟩ subspace (a is MSB): * diag(1, 1) on |00⟩/|11⟩ and the off-diagonal 2×2: * [[1/√2, i/√2], [i/√2, 1/√2]] for |01⟩/|10⟩. */ export declare function applyCsrSwap(sv: StateVector, control: number, a: number, b: number): StateVector; /** * Apply a controlled single-qubit gate: if control = |1⟩, apply gate to target. */ export declare function applyControlled(sv: StateVector, control: number, target: number, [[a, b], [c, d]]: Gate2x2): StateVector; /** * Apply an N-qubit unitary to qubits `qs` (qs[0] = MSB of local 2^N index). * Matrix is 2^N × 2^N. Row/column order matches `applyTwo`: qs[0] is MSB. */ export declare function applyUnitary(sv: StateVector, qs: readonly number[], matrix: readonly (readonly Complex[])[]): StateVector; /** Return probability of each basis state as a plain Record. */ export declare function probabilities(sv: StateVector): Map; //# sourceMappingURL=statevector.d.ts.map