Skip to content
Merged
Show file tree
Hide file tree
Changes from 5 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: 2 additions & 0 deletions Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
Random = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c"
Strided = "5e0ebb24-38b0-5f93-81fe-25c709ecae67"
TensorKit = "07d1fe3e-3e46-537d-9eac-e9e13d0d4cec"
TensorKitSectors = "13a9c161-d5da-41f0-bcbd-e1a08ae0647f"
TensorOperations = "6aa20fa7-93e2-5fca-9bc0-fbd0db3c71a2"
TupleTools = "9d95972d-f1c8-5527-a6e0-b4b365fa01f6"
VectorInterface = "409d34a3-91d5-4945-b6ec-7529ddf182d8"
Expand All @@ -24,6 +25,7 @@ Random = "1"
SafeTestsets = "0.1"
Strided = "2"
TensorKit = "0.14"
TensorKitSectors = "0.1.6"
TensorOperations = "5"
Test = "1"
TestExtras = "0.2, 0.3"
Expand Down
2 changes: 2 additions & 0 deletions src/BlockTensorKit.jl
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ export sparse
export dropzeros!, droptol!
export undef_blocks

using TensorKitSectors
using TensorKit
using TensorKit:
OneOrNoneIterator,
Expand Down Expand Up @@ -45,6 +46,7 @@ using Compat

import VectorInterface as VI
import TensorKit as TK
import TensorKitSectors as TKS
import TensorOperations as TO
import TupleTools as TT

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 = TK.sectortype(A)
Tnew = TKS.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 = TK.sectortype(A)
Tnew = TKS.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 = TK.sectortype(A)
Tnew = TKS.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 = TK.sectortype(A)
Tnew = TKS.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