ts-quantum
Version:
TypeScript library for quantum mechanics calculations and utilities
61 lines (60 loc) • 2.09 kB
TypeScript
/**
* Hilbert space implementation supporting composition and tensor products
*/
import { Complex, IStateVector } from './types';
/**
* Represents a quantum Hilbert space with dimension and optional basis labels
*/
export declare class HilbertSpace {
readonly dimension: number;
readonly basis: string[];
constructor(dimension: number, basis?: string[]);
/**
* Composes this Hilbert space with another via tensor product: this ⊗ other
*/
compose(other: HilbertSpace): HilbertSpace;
/**
* Decomposes this Hilbert space into tensor product factors
* @param dims Array of dimensions that should multiply to space dimension
*/
decompose(dims: number[]): HilbertSpace[];
/**
* Creates tensor product with another space: this ⊗ other
*/
tensorProduct(other: HilbertSpace): HilbertSpace;
/**
* Performs partial trace over specified subsystems
* @param subsystemDims Dimensions of subsystems to trace out
*/
partialTrace(subsystemDims: number[]): HilbertSpace;
/**
* Checks if a state vector belongs to this Hilbert space
*/
containsState(state: IStateVector): boolean;
/**
* Creates a computational basis state |i⟩
*/
computationalBasisState(i: number): IStateVector;
/**
* Returns array of all computational basis states
*/
computationalBasis(): IStateVector[];
/**
* Creates normalized superposition of basis states with given coefficients
*/
superposition(coefficients: Complex[]): IStateVector;
/**
* Extends this space to a larger space by tensoring with auxiliary space
* @param auxDimension Dimension of auxiliary space
* @param position Position to insert this space (0 = leftmost)
*/
extendToLargerSpace(auxDimension: number, position?: number): HilbertSpace;
/**
* Creates an equally weighted superposition of all basis states
*/
equalSuperposition(): IStateVector;
/**
* Returns string representation of the Hilbert space
*/
toString(): string;
}