Quantum operators
Quantum operators form an algebra over a field, which are vector spaces with a bilinear operation (often called the "multiplication") between vectors defined.
With the help of the structure constants of the algebra, the result of the bilinear operation between any arbitrary two vectors can be expressed by 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. It is noted that the "bilinear operation" is not restricted to the usual multiplication. For example, it is the commutator, which is a composition of the usual multiplication and subtraction (for any A and B, the commutator [A, B] is defined as [A, B]≝AB-BA) that serves as the bilinear operator for Lie algebras.
In general, there are three basic operations on quantum operators, i.e. the scalar multiplication between a scalar and a quantum operator, the usual addition and the usual multiplication between quantum operators. Other 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 operatorid::ID: the id of the quantum operator
Arithmetic operations (+, -, *, /) between a scalar, an OperatorProd or an OperatorSum is defined. See Manual for details.
Manual
QuantumLattices.QuantumOperators.LaTeX — Type
LaTeX{SP, SB}(body, spdelimiter::String=", ", sbdelimiter::String=", "; options...) where {SP, SB}LaTeX string representation of quantum operators.
QuantumLattices.QuantumOperators.LinearFunction — Type
LinearFunction{O<:Union{Union{}, OperatorPack}, F<:Function} <: LinearTransformationWrapper a function to be a linear transformation.
QuantumLattices.QuantumOperators.LinearTransformation — Type
LinearTransformation <: FunctionAbstract linear transformation on quantum operators.
QuantumLattices.QuantumOperators.LinearTransformation — Method
(transformation::LinearTransformation)(ms::OperatorSet; kwargs...) -> OperatorSetGet the linear transformed quantum operators.
QuantumLattices.QuantumOperators.Matrixization — Type
Matrixization <: LinearTransformationMatrixization transformation.
QuantumLattices.QuantumOperators.Operator — Type
Operator{V, I<:ZeroAtLeast{OperatorIndex}} <: OperatorProd{V, I}Operator.
QuantumLattices.QuantumOperators.OperatorIndex — Type
OperatorIndex <: QuantumOperatorAn operator index is the irreducible symbolic unit to completely represent a quantum operator.
It plays the role of the symbols as in usual computer algebras while it can host internal structures, which is convenient to represent quantum operators with complicated spatial and/or internal degrees of freedom.
QuantumLattices.QuantumOperators.OperatorPack — Type
OperatorPack{V, I} <: QuantumOperatorEntity that represent 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 packid::I: the id of the pack
QuantumLattices.QuantumOperators.OperatorProd — Type
OperatorProd{V, I<:Tuple} <: OperatorPack{V, I}A special kind of OperatorPack, where the relation between the coefficient and each component of the operator id can be viewed as product.
QuantumLattices.QuantumOperators.OperatorSet — Type
OperatorSet{M<:OperatorPack} <: QuantumOperatorSet of OperatorPacks.
- The relation between two
OperatorPacks in anOperatorSetcan be viewed as addition. - But in general, only iteration over
OperatorPacks and length are supported. - To use arithmetic operations, please refer to its subtype,
OperatorSum.
QuantumLattices.QuantumOperators.OperatorSum — Type
OperatorSum{M<:OperatorPack, I} <: OperatorSet{M}Sum of OperatorPacks.
Similar items are automatically merged with the aid of the id system.
QuantumLattices.QuantumOperators.OperatorSum — Method
OperatorSum(ms)
OperatorSum(ms::QuantumOperator...)
OperatorSum{M}(ms) where {M<:OperatorPack}
OperatorSum{M}(ms::QuantumOperator...) where {M<:OperatorPack}Get the sum of OperatorPacks.
QuantumLattices.QuantumOperators.Operators — Type
Operators{O<:Operator, I<:ZeroAtLeast{OperatorIndex}}A set of operators.
Type alias for OperatorSum{O<:Operator, I<:ZeroAtLeast{OperatorIndex}}.
QuantumLattices.QuantumOperators.Operators — Method
Operators(opts::Operator...)
Operators{M}(opts::Operator...)Get a set of operators.
QuantumLattices.QuantumOperators.Permutation — Type
Permutation{T} <: LinearTransformationPermutation transformation.
QuantumLattices.QuantumOperators.Permutation — Method
(permutation::Permutation)(m::OperatorProd; rev::Bool=false, kwargs...) -> OperatorSumPermute the operator units of an OperatorProd to the descending order according to the table contained in permutation.
QuantumLattices.QuantumOperators.QuantumOperator — Type
QuantumOperatorAbstract type of any quantum operator.
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.
QuantumLattices.QuantumOperators.UnitSubstitution — Type
UnitSubstitution{U<:OperatorIndex, S<:OperatorSum} <: LinearTransformationUnit substitution transformation, which substitutes each OperatorIndex in the old quantum operators to a new expression represented by an OperatorSum.
QuantumLattices.QuantumOperators.UnitSubstitution — Method
(unitsubstitution::UnitSubstitution)(m::OperatorProd; kwargs...) -> OperatorSumSubstitute every OperatorIndex in an OperatorProd with a new OperatorSum.
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.
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) -> OperatorSumOverloaded * between quantum operators or a quantum operator and a number.
Base.adjoint — Method
adjoint(id::ZeroAtLeast{OperatorIndex}) -> ZeroAtLeast{OperatorIndex}Get the adjoint of an id.
Base.adjoint — Method
adjoint(opts::Operators) -> OperatorsGet the adjoint of a set of operators.
Base.adjoint — Method
adjoint(m::Operator) -> OperatorGet the adjoint of an operator.
Base.convert — Method
convert(::Type{M}, m::Number) where {M<:OperatorProd}Convert a number to a quantum operator.
Base.convert — Method
convert(::Type{M}, u::OperatorIndex) where {M<:Operator}Convert an operator index to an operator.
Base.convert — Method
convert(::Type{M}, m::OperatorPack) where {M<:OperatorPack}Convert a quantum operator from one type to another.
Base.eltype — Method
eltype(m::OperatorProd)
eltype(::Type{M}) where {M<:OperatorProd}Get the eltype of an OperatorProd.
Base.eltype — Method
eltype(ms::OperatorSet)
eltype(::Type{<:OperatorSet{M}}) where {M<:OperatorPack}Get the eltype of an OperatorSet.
Base.empty — Method
empty(ms::OperatorSum) -> typeof(ms)
empty!(ms::OperatorSum) -> typeof(ms)Get an empty copy or empty an OperatorSum.
Base.getindex — Method
getindex(m::OperatorProd, i::Integer) -> eltype(idtype(m))
getindex(m::OperatorProd, slice) -> OperatorProdOverloaded [].
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 [].
Base.getproperty — Method
getproperty(id::ZeroAtLeast{OperatorIndex}, name::Symbol)Get the property of a composite id.
Base.haskey — Method
haskey(ms::OperatorSum, id) -> BoolJudge whether an OperatorSum contains an OperatorPack with the given id.
Base.isapprox — Method
isapprox(m₁::OperatorPack, m₂::OperatorPack; atol::Real=atol, rtol::Real=rtol) -> BoolCompare two OperatorPacks and judge whether they are approximate to each other.
Base.isapprox — Method
isapprox(ms₁::OperatorSum, ms₂::OperatorSum; atol::Real=atol, rtol::Real=rtol) -> BoolCompare two OperatorSums and judge whether they are approximate to each other.
Base.iszero — Method
iszero(u::OperatorIndex) -> BoolJudge whether an OperatorIndex is zero, which is defined to be always false.
Base.iszero — Method
iszero(m::OperatorPack) -> BoolJudge whether an OperatorPack is zero, i.e., its value is zero.
Base.iszero — Method
iszero(ms::OperatorSet) -> BoolJudge whether an OperatorSet is zero, i.e, it does not contain any OperatorPack.
Base.iszero — Method
iszero(ms::OperatorSum) -> BoolJudge whether an OperatorSum is zero, i.e, it does not contain any OperatorPack.
Base.iterate — Method
iterate(m::OperatorProd)
iterate(m::OperatorProd, state)Iterate over the components of the id of an OperatorProd.
Base.iterate — Method
iterate(ms::OperatorSum)
iterate(ms::OperatorSum, state)Iterate over the OperatorPacks contained in an OperatorSum.
Base.length — Method
length(m::OperatorProd) -> IntGet the length of an OperatorProd.
Base.length — Method
length(ms::OperatorSum) -> IntGet the number of OperatorPacks contained in an OperatorSum.
Base.propertynames — Method
propertynames(::Type{I}) where I<:ZeroAtLeast{OperatorIndex} -> ZeroAtLeast{Symbol}Get the property names of a composite id.
Base.replace — Method
replace(m::OperatorPack, v) -> OperatorPackReplace the value of an OperatorPack.
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.
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.
Base.valtype — Method
valtype(m::OperatorPack)
valtype(::Type{T}) where {T<:OperatorPack}Get the type of the value of an OperatorPack.
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.
LinearAlgebra.ishermitian — Method
ishermitian(id::ZeroAtLeast{OperatorIndex}) -> BoolJudge whether an id is Hermitian.
LinearAlgebra.ishermitian — Method
ishermitian(opts::Operators) -> BoolJudge whether a set of operators as a whole is Hermitian.
LinearAlgebra.ishermitian — Method
ishermitian(m::Operator) -> BoolJudge whether an operator is Hermitian.
LinearAlgebra.mul! — Method
mul!(ms::OperatorSum, factor::Number) -> OperatorSumGet the in-place multiplication of an OperatorSum with a number.
LinearAlgebra.rank — Method
rank(id::ZeroAtLeast{OperatorIndex}) -> Int
rank(::Type{<:ZeroAtLeast{OperatorIndex, N}}) where N -> IntGet the rank of an id.
LinearAlgebra.rank — Method
rank(m::OperatorProd) -> Int
rank(::Type{M}) where {M<:OperatorProd} -> IntGet the rank of an OperatorProd.
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.
QuantumLattices.QuantumOperators.idtype — Method
idtype(m::OperatorPack)
idtype(::Type{T}) where {T<:OperatorPack}Get the type of the id of an OperatorPack.
QuantumLattices.QuantumOperators.isequivalenttoscalar — Method
isequivalenttoscalar(m::QuantumOperator) -> Bool
isequivalenttoscalar(::Type{M}) where {M<:QuantumOperator} -> BoolJudge whether a QuantumOperator is equivalent to a scalar.
QuantumLattices.QuantumOperators.isequivalenttoscalar — Method
isequivalenttoscalar(::Type{<:OperatorPack}) -> Bool
isequivalenttoscalar(::Type{<:OperatorPack{V, Tuple{}} where V}) -> BoolJudge whether an OperatorPack is equivalent to a scalar.
QuantumLattices.QuantumOperators.latexformat — Method
latexformat(T::Type{<:OperatorIndex}) -> LaTeX
latexformat(T::Type{<:OperatorIndex}, l::LaTeX) -> LaTeXGet/Set the LaTeX format for a subtype of OperatorIndex.
QuantumLattices.QuantumOperators.latexname — Method
latexname(T::Type{<:OperatorIndex}) -> SymbolGet the name of a type of OperatorIndex in the latex format lookups.
QuantumLattices.QuantumOperators.matrix — Function
matrixGeneric matrix representation.
QuantumLattices.QuantumOperators.operatortype — Method
operatortype(m::QuantumOperator)Get the operator type of a QuantumOperator, which is defined to be the type it corresponds to so that addition between two such objects can be performed directly. Usually, it is a subtype of OperatorPack.
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.
QuantumLattices.QuantumOperators.scalartype — Method
scalartype(t)
scalartype(::Type{T}) where {T<:Number}
scalartype(::Type{<:AbstractArray{T}}) where T
scalartype(::Type{<:ZeroAtLeast{T}}) where TGet the scalar type of an object.
QuantumLattices.QuantumOperators.scalartype — Method
scalartype(::Type{M}) where {M<:QuantumOperator}Get the scalar type of a QuantumOperator.
QuantumLattices.QuantumOperators.scalartype — Method
scalartype(::Type{T}) where {T<:OperatorPack}Scalar type of the coefficient of an OperatorPack.
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}) -> TupleGet the body/superscript/subscript of the LaTeX string representation of an operator index.
QuantumLattices.QuantumOperators.script — Method
script(u::OperatorIndex, ::Val{}; kwargs...) -> StringDefault script for an operator index, which always return an empty string.
QuantumLattices.QuantumOperators.sequence — Method
sequence(m::OperatorProd, table) -> NTuple{rank(m), Int}Get the sequence of the id of a quantum operator according to a table.
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.
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.
QuantumLattices.div! — Method
div!(ms::OperatorSum, factor::Number) -> OperatorSumGet the in-place division of an OperatorSum with a number.
QuantumLattices.expand — Method
expand(m::QuantumOperator) -> typeof(m)Expand a QuantumOperator, which is defined to be itself.
QuantumLattices.id — Method
id(m::OperatorPack) -> idtype(m)Get the id of an OperatorPack.
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.
QuantumLattices.update! — Method
update!(m::QuantumOperator; parameters...) -> typeof(m)Update the parameters of a QuantumOperator in place and return the updated one.
By default, the parameter update of a QuantumOperator does nothing.
QuantumLattices.value — Method
value(m::OperatorPack) -> valtype(m)Get the value of an OperatorPack.