Options
All
  • Public
  • Public/Protected
  • All
Menu

Class Operator

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

Hierarchy

  • Operator

Index

Constructors

constructor

Properties

dimensionsIn

dimensionsIn: Dimension[]

dimensionsOut

dimensionsOut: Dimension[]

entries

entries: OperatorEntry[]

Accessors

coordNamesIn

  • get coordNamesIn(): string[][]

coordNamesOut

  • get coordNamesOut(): string[][]

dimensions

namesIn

  • get namesIn(): string[]

namesOut

  • get namesOut(): string[]

sizeIn

  • get sizeIn(): number[]

sizeOut

  • get sizeOut(): number[]

totalSizeIn

  • get totalSizeIn(): number
  • Returns number

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

totalSizeOut

  • get totalSizeOut(): number
  • Returns number

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

Methods

add

  • Add two operators.

    Note: May be overengineered for adding 2 vectors with this map-reduce approach.

    Parameters

    • m2: Operator

      Other operator with same dimensions.

    Returns Operator

    m1 + m2

conj

contractLeft

  • 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

contractRight

  • 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

copy

  • Create a copy of the vector.

    todo

    Make it more lightweight than using lodash.

    Returns Operator

dag

isCloseTo

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

    Parameters

    • m2: Operator

      An operator to compare

    • Default value eps: number = 0.000001

      Euclidean distance tolerance.

    Returns boolean

    Checks M1 ~= M2

isCloseToHermitian

  • isCloseToHermitian(eps?: number): boolean

isCloseToIdentity

  • 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

    • Default value eps: number = 0.000001

      Euclidean distance tolerance.

    Returns boolean

    Checks M ~= Id

isCloseToNormal

  • isCloseToNormal(eps?: number): boolean

isCloseToProjection

  • isCloseToProjection(eps?: number): boolean

isCloseToUnitary

  • isCloseToUnitary(eps?: number): boolean

isCloseToUnitaryOnSubspace

  • 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

    • Default value eps: number = 0.000001

      Euclidean distance tolerance.

    Returns boolean

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

isCloseToZero

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

    Parameters

    • Default value eps: number = 0.000001

      Euclidean distance tolerance.

    Returns boolean

    Checks M ~= 0

mapValues

mulConstant

mulOp

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

    Parameters

    • m: Operator

      Operator M2 with dimensions compatible with operators input dimensions of M1.

    Returns Operator

    M = M1 M2

mulVec

  • 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

  • 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: 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

  • normSquared(): number

outer

permute

  • 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]

    • Default value orderIn: number[] = orderOut

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

    Returns Operator

permuteDimsIn

  • 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

  • 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

sub

  • Subtract operators from each other.

    Parameters

    • m2: Operator

      Another operator with compatible dimensions.

    Returns Operator

    m1 - m2

toBasisAll

  • toBasisAll(dimName: string, basisStr: string): Operator

toDense

  • Export to a dense array format.

    Returns Complex[][]

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

toIndexIndexValues

toString

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

    see

    Complex.toString for formating options.

    Parameters

    • Default value complexFormat: string = "cartesian"

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

    • Default value precision: number = 2

      float display precision

    • Default value separator: string = " + "

      entry separator

    • Default value 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|

toVectorPerInput

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

    Returns IColumnOrRow[]

    a sparse array of vector per input

toVectorPerOutput

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

    Returns IColumnOrRow[]

    a sparse array of vector per output.

transpose

Static add

  • As sum of many operators with compatible dimensions.

    see

    Operator.add for the actual implementation.

    todo

    Can be optimized if needed.

    Parameters

    Returns Operator

    m1 + m2 + ...

Static fromArray

  • 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.

    • Default value dimensionsIn: Dimension[] = dimensionsOut

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

    • Default value removeZeros: boolean = true

      If to remove zero value.

    Returns Operator

Static fromSparseCoordNames

  • 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.

    • Default value dimensionsIn: Dimension[] = dimensionsOut

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

    Returns Operator

    An operator, as desired.

Static identity

Static indicator

  • 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

Static outer

  • 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, ...]

Static shift

Static zeros

Generated using TypeDoc