Quantum operators

Quantum operators form an algebra over a field, i.e., a vector space equipped with a bilinear operation (often called the "multiplication") defined between vectors.

With the help of the structure constants of the algebra, the result of the bilinear operation between any two vectors can be expressed as a sum of individual ones. Therefore, in principle, an algebra can be represented by the complete basis set of its corresponding vector space and a rank-3 tensor encapsulating its structure constants. Note that the "bilinear operation" is not restricted to the usual multiplication. For example, in Lie algebras, it is the commutator (defined as [A, B] ≝ AB - BA), which is a composition of the usual multiplication and subtraction.

In general, there are three basic operations on quantum operators: the scalar multiplication between a scalar and a quantum operator, the usual addition, and the usual multiplication between quantum operators. Other more complicated operations can be composed from these basic ones. These basic operations are implemented in this module.

OperatorIndex

OperatorIndex is the building block of quantum operators, which specifies the basis of the vector space of the corresponding algebra.

OperatorProd and OperatorSum

OperatorProd defines the product operator as an entity of basis quantum operators while OperatorSum defines the summation as an entity of OperatorProds. Both of them are subtypes of QuantumOperator, which is the abstract type for all quantum operators.

An OperatorProd must have two predefined contents:

  • value::Number: the coefficient of the quantum operator
  • id::ID: the id of the quantum operator

Arithmetic operations (+, -, *, /) between a scalar, an OperatorProd or an OperatorSum are defined. See Manual for details.

Manual

QuantumLattices.QuantumOperators.OperatorIndex — Type
OperatorIndex <: QuantumOperator

An operator index is the irreducible symbolic unit for completely representing a quantum operator.

It plays the role of the symbols in computer algebra systems while it can host internal structures, which is convenient to represent quantum operators with complicated spatial and/or internal degrees of freedom.

source
QuantumLattices.QuantumOperators.OperatorPack — Type
OperatorPack{V, I} <: QuantumOperator

Entity that represents the pack of a number and an id of a quantum operator.

Basically, a concrete subtype should contain two predefined contents:

  • value::V: the coefficient of the pack
  • id::I: the id of the pack
source
QuantumLattices.QuantumOperators.OperatorSet — Type
OperatorSet{M<:OperatorPack} <: QuantumOperator

Set of OperatorPacks.

  1. The relation between two OperatorPacks in an OperatorSet can be viewed as addition.
  2. But in general, only iteration over OperatorPacks and length are supported.
  3. To use arithmetic operations, please refer to its subtype, OperatorSum.
source
QuantumLattices.QuantumOperators.Permutation — Method
(permutation::Permutation)(m::OperatorProd; rev::Bool=false, kwargs...) -> OperatorSum

Permute the operator units of an OperatorProd to the descending order according to the table contained in permutation.

Note

To use this function, the user must implement a method of permute, which computes the result of the permutation of two operator units:

permute(u₁::OperatorIndex, u₂::OperatorIndex) -> Union{OperatorProd, OperatorSum}

Here, u₁ and u₂ are two arbitrary operator units contained in id(m).

source
QuantumLattices.QuantumOperators.TabledUnitSubstitution — Type
TabledUnitSubstitution{U<:OperatorIndex, S<:OperatorSum, T<:AbstractDict{U, S}} <: UnitSubstitution{U, S}

A concrete unit substitution transformation, which stores every substitution of the old OperatorIndexs in its table as a dictionary.

source
QuantumLattices.QuantumOperators.UnitSubstitution — Type
UnitSubstitution{U<:OperatorIndex, S<:OperatorSum} <: LinearTransformation

Unit substitution transformation, which substitutes each OperatorIndex in the old quantum operators to a new expression represented by an OperatorSum.

source
QuantumLattices.ZeroAtLeast — Method
ZeroAtLeast(::Type{U}, attrs::Vararg{NTuple{N}, M}) where {U<:OperatorIndex, N, M}

Get the composite id from the components of singular ids.

source
Base.:* — Method
*(factor::Number, m::OperatorIndex) -> Operator
*(m::OperatorIndex, factor::Number) -> Operator
*(m₁::OperatorIndex, m₂::OperatorIndex) -> Operator
*(factor::Number, m::OperatorPack) -> OperatorPack
*(m::OperatorPack, factor::Number) -> OperatorPack
*(m₁::OperatorPack, m₂::OperatorIndex) -> OperatorPack
*(m₁::OperatorIndex, m₁::OperatorPack) -> OperatorPack
*(m₁::OperatorPack, m₂::OperatorPack) -> OperatorPack
*(factor::Number, ms::OperatorSum) -> OperatorSum
*(ms::OperatorSum, factor::Number) -> OperatorSum
*(m::OperatorIndex, ms::OperatorSum) -> OperatorSum
*(ms::OperatorSum, m::OperatorIndex) -> OperatorSum
*(m::OperatorPack, ms::OperatorSum) -> OperatorSum
*(ms::OperatorSum, m::OperatorPack) -> OperatorSum
*(ms₁::OperatorSum, ms₂::OperatorSum) -> OperatorSum

