Options
All
  • Public
  • Public/Protected
  • All
Menu

Operator class. A complex number sparse matrix aware of dimensions and tensor structure.

Hierarchy

  • Operator

Index

Constructors

Properties

cachedPerInput: null | IColumnOrRow[] = null
cachedPerOutput: null | IColumnOrRow[] = null
dimensionsIn: Dimension[]
dimensionsOut: Dimension[]
entries: OperatorEntry[]

Accessors

  • get coordNamesIn(): string[][]
  • get coordNamesOut(): string[][]
  • get namesIn(): string[]
  • get namesOut(): string[]
  • get sizeIn(): number[]
  • get sizeOut(): number[]
  • get totalSizeIn(): number
  • Returns number

    The total size of input (a product of all input sizes). It is the matrix column number.

  • get totalSizeOut(): number
  • Returns number

    The total size of output (a product of all output sizes). It is the matrix row number.

Methods

  • Operator contraction with a vector, reducing 'output' dimensions.

    Parameters

    • coordIndices: number[]

      Dimension indices at which we perform the opration. They need to be unique.

    • v: Vector

      Vector to contract with.

    Returns Operator

    sum_i1 v_i1 A_(i1 i2),j

  • Operator contraction with a vector, reducing 'input' dimensions.

    Parameters

    • coordIndices: number[]

      Dimension indices at which we perform the opration. They need to be unique.

    • v: Vector

      Vector to contract with.

    Returns Operator

    sum_j1 A_i,(j1 j2) v_j1

  • isCloseTo(m2: Operator, eps?: number): boolean
  • Is it close to another operator?

    Parameters

    • m2: Operator

      An operator to compare

    • eps: number = 1e-6

      Euclidean distance tolerance.

    Returns boolean

    Checks M1 ~= M2

  • isCloseToHermitian(eps?: number): boolean
  • isCloseToIdentity(eps?: number): boolean
  • Is it close to identity?

    note

    Checks only if in and out dimensions are the same, otherwise there is an error.

    Parameters

    • eps: number = 1e-6

      Euclidean distance tolerance.

    Returns boolean

    Checks M ~= Id

  • isCloseToNormal(eps?: number): boolean
  • isCloseToProjection(eps?: number): boolean
  • isCloseToUnitary(eps?: number): boolean
  • isCloseToUnitaryOnSubspace(eps?: number): boolean
  • Is it close to an unitary, when restricted to of the subspace defines by its image. A stronger condition than the partial isometry https://en.wikipedia.org/wiki/Partial_isometry. E.g. spin-up operator |u><d| is a partial isometry, but not unitary on subspace.

    Parameters

    • eps: number = 1e-6

      Euclidean distance tolerance.

    Returns boolean

    M^dag M ~= M M^dag ~= P, P P = P

  • isCloseToZero(eps?: number): boolean
  • Is it close to zero?

    Parameters

    • eps: number = 1e-6

      Euclidean distance tolerance.

    Returns boolean

    Checks M ~= 0

  • Multiplies operator by a real number.

    Parameters

    • x: number

      A factor.

    Returns Operator

    x M

  • Multiply an operator by another operator. Order as in the syntax (M1 this operator, M2 - the argument).

    Parameters

    • m2: Operator

      Operator M2 with dimensions compatible with operators input dimensions of M1 (this).

    Returns Operator

    M = M1 M2

  • Multiply an operator by a vector.

    Parameters

    • v: Vector

      Vector with dimensions compatible with operators input dimensions.

    Returns Vector

    u = M v (a vector with dimensions as operator output dimensions).

  • mulVecPartial(coordIndices: readonly number[], v: Vector): Vector
  • Perform multiplication on a vector, (M v), on some dimensions. E.g. if there are 3 particles, and you want to apply an operation only on the first: M_0 v. Or if you want to apply an operation on the first and the third: M_02 v. In principle, you can do the same by mutlipying matrices with identities, but wouldnot scale.

    Parameters

    • coordIndices: readonly number[]

      Dimension indices at which we perform the opration. They need to be unique.

    • v: Vector

      Vector on which we apply the operation.

    Returns Vector

    M_(coord_indices) ⊗ I_(everywhere_else) v

  • normSquared(): number
  • partialTrace(coordIndices: number[]): Operator
  • Partial trace of the operator, X_B = Tr_A[X_AB].

    Parameters

    • coordIndices: number[]

      Dimension indices to be reduced.

    Returns Operator

    X_B = Tr_A[X_AB]

  • permute(orderOut: number[], orderIn?: number[]): Operator
  • Changing order of dimensions for an operator, from [0, 1, 2, ...] to something else.

    Parameters

    • orderOut: number[]

      E.g. [2, 0, 1]

    • orderIn: number[] = orderOut

      E.g. [2, 0, 1] (be default, same as orderOut)

    Returns Operator

  • permuteDimsIn(orderIn: number[]): Operator
  • Changing order of input dimensions for an operator, from [0, 1, 2, ...] to something else.

    Parameters

    • orderIn: number[]

      E.g. [2, 0, 1]

    Returns Operator

  • permuteDimsOut(orderOut: number[]): Operator
  • Changing order of output dimensions for an operator, from [0, 1, 2, ...] to something else.

    Parameters

    • orderOut: number[]

      E.g. [2, 0, 1]

    Returns Operator

  • Subtract operators from each other.

    Parameters

    • m2: Operator

      Another operator with compatible dimensions.

    Returns Operator

    m1 - m2

  • toBasisAll(dimName: string, basisStr: string): Operator
  • Export to a dense array format.

    Returns Complex[][]

    array m[i][j], where i is output index and j in input index.

  • toString(complexFormat?: ComplexFormat, precision?: number, separator?: string, intro?: boolean): string
  • String description of an operator.

    see

    Complex.toString for formating options.

    Parameters

    • complexFormat: ComplexFormat = 'cartesian'

      complex number format; a choice between ["cartesian", "polar", "polarTau"]

    • precision: number = 2

      float display precision

    • separator: string = ' + '

      entry separator

    • intro: boolean = true

      if to show dimensions and sized

    Returns string

    A string like: Operator with 4 entiresof max size [[2,2], [2,2]] with dimensions [[polarization,spin], [polarization,spin]] (1.00 +0.00i) |H,u⟩⟨H,u| + (1.00 +0.00i) |H,d⟩⟨H,d| + (1.00 +0.00i) |V,u⟩⟨V,u| + (1.00 +0.00i) |V,d⟩⟨V,d|

  • An operator as column (input) vectors. Mostly for internal use (e.g. multiplication).

    Returns IColumnOrRow[]

    a sparse array of vector per input

  • An operator as row (output) vectors. Mostly for internal use (e.g. multiplication).

    Returns IColumnOrRow[]

    a sparse array of vector per output.

  • Creates an operator from a dense array of complex numbers. It needs dimensions to create the complex structure.

    example

    const spinY = Operator.fromArray([ [Cx(0, 0), Cx(0, -1)], [Cx(0, 1), Cx(0, 0)] ], [Dimension.spin()])

    todo

    Consider using flatMap for readibility.

    Parameters

    • denseArray: Complex[][]

      A 2-d array of complex numbers.

    • dimensionsOut: Dimension[]

      Dimensions out.

    • dimensionsIn: Dimension[] = dimensionsOut

      Dimensions in (if not provided, then the same as out).

    • removeZeros: boolean = true

      If to remove zero value.

    Returns Operator

  • The most typically way of creating custom operators, directly from its entries (delivered in a visual form).

    example

    export const opY = Operator.fromSparseCoordNames([ ['V', 'H', Cx(0, 1)], ['H', 'V', Cx(0, -1)], ], [Dimension.polariztion()])

    Parameters

    • stringedEntries: [string | string[], string | string[], Complex][]

      A list of entries, using symbols. ['Hu', 'Vu', C(0.5, -1)] -> (0.50 - 1.00i) |H,u⟩⟨V,u|

    • dimensionsOut: Dimension[]

      Output dimensions.

    • dimensionsIn: Dimension[] = dimensionsOut

      Input dimensions. If not specified, the same as in dimensionsOut.

    Returns Operator

    An operator, as desired.

  • Creates an operator projecting on a single element, given by its symbol, e.g. |H,u⟩⟨H,u|.

    example

    Operator.indicator([Dimensions.polarization(), Dimensions.spin()], 'Hu')

    Parameters

    • dimensions: Dimension[]
    • coordNames: string | string[]

      Symbols for each ordinate. For symbols with more than one letter you need to use an array of strings.

    Returns Operator

  • Outer product (tensor product) between two or more operators.

    see

    Operator.outer for the actual implementation.

    todo

    Can be optimized if needed.

    Parameters

    Returns Operator

    ⨂[m1, m2, ...]

  • Turn vector into a (non-normalized) projection on it: |v⟩ -> |v⟩⟨v|

    Parameters

    Returns Operator

    |v⟩⟨v|

Generated using TypeDoc