Basic Types

Basic Types

Basis

Basis is a useful object when describing a Hilbert space. In quantum physics, there are many kind of basis in different problems, including qubits, lattice site, infinity basis, etc.

The basis we mention here and implemented in this package is the tagged part. If you need to use Dirac ket expression, you can simply do it by hands with dot function in Julia's linear algebra stdlib. We will not be able to help you to figure out which one is left ket and which one is the right at the moment. To be specific, the basis here means what is inside you ket expression.

$|basis\rangle$ or $\langle basis|$

Label

All the labels are subtype of SiteLabel, label type is used to provide information about the content in a AbstractSites instance.

QMTK offers three kind of labels: Bit, Spin, Half for binary configurations.

QMTK.BitType.
Bit <: BitSiteLabel

Binary State, Bit. Has two state: 0, 1

source
QMTK.SpinType.
Spin <: BitSiteLabel

Binary State, Spin. Has two state: -1, 1

source
QMTK.HalfType.
Half <: BitSiteLabel

Binary State, Half. Has two state: -0.5, 0.5

source

Sites

The abstract hierachy for site is defined as any subtype of AbstractArray with label.

AbstractSites{Label, T, N} <: AbstractArray{T, N}

Sites are arrays with certain labels

source

Sites is a Julia native array with certain label that tells the program which kind of site it is.

QMTK.SitesType.
Sites{L <: SiteLabel, T, N} <: AbstractSites{L, T, N}

Lattice Sites are Julia Arrays with certain Label, it is able to use array interface.

TODO: type promote to normal arrays when mixed with normal arrays.

source

And naive example of Sites could be the Bit configuration on a Chain lattice (a 1-D Array of Bits on the memory)

$0\quad 1\quad 0\quad 1\quad 1\quad 0$

You can declare it by

julia> Sites(Bit, [0, 1, 0, 1, 1, 0])
6-element QMTK.Sites{QMTK.Bit,Int64,1}:
 0
 1
 0
 1
 1
 0

Sites is implemented to support most of Julia array interface, but since Julia do not have inherit of interface, not all operations is overloaded, please use method data, when you need to access its content in calculatoin.

QMTK.dataFunction.
data(sites)

get data of this sites

source
data(space::AbstractSpace{T, S}) -> T

get the current data of this space

source

SubSites

For small sites, it usually contains only a few configuration, and when we try to use a subset of Sites, it would be a waste to create a new Sites, SubSites offer a way to do this efficiently by telling the compiler how large it is in compile time (by Tuple).

QMTK.SubSitesType.
SubSites{Label, T, Length} <: AbstractSites{Label, T, 1}

Sub-sites is usually derived from Sites. It contains several sites in a tuple for local operations.

NOTE: SubSites should be designed faster for bitwise operations, cause this will be a temperory type for traversing through lattice.

source

Or to be simple, you can just interpret SubSites to be a Tuple with certain SiteLabel. Use it like a native Tuple.

julia> SubSites(Bit, 1, 0)
2-element QMTK.SubSites{QMTK.Bit,Int64,2}:
 1
 0

and just like tuple

julia> a, b = SubSites(Bit, 1, 0);

julia> a
1

julia> b
0

Space

Space are math objects contains a set of objects with certain structure. In QMTK we present it as AbstractSpace.

AbstractSpace{T, S}

General abstract type for space with T as its content in state S.

In fact, an instance of a space should be a type with a temporary memory to store an element of the space in type T.

source

There are currently two kinds of state for a space.

SpaceState
Randomized
Initialized

There are two kind of space currently

QMTK.RealSpaceType.
RealSpace{T, DType, S} <: AbstractSpace{T, S}

A real space contains element of type DType (e.g Array or a Number), the numeric content of each element has type T (eltype(DType) = T)

A naive example is the 1-D real space

julia> RealSpace(min=-1, max=1)
QMTK.RealSpace{Float64,Float64,QMTK.Randomized}(-1.0, 1.0, -0.04293376352914002)
source
QMTK.SiteSpaceType.
SiteSpace{NFlips, S} <: AbstractSpace{Sites, S}

A space of sites contains all possible configurations of the sites. NFlips indicated how many site will flip according to certain rules when shake! is called.

SiteSpace(label, shape; nflips)

constructs a SiteSpace with label in type SiteLabel, and shape with an optional keyword nflips (default to be 1).

julia> SiteSpace(Bit, 2, 2)
QMTK.SiteSpace{1,QMTK.Randomized}(Int8[1 1; 0 0])
source

Interface

A space object has the following interface

methoddescription
dataproperty, required
reset!required
copyrequired
acquirerequired
shake!required
randomizedrequired
traverseoptional
QMTK.dataMethod.
data(space::AbstractSpace{T, S}) -> T

get the current data of this space

source
QMTK.reset!Function.
reset!(space) -> space # with initilized state

reset the temporary data of this space to initial position be careful that the state of the space will also be changed assign it to your variable manually.

space = reset!(space)
source
Base.copyFunction.
copy(space) -> space

copy the space instance

source
QMTK.acquireFunction.
acquire(space) -> element

get a copy of current element of the space

source
QMTK.shake!Function.
shake!(space) -> space

shake the space and move current element to a random position. the space has to be a space with Randomized state. or it will an UnRandomizedError.

source
QMTK.randomize!Function.
randomize!(space) -> space

randomized the space, move current element to a random position and change the state of this space to Initialized

source
QMTK.traverseFunction.
traverse(space) -> iterator

get an iterator that traverses the whole space.

source