Overloaded * between quantum operators or a quantum operator and a number.

source
Base.:+ — Method
+(m::QuantumOperator) -> typeof(m)
+(m₁::QuantumOperator, m₂::QuantumOperator) -> OperatorSum
+(factor::Number, m::QuantumOperator) -> OperatorSum
+(m::QuantumOperator, factor::Number) -> OperatorSum

Overloaded + between quantum operators.

source
Base.:- — Method
-(m::QuantumOperator) -> QuantumOperator
-(m₁::QuantumOperator, m₂::QuantumOperator) -> OperatorSum
-(factor::Number, m::QuantumOperator) -> OperatorSum
-(m::QuantumOperator, factor::Number) -> OperatorSum

Overloaded - between quantum operators.

source
Base.:/ — Method
/(m::QuantumOperator, factor::Number) -> QuantumOperator

Overloaded / between a quantum operator and a number.

source
Base.:// — Method
//(m::QuantumOperator, factor::Number) -> QuantumOperator

Overloaded // between a quantum operator and a number.

source
Base.:^ — Method
^(m::QuantumOperator, n::Integer) -> QuantumOperator

Overloaded ^ between a quantum operator and an integer.

source
Base.adjoint — Method
adjoint(id::ZeroAtLeast{OperatorIndex}) -> ZeroAtLeast{OperatorIndex}

Get the adjoint of an id.

source
Base.adjoint — Method
adjoint(opts::Operators) -> Operators

Get the adjoint of a set of operators.

source
Base.adjoint — Method
adjoint(m::Operator) -> Operator

Get the adjoint of an operator.

source
Base.conj — Method
conj(m::OperatorIndex) -> OperatorIndex
conj(m::OperatorPack) -> OperatorPack
conj(m::OperatorSum) -> OperatorSum

Get the conjugation.

source
Base.convert — Method
convert(::Type{M}, m::Number) where {M<:OperatorProd}

Convert a number to a quantum operator.

source
Base.convert — Method
convert(::Type{M}, u::OperatorIndex) where {M<:Operator}

Convert an operator index to an operator.

source
Base.convert — Method
convert(::Type{M}, m::OperatorPack) where {M<:OperatorPack}

Convert a quantum operator from one type to another.

source
Base.eltype — Method
eltype(m::OperatorProd)
eltype(::Type{M}) where {M<:OperatorProd}

Get the eltype of an OperatorProd.

source
Base.eltype — Method
eltype(ms::OperatorSet)
eltype(::Type{<:OperatorSet{M}}) where {M<:OperatorPack}

Get the eltype of an OperatorSet.

source
Base.empty — Method
empty(ms::OperatorSum) -> typeof(ms)
empty!(ms::OperatorSum) -> typeof(ms)

Get an empty copy or empty an OperatorSum.

source
Base.getindex — Method
getindex(m::OperatorProd, i::Integer) -> eltype(idtype(m))
getindex(m::OperatorProd, slice) -> OperatorProd

Overloaded [].

source
Base.getindex — Method
getindex(ms::OperatorSum, index::Integer) -> eltype(ms)
getindex(ms::OperatorSum, indexes::AbstractVector{<:Integer}) -> typeof(ms)
getindex(ms::OperatorSum, ::Colon) -> typeof(ms)

Overloaded [].

source
Base.getproperty — Method
getproperty(id::ZeroAtLeast{OperatorIndex}, name::Symbol)

Get the property of a composite id.

source
Base.haskey — Method
haskey(ms::OperatorSum, id) -> Bool

Judge whether an OperatorSum contains an OperatorPack with the given id.

source
Base.isapprox — Method
isapprox(m₁::OperatorPack, m₂::OperatorPack; atol::Real=atol, rtol::Real=rtol) -> Bool

Compare two OperatorPacks and judge whether they are approximate to each other.

source
Base.isapprox — Method
isapprox(ms₁::OperatorSum, ms₂::OperatorSum; atol::Real=atol, rtol::Real=rtol) -> Bool

Compare two OperatorSums and judge whether they are approximate to each other.

source
Base.iszero — Method
iszero(u::OperatorIndex) -> Bool

Judge whether an OperatorIndex is zero, which is defined to be always false.

source
Base.iszero — Method
iszero(m::OperatorPack) -> Bool

Judge whether an OperatorPack is zero, i.e., its value is zero.

source
Base.iszero — Method
iszero(ms::OperatorSet) -> Bool

Judge whether an OperatorSet is zero, i.e., it does not contain any OperatorPack.

source
Base.iszero — Method
iszero(ms::OperatorSum) -> Bool

Judge whether an OperatorSum is zero, i.e., it does not contain any OperatorPack.

source
Base.iterate — Method
iterate(m::OperatorProd)
iterate(m::OperatorProd, state)

Iterate over the components of the id of an OperatorProd.

source
Base.iterate — Method
iterate(ms::OperatorSum)
iterate(ms::OperatorSum, state)

Iterate over the OperatorPacks contained in an OperatorSum.

source
Base.length — Method
length(m::OperatorProd) -> Int

Get the length of an OperatorProd.

