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.
OperatorUnit
OperatorUnit
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 OperatorProd
s. 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.ID
— TypeID{U<:OperatorUnit, N}
The id of a composite quantum operator, which is an ordered set of operator units.
Type alias for NTuple{N, U} where {U<:OperatorUnit}
.
QuantumLattices.QuantumOperators.ID
— MethodID(id::OperatorUnit...)
ID(u::OperatorUnit, id::ID{OperatorUnit})
ID(id::ID{OperatorUnit}, u::OperatorUnit)
ID(id₁::ID{OperatorUnit}, id₂::ID{OperatorUnit})
Get the id from operator units/ids.
QuantumLattices.QuantumOperators.ID
— MethodID(::Type{U}, attrs::Vararg{NTuple{N}, M}) where {U<:OperatorUnit, N, M}
Get the composite id from the components of singular ids.
QuantumLattices.QuantumOperators.LaTeX
— TypeLaTeX{SP, SB}(body, spdelimiter::String=", ", sbdelimiter::String=", "; options...) where {SP, SB}
LaTeX string representation of quantum operators.
QuantumLattices.QuantumOperators.LinearFunction
— TypeLinearFunction{F<:Function} <: LinearTransformation
Wrapper a function to be a linear transformation.
QuantumLattices.QuantumOperators.LinearTransformation
— TypeLinearTransformation <: Transformation
Abstract linear transformation on quantum operators.
QuantumLattices.QuantumOperators.LinearTransformation
— Method(transformation::LinearTransformation)(ms::OperatorSet; kwargs...) -> OperatorSet
Get the linear transformed quantum operators.
QuantumLattices.QuantumOperators.Matrixization
— TypeMatrixization <: LinearTransformation
The matrixization transformation.
QuantumLattices.QuantumOperators.Operator
— TypeOperator{V, I<:ID{OperatorUnit}} <: OperatorProd{V, I}
Operator.
QuantumLattices.QuantumOperators.OperatorPack
— TypeOperatorPack{V, I} <: QuantumOperator
The entity 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
— TypeOperatorProd{V, I<:Tuple} <: OperatorPack{V, I}
A special kind of OperatorPack
, where the relation between the coefficient and each component of the opeator id can be viewed as product.
QuantumLattices.QuantumOperators.OperatorSet
— TypeOperatorSet{M<:OperatorPack} <: QuantumOperator
Set of OperatorPack
s.
- The relation between two
OperatorPack
s in anOperatorSet
can be viewed as addition. - But in general, only iteration over
OperatorPack
s and length are supported. - To use arithmetic operations, please refer to its subtype,
OperatorSum
.
QuantumLattices.QuantumOperators.OperatorSum
— TypeOperatorSum{M<:OperatorPack, I} <: OperatorSet{M}
The sum of OperatorPack
s.
Similar items are automatically merged with the aid of the id system.
QuantumLattices.QuantumOperators.OperatorSum
— MethodOperatorSum(ms)
OperatorSum(ms::QuantumOperator...)
OperatorSum{M}(ms) where {M<:OperatorPack}
OperatorSum{M}(ms::QuantumOperator...) where {M<:OperatorPack}
Get the sum of OperatorPack
s.
QuantumLattices.QuantumOperators.OperatorUnit
— TypeOperatorUnit <: QuantumOperator
An operator unit 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 for quantum operators in representative of the internal degrees of freedom.
QuantumLattices.QuantumOperators.Operators
— TypeOperators{O<:Operator, I<:ID{OperatorUnit}}
A set of operators.
Type alias for OperatorSum{O<:Operator, I<:ID{OperatorUnit}}
.
QuantumLattices.QuantumOperators.Operators
— MethodOperators(opts::Operator...)
Operators{M}(opts::Operator...)
Get a set of operators.
QuantumLattices.QuantumOperators.Permutation
— TypePermutation{T} <: LinearTransformation
The permutation transformation.
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
.
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₁::OperatorUnit, u₂::OperatorUnit) -> Union{OperatorProd, OperatorSum}
Here, u₁
and u₂
are two arbitrary operator units contained in id(m)
.
QuantumLattices.QuantumOperators.QuantumOperator
— TypeQuantumOperator
The abstract type of any quantum operator.
QuantumLattices.QuantumOperators.RankFilter
— TypeRankFilter{R} <: LinearTransformation
Rank filter, which filters out the OperatorProd
with a given rank R
.
QuantumLattices.QuantumOperators.TabledUnitSubstitution
— TypeTabledUnitSubstitution{U<:OperatorUnit, S<:OperatorSum, T<:AbstractDict{U, S}} <: UnitSubstitution{U, S}
A concrete "unit substitution" transformation, which stores every substitution of the old OperatorUnit
s in its table as a dictionary.
QuantumLattices.QuantumOperators.Transformation
— TypeTransformation <: Function
Abstract transformation on quantum operators.
QuantumLattices.QuantumOperators.UnitSubstitution
— TypeUnitSubstitution{U<:OperatorUnit, S<:OperatorSum} <: LinearTransformation
The "unit substitution" transformation, which substitutes each OperatorUnit
in the old quantum operators to a new expression represented by an OperatorSum
.
QuantumLattices.QuantumOperators.UnitSubstitution
— Method(unitsubstitution::UnitSubstitution)(m::OperatorProd; kwargs...) -> OperatorSum
Substitute every OperatorUnit
in an OperatorProd
with a new OperatorSum
.
Base.:*
— Method*(factor::Number, m::OperatorUnit) -> Operator
*(m::OperatorUnit, factor::Number) -> Operator
*(m₁::OperatorUnit, m₂::OperatorUnit) -> Operator
*(factor::Number, m::OperatorPack) -> OperatorPack
*(m::OperatorPack, factor::Number) -> OperatorPack
*(m₁::OperatorPack, m₂::OperatorUnit) -> OperatorPack
*(m₁::OperatorUnit, m₁::OperatorPack) -> OperatorPack
*(m₁::OperatorPack, m₂::OperatorPack) -> OperatorPack
*(factor::Number, ms::OperatorSum) -> OperatorSum
*(ms::OperatorSum, factor::Number) -> OperatorSum
*(m::OperatorUnit, ms::OperatorSum) -> OperatorSum
*(ms::OperatorSum, m::OperatorUnit) -> 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.
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.
Base.:-
— Method-(m::QuantumOperator) -> QuantumOperator
-(m₁::QuantumOperator, m₂::QuantumOperator) -> OperatorSum
-(factor::Number, m::QuantumOperator) -> OperatorSum
-(m::QuantumOperator, factor::Number) -> OperatorSum
Overloaded -
between quantum operators.
Base.:/
— Method/(m::QuantumOperator, factor::Number) -> QuantumOperator
Overloaded /
between a quantum operator and a number.
Base.://
— Method//(m::QuantumOperator, factor::Number) -> QuantumOperator
Overloaded //
between a quantum operator and a number.
Base.:^
— Method^(m::QuantumOperator, n::Integer) -> QuantumOperator
Overloaded ^
between a quantum operator and an integer.
Base.adjoint
— Methodadjoint(id::ID{OperatorUnit}) -> ID
Get the adjoint of an id.
Base.adjoint
— Methodadjoint(opts::Operators) -> Operators
Get the adjoint of a set of operators.
Base.adjoint
— Methodadjoint(m::Operator) -> Operator
Get the adjoint of an operator.
Base.conj
— Methodconj(m::OperatorUnit) -> OperatorUnit
conj(m::OperatorPack) -> OperatorPack
conj(m::OperatorSum) -> OperatorSum
Get the conjugation.
Base.convert
— Methodconvert(::Type{M}, m::Number) where {M<:OperatorProd}
Convert a number to a quantum operator.
Base.convert
— Methodconvert(::Type{M}, m::OperatorPack) where {M<:OperatorPack}
Convert a quantum operator from one type to another.
Base.convert
— Methodconvert(::Type{M}, u::OperatorUnit) where {M<:Operator}
Convert an operator unit to an operator.
Base.empty
— Methodempty(ms::OperatorSum) -> typeof(ms)
empty!(ms::OperatorSum) -> typeof(ms)
Get an empty copy or empty an OperatorSum
.
Base.getindex
— Methodgetindex(m::OperatorProd, i::Integer) -> OperatorUnit
getindex(m::OperatorProd, slice) -> OperatorProd
Overloaded []
.
Base.getindex
— Methodgetindex(ms::OperatorSum, index::Integer) -> eltype(ms)
getindex(ms::OperatorSum, indexes::AbstractVector{<:Integer}) -> typeof(ms)
getindex(ms::OperatorSum, ::Colon) -> typeof(ms)
Overloaded []
.
Base.getproperty
— Methodgetproperty(id::ID{OperatorUnit}, name::Symbol)
Get the property of a composite id.
Base.haskey
— Methodhaskey(ms::OperatorSum, id) -> Bool
Judge whether an OperatorSum
contains an OperatorPack
with the given id
.
Base.isapprox
— Methodisapprox(m₁::OperatorPack, m₂::OperatorPack; atol::Real=atol, rtol::Real=rtol) -> Bool
Compare two OperatorPack
s and judge whether they are approximate to each other.
Base.isapprox
— Methodisapprox(ms₁::OperatorSum, ms₂::OperatorSum; atol::Real=atol, rtol::Real=rtol) -> Bool
Compare two OperatorSum
s and judge whether they are approximate to each other.
Base.iszero
— Methodiszero(m::OperatorPack) -> Bool
Judge whether an OperatorPack
is zero, i.e., its value is zero.
Base.iszero
— Methodiszero(ms::OperatorSet) -> Bool
Judge whether an OperatorSet
is zero, i.e, it does not contain any OperatorPack
.
Base.iszero
— Methodiszero(ms::OperatorSum) -> Bool
Judge whether an OperatorSum
is zero, i.e, it does not contain any OperatorPack
.
Base.iszero
— Methodiszero(u::OperatorUnit) -> Bool
Judge whether an OperatorUnit
is zero, which is defined to be always false
.
Base.length
— Methodlength(m::OperatorProd) -> Int
Get the length of an OperatorProd
.
Base.length
— Methodlength(ms::OperatorSum) -> Int
Get the number of OperatorPack
s contained in an OperatorSum
.
Base.map!
— Methodmap!(f::Function, ms::OperatorSum; kwargs...) -> typeof(ms)
In place map of an OperatorSum
by the function f
elementally.
Base.one
— Methodone(::Type{M}) where {M<:OperatorProd}
one(m::OperatorProd)
Get the identity quantum operator.
Base.propertynames
— Methodpropertynames(::Type{I}) where I<:ID{OperatorUnit} -> Tuple{Vararg{Symbol}}
Get the property names of a composite id.
Base.replace
— Methodreplace(m::OperatorPack, v) -> OperatorPack
Replace the value of an OperatorPack
.
Base.replace
— Methodreplace(m::QuantumOperator; kwargs...) -> typeof(m)
Return a copy of a concrete QuantumOperator
with some of the field values replaced by the keyword arguments.
Base.show
— Methodshow(io::IO, ::MIME"text/latex", m::QuantumOperator)
Show a quantum operator.
Base.split
— Methodsplit(m::OperatorProd) -> Tuple{valtype(m), Vararg{Any}}
Split an OperatorProd
into the coefficient and a sequence of the components of its id.
Base.valtype
— Methodvaltype(m::OperatorPack)
valtype(::Type{T}) where {T<:OperatorPack}
Get the type of the value of an OperatorPack
.
Base.zero
— Methodzero(::Type{M}) where {M<:QuantumOperator} -> OperatorSum
Get the zero sum.
LaTeXStrings.latexstring
— Methodlatexstring(opt::OperatorProd) -> String
Get the string representation of an operator in the LaTeX format.
LaTeXStrings.latexstring
— Methodlatexstring(opts::OperatorSet) -> String
Get the string representation of a set of operators in the LaTeX format.
LaTeXStrings.latexstring
— Methodlatexstring(u::OperatorUnit) -> String
LaTeX string representation of an operator unit.
LinearAlgebra.ishermitian
— Methodishermitian(id::ID{OperatorUnit}) -> Bool
Judge whether an id is Hermitian.
LinearAlgebra.ishermitian
— Methodishermitian(opts::Operators) -> Bool
Judge whether a set of operators as a whole is Hermitian.
LinearAlgebra.ishermitian
— Methodishermitian(m::Operator) -> Bool
Judge whether an operator is Hermitian.
LinearAlgebra.mul!
— Methodmul!(ms::OperatorSum, factor::Number) -> OperatorSum
Get the in-place multiplication of an OperatorSum
with a number.
LinearAlgebra.rank
— Methodrank(id::ID{OperatorUnit}) -> Int
rank(::Type{<:ID{OperatorUnit, N}}) where N -> Int
Get the rank of an id.
LinearAlgebra.rank
— Methodrank(m::OperatorProd) -> Int
rank(::Type{M}) where {M<:OperatorProd} -> Int
Get the rank of an OperatorProd
.
QuantumLattices.QuantumOperators.idtype
— Methodidtype(m::OperatorPack)
idtype(::Type{T}) where {T<:OperatorPack}
The type of the id of an OperatorPack
.
QuantumLattices.QuantumOperators.latexformat
— Methodlatexformat(T::Type{<:OperatorUnit}) -> LaTeX
latexformat(T::Type{<:OperatorUnit}, l::LaTeX) -> LaTeX
Get/Set the LaTeX format for a subtype of OperatorUnit
.
QuantumLattices.QuantumOperators.latexname
— Methodlatexname(T::Type{<:OperatorUnit}) -> Symbol
Get the name of a type of OperatorUnit
in the latex format lookups.
QuantumLattices.QuantumOperators.matrix
— Functionmatrix
Generic matrix representation.
QuantumLattices.QuantumOperators.optype
— Methodoptype(m::QuantumOperator)
optype(::Type{<:QuantumOperator})
Get the corresponding OperatorPack
type of a generic quantum operator.
QuantumLattices.QuantumOperators.script
— Methodscript(u::OperatorUnit, l::LaTeX, ::Val{:BD}) -> Any
script(u::OperatorUnit, l::LaTeX, ::Val{:SP}) -> Tuple
script(u::OperatorUnit, l::LaTeX, ::Val{:SB}) -> Tuple
Get the body/superscript/subscript of the LaTeX string representation of an operator unit.
QuantumLattices.QuantumOperators.script
— Methodscript(u::OperatorUnit, ::Val{}; kwargs...) -> String
Default script for an operator unit, which always return an empty string.
QuantumLattices.QuantumOperators.sequence
— Methodsequence(m::OperatorProd, table) -> NTuple{rank(m), Int}
Get the sequence of the id of a quantum operator according to a table.
QuantumLattices.add!
— Methodadd!(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!
— Methodadd!(ms::OperatorSum) -> typeof(ms)
add!(ms::OperatorSum, m::Union{Number, OperatorUnit, OperatorPack}) -> typeof(ms)
add!(ms::OperatorSum, mms::OperatorSum) -> typeof(ms)
Get the in-place addition of quantum operators.
QuantumLattices.div!
— Methoddiv!(ms::OperatorSum, factor::Number) -> OperatorSum
Get the in-place division of an OperatorSum
with a number.
QuantumLattices.dtype
— Methoddtype(m::OperatorPack)
dtype(::Type{T}) where {T<:OperatorPack}
The data type of the coefficient of an OperatorPack
.
QuantumLattices.id
— Methodid(m::OperatorPack) -> idtype(m)
Get the id of an OperatorPack
.
QuantumLattices.sub!
— Methodsub!(ms::OperatorSum) -> typeof(ms)
sub!(ms::OperatorSum, m::Union{Number, OperatorUnit, OperatorPack}) -> typeof(ms)
sub!(ms::OperatorSum, mms::OperatorSum) -> typeof(ms)
Get the in-place subtraction of quantum operators.
QuantumLattices.value
— Methodvalue(m::OperatorPack) -> valtype(m)
Get the value of an OperatorPack
.