Skip to content

Commit 1ebe195

Browse files
lkdvoskshyatt
andcommitted
careful with jordanmpotensortype
Co-authored-by: Katharine Hyatt <khyatt@flatironinstitute.org>
1 parent 840ff35 commit 1ebe195

2 files changed

Lines changed: 10 additions & 11 deletions

File tree

src/operators/jordanmpotensor.jl

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -121,15 +121,16 @@ function JordanMPOTensor(W::SparseBlockTensorMap{TT, E, S, 2, 2}) where {TT, E,
121121
)
122122
end
123123

124-
function jordanmpotensortype(::Type{S}, ::Type{E}) where {S <: VectorSpace, E <: Number}
125-
TA = Union{tensormaptype(S, 2, 2, E), BraidingTensor{E, S}}
124+
function jordanmpotensortype(::Type{S}, ::Type{E}) where {S <: VectorSpace, E}
125+
TA = tensormaptype(S, 2, 2, E)
126+
= BraidingTensor{scalartype(TA), S}
126127
TB = tensormaptype(S, 2, 1, E)
127128
TC = tensormaptype(S, 1, 2, E)
128129
TD = tensormaptype(S, 1, 1, E)
129-
return JordanMPOTensor{E, S, TA, TB, TC, TD}
130+
return JordanMPOTensor{E, S, Union{TA, Tτ}, TB, TC, TD}
130131
end
131-
function jordanmpotensortype(::Type{O}) where {O <: MPOTensor}
132-
return jordanmpotensortype(spacetype(O), scalartype(O))
132+
function jordanmpotensortype(::Type{O}) where {O <: AbstractTensorMap}
133+
return jordanmpotensortype(spacetype(O), storagetype(O))
133134
end
134135

135136
function Base.similar(W::JordanMPOTensor, ::Type{T}) where {T <: Number}

src/operators/mpohamiltonian.jl

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -437,7 +437,6 @@ function FiniteMPOHamiltonian(lattice::AbstractArray{<:VectorSpace}, local_opera
437437

438438
# construct the sparse MPO
439439
T = _find_tensortype(nonzero_opps)
440-
E = scalartype(T)
441440
S = spacetype(T)
442441

443442
# avoid using one(S)
@@ -465,7 +464,7 @@ function FiniteMPOHamiltonian(lattice::AbstractArray{<:VectorSpace}, local_opera
465464
end
466465

467466
# construct the tensor
468-
TW = jordanmpotensortype(S, E)
467+
TW = jordanmpotensortype(T)
469468
Os = map(1:length(lattice)) do site
470469
V = virtualsumspaces[site] * lattice[site]
471470
lattice[site] * virtualsumspaces[site + 1]
@@ -476,7 +475,7 @@ function FiniteMPOHamiltonian(lattice::AbstractArray{<:VectorSpace}, local_opera
476475
key_R = key_R′ == 0 ? length(virtualsumspaces[site + 1]) : key_R′
477476
O[key_L, 1, 1, key_R] += if o isa Number
478477
iszero(o) && continue
479-
τ = BraidingTensor{E}(eachspace(O)[key_L, 1, 1, key_R])
478+
τ = BraidingTensor{scalartype(TW)}(eachspace(O)[key_L, 1, 1, key_R])
480479
isone(o) ? τ : τ * o
481480
else
482481
o
@@ -520,7 +519,6 @@ function InfiniteMPOHamiltonian(lattice′::AbstractArray{<:VectorSpace}, local_
520519

521520
# construct the sparse MPO
522521
T = _find_tensortype(nonzero_opps)
523-
E = scalartype(T)
524522
S = spacetype(T)
525523

526524
# construct the virtual spaces
@@ -588,7 +586,7 @@ function InfiniteMPOHamiltonian(lattice′::AbstractArray{<:VectorSpace}, local_
588586
end
589587

590588
# construct the tensor
591-
TW = jordanmpotensortype(S, E)
589+
TW = jordanmpotensortype(T)
592590
Os = map(1:length(lattice)) do site
593591
V = virtualsumspaces[site - 1] * lattice[site]
594592
lattice[site] * virtualsumspaces[site]
@@ -599,7 +597,7 @@ function InfiniteMPOHamiltonian(lattice′::AbstractArray{<:VectorSpace}, local_
599597
key_R = key_R′ == 0 ? length(virtualspaces[site]) : key_R′
600598
O[key_L, 1, 1, key_R] += if o isa Number
601599
iszero(o) && continue
602-
τ = BraidingTensor{E}(eachspace(O)[key_L, 1, 1, key_R])
600+
τ = BraidingTensor{scalartype(TW)}(eachspace(O)[key_L, 1, 1, key_R])
603601
isone(o) ? τ : τ * o
604602
else
605603
o

0 commit comments

Comments
 (0)