@@ -92,13 +92,13 @@ function FiniteMPS(
9292 # determine the MPS manifold from the input and instantiate the MPS
9393 mps_tensors = map (ALs, ARs, ACs) do AL, AR, AC
9494 mps_tensor = coalesce (AL, AR, AC)
95- ismissing (sitetensor ) && throw (ArgumentError (" missing site tensor at site $i " ))
95+ ismissing (mps_tensor ) && throw (ArgumentError (" missing site tensor at site $i " ))
9696 return mps_tensor
9797 end
9898 manifold = FiniteMPSManifold (mps_tensors)
9999 A = _not_missing_type (MA)
100100 B = _not_missing_type (MB)
101- mps = FiniteMPS {A, B} (undef, manifold)
101+ mps = FiniteMPS {A, B} (undef, length ( manifold) )
102102
103103 # populate the non-missing tensors into the MPS
104104 for i in 1 : L
@@ -116,13 +116,15 @@ function FiniteMPS(
116116 getfield (mps, :ACs )[i] = ACs[i]
117117 end
118118 if ! ismissing (Cs[i])
119- space (Cs[i]) == left_virtualspace (V_mps) ← left_virtualspace (V_mps) ||
119+ V = left_virtualspace (manifold, i)
120+ space (Cs[i]) == (V ← V) ||
120121 throw (SpaceMismatch (" incompatible space for C[$i ]" ))
121122 getfield (mps, :Cs )[i] = Cs[i]
122123 end
123124 end
124125 if ! ismissing (Cs[end ])
125- space (Cs[end ]) == right_virtualspace (manifold, L) ← right_virtualspace (manifold, L) ||
126+ V = right_virtualspace (manifold, L)
127+ space (Cs[end ]) == (V ← V) ||
126128 throw (SpaceMismatch (" incompatible space for C[$(L + 1 ) ]" ))
127129 getfield (mps, :Cs )[L + 1 ] = Cs[L + 1 ]
128130 end
@@ -198,7 +200,7 @@ function FiniteMPS(As::Vector{<:GenericMPSTensor}; normalize::Bool = false)
198200 mps = FiniteMPS
199201
200202 # start with first in case eltype changes
201- AL1, C = qr_compact (As[i] )
203+ AL1, C = qr_compact (first (As) )
202204 normalize && normalize! (C)
203205
204206 # instantiate the destination
@@ -225,7 +227,7 @@ function FiniteMPS(ψ::AbstractTensor)
225227 A = _transpose_front (
226228 U * transpose (ψ * U' , ((), reverse (ntuple (identity, numind (ψ) + 1 ))))
227229 )
228- return FiniteMPS (decompose_localmps (A); normalize = false , overwrite = true )
230+ return FiniteMPS (decompose_localmps (A); normalize = false )
229231end
230232
231233for f in (:zeros , :ones )
@@ -239,12 +241,12 @@ for f in (:zeros, :ones)
239241end
240242
241243for randfun in (:rand , :randn )
242- randfun! = Symbol (randf , :! )
243- @eval function $randfun (rng:: Random.AbstractRNG , :: Type{T} , manifold:: FiniteMPSManifold ) where {T}
244+ randfun! = Symbol (randfun , :! )
245+ @eval function Random . $randfun (rng:: Random.AbstractRNG , :: Type{T} , manifold:: FiniteMPSManifold ) where {T}
244246 As = map (i -> $ randfun (rng, T, manifold[i]), 1 : length (manifold))
245247 return normalize! (FiniteMPS (As))
246248 end
247- @eval function $randfun! (rng:: Random.AbstractRNG , mps:: FiniteMPS )
249+ @eval function Random . $randfun! (rng:: Random.AbstractRNG , mps:: FiniteMPS )
248250 for i in 1 : length (mps)
249251 mps. AC[i] = $ randfun! (rng, mps. AC[i])
250252 end
@@ -264,7 +266,7 @@ Base.@deprecate(
264266 FiniteMPS (
265267 f, elt, Pspaces:: Vector{<:TensorSpace{S}} , maxVspace:: S ; left:: S = oneunit (S), right:: S = oneunit (S)
266268 ) where {S <: ElementarySpace },
267- f (elt, FiniteMPSManifold (Pspaces, maxVspaces ; left_virtualspace = left, right_virtualspace = right))
269+ f (elt, FiniteMPSManifold (Pspaces, maxVspace ; left_virtualspace = left, right_virtualspace = right))
268270)
269271Base. @deprecate (
270272 FiniteMPS (
@@ -274,13 +276,13 @@ Base.@deprecate(
274276)
275277Base. @deprecate (
276278 FiniteMPS (
277- f, elt, N:: Int , V:: VectorSpace , args... ; left:: S = oneunit (S), right:: S = oneunit (S)
279+ f, elt, N:: Int , V:: TensorSpace{S} , args... ; left:: S = oneunit (S), right:: S = oneunit (S)
278280 ) where {S <: ElementarySpace },
279281 f (elt, FiniteMPSManifold (fill (V, N), args... ; left_virtualspace = left, right_virtualspace = right))
280282)
281283Base. @deprecate (
282284 FiniteMPS (
283- N:: Int , V:: VectorSpace , args... ; left:: S = oneunit (S), right:: S = oneunit (S)
285+ N:: Int , V:: TensorSpace{S} , args... ; left:: S = oneunit (S), right:: S = oneunit (S)
284286 ) where {S <: ElementarySpace },
285287 rand (FiniteMPSManifold (fill (V, N), args... ; left_virtualspace = left, right_virtualspace = right))
286288)
0 commit comments