Skip to content

Commit

Permalink
Add function barrier, similar to (qn_)svdMPO in ITensors.
Browse files Browse the repository at this point in the history
  • Loading branch information
b-kloss committed Jan 8, 2024
1 parent ada435b commit eb556ed
Showing 1 changed file with 25 additions and 1 deletion.
26 changes: 25 additions & 1 deletion src/treetensornetworks/opsum_to_ttn.jl
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,18 @@ Hamiltonian, compressing shared interaction channels.
"""
function svdTTN(
os::OpSum{C}, sites::IndsNetwork{VT,<:Index}, root_vertex::VT; kwargs...
)::TTN where {C,VT}
# Function barrier to improve type stability
ValType = ITensors.determineValType(terms(os))
return svdTTN(ValType, os, sites, root_vertex; kwargs...)
end

function svdTTN(
ValType::Type{<:Number},
os::OpSum{C},
sites::IndsNetwork{VT,<:Index},
root_vertex::VT;
kwargs...,
)::TTN where {C,VT}
mindim::Int = get(kwargs, :mindim, 1)
maxdim::Int = get(kwargs, :maxdim, 10000)
Expand Down Expand Up @@ -223,12 +235,24 @@ end

function qn_svdTTN(
os::OpSum{C}, sites::IndsNetwork{VT,<:Index}, root_vertex::VT; kwargs...
)::TTN where {C,VT}
# Function barrier to improve type stability
ValType = ITensors.determineValType(terms(os))
return qn_svdTTN(ValType, os, sites, root_vertex; kwargs...)
end

function qn_svdTTN(
ValType::Type{<:Number},
os::OpSum{C},
sites::IndsNetwork{VT,<:Index},
root_vertex::VT;
kwargs...,
)::TTN where {C,VT}
mindim::Int = get(kwargs, :mindim, 1)
maxdim::Int = get(kwargs, :maxdim, 10000)
cutoff::Float64 = get(kwargs, :cutoff, 1e-15)

ValType = ITensors.determineValType(ITensors.terms(os))
#ValType = ITensors.determineValType(ITensors.terms(os)) #now included as argument in function signature

# traverse tree outwards from root vertex
vs = reverse(post_order_dfs_vertices(sites, root_vertex)) # store vertices in fixed ordering relative to root
Expand Down

0 comments on commit eb556ed

Please sign in to comment.