Vector spaces
A vector space is a linear space, in which the addition of vectors and multiplication of a vector by a scalar are defined.
Vector spaces are frequently encountered in physics, e.g. the Hilbert space in quantum mechanics. In this submodule, we only implement those with finite dimensions. We want to remark that in our implementation, a vector space is a subtype of an abstract vector, therefore, the bases always possess a order, which means, two vector spaces are not considered to be equal to each other even if their corresponding actual mathematical spaces are the same but the orders of the bases are different.
VectorSpace
VectorSpace{B}
is the abstraction of a vector space, which has only one type parameter:
B<:Any
: the type of the bases of the vector space
Basically, a subtype should implement the following 3 methods:
Get the dimension of a vector spacedimension(vs::VectorSpace) -> Int
Get the ith basis of a vector spaceBase.getindex(vs::VectorSpace{B}, i::Int) where B -> B
Search the index of a basis in a vector spaceBase.searchsortedfirst(vs::VectorSpace{B}, basis::B) where B -> Int
Other features include
- comparison:
==
andisequal
- iteration:
iterate
- inquiry:
size
,findfirst
andin
EnumerativeVectorSpace
EnumerativeVectorSpace
is the simplest vector space, whose bases are stored in the predefined content :table
.
CartesianVectorSpace
CartesianVectorSpace
defines the abstract class of multiindexable vector spaces, whose bases can be accessed by a Cartesian index.
NamedVectorSpace
NamedVectorSpace{M, NS, BS, VS}
defines a multiindexable vector space, each of whose indexable dimensions is associated with a name.
It has four type parameters:
M
: mode of the named vector space. It specifies how the indexable dimensions are combined to form the bases of the named vector space, and must take one of the following values::⊕
: elements from each indexable dimensions are zipped together to form the bases,:⊗
: elements from each indexable dimensions are direct producted together to form the bases.
For the :⊕
mode, all the indexable dimensions should have the same number of elements, and the number of formed bases is equal to this number; for the :⊗
mode, there are no restriction on the numbers of the indexable dimensions, and the number of the final bases is equal to their product.
NS::Tuple{Vararg{Symbol}}
: the names of the indexable dimensionsBS<:Tuple
: the eltypes of the indexable dimensionsVS<:Tuple{Vararg{AbstractVector}}
: the contents of the indexable dimensions
The concrete types must have the following predefined content:
:contents::VS
: storage of the contents of the indexable dimensions
Manual
QuantumLattices.Mathematics.VectorSpaces.CartesianVectorSpace
— TypeCartesianVectorSpace{B} <: VectorSpace{B}
Abstract Cartesian vector space.
QuantumLattices.Mathematics.VectorSpaces.EnumerativeVectorSpace
— TypeEnumerativeVectorSpace{B} <: VectorSpace{B}
Abstract enumerative vector space.
QuantumLattices.Mathematics.VectorSpaces.NamedVectorSpace
— TypeNamedVectorSpace{M, NS, BS<:Tuple, VS<:Tuple{Vararg{AbstractVector}}} <: CartesianVectorSpace{NamedTuple{NS, BS}}
Abstract named vector space.
This is a wrapper of Cartesian indexable vector spaces, each of whose indexable dimensions is associated with a name.
It has four type parameters:
M
: mode of the named vector space. It specifies how the indexable dimensions are combined to form the bases of the named vector space, and must take one of the following values::⊕
: elements from each indexable dimensions are zipped together to form the bases,:⊗
: elements from each indexable dimensions are direct producted together to form the bases.
For the :⊕
mode, all the indexable dimensions should have the same number of elements, and the number of formed bases is equal to this number; for the :⊗
mode, there are no restriction on the numbers of the indexable dimensions, and the number of the final bases is equal to their product.
NS::Tuple{Vararg{Symbol}}
: the names of the indexable dimensionsBS<:Tuple
: the eltypes of the indexable dimensionsVS<:Tuple{Vararg{AbstractVector}}
: the contents of the indexable dimensions
The subtypes must have the following predefined content:
:contents::VS
: storage of the contents of the indexable dimensions
QuantumLattices.Mathematics.VectorSpaces.VectorSpace
— TypeVectorSpace{B} <: AbstractVector{B}
Abstract vector space.
Base.eltype
— Methodeltype(nvs::NamedVectorSpace, i::Int)
eltype(::Type{<:NamedVectorSpace{M, NS, BS} where {M, NS}}, i::Int) where BS
Get the eltype of the ith indexable dimensions of a named vector space.
Base.keys
— Methodkeys(nvs::NamedVectorSpace) -> Tuple{Vararg{Symbol}}
keys(::Type{<:NamedVectorSpace{M, NS} where M}) where NS -> Tuple{Vararg{Symbol}}
Get the names of a named vector space.
Base.pairs
— Methodpairs(nvs::NamedVectorSpace) -> Base.Iterators.Pairs
Get the name-value pairs of a named vector space.
Base.values
— Methodvalues(nvs::NamedVectorSpace) -> Tuple{Vararg{AbstractVector}}
Get the contents of a named vector space.