Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions src/tensors/tensoroperations.jl
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,12 @@ function TK.BraidingTensor{T, S}(
V1::SumSpace{S}, V2::SumSpace{S}, adjoint::Bool = false
) where {T, S}
τtype = TK.braidingtensortype(S, T)
return τtype(V1, V2, adjoint)
end
function TK.BraidingTensor{T, S, A}(
V1::SumSpace{S}, V2::SumSpace{S}, adjoint::Bool = false
) where {T, S, A}
τtype = BraidingTensor{T, S, A}
cod, dom = adjoint ? (V1 ⊗ V2, V2 ⊗ V1) : (V2 ⊗ V1, V1 ⊗ V2)
tdst = SparseBlockTensorMap{τtype}(undef, cod, dom)
Vs = eachspace(tdst)
Expand All @@ -130,3 +136,12 @@ function TK.BraidingTensor{T, S}(
end
return tdst
end

TK.braidingtensortype(::Type{SumSpace{S}}, ::Type{TorA}) where {S <: IndexSpace, TorA} =
TK.braidingtensortype(S, TorA)

# TODO: remove once proper promotion rules in TensorKit are in place
TK.BraidingTensor{T, S, A}(V1::S, V2::SumSpace{S}, adjoint::Bool = false) where {T, S, A} =
BraidingTensor{T, S, A}(promote(V1, V2)..., adjoint)
TK.BraidingTensor{T, S, A}(V1::SumSpace{S}, V2::S, adjoint::Bool = false) where {T, S, A} =
BraidingTensor{T, S, A}(promote(V1, V2)..., adjoint)
12 changes: 12 additions & 0 deletions test/abstracttensor/braidingtensor.jl
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using Test
using TestExtras
using TensorKit
using TensorKit: ℙ
using BlockTensorKit
using Random

Expand Down Expand Up @@ -34,3 +35,14 @@ Random.seed!(1234)
@test !(y ≈ braid(x, ((2, 1), (3,)), (2, 1, 3)))
end
end

@testset "Issue #68" begin
x = randn(ComplexF64, (⊞(ℙ^1) ⊗ ⊞(ℙ^1)) ← ⊞(ℙ^1))
O = randn(ComplexF64, ((ℙ^1 ⊞ ℙ^4 ⊞ ℙ^16 ⊞ ℙ^4) ⊗ ⊞(ℙ^2)) ← (⊞(ℙ^2) ⊗ ⊞(ℙ^1)))
A = randn(ComplexF64, (ℙ^4 ⊗ F^2 ⊗ (ℙ^2)') ← ℙ^1)
Ab = randn(ComplexF64, (ℙ^4 ⊗ ℙ^2 ⊗ (ℙ^2)') ← ℙ^1)

@plansor y[-1 -2; -3] ≔ A[-1 4 2; 1] * O[-2 6; 4 5] * τ[5 7; 2 3] *
conj(Ab[-3 6 7; 8]) * x[1 3; 8]
@test space(y) == (⊞(ℙ^4) ⊗ ⊞(ℙ^1)) ← ⊞(ℙ^4)
end
Loading