Algebra over fields

An algebra over a field is a vector space over that field, in which a bilinear operator (often called the "multiplication") between vectors is 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 only. 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 this module, for scalars in the field and elements in the algebra, we only provide the interfaces of the scalar multiplication (including the scalar division) between a scalar and an element, the addition (including the subtraction) and the usual multiplication between two elements. Other complicated operations should be composed from these basic ones.

SimpleID and ID

SimpleID is the building block of the id system of an algebra over a field, while ID defines the specific identifier of an element in that algebra.

Generally, the usual multiplication between two elements of an algebra is not commutable, and the rank of the multiplication is just the add-up before the simplification with the help of the algebra structure. We thus use a simple id to denote a single basis of the corresponding vector space, and an id to denote the identifier of an element. With the help of the direct product () of two ids, an over complete id system designed for the whole algebra is constructed. This id system is redundant because it does not reflects the structure constants of the algebra, which reduces independent basis elements. Extra mechanisms should be provided to kill this redundancy, which goes beyond the current module. Users should define them themselves.

Element and Elements

Element defines a single element of an algebra while Elements defines an expression composed of several elements from an algebra.

An Element must have two predefined contents:

  • value::Number: the coefficient of the element
  • id::ID: the id of the element

Arithmetic operations (+, -, *, /) between a scalar, an Element or an Elements is defined. See Manual for details.

Manual

Core.NumberMethod
Number(m::Element) -> valtype(m)

Get the value of an element.

source
Base.:*Method
*(m::Element, ::Nothing) -> Nothing
*(::Nothing, m::Element) -> Nothing
*(factor::Number, m::Element) -> Element
*(m::Element, factor::Number) -> Element
*(m1::Element, m2::Element) -> Element
*(ms::Elements, ::Nothing) -> Nothing
*(::Nothing, ms::Elements) -> Nothing
*(factor::Number, ms::Elements) -> Elements
*(ms::Elements, factor::Number) -> Elements
*(m::Element, ms::Elements) -> Elements
*(ms::Elements, m::Element) -> Elements
*(ms1::Elements, ms2::Elements) -> Elements

Overloaded * operator for element-scalar multiplications and element-element multiplications of an algebra over a field.

source
Base.:*Method
*(sid1::SimpleID, sid2::SimpleID) -> ID{SimpleID}
*(sid::SimpleID, cid::ID{SimpleID}) -> ID{SimpleID}
*(cid::ID{SimpleID}, sid::SimpleID) -> ID{SimpleID}
*(cid1::ID{SimpleID}, cid2::ID{SimpleID}) -> ID{SimpleID}

Get the product of the id system.

source
Base.:+Method
+(m::Element) -> typeof(m)
+(m::Element, ::Nothing) -> typeof(m)
+(::Nothing, m::Element) -> typeof(m)
+(m::Element, factor::Number) -> Elements
+(factor::Number, m::Element) -> Elements
+(m1::Element, m2::Element) -> Elements
+(ms::Elements) -> typeof(ms)
+(ms::Elements, ::Nothing) -> typeof(ms)
+(::Nothing, ms::Elements) -> typeof(ms)
+(ms::Elements, factor::Number) -> Elements
+(factor::Number, ms::Elements) -> Elements
+(ms::Elements, m::Element) -> Elements
+(m::Element, ms::Elements) -> Elements
+(ms1::Elements, ms2::Elements) -> Elements

Overloaded + operator between elements of an algebra over a field.

source
Base.:-Method
-(m::Element) -> typeof(m)
-(m::Element, ::Nothing) -> typeof(m)
-(::Nothing, m::Element) -> typeof(m)
-(m::Element, factor::Number) -> Elements
-(factor::Number, m::Element) -> Elements
-(m1::Element, m2::Element) -> Elements
-(ms::Elements) -> typeof(ms)
-(ms::Elements, ::Nothing) -> typeof(ms)
-(::Nothing, ms::Elements) -> typeof(ms)
-(ms::Elements, factor::Number) -> Elements
-(factor::Number, ms::Elements) -> Elements
-(m::Element, ms::Elements) -> Elements
-(ms::Elements, m::Element) -> Elements
-(ms1::Elements, ms2::Elements) -> Elements

