Skip to content

Commit d039b4e

Browse files
committed
fix scalartype determination in InfiniteMPS constructor
1 parent b2c4daf commit d039b4e

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

src/states/infinitemps.jl

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -193,8 +193,10 @@ function InfiniteMPS(AL::AbstractVector{<:GenericMPSTensor}, C₀::MPSBondTensor
193193
# initialize tensor storage
194194
AC = similar.(AL)
195195
AR = similar.(AL)
196-
C = similar(AR, typeof(C₀))
197-
ψ = InfiniteMPS{eltype(AL), eltype(C)}(AL, AR, C, AC)
196+
T = TensorOperations.promote_contract(scalartype(AL), scalartype(C₀))
197+
TC = TensorOperations.tensoradd_type(T, C₀, ((1,), (2,)), false)
198+
C = similar(AR, TC)
199+
ψ = InfiniteMPS{eltype(AL), TC}(AL, AR, C, AC)
198200

199201
# gaugefix the MPS
200202
gaugefix!(ψ, AL, C₀; order = :R, kwargs...)
@@ -209,8 +211,10 @@ function InfiniteMPS(C₀::MPSBondTensor, AR::AbstractVector{<:GenericMPSTensor}
209211
# initialize tensor storage
210212
AC = similar.(AR)
211213
AL = similar.(AR)
212-
C = similar(AR, typeof(C₀))
213-
ψ = InfiniteMPS{eltype(AL), eltype(C)}(AL, AR, C, AC)
214+
T = TensorOperations.promote_contract(eltype(AR), eltype(C₀))
215+
TC = TensorOperations.tensoradd_type(T, C₀, ((1,), (2,)), false)
216+
C = similar(AR, TC)
217+
ψ = InfiniteMPS{eltype(AL), TC}(AL, AR, C, AC)
214218

215219
# gaugefix the MPS
216220
gaugefix!(ψ, AR, C₀; order = :L, kwargs...)

0 commit comments

Comments
 (0)