Skip to content

Commit b596f95

Browse files
authored
Merge pull request #17 from tensor4all/16-support-zip-up-algorithm
Implement interface for zipup
2 parents 313c75f + f97bb7e commit b596f95

File tree

3 files changed

+14
-9
lines changed

3 files changed

+14
-9
lines changed

src/contractMPO.jl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ function contract_mpo_mpo(M1::MPO, M2::MPO; alg::String = "densitymatrix", kwarg
33
return contract_densitymatrix(M1, M2; kwargs...)
44
elseif alg == "fit"
55
return contract_fit(M1, M2; kwargs...)
6+
elseif alg == "zipup"
7+
return ITensors.contract(M1, M2; alg = "zipup", kwargs...)
68
elseif alg == "naive"
79
return ITensors.contract(M1, M2; alg = "naive", kwargs...)
810
else

test/densitymatrix.jl renamed to test/contractMPO.jl

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,13 @@ using Test
22

33
import FastMPOContractions as FMPOC
44
using ITensors
5+
using Random
56

7+
algs = ["densitymatrix", "fit", "zipup"]
68

9+
@testset "MPO-MPO contraction (x-y-z)" for alg in algs
10+
Random.seed!(1234)
711

8-
@testset "densitymatrix (x-y-z)" begin
912
R = 3
1013
sitesx = [Index(2, "Qubit,x=$n") for n = 1:R]
1114
sitesy = [Index(2, "Qubit,y=$n") for n = 1:R]
@@ -16,11 +19,11 @@ using ITensors
1619
a = _random_mpo(sitesa)
1720
b = _random_mpo(sitesb)
1821
ab_ref = contract(a, b; alg = "naive")
19-
ab = FMPOC.contract_densitymatrix(a, b)
22+
ab = FMPOC.contract_mpo_mpo(a, b; alg=alg)
2023
@test ab_ref ab
2124
end
2225

23-
@testset "densitymatrix (xk-y-z)" begin
26+
@testset "MPO-MPO contraction (xk-y-z)" for alg in algs
2427
R = 3
2528
sitesx = [Index(2, "Qubit,x=$n") for n = 1:R]
2629
sitesk = [Index(2, "Qubit,k=$n") for n = 1:R]
@@ -32,11 +35,11 @@ end
3235
a = _random_mpo(sitesa)
3336
b = _random_mpo(sitesb)
3437
ab_ref = contract(a, b; alg = "naive")
35-
ab = FMPOC.contract_densitymatrix(a, b)
38+
ab = FMPOC.contract_mpo_mpo(a, b; alg=alg)
3639
@test ab_ref ab
3740
end
3841

39-
@testset "densitymatrix (xk-y-zl)" begin
42+
@testset "MPO-MPO contraction (xk-y-zl)" for alg in algs
4043
R = 3
4144
sitesx = [Index(2, "Qubit,x=$n") for n = 1:R]
4245
sitesk = [Index(2, "Qubit,k=$n") for n = 1:R]
@@ -49,11 +52,11 @@ end
4952
a = _random_mpo(sitesa)
5053
b = _random_mpo(sitesb)
5154
ab_ref = contract(a, b; alg = "naive")
52-
ab = FMPOC.contract_densitymatrix(a, b)
55+
ab = FMPOC.contract_mpo_mpo(a, b; alg=alg)
5356
@test ab_ref ab
5457
end
5558

56-
@testset "densitymatrix (xk-ym-zl)" begin
59+
@testset "MPO-MPO contraction (xk-ym-zl)" for alg in algs
5760
R = 3
5861
sitesx = [Index(2, "Qubit,x=$n") for n = 1:R]
5962
sitesk = [Index(2, "Qubit,k=$n") for n = 1:R]
@@ -67,6 +70,6 @@ end
6770
a = _random_mpo(sitesa)
6871
b = _random_mpo(sitesb)
6972
ab_ref = contract(a, b; alg = "naive")
70-
ab = FMPOC.contract_densitymatrix(a, b)
73+
ab = FMPOC.contract_mpo_mpo(a, b; alg=alg)
7174
@test ab_ref ab
7275
end

test/runtests.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ include("test_with_jet.jl")
66

77
include("_util.jl")
88

9-
include("densitymatrix.jl")
9+
include("contractMPO.jl")
1010
include("fitalgorithm.jl")
1111
include("util.jl")
1212
include("fitalgorithm_sum.jl")

0 commit comments

Comments
 (0)