source
Base.length — Method
length(ms::OperatorSum) -> Int

Get the number of OperatorPacks contained in an OperatorSum.

source
Base.map! — Method
map!(f::Function, ms::OperatorSum; kwargs...) -> typeof(ms)

Map in place an OperatorSum by the function f elementwise.

source
Base.one — Method
one(::Type{M}) where {M<:OperatorProd}
one(m::OperatorProd)

Get the identity quantum operator.

source
Base.propertynames — Method
propertynames(::Type{I}) where I<:ZeroAtLeast{OperatorIndex} -> ZeroAtLeast{Symbol}

Get the property names of a composite id.

source
Base.replace — Method
replace(m::OperatorPack, v) -> OperatorPack

Replace the value of an OperatorPack.

source
Base.show — Method
show(io::IO, ::MIME"text/latex", op::QuantumOperator)
show(io::IO, m::MIME"text/latex", ops::OneAtLeast{<:QuantumOperator})
show(io::IO, ::MIME"text/latex", ops::AbstractVector{<:QuantumOperator})
show(io::IO, ::MIME"text/latex", ops::AbstractMatrix{<:QuantumOperator})

Show a quantum operator.

source
Base.split — Method
split(m::OperatorProd) -> Tuple{valtype(m), Vararg{Any}}

Split an OperatorProd into the coefficient and a sequence of the components of its id.

source
Base.valtype — Method
valtype(m::OperatorPack)
valtype(::Type{T}) where {T<:OperatorPack}

Get the type of the value of an OperatorPack.

source
Base.zero — Method
zero(m::QuantumOperator)

Get a zero QuantumOperator.

source
Base.zero — Method
zero(::Type{M}) where {M<:OperatorIndex} -> OperatorSum
zero(::Type{M}) where {M<:OperatorPack} -> OperatorSum
zero(::Type{M}) where {M<:OperatorSum} -> OperatorSum

Get the zero sum.

source
LinearAlgebra.dot — Method
dot(m₁::QuantumOperator, m₂::QuantumOperator)
dot(m::QuantumOperator, c::Number)
dot(c::Number, m::QuantumOperator)

Dot product between two QuantumOperators or between a QuantumOperator and a number.

source
LinearAlgebra.mul! — Method
mul!(ms::OperatorSum, factor::Number) -> OperatorSum

Get the in-place multiplication of an OperatorSum with a number.

source
LinearAlgebra.rank — Method
rank(id::ZeroAtLeast{OperatorIndex}) -> Int
rank(::Type{<:ZeroAtLeast{OperatorIndex, N}}) where N -> Int

Get the rank of an id.

source
LinearAlgebra.rank — Method
rank(m::OperatorProd) -> Int
rank(::Type{M}) where {M<:OperatorProd} -> Int

Get the rank of an OperatorProd.

source
QuantumLattices.:⊗ — Method
⊗(id::OperatorIndex...)
⊗(u::OperatorIndex, id::ZeroAtLeast{OperatorIndex})
⊗(id::ZeroAtLeast{OperatorIndex}, u::OperatorIndex)
⊗(id₁::ZeroAtLeast{OperatorIndex}, id₂::ZeroAtLeast{OperatorIndex})

Get the id from operator units/ids.

source
QuantumLattices.QuantumOperators.operatortype — Method
operatortype(::Type{M}) where {M<:OperatorIndex}
operatortype(::Type{M}) where {M<:OperatorPack}
operatortype(::Type{M}) where {M<:OperatorSet}

Get the corresponding OperatorPack type of a quantum operator.

source
QuantumLattices.QuantumOperators.script — Method
script(u::OperatorIndex, l::LaTeX, ::Val{:BD}) -> Any
script(u::OperatorIndex, l::LaTeX, ::Val{:SP}) -> Tuple
script(u::OperatorIndex, l::LaTeX, ::Val{:SB}) -> Tuple

Get the body/superscript/subscript of the LaTeX string representation of an operator index.

source
QuantumLattices.add! — Method
add!(destination, transformation::LinearTransformation, op::OperatorPack; kwargs...) -> typeof(destination)
add!(destination, transformation::LinearTransformation, op::OperatorSet; kwargs...) -> typeof(destination)

Add the result of the linear transformation on a quantum operator to the destination.

source
QuantumLattices.add! — Method
add!(ms::OperatorSum) -> typeof(ms)
add!(ms::OperatorSum, m::Union{Number, OperatorIndex, OperatorPack}) -> typeof(ms)
add!(ms::OperatorSum, mms::OperatorSum) -> typeof(ms)

Get the in-place addition of quantum operators.

source
QuantumLattices.div! — Method
div!(ms::OperatorSum, factor::Number) -> OperatorSum

Get the in-place division of an OperatorSum with a number.

source
QuantumLattices.sub! — Method
sub!(ms::OperatorSum) -> typeof(ms)
sub!(ms::OperatorSum, m::Union{Number, OperatorIndex, OperatorPack}) -> typeof(ms)
sub!(ms::OperatorSum, mms::OperatorSum) -> typeof(ms)

Get the in-place subtraction of quantum operators.

source