Skip to content

Commit 00642ac

Browse files
committed
add styles to abstractmps
1 parent a747023 commit 00642ac

File tree

1 file changed

+80
-3
lines changed

1 file changed

+80
-3
lines changed

src/states/abstractmps.jl

Lines changed: 80 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ const MPSTensor{S} = GenericMPSTensor{S, 2} # the usual mps tensors on which we
1515

1616
"""
1717
MPSTensor([f, eltype], d::Int, left_D::Int, [right_D]::Int])
18-
MPSTensor([f, eltype], physicalspace::Union{S,CompositeSpace{S}},
18+
MPSTensor([f, eltype], physicalspace::Union{S,CompositeSpace{S}},
1919
left_virtualspace::S, [right_virtualspace]::S) where {S<:ElementarySpace}
2020
2121
Construct an `MPSTensor` with given physical and virtual spaces.
@@ -164,6 +164,8 @@ If this hasn't been computed before, this can be computed as:
164164
- `kind=:ALAC` : AL[i] * AC[i+1]
165165
""" AC2
166166

167+
AC2(psi::AbstractMPS, site::Int; kwargs...) = AC2(GeometryStyle(psi), psi, site; kwargs...)
168+
167169
#===========================================================================================
168170
MPS types
169171
===========================================================================================#
@@ -202,7 +204,7 @@ TensorKit.sectortype(ψtype::Type{<:AbstractMPS}) = sectortype(site_type(ψtype)
202204

203205
"""
204206
left_virtualspace(ψ::AbstractMPS, [pos=1:length(ψ)])
205-
207+
206208
Return the virtual space of the bond to the left of sites `pos`.
207209
208210
!!! warning
@@ -245,4 +247,79 @@ physicalspace(ψ::AbstractMPS) = map(Base.Fix1(physicalspace, ψ), eachsite(ψ))
245247
246248
Return an iterator over the sites of the MPS `state`.
247249
"""
248-
eachsite::AbstractMPS) = eachindex(ψ)
250+
eachsite::AbstractMPS) = eachsite(GeometryStyle(ψ), ψ)
251+
252+
eachsite(::GeometryStyle, ψ::AbstractMPS) = eachindex(ψ)
253+
254+
# TensorKit utility
255+
# -----------------
256+
257+
function TensorKit.dot(ψ₁::AbstractMPS, ψ₂::AbstractMPS; kwargs...)
258+
geometry_style = GeometryStyle(ψ₁) & GeometryStyle(ψ₂)
259+
return TensorKit.dot(geometry_style, ψ₁, ψ₂; kwargs...)
260+
end
261+
function Base.isapprox(ψ₁::AbstractMPS, ψ₂::AbstractMPS; kwargs...)
262+
return isapprox(dot(ψ₁, ψ₂), 1; kwargs...)
263+
end
264+
TensorKit.norm::AbstractMPS) = TensorKit.norm(GeometryStyle(ψ), ψ)
265+
TensorKit.normalize!::AbstractMPS) = TensorKit.normalize!(GeometryStyle(ψ), ψ)
266+
TensorKit.normalize::AbstractMPS) = normalize!(copy(ψ))
267+
#===========================================================================================
268+
Fixedpoints
269+
===========================================================================================#
270+
271+
"""
272+
l_RR(ψ, location)
273+
274+
Left dominant eigenvector of the `AR`-`AR` transfermatrix.
275+
"""
276+
l_RR::AbstractMPS, loc::Int = 1) = l_RR(GeometryStyle(ψ), ψ, loc)
277+
278+
"""
279+
l_RL(ψ, location)
280+
281+
Left dominant eigenvector of the `AR`-`AL` transfermatrix.
282+
"""
283+
l_RL::AbstractMPS, loc::Int = 1) = l_RL(GeometryStyle(ψ), ψ, loc)
284+
285+
"""
286+
l_LR(ψ, location)
287+
288+
Left dominant eigenvector of the `AL`-`AR` transfermatrix.
289+
"""
290+
l_LR::AbstractMPS, loc::Int = 1) = l_LR(GeometryStyle(ψ), ψ, loc)
291+
292+
"""
293+
l_LL(ψ, location)
294+
295+
Left dominant eigenvector of the `AL`-`AL` transfermatrix.
296+
"""
297+
l_LL::AbstractMPS, loc::Int = 1) = l_LL(GeometryStyle(ψ), ψ, loc)
298+
299+
"""
300+
r_RR(ψ, location)
301+
302+
Right dominant eigenvector of the `AR`-`AR` transfermatrix.
303+
"""
304+
r_RR::AbstractMPS, loc::Int = length(ψ)) = r_RR(GeometryStyle(ψ), ψ, loc)
305+
306+
"""
307+
r_RL(ψ, location)
308+
309+
Right dominant eigenvector of the `AR`-`AL` transfermatrix.
310+
"""
311+
r_RL::AbstractMPS, loc::Int = length(ψ)) = r_RL(GeometryStyle(ψ), ψ, loc)
312+
313+
"""
314+
r_LR(ψ, location)
315+
316+
Right dominant eigenvector of the `AL`-`AR` transfermatrix.
317+
"""
318+
r_LR::AbstractMPS, loc::Int = length(ψ)) = r_LR(GeometryStyle(ψ), ψ, loc)
319+
320+
"""
321+
r_LL(ψ, location)
322+
323+
Right dominant eigenvector of the `AL`-`AL` transfermatrix.
324+
"""
325+
r_LL::AbstractMPS, loc::Int = length(ψ)) = r_LL(GeometryStyle(ψ), ψ, loc)

0 commit comments

Comments
 (0)