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
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "BlockTensorKit"
uuid = "5f87ffc2-9cf1-4a46-8172-465d160bd8cd"
authors = ["Lukas Devos <[email protected]> and contributors"]
version = "0.1.9"
version = "0.1.10"

[deps]
BlockArrays = "8e7c35d0-a365-5155-bbbb-fb81a777f24e"
Expand Down
3 changes: 2 additions & 1 deletion src/BlockTensorKit.jl
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@ using TensorKit:
SectorDict,
AdjointTensorMap,
adjointtensorindices,
compose
compose,
sectorscalartype
using VectorInterface
using TensorOperations
using TensorOperations:
Expand Down
2 changes: 1 addition & 1 deletion src/tensors/abstractblocktensor/abstracttensormap.jl
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ function TensorKit.block(t::AbstractBlockTensorMap, c::Sector)
end

# TODO: this might get fixed once new tensormap is implemented
TensorKit.blocks(t::AbstractBlockTensorMap) = ((c, block(t, c)) for c in blocksectors(t))
TensorKit.blocks(t::AbstractBlockTensorMap) = ((c => block(t, c)) for c in blocksectors(t))
TensorKit.blocksectors(t::AbstractBlockTensorMap) = blocksectors(space(t))
TensorKit.hasblock(t::AbstractBlockTensorMap, c::Sector) = c in blocksectors(t)

Expand Down
21 changes: 16 additions & 5 deletions src/tensors/tensoroperations.jl
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,12 @@ function TO.tensoradd_type(
TC, A::AbstractBlockTensorMap, ::Index2Tuple{N₁,N₂}, ::Bool
) where {N₁,N₂}
TA = eltype(A)
I = sectortype(A)
Tnew = sectorscalartype(I) <: Real ? TC : complex(TC)
if TA isa Union
M = Union{TK.similarstoragetype(TA.a, TC),TK.similarstoragetype(TA.b, TC)}
M = Union{TK.similarstoragetype(TA.a, Tnew),TK.similarstoragetype(TA.b, Tnew)}
else
M = TK.similarstoragetype(TA, TC)
M = TK.similarstoragetype(TA, Tnew)
end
return if issparse(A)
sparseblocktensormaptype(spacetype(A), N₁, N₂, M)
Expand All @@ -33,7 +35,10 @@ function TO.tensorcontract_type(
) where {N₁,N₂}
spacetype(A) == spacetype(B) ||
throw(SpaceMismatch("incompatible space types: $(spacetype(A)) ≠ $(spacetype(B))"))
M = promote_storagetype(TC, eltype(A), eltype(B))

I = sectortype(A)
Tnew = sectorscalartype(I) <: Real ? TC : complex(TC)
M = promote_storagetype(Tnew, eltype(A), eltype(B))
return if issparse(A) && issparse(B)
sparseblocktensormaptype(spacetype(A), N₁, N₂, M)
else
Expand All @@ -52,7 +57,10 @@ function TO.tensorcontract_type(
) where {N₁,N₂}
spacetype(A) == spacetype(B) ||
throw(SpaceMismatch("incompatible space types: $(spacetype(A)) ≠ $(spacetype(B))"))
M = promote_storagetype(TC, typeof(A), eltype(B))

I = sectortype(A)
Tnew = sectorscalartype(I) <: Real ? TC : complex(TC)
M = promote_storagetype(Tnew, typeof(A), eltype(B))
return if issparse(A) && issparse(B)
sparseblocktensormaptype(spacetype(A), N₁, N₂, M)
else
Expand All @@ -71,7 +79,10 @@ function TO.tensorcontract_type(
) where {N₁,N₂}
spacetype(A) == spacetype(B) ||
throw(SpaceMismatch("incompatible space types: $(spacetype(A)) ≠ $(spacetype(B))"))
M = promote_storagetype(TC, eltype(A), typeof(B))

I = sectortype(A)
Tnew = sectorscalartype(I) <: Real ? TC : complex(TC)
M = promote_storagetype(Tnew, eltype(A), typeof(B))
return if issparse(A) && issparse(B)
sparseblocktensormaptype(spacetype(A), N₁, N₂, M)
else
Expand Down
Loading