diff --git a/docs/src/transformations.md b/docs/src/transformations.md index 956f10af1..c84454534 100644 --- a/docs/src/transformations.md +++ b/docs/src/transformations.md @@ -127,7 +127,7 @@ Tenet.AntiDiagonalGauging ### Rank simplification ```@docs -Tenet.RankSimplification +Tenet.ContractSimplification ``` ```@example plot @@ -140,7 +140,7 @@ C = Tensor(rand(2, 2, 2), (:m, :n, :o)) #hide E = Tensor(rand(2, 2, 2, 2), (:o, :p, :q, :j)) #hide tn = TensorNetwork([A, B, C, E]) #hide -reduced = transform(tn, Tenet.RankSimplification) #hide +reduced = transform(tn, Tenet.ContractSimplification) #hide smooth_annotation!( #hide fig[1, 1]; #hide diff --git a/src/Transformations.jl b/src/Transformations.jl index ef956bb21..45e46d528 100644 --- a/src/Transformations.jl +++ b/src/Transformations.jl @@ -104,20 +104,20 @@ function transform!(tn::TensorNetwork, ::HyperGroup) end """ - RankSimplification <: Transformation + ContractSimplification <: Transformation Preemptively contract tensors whose result doesn't increase in size. """ -@kwdef struct RankSimplification <: Transformation +@kwdef struct ContractSimplification <: Transformation minimize::Symbol = :length - function RankSimplification(minimize::Symbol) + function ContractSimplification(minimize::Symbol) @assert minimize in (:length, :rank) return new(minimize) end end -function transform!(tn::TensorNetwork, config::RankSimplification) +function transform!(tn::TensorNetwork, config::ContractSimplification) # select indices that benefit from contraction targets = filter(inds(tn; set=:inner)) do index candidate_tensors = select(tn, :containing, index) diff --git a/test/Transformations_test.jl b/test/Transformations_test.jl index 73e879f73..5dfb90c37 100644 --- a/test/Transformations_test.jl +++ b/test/Transformations_test.jl @@ -114,8 +114,8 @@ end end - @testset "RankSimplification" begin - using Tenet: RankSimplification + @testset "ContractSimplification" begin + using Tenet: ContractSimplification # create a tensor network where tensors B and D can be absorbed A = Tensor(rand(2, 2, 2, 2), (:i, :j, :k, :l)) @@ -125,7 +125,7 @@ E = Tensor(rand(2, 2, 2, 2), (:o, :p, :q, :j)) tn = TensorNetwork([A, B, C, D, E]) - reduced = transform(tn, RankSimplification) + reduced = transform(tn, ContractSimplification) # Test that the resulting tn contains no tensors with larger rank than the original rank = length ∘ size ∘ parent