ts-quantum
Version:
TypeScript library for quantum mechanics calculations and utilities
93 lines (92 loc) • 2.72 kB
TypeScript
/**
* Specialized quantum operator implementations for performance optimization
*/
import { Complex, IStateVector, OperatorType, IOperator } from '../core/types';
import { StateVector } from '../states/stateVector';
/**
* Identity operator with no matrix storage - optimal performance
*/
export declare class IdentityOperator implements IOperator {
readonly objectType: 'operator';
readonly dimension: number;
readonly type: OperatorType;
constructor(dimension: number);
/**
* Apply identity operator - returns cloned state
*/
apply(state: IStateVector): StateVector;
/**
* Compose with another operator - returns other operator
*/
compose(other: IOperator): IOperator;
/**
* Adjoint of identity is identity
*/
adjoint(): IOperator;
/**
* Generate identity matrix on demand
*/
toMatrix(): Complex[][];
tensorProduct(other: IOperator): IOperator;
partialTrace(dims: number[], traceOutIndices: number[]): IOperator;
scale(scalar: Complex): IOperator;
add(other: IOperator): IOperator;
eigenDecompose(): {
values: Complex[];
vectors: IOperator[];
};
norm(): number;
isZero(): boolean;
}
/**
* Diagonal operator with compressed storage
*/
export declare class DiagonalOperator implements IOperator {
readonly objectType: 'operator';
readonly dimension: number;
readonly type: OperatorType;
private diagonal;
constructor(diagonal: Complex[]);
/**
* Apply diagonal operator - element-wise multiplication
*/
apply(state: IStateVector): StateVector;
/**
* Compose with another operator
*/
compose(other: IOperator): IOperator;
/**
* Adjoint of diagonal operator
*/
adjoint(): IOperator;
/**
* Generate full matrix on demand
*/
toMatrix(): Complex[][];
tensorProduct(other: IOperator): IOperator;
partialTrace(dims: number[], traceOutIndices: number[]): IOperator;
scale(scalar: Complex): IOperator;
add(other: IOperator): IOperator;
eigenDecompose(): {
values: Complex[];
vectors: IOperator[];
};
norm(): number;
isZero(tolerance?: number): boolean;
/**
* Get diagonal elements
*/
getDiagonal(): Complex[];
}
/**
* Factory function to create identity operator
*/
export declare function createIdentityOperator(dimension: number): IdentityOperator;
/**
* Factory function to create diagonal operator
*/
export declare function createDiagonalOperator(diagonal: Complex[]): DiagonalOperator;
/**
* Check if matrix is diagonal
*/
export declare function isDiagonalMatrix(matrix: Complex[][], tolerance?: number): boolean;