Skip to content

Commit 840ff35

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

1 file changed

Lines changed: 4 additions & 4 deletions

File tree

src/states/abstractmps.jl

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,8 @@ Construct an `MPSTensor` with given physical and virtual spaces.
3535
function MPSTensor(
3636
::UndefInitializer, eltype, P::Union{S, CompositeSpace{S}}, Vₗ::S, Vᵣ::S = Vₗ
3737
) where {S <: ElementarySpace}
38-
return TensorMap{eltype}(undef, Vₗ P Vᵣ)
38+
TT = tensormaptype(S, 1 + (P isa S ? 1 : length(P)), 1, eltype)
39+
return TT(undef, Vₗ P Vᵣ)
3940
end
4041
function MPSTensor(
4142
f, eltype, P::Union{S, CompositeSpace{S}}, Vₗ::S, Vᵣ::S = Vₗ
@@ -81,9 +82,8 @@ Convert an array to an `MPSTensor`.
8182
function MPSTensor(A::AbstractArray{T}) where {T <: Number}
8283
@assert ndims(A) > 2 "MPSTensor should have at least 3 dims, but has $ndims(A)"
8384
sz = size(A)
84-
t = TensorMap(undef, T, foldl(, ComplexSpace.(sz[1:(end - 1)])) ^sz[end])
85-
t[] .= A
86-
return t
85+
V = foldl(, ComplexSpace.(sz[1:(end - 1)])) ^sz[end]
86+
return TensorMap(A, V)
8787
end
8888

8989
"""

0 commit comments

Comments
 (0)