Skip to content

Commit

Permalink
Fix DMRG variational apply test and type signature in type definition.
Browse files Browse the repository at this point in the history
  • Loading branch information
b-kloss committed Feb 2, 2024
1 parent 88351d7 commit 59cbf79
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 4 deletions.
4 changes: 3 additions & 1 deletion src/treetensornetworks/projttns/projouterprodttn.jl
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,8 @@ function contract_ket(P::ProjOuterProdTTN, v::ITensor)
return v
end

# ToDo: debug this, not yet working
# probably
function contract(P::ProjOuterProdTTN, x::ITensor)
return conj(contract_ket(P, x)) * contract_ket(P, ITensor(true))
return conj(contract_ket(P, dag(x))) * contract_ket(P, ITensor(true))
end
6 changes: 3 additions & 3 deletions src/treetensornetworks/projttns/projttnsum.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
ProjTTNSum
"""
struct ProjTTNSum{V} <: AbstractProjTTN{V}
terms::Vector{AbstractProjTTN{V}}
function ProjTTNSum(terms::Vector{<:AbstractProjTTN})
return new{eltype(terms)}(terms)
terms::Vector{T} where {T<:AbstractProjTTN{V}}
function ProjTTNSum(terms::Vector{T}) where {V,T<:AbstractProjTTN{V}}
return new{V}(terms)
end
end

Expand Down
4 changes: 4 additions & 0 deletions test/test_treetensornetworks/test_solvers/test_contract.jl
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,10 @@ using Test
# Test basic usage with default parameters
Hpsi = apply(H, psi; alg="fit", init=psi, nsweeps=1)
@test inner(psi, Hpsi) inner(psi', H, psi) atol = 1E-5
# Test variational compression via DMRG
Hfit = ProjOuterProdTTN(psi', H)
Hpsi_via_dmrg = dmrg(Hfit, psi; updater_kwargs=(; which_eigval=:LR,), nsweeps=1)
@test abs(inner(Hpsi_via_dmrg, Hpsi / norm(Hpsi))) 1 atol = 1E-4

# Test basic usage for use with multiple ProjOuterProdTTN with default parameters
# BLAS.axpy-like test
Expand Down

0 comments on commit 59cbf79

Please sign in to comment.