Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Lazy builders #192

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions src/Ansatz/Chain.jl
Original file line number Diff line number Diff line change
Expand Up @@ -746,3 +746,18 @@ end
# TODO optimize
overlap(a::Product, b::Chain) = contract(merge(Quantum(a), Quantum(b)'))
overlap(a::Chain, b::Product) = contract(merge(Quantum(a), Quantum(b)'))


# Quick MPS/MPO builders for lazy people

""" Builds a product state MPS for the state |+> = [1/sqrt(2), 1/sqrt(2)]"""
product_plus(n::Int=20) = convert(Chain, Product(fill([1, 1]/sqrt(2), n)))

""" Builds a product state MPS for the state |Z↑> = [1,0] """
product_up(n::Int=20) = convert(Chain, Product(fill([1, 0], n)))

""" Builds a random MPS of length `n` and max bond dimension `linkdims` """
random_mps(n::Int=10; linkdims::Int=20) = rand(Chain, Open, State; n, χ=linkdims)

random_mpo(n::Int=10; linkdims::Int=2) = rand(Chain, Open, Operator; n, χ=linkdims)

1 change: 1 addition & 0 deletions src/Tenet.jl
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ export MPS, pMPS, MPO, pMPO
export leftindex, rightindex, isleftcanonical, isrightcanonical
export canonize_site, canonize_site!, truncate!
export canonize, canonize!, mixed_canonize, mixed_canonize!
export random_mps, random_mpo, product_up, product_plus

include("Ansatz/Grid.jl")
export Grid
Expand Down
Loading