Skip to content

Commit 2b0ccfc

Browse files
committed
add block for empty tensors
1 parent cb825b9 commit 2b0ccfc

File tree

1 file changed

+20
-3
lines changed

1 file changed

+20
-3
lines changed

src/tensors/abstractblocktensor/abstracttensormap.jl

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -56,9 +56,26 @@ function TensorKit.block(t::AbstractBlockTensorMap, c::Sector)::TK.blocktype(t)
5656
rows = prod(TT.getindices(size(t), codomainind(t)))
5757
cols = prod(TT.getindices(size(t), domainind(t)))
5858

59-
if rows == cols == 0
60-
allblocks = Matrix{TK.blocktype(eltype(t))}()
61-
return mortar(allblocks)
59+
if rows == 0 || cols == 0
60+
allblocks = Matrix{TK.blocktype(eltype(t))}(undef, rows, cols)
61+
62+
rowaxes = Int[]
63+
if rows != 0
64+
W′ = codomain(t) zero(spacetype(t))
65+
for V in eachspace(W′)
66+
push!(rowaxes, blockdim(codomain(V), c))
67+
end
68+
end
69+
70+
colaxes = Int[]
71+
if cols != 0
72+
W′ = zero(spacetype(t)) domain(t)
73+
for V in eachspace(W′)
74+
push!(colaxes, blockdim(domain(V), c))
75+
end
76+
end
77+
78+
return mortar(allblocks, rowaxes, colaxes)
6279
end
6380

6481
allblocks = map(Base.Fix2(block, c), parent(t))

0 commit comments

Comments
 (0)