q5m.js - Quantum Computing Library - v0.1.1
    Preparing search index...

    Class Q5mState<TMaterial>Abstract

    Abstract base class for quantum states with state vector representation.

    Type Parameters

    Hierarchy (View Summary)

    Index

    Accessors

    • get isDense(): boolean

      Flag indicating whether dense or sparse representation is currently used (backward compatibility)

      Returns boolean

    Constructors

    Methods

    • Calculates the state space dimension for the given number of quantum units.

      Parameters

      • numQuantum: number

      Returns number

    • Returns the effective number of quantum units (e.g., qubits) in this state.

      Returns number

    • Returns the full array of quantum amplitudes of the quantum state. Uses memoization to reduce memory allocations for repeated access.

      Returns Complex[]

      Array of quantum amplitudes.

      Do not modify the returned array directly.

    • Returns the measurement probabilities for all computational basis states.

      Returns number[]

    • Returns the probability of measuring a specific computational basis state.

      Parameters

      • basisIndex: number

      Returns number

    • Invalidates memoized amplitude cache when state changes.

      Returns void

    • Selects the appropriate representation for the quantum state.

      Parameters

      Returns void

    • Select the best representation type based on size and sparsity.

      Parameters

      • size: number
      • nonZeroCount: number

      Returns RepType

    • Determine if CSR representation should be used.

      Parameters

      • size: number
      • sparsity: number
      • nonZeroCount: number
      • sparseMemory: number
      • csrMemory: number

      Returns boolean

    • Create CSR format from sparse Map representation.

      Parameters

      • sparseMap: Map<number, Complex>
      • totalSize: number

      Returns CSRFormat

    • Convert CSR format to memory-optimized TypedArray format.

      Parameters

      • csr: CSRFormat

      Returns OptimizedCSRFormat

    • Calculates the estimated memory usage for the current quantum state.

      Returns number

    • Calculate memory usage for CSR representation.

      Returns number

    • Perform efficient matrix-vector multiplication for CSR representation.

      Parameters

      • unitaryMatrix: Matrix

      Returns Complex[]

    • Perform efficient sparse matrix-vector multiplication when both matrix and vector are sparse.

      Parameters

      • sparseMatrix: OptimizedCSRFormat

      Returns Complex[]

    • Optimized application of controlled gates for CSR representation.

      Parameters

      • controlledMatrix: Matrix

      Returns Complex[]

    • Optimized application of single-qubit gates to large quantum systems.

      Parameters

      • singleQubitMatrix: Matrix

      Returns Complex[]

    • Protected

      Standard dense matrix-vector multiplication. Uses optimized implementation from math/vector-matrix.ts

      Parameters

      • unitaryMatrix: Matrix

        Dense unitary matrix

      Returns Complex[]

      New state vector after multiplication

    • Protected

      Sparse matrix-vector multiplication for sparse Map representation. Uses optimized implementation from math/vector-matrix.ts

      Parameters

      • unitaryMatrix: Matrix

        Dense unitary matrix

      Returns Complex[]

      New state vector after multiplication

    Properties

    stateCount: number

    The total number of basis states in the Hilbert space (its dimension).

    numQuantum: number

    The number of quantum units (e.g., qubits, qutrits) in this state.

    material: TMaterial

    The quantum material associated with this state.

    stateVector?: Complex[]

    The state vector containing quantum amplitudes for each basis state. Optional for sparse representations.

    sparseAmplitudes?: Map<number, Complex>

    Sparse representation using Map for memory optimization

    csrData?: CSRFormat

    CSR (Compressed Sparse Row) representation for large sparse states

    optimizedCSRData?: OptimizedCSRFormat

    Optimized CSR representation using TypedArrays

    rep: RepType = RepType.DENSE

    Current representation type

    sparseConfig: SparseConfig = DEFAULT_SPARSE_CONFIG

    Configuration for sparse optimization