Overloaded - operator between elements of an algebra over a field.

source
Base.:/Method
/(m::Element, factor::Number) -> Element
/(m::Element, factor::Scalar) -> Element
/(ms::Elements, factor::Number) -> Elements
/(ms::Elements, factor::Scalar) -> Elements

Overloaded / operator for element-scalar division of an algebra over a field.

source
Base.://Method
//(m::Element, factor::Integer) -> Element
//(m::Element, factor::Scalar) -> Element
//(ms::Elements, factor::Integer) ->  Elements
//(ms::Elements, factor::Scalar) -> Elements

Overloaded // operator for element-scalar division of an algebra over a field.

source
Base.:==Method
==(ms::Elements, ::Nothing) -> Bool
==(::Nothing, ms::Elements) -> Bool

Judge whether a set of elements is identically empty.

source
Base.:==Method
==(m1::Element, m2::Element) -> Bool

Compare two elements and judge whether they are equal to each other.

source
Base.:^Method
^(m::Element, n::Integer) -> Element
^(ms::Elements, n::Integer) -> Elements

Overloaded ^ operator for element-integer power of an algebra over a field.

source
Base.convertMethod
convert(::Type{M}, m::Scalar) where M<:Scalar
convert(::Type{M}, m::Number) where M<:Scalar
convert(::Type{M}, m::Element) where M<:Element
  1. Convert a scalar element from one type to another;
  2. Convert a scalar to a scalar element;
  3. Convert an element from one type to another.
source
Base.getpropertyMethod
getproperty(cid::ID{SimpleID}, name::Symbol)

Get the property of a composite id.

source
Base.isapproxMethod
isapprox(m1::Element, m2::Element; atol::Real=atol, rtol::Real=rtol) -> Bool

Compare two elements and judge whether they are inexactly equivalent to each other.

source
Base.isequalMethod
isequal(ms::Elements, ::Nothing) -> Bool
isequal(::Nothing, ms::Elements) -> Bool

Judge whether a set of elements is identically empty.

source
Base.isequalMethod
isequal(m1::Element, m2::Element) -> Bool

Compare two elements and judge whether they are equal to each other.

source
Base.islessMethod
isless(::Type{<:SimpleID}, cid1::ID{SimpleID}, cid2::ID{SimpleID}) -> Bool

Compare two ids and judge whether the first is less than the second.

The comparison rule are as follows:

  1. ids with smaller ranks are always less than those with higher ranks;
  2. if two ids are of the same rank, the comparison goes just like that between tuples.
source
Base.oneMethod
one(::Type{M}) where M<:Element
one(m::Element)

Get the identity operator.

source
Base.permute!Method
permute!(result::Elements, m::Element, table) -> Elements
permute!(result::Elements, ms::Elements, table) -> Elements

Permute the ids of an-element/a-set-of-elements to the descending order according to a table, and store the permuted elements in result.

Note

To use this function, the user must implement a method of permute, which computes the result of the permutation of a rank-2 element and takes the following interface:

permute(::Type{M}, id1::SimpleID, id2::SimpleID) -> Union{M, Elements}

Here, M is the type of the input element m in permute!, id1 and id2 are two arbitary simple ids contained in id(m).

source
Base.promote_ruleMethod
promote_rule(::Type{M1}, ::Type{M2}) where {M1<:Element, M2<:Element}

Define the promote rule for Element types.

source
Base.promote_typeMethod
promote_type(::Type{Tuple{}}, I::Type{<:ID{SimpleID, N}}) where N
promote_type(I::Type{<:ID{SimpleID, N}}, ::Type{Tuple{}}) where N

Define the promote rule for ID types.

source
Base.promote_typeMethod
promote_type(::Type{M}, ::Type{V}, ::Val{:*}) where {M<:Element, V<:Number}
promote_type(::Type{V}, ::Type{M}, ::Val{:*}) where {M<:Element, V<:Number}

