Skip to content

Commit bda4a22

Browse files
remove center as a function, only keep mps.center property
1 parent ff06f37 commit bda4a22

File tree

2 files changed

+18
-14
lines changed

2 files changed

+18
-14
lines changed

src/MPSKit.jl

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ export PeriodicArray, PeriodicVector, PeriodicMatrix, WindowArray
2424
export MPSTensor
2525
export QP, LeftGaugedQP, RightGaugedQP
2626
export r_LL, l_LL, r_RR, l_RR, r_RL, r_LR, l_RL, l_LR # should be properties
27-
export center
2827

2928
# useful utility functions?
3029
export add_util_leg, max_Ds, recalculate!

src/states/finitemps.jl

Lines changed: 18 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,18 @@
33
44
Type that represents a finite Matrix Product State.
55
6-
## Fields
7-
- `ALs` -- left-gauged MPS tensors
8-
- `ARs` -- right-gauged MPS tensors
9-
- `ACs` -- center-gauged MPS tensors
10-
- `Cs` -- gauge tensors
6+
## Properties
7+
- `AL` -- left-gauged MPS tensors
8+
- `AR` -- right-gauged MPS tensors
9+
- `AC` -- center-gauged MPS tensors
10+
- `C` -- gauge tensors
11+
- `center` -- location of the gauge center
12+
13+
The center property returns `center::HalfInt` that indicates the location of the MPS center:
14+
- `isinteger(center)` → `center` is a whole number and indicates the location of the first `AC` tensor present in the underlying `ψ.ACs` field.
15+
- `ishalfodd(center)` → `center` is a half-odd-integer, meaning that there are no `AC` tensors, and indicating between which sites the bond tensor lives.
1116
12-
Where each is entry can be a tensor or `missing`.
17+
e.g `mps.center = 7/2` means that the bond tensor is to the right of the 3rd site and can be accessed via `mps.C[3]`.
1318
1419
## Notes
1520
By convention, we have that:
@@ -131,14 +136,14 @@ function Base.getproperty(ψ::FiniteMPS, prop::Symbol)
131136
elseif prop == :C
132137
return CView(ψ)
133138
elseif prop == :center
134-
return center(ψ)
139+
return _gaugecenter(ψ)
135140
else
136141
return getfield(ψ, prop)
137142
end
138143
end
139144

140145
"""
141-
center(ψ::FiniteMPS)::HalfInt
146+
_gaugecenter(ψ::FiniteMPS)::HalfInt
142147
143148
Return the location of the MPS center.
144149
@@ -149,12 +154,12 @@ Return the location of the MPS center.
149154
## Example
150155
```julia
151156
ψ = FiniteMPS(3, ℂ^2, ℂ^16)
152-
center(ψ) # returns 7/2, bond tensor is to the right of the 3rd site
157+
ψ.center # returns 7/2, bond tensor is to the right of the 3rd site
153158
ψ.AC[1] # moves center to first site
154-
center(ψ) # returns 1
159+
ψ.center # returns 1
155160
```
156161
"""
157-
function center::FiniteMPS)::HalfInt
162+
function _gaugecenter::FiniteMPS)::HalfInt
158163
L = length(ψ)
159164

160165
center = findfirst(!ismissing, ψ.ACs) # give priority to integer values of center
@@ -352,7 +357,7 @@ function Base.show(io::IOContext, ψ::FiniteMPS)
352357
end
353358
354359
L = length(ψ)
355-
c = center(ψ)
360+
c = ψ.center
356361
357362
for site in HalfInt.(reverse((1 / 2):(1 / 2):(L + 1 / 2)))
358363
if site < half_screen_rows || site > L - half_screen_rows
@@ -494,7 +499,7 @@ function TensorKit.dot(ψ₁::FiniteMPS, ψ₂::FiniteMPS)
494499
end
495500

496501
function TensorKit.norm(ψ::FiniteMPS)
497-
c = center(ψ)
502+
c = ψ.center
498503
if isinteger(c) # center is an AC
499504
return norm(ψ.AC[Int(c)])
500505
else # center is a bond-tensor

0 commit comments

Comments
 (0)