Skip to content

Commit 3a94b4d

Browse files
committed
generalize tensoradd_type
1 parent 7e926b9 commit 3a94b4d

1 file changed

Lines changed: 6 additions & 8 deletions

File tree

src/tensors/tensoroperations.jl

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,14 @@
11
# TensorOperations
22
# ----------------
33
function TO.tensoradd_type(
4-
TC, A::BlockTensorMap, ::Index2Tuple{N₁,N₂}, ::Bool
4+
TC, A::AbstractBlockTensorMap, ::Index2Tuple{N₁,N₂}, ::Bool
55
) where {N₁,N₂}
66
M = TK.similarstoragetype(eltype(A), TC)
7-
return blocktensormaptype(spacetype(A), N₁, N₂, M)
8-
end
9-
function TO.tensoradd_type(
10-
TC, A::SparseBlockTensorMap, ::Index2Tuple{N₁,N₂}, ::Bool
11-
) where {N₁,N₂}
12-
M = TK.similarstoragetype(eltype(A), TC)
13-
return sparseblocktensormaptype(spacetype(A), N₁, N₂, M)
7+
return if issparse(A)
8+
sparseblocktensormaptype(spacetype(A), N₁, N₂, M)
9+
else
10+
blocktensormaptype(spacetype(A), N₁, N₂, M)
11+
end
1412
end
1513
function TO.tensoradd_type(TC, A::AdjointBlockTensorMap, pA::Index2Tuple, conjA::Bool)
1614
return TO.tensoradd_type(TC, A', adjointtensorindices(A, pA), !conjA)

0 commit comments

Comments
 (0)