Define the promote rule for the multiplication between an Element and a scalar.

source
Base.propertynamesMethod
propertynames(::Type{I}) where I<:ID{SimpleID} -> Tuple{Vararg{Symbol}}

Get the property names of a composite id.

source
Base.replaceMethod
replace(m::Element, v::Number) -> Element

Replace the value of an element.

source
Base.replaceMethod
replace(m::Element, pairs::Pair{<:SimpleID, <:Union{Element, Elements}}...) -> Element/Elements
replace(ms::Elements, pairs::Pair{<:SimpleID, <:Union{Element, Elements}}...) -> Elements

Replace the rank-1 components of an element with new element/elements.

source
Base.replaceMethod
replace(m::Element; kwargs...) -> typeof(m)

Return a copy of a concrete Element with some of the field values replaced by the keyword arguments.

source
Base.reprMethod
repr(ms::Elements) -> String

Get the repr representation of a set of elements.

source
Base.showMethod
show(io::IO, ms::Elements)

Show a set of elements.

source
Base.showMethod
show(io::IO, cid::Tuple{SimpleID, Vararg{SimpleID}})

Show a composite id.

source
Base.splitMethod
split(m::Element) -> Tuple{Any, Vararg{Element}}

Split an element into the coefficient and a sequence of rank-1 elements.

source
Base.valtypeMethod
valtype(m::Element)
valtype(::Type{T}) where {T<:Element}

Get the type of the value of an element.

The result is also the type of the field over which the algebra is defined.

source
Base.zeroMethod
zero(ms::Elements) -> Nothing
zero(::Type{<:Elements}) -> Nothing

Get a zero set of elements.

A zero set of elements is defined to be the one with no elements.

source
QuantumLattices.Interfaces.:⊗Method
⊗(m::Element, ms::Elements) -> Elements
⊗(ms::Elements, m::Element) -> Elements
⊗(ms1::Elements, ms2::Elements) -> Elements

Overloaded operator for element-element multiplications of an algebra over a field.

source
QuantumLattices.Interfaces.:⋅Method
⋅(m::Element, ms::Elements) -> Elements
⋅(ms::Elements, m::Element) -> Elements
⋅(ms1::Elements, ms2::Elements) -> Elements

Overloaded operator for element-element multiplications of an algebra over a field.

source
QuantumLattices.Interfaces.add!Method
add!(ms::Elements) -> typeof(ms)
add!(ms::Elements, ::Nothing) -> typeof(ms)
add!(ms::Elements, m::Number) -> typeof(ms)
add!(ms::Elements, m::Element) -> typeof(ms)
add!(ms::Elements, mms::Elements) -> typeof(ms)

Get the inplace addition of elements to a set.

source
QuantumLattices.Interfaces.div!Method
div!(ms::Elements, factor::Scalar) -> Elements
div!(ms::Elements, factor::Number) -> Elements

Get the inplace division of element with a scalar.

source
QuantumLattices.Interfaces.mul!Method
mul!(ms::Elements, factor::Scalar) -> Elements
mul!(ms::Elements, factor::Number) -> Elements

Get the inplace multiplication of elements with a scalar.

source
QuantumLattices.Interfaces.permuteMethod
permute(m::Element, table) -> Elements
permute(ms::Elements, table) -> Elements

Permute the ids of an-element/a-set-of-elements to the descending order according to a table.

source
QuantumLattices.Interfaces.rankMethod
rank(id::ID{SimpleID}) -> Int
rank(::Type{<:ID{SimpleID}}) -> Any
rank(::Type{<:ID{SimpleID, N}}) where N -> Int

Get the rank of a composite id.

source
QuantumLattices.Interfaces.sub!Method
sub!(ms::Elements) -> typeof(ms)
sub!(ms::Elements, ::Nothing) -> typeof(ms)
add!(ms::Elements, m::Number) -> typeof(ms)
sub!(ms::Elements, m::Element) -> typeof(ms)
sub!(ms::Elements, mms::Elements) -> typeof(ms)

Get the inplace subtraction of elements from a set.

source