ts-quantum
Version:
TypeScript library for quantum mechanics calculations and utilities
118 lines (117 loc) • 3.54 kB
TypeScript
/**
* Density matrix implementation for mixed quantum states and operations
*/
import { Complex, IStateVector, OperatorType, IDensityMatrix, IQuantumChannel, IOperator } from '../core/types';
import { StateVector } from './stateVector';
/**
* Implementation of density matrix operations
*/
export declare class DensityMatrixOperator implements IDensityMatrix {
readonly objectType: 'operator';
readonly dimension: number;
readonly type: OperatorType;
private operator;
constructor(matrix: Complex[][]);
/**
* Applies density matrix to state vector
*/
apply(state: IStateVector): StateVector;
/**
* Composes with another operator
*/
compose(other: IOperator): IOperator;
/**
* Returns adjoint (same as original for density matrix)
*/
adjoint(): IDensityMatrix;
/**
* Returns matrix representation
*/
toMatrix(): Complex[][];
/**
* Calculates trace of density matrix
*/
trace(): Complex;
/**
* Calculates purity Tr(ρ²)
*/
purity(): number;
/**
* Calculates von Neumann entropy -Tr(ρ ln ρ)
*/
vonNeumannEntropy(): number;
/**
* Performs partial trace over specified subsystems
*/
partialTrace(dims: number[], traceOutIndices: number[]): IOperator;
/**
* Scales density matrix by a complex number
*/
scale(scalar: Complex): IOperator;
/**
* Adds this density matrix with another operator
*/
add(other: IOperator): IOperator;
/**
* Returns eigenvalues and eigenvectors
*/
eigenDecompose(): {
values: Complex[];
vectors: IOperator[];
};
/**
* Creates density matrix from pure state
*/
static fromPureState(state: IStateVector): IDensityMatrix;
/**
* Creates density matrix from mixed state
*/
static mixedState(states: IStateVector[], probabilities: number[]): IDensityMatrix;
/**
* Returns tensor product with another operator
*/
tensorProduct(other: IOperator): IOperator;
/**
* Calculates the operator norm
*/
norm(): number;
/**
* Tests whether the density matrix is identically zero
*/
isZero(tolerance?: number): boolean;
}
/**
* Implementation of quantum channels using Kraus operators
*/
export declare class KrausChannel implements IQuantumChannel {
private krausOperators;
constructor(krausOperators: IOperator[]);
getOperators(): IOperator[];
apply(state: IDensityMatrix): IDensityMatrix;
}
/**
* Creates a depolarizing channel
* For qubits: ρ → (1-p)ρ + p/3(XρX + YρY + ZρZ)
*/
export declare function createDepolarizingChannel(dimension: number, p: number): IQuantumChannel;
/**
* Creates an amplitude damping channel
* Models energy decay: |1⟩ → |0⟩ with probability γ
*/
export declare function createAmplitudeDampingChannel(gamma: number): IQuantumChannel;
/**
* Creates a phase damping channel
* Models pure dephasing without energy loss
*/
export declare function createPhaseDampingChannel(gamma: number): IQuantumChannel;
/**
* Creates a bit flip channel
* Applies X gate with probability p: ρ → (1-p)ρ + pXρX
*/
export declare function createBitFlipChannel(p: number): IQuantumChannel;
/**
* Creates a phase flip channel
* Applies Z gate with probability p: ρ → (1-p)ρ + pZρZ
*/
export declare function createPhaseFlipChannel(p: number): IQuantumChannel;
export { traceFidelity, concurrence, negativity } from '../utils/information';