diff --git a/src/Ansatz/Chain.jl b/src/Ansatz/Chain.jl index 8b448d223..0f0ceb90c 100644 --- a/src/Ansatz/Chain.jl +++ b/src/Ansatz/Chain.jl @@ -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) + diff --git a/src/Tenet.jl b/src/Tenet.jl index dce3e5f15..49b80057f 100644 --- a/src/Tenet.jl +++ b/src/Tenet.jl @@ -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