MPS and MPO

Types

ITensors.MPSType
MPS

A finite size matrix product state type. Keeps track of the orthogonality center.

source
ITensors.MPOType
MPO

A finite size matrix product operator type. Keeps track of the orthogonality center.

source

MPS Constructors

ITensors.MPSMethod
MPS(N::Int)

Construct an MPS with N sites with default constructed ITensors.

source
ITensors.MPSMethod
MPS([::Type{ElT} = Float64, ]sites)

Construct an MPS filled with Empty ITensors of type ElT from a collection of indices.

source
ITensors.randomMPSMethod
randomMPS(sites::Vector{<:Index}; linkdim=1)

Construct a random MPS with link dimension linkdim of type Float64.

source
ITensors.randomMPSMethod
randomMPS(::Type{ElT<:Number}, sites::Vector{<:Index}; linkdim=1)

Construct a random MPS with link dimension linkdim of type ElT.

source
ITensors.randomMPSMethod
randomMPS(sites::Vector{<:Index}, state; linkdim=1)

Construct a real, random MPS with link dimension linkdim, made by randomizing an initial product state specified by state. This version of randomMPS is necessary when creating QN-conserving random MPS (consisting of QNITensors). The initial state array provided determines the total QN of the resulting random MPS.

source
ITensors.productMPSMethod
productMPS(sites::Vector{<:Index},states)

Construct a product state MPS having site indices sites, and which corresponds to the initial state given by the array states. The states array may consist of either an array of integers or strings, as recognized by the state function defined for the relevant Index tag type.

Examples

N = 10
sites = siteinds("S=1/2",N)
states = [isodd(n) ? "Up" : "Dn" for n=1:N]
psi = productMPS(sites,states)
source
ITensors.productMPSMethod
productMPS(::Type{T},
           sites::Vector{<:Index},
           states::Union{Vector{String},
                         Vector{Int},
                         String,
                         Int})

Construct a product state MPS of element type T, having site indices sites, and which corresponds to the initial state given by the array states. The input states may be an array of strings or an array of ints recognized by the state function defined for the relevant Index tag type. In addition, a single string or int can be input to create a uniform state.

Examples

N = 10
sites = siteinds("S=1/2", N)
states = [isodd(n) ? "Up" : "Dn" for n=1:N]
psi = productMPS(ComplexF64, sites, states)
phi = productMPS(sites, "Up")
source
ITensors.productMPSMethod
productMPS(ivals::Vector{<:IndexVal})

Construct a product state MPS with element type Float64 and nonzero values determined from the input IndexVals.

source
ITensors.productMPSMethod
productMPS(::Type{T<:Number}, ivals::Vector{<:IndexVal})

Construct a product state MPS with element type T and nonzero values determined from the input IndexVals.

source

MPO Constructors

ITensors.MPOMethod
MPO(N::Int)

Make an MPO of length N filled with default ITensors.

source
ITensors.MPOMethod
MPO([::Type{ElT} = Float64}, ]sites, ops::Vector{String})

Make an MPO with pairs of sites s[i] and s[i]' and operators ops on each site.

source
ITensors.MPOMethod
MPO([::Type{ElT} = Float64, ]sites, op::String)

Make an MPO with pairs of sites s[i] and s[i]' and operator op on every site.

source

Properties

ITensors.linkindMethod
linkind(M::MPS, j::Int)

linkind(M::MPO, j::Int)

Get the link or bond Index connecting the MPS or MPO tensor on site j to site j+1.

If there is no link Index, return nothing.

source

Grabbing and finding indices

ITensors.firstsiteindFunction
firstsiteind(M::Union{MPS,MPO}, j::Int; kwargs...)

Return the first site Index found on the MPS or MPO (the first Index unique to the jth MPS/MPO tensor).

You can choose different filters, like prime level and tags, with the kwargs.

source
ITensors.firstsiteindsFunction
firstsiteinds(M::MPO; kwargs...)

Get a Vector of the first site Index found on each site of M.

By default, it finds the first site Index with prime level 0.

source
ITensors.siteindMethod
siteind(M::MPO, j::Int; plev = 0, kwargs...)

Get the first site Index of the MPO found, by default with prime level 0.

source
ITensors.siteindsMethod
siteinds(M::MPO; kwargs...)

Get a Vector of IndexSets the all of the site indices of M.

source
ITensors.siteindsMethod
siteinds(M::Union{MPS, MPO}}, j::Int; kwargs...)

Return the site Indices found of the MPO or MPO at the site j as an IndexSet.

Optionally filter prime tags and prime levels with keyword arguments like plev and tags.

source
ITensors.findsiteFunction
findsite(M::Union{MPS, MPO}, is)

Return the first site of the MPS or MPO that has at least one Index in common with the Index or collection of indices is.

To find all sites with common indices with is, use the findsites function.

Examples

s = siteinds("S=1/2", 5)
ψ = randomMPS(s)
findsite(ψ, s[3]) == 3
findsite(ψ, (s[3], s[4])) == 3

M = MPO(s)
findsite(M, s[4]) == 4
findsite(M, s[4]') == 4
findsite(M, (s[4]', s[4])) == 4
findsite(M, (s[4]', s[3])) == 3
source
ITensors.findsitesFunction
findsites(M::Union{MPS, MPO}, is)

Return the sites of the MPS or MPO that have indices in common with the collection of site indices is.

Examples

s = siteinds("S=1/2", 5)
ψ = randomMPS(s)
findsites(ψ, s[3]) == [3]
findsites(ψ, (s[4], s[1])) == [1, 4]

M = MPO(s)
findsites(M, s[4]) == [4]
findsites(M, s[4]') == [4]
findsites(M, (s[4]', s[4])) == [4]
findsites(M, (s[4]', s[3])) == [3, 4]
source

Priming and tagging

ITensors.primeMethod
prime(M::MPS, args...; kwargs...)

prime(M::MPO, args...; kwargs...)

Apply prime to all ITensors of an MPS/MPO, returning a new MPS/MPO.

The ITensors of the MPS/MPO will be a view of the storage of the original ITensors.

source
ITensors.prime!Method
prime!(M::MPS, args...; kwargs...)

prime!(M::MPO, args...; kwargs...)

Apply prime to all ITensors of an MPS/MPO in-place.

source
ITensors.setprimeMethod
setprime(M::MPS, args...; kwargs...)

setprime(M::MPO, args...; kwargs...)

Apply setprime to all ITensors of an MPS/MPO, returning a new MPS/MPO.

The ITensors of the MPS/MPO will be a view of the storage of the original ITensors.

source
ITensors.setprime!Method
setprime!(M::MPS, args...; kwargs...)

setprime!(M::MPO, args...; kwargs...)

Apply setprime to all ITensors of an MPS/MPO in-place.

source
ITensors.noprimeMethod
noprime(M::MPS, args...; kwargs...)

noprime(M::MPO, args...; kwargs...)

Apply noprime to all ITensors of an MPS/MPO, returning a new MPS/MPO.

The ITensors of the MPS/MPO will be a view of the storage of the original ITensors.

source
ITensors.noprime!Method
noprime!(M::MPS, args...; kwargs...)

noprime!(M::MPO, args...; kwargs...)

Apply noprime to all ITensors of an MPS/MPO in-place.

source
ITensors.addtagsMethod
addtags(M::MPS, args...; kwargs...)

addtags(M::MPO, args...; kwargs...)

Apply addtags to all ITensors of an MPS/MPO, returning a new MPS/MPO.

The ITensors of the MPS/MPO will be a view of the storage of the original ITensors.

source
ITensors.addtags!Method
addtags!(M::MPS, args...; kwargs...)

addtags!(M::MPO, args...; kwargs...)

Apply addtags to all ITensors of an MPS/MPO in-place.

source
ITensors.removetagsMethod
removetags(M::MPS, args...; kwargs...)

removetags(M::MPO, args...; kwargs...)

Apply removetags to all ITensors of an MPS/MPO, returning a new MPS/MPO.

The ITensors of the MPS/MPO will be a view of the storage of the original ITensors.

source
ITensors.removetags!Method
removetags!(M::MPS, args...; kwargs...)

removetags!(M::MPO, args...; kwargs...)

Apply removetags to all ITensors of an MPS/MPO in-place.

source
ITensors.replacetagsMethod
replacetags(M::MPS, args...; kwargs...)

replacetags(M::MPO, args...; kwargs...)

Apply replacetags to all ITensors of an MPS/MPO, returning a new MPS/MPO.

The ITensors of the MPS/MPO will be a view of the storage of the original ITensors.

source
ITensors.replacetags!Method
replacetags!(M::MPS, args...; kwargs...)

replacetags!(M::MPO, args...; kwargs...)

Apply replacetags to all ITensors of an MPS/MPO in-place.

source
ITensors.settagsMethod
settags(M::MPS, args...; kwargs...)

settags(M::MPO, args...; kwargs...)

Apply settags to all ITensors of an MPS/MPO, returning a new MPS/MPO.

The ITensors of the MPS/MPO will be a view of the storage of the original ITensors.

source
ITensors.settags!Method
settags!(M::MPS, args...; kwargs...)

settags!(M::MPO, args...; kwargs...)

Apply settags to all ITensors of an MPS/MPO in-place.

source

Operations

ITensors.dagMethod
dag(M::MPS, args...; kwargs...)

dag(M::MPO, args...; kwargs...)

Apply dag to all ITensors of an MPS/MPO, returning a new MPS/MPO.

The ITensors of the MPS/MPO will be a view of the storage of the original ITensors.

source
ITensors.dag!Method
dag!(M::MPS, args...; kwargs...)

dag!(M::MPO, args...; kwargs...)

Apply dag to all ITensors of an MPS/MPO in-place.

source
ITensors.orthogonalize!Function
orthogonalize!(M::MPS, j::Int; kwargs...)
orthogonalize(M::MPS, j::Int; kwargs...)

orthogonalize!(M::MPO, j::Int; kwargs...)
orthogonalize(M::MPO, j::Int; kwargs...)

Move the orthogonality center of the MPS to site j. No observable property of the MPS will be changed, and no truncation of the bond indices is performed. Afterward, tensors 1,2,...,j-1 will be left-orthogonal and tensors j+1,j+2,...,N will be right-orthogonal.

Either modify in-place with orthogonalize! or out-of-place with orthogonalize.

source
NDTensors.truncate!Function
truncate!(M::MPS; kwargs...)

truncate!(M::MPO; kwargs...)

Perform a truncation of all bonds of an MPS/MPO, using the truncation parameters (cutoff,maxdim, etc.) provided as keyword arguments.

source
ITensors.replacebond!Method
replacebond!(M::MPS, b::Int, phi::ITensor; kwargs...)

Factorize the ITensor phi and replace the ITensors b and b+1 of MPS M with the factors. Choose the orthogonality with ortho="left"/"right".

source
ITensors.sampleMethod
sample(m::MPS)

Given a normalized MPS m with orthocenter(m)==1, returns a Vector{Int} of length(m) corresponding to one sample of the probability distribution defined by squaring the components of the tensor that the MPS represents

source
ITensors.sample!Method
sample!(m::MPS)

Given a normalized MPS m, returns a Vector{Int} of length(m) corresponding to one sample of the probability distribution defined by squaring the components of the tensor that the MPS represents. If the MPS does not have an orthogonality center, orthogonalize!(m,1) will be called before computing the sample.

source

Algebra Operations

LinearAlgebra.dotMethod
dot(A::MPS, B::MPS; make_inds_match = true)
inner(A::MPS, B::MPS; make_inds_match = true)

dot(A::MPO, B::MPO)
inner(A::MPO, B::MPO)

Compute the inner product <A|B>. If A and B are MPOs, computes the Frobenius inner product.

If make_inds_match = true, the function attempts to make the site indices match before contracting (so for example, the inputs can have different site indices, as long as they have the same dimensions or QN blocks).

For now, make_inds_match is only supported for MPSs.

See also logdot/loginner.

source
ITensors.logdotMethod
logdot(A::MPS, B::MPS; make_inds_match = true)
loginner(A::MPS, B::MPS; make_inds_match = true)

logdot(A::MPO, B::MPO)
loginner(A::MPO, B::MPO)

Compute the logarithm of the inner product <A|B>. If A and B are MPOs, computes the logarithm of the Frobenius inner product.

This is useful for larger MPS/MPO, where in the limit of large numbers of sites the inner product can diverge or approach zero.

If make_inds_match = true, the function attempts to make the site indices match before contracting (so for example, the inputs can have different site indices, as long as they have the same dimensions or QN blocks).

For now, make_inds_match is only supported for MPSs.

source
ITensors.lognormMethod
lognorm(A::MPS)

lognorm(A::MPO)

Compute the logarithm of the norm of the MPS or MPO.

This is useful for larger MPS/MPO that are not gauged, where in the limit of large numbers of sites the norm can diverge or approach zero.

See also norm and loginner/logdot.

source
Base.:+Method
add(A::MPS, B::MPS; kwargs...)
+(A::MPS, B::MPS; kwargs...)

add(A::MPO, B::MPO; kwargs...)
+(A::MPO, B::MPO; kwargs...)

Add two MPS/MPO with each other, with some optional truncation.

source
Base.:*Method
contract(::MPS, ::MPO; kwargs...)
*(::MPS, ::MPO; kwargs...)

contract(::MPO, ::MPS; kwargs...)
*(::MPO, ::MPS; kwargs...)

Contract the MPO with the MPS, returning an MPS with the unique site indices of the MPO.

Choose the method with the method keyword, for example "densitymatrix" and "naive".

source