Skip to content

Commit ea0f467

Browse files
authored
Identity map fix v2 (#239)
1 parent e71da87 commit ea0f467

File tree

3 files changed

+10
-6
lines changed

3 files changed

+10
-6
lines changed

Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name = "ITensorNetworks"
22
uuid = "2919e153-833c-4bdc-8836-1ea460a35fc7"
33
authors = ["Matthew Fishman <[email protected]>, Joseph Tindall <[email protected]> and contributors"]
4-
version = "0.13.10"
4+
version = "0.13.11"
55

66
[deps]
77
AbstractTrees = "1520ce14-60c1-5f80-bbc7-55ef81b5835c"

src/formnetworks/bilinearformnetwork.jl

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,12 +53,14 @@ function Base.copy(blf::BilinearFormNetwork)
5353
)
5454
end
5555

56-
function itensor_identity_map(i_pairs::Vector)
56+
function itensor_identity_map(elt::Type, i_pairs::Vector)
5757
return prod(i_pairs; init=ITensor(one(Bool))) do i_pair
58-
return denseblocks(delta(last(i_pair), dag(first(i_pair))))
58+
return denseblocks(delta(elt, last(i_pair), dag(first(i_pair))))
5959
end
6060
end
6161

62+
itensor_identity_map(i_pairs::Vector) = itensor_identity_map(Float64, i_pairs)
63+
6264
function BilinearFormNetwork(
6365
bra::AbstractITensorNetwork,
6466
ket::AbstractITensorNetwork;
@@ -72,7 +74,7 @@ function BilinearFormNetwork(
7274
operator_inds = union_all_inds(s, s_mapped)
7375

7476
O = ITensorNetwork(operator_inds; link_space) do v
75-
return inds -> itensor_identity_map(s[v] .=> s_mapped[v])
77+
return inds -> itensor_identity_map(scalartype(ket), s[v] .=> s_mapped[v])
7678
end
7779
return BilinearFormNetwork(O, bra, ket; dual_site_index_map, kwargs...)
7880
end

src/specialitensornetworks.jl

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,10 @@ end
2929
"""
3030
Build an ITensor network on a graph specified by the inds network s. Bond_dim is given by link_space and entries are randomised (normal distribution, mean 0 std 1)
3131
"""
32-
function random_tensornetwork(rng::AbstractRNG, eltype::Type, s::IndsNetwork; kwargs...)
33-
return ITensorNetwork(s; kwargs...) do v
32+
function random_tensornetwork(
33+
rng::AbstractRNG, eltype::Type, s::IndsNetwork; link_space=1, kwargs...
34+
)
35+
return ITensorNetwork(s; link_space, kwargs...) do v
3436
return inds -> itensor(randn(rng, eltype, dim.(inds)...), inds)
3537
end
3638
end

0 commit comments

Comments
 (0)