Skip to content

Commit aad8fc8

Browse files
committed
apply suggestions related to tensor types
1 parent 00825af commit aad8fc8

File tree

1 file changed

+6
-10
lines changed

1 file changed

+6
-10
lines changed

src/tensors/tensoroperations.jl

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -52,9 +52,8 @@ end
5252

5353
function TO.tensoradd_type(TC, A::AbstractTensorMap, ::Index2Tuple{N₁,N₂},
5454
::Bool) where {N₁,N₂}
55-
sst = sectorscalartype(sectortype(A))
56-
Tnew = sst <: Real ? TC : VectorInterface.promote_add(TC, scalartype(A), sst)
57-
M = similarstoragetype(A, Tnew)
55+
I = sectortype(A)
56+
M = similarstoragetype(A, sectorscalartype(I) <: Real ? TC : complex(TC))
5857
return tensormaptype(spacetype(A), N₁, N₂, M)
5958
end
6059

@@ -115,14 +114,11 @@ function TO.tensorcontract_type(TC,
115114
A::AbstractTensorMap, ::Index2Tuple, ::Bool,
116115
B::AbstractTensorMap, ::Index2Tuple, ::Bool,
117116
::Index2Tuple{N₁,N₂}) where {N₁,N₂}
118-
sst(x) = sectorscalartype(sectortype(x))
119-
Tnew = (sst(A) <: Real && sst(B) <: Real) ? TC :
120-
TO.promote_contract(TC, scalartype(A), sst(A),
121-
scalartype(B), sst(B))
122-
M = similarstoragetype(A, Tnew)
123-
M == similarstoragetype(B, Tnew) ||
124-
throw(ArgumentError("incompatible storage types:\n$(M)$(similarstoragetype(B, Tnew))"))
125117
spacetype(A) == spacetype(B) || throw(SpaceMismatch("incompatible space types"))
118+
I = sectortype(A)
119+
M = similarstoragetype(A, sectorscalartype(I) <: Real ? TC : complex(TC))
120+
MB = similarstoragetype(B, sectorscalartype(I) <: Real ? TC : complex(TC))
121+
M == MB || throw(ArgumentError("incompatible storage types:\n$(M)$(MB)"))
126122
return tensormaptype(spacetype(A), N₁, N₂, M)
127123
end
128124

0 commit comments

Comments
 (0)