Skip to content

Commit d6415f3

Browse files
committed
formatter
1 parent 8c8b851 commit d6415f3

File tree

5 files changed

+41
-32
lines changed

5 files changed

+41
-32
lines changed

src/algorithms/expval.jl

Lines changed: 20 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -48,10 +48,10 @@ function expectation_value(ψ::AbstractMPS, (inds, O)::Pair)
4848
sites, local_mpo = instantiate_operator(ψ, inds => O)
4949

5050
# left side
51-
Vl = insertrightunit(l_LL(ψ, sites[1]), 1; dual=true)
51+
Vl = insertrightunit(l_LL(ψ, sites[1]), 1; dual = true)
5252

5353
# middle
54-
M = foldl(zip(sites, local_mpo); init=Vl) do v, (site, o)
54+
M = foldl(zip(sites, local_mpo); init = Vl) do v, (site, o)
5555
if o isa Number
5656
return scale!(v * TransferMatrix.AL[site], ψ.AL[site]), o)
5757
else
@@ -60,8 +60,7 @@ function expectation_value(ψ::AbstractMPS, (inds, O)::Pair)
6060
end
6161

6262
# right side
63-
E = @plansor removeunit(M, 2)[1; 2] * ψ.C[sites[end]][2; 3] *
64-
conj.C[sites[end]][1; 3])
63+
E = @plansor removeunit(M, 2)[1; 2] * ψ.C[sites[end]][2; 3] * conj.C[sites[end]][1; 3])
6564
return E / dot(ψ, ψ)
6665
end
6766

@@ -84,33 +83,38 @@ function contract_mpo_expval(
8483
return @plansor GL[1 2; 3] * AC[3 7; 5] * GR[5 8; 6] * O[2 4; 7 8] * conj(ACbar[1 4; 6])
8584
end
8685
# generic fallback
87-
function contract_mpo_expval(AC, GL, O, GR, ACbar=AC)
86+
function contract_mpo_expval(AC, GL, O, GR, ACbar = AC)
8887
return dot(ACbar, MPO_AC_Hamiltonian(GL, O, GR) * AC)
8988
end
9089

91-
function contract_mpo_expval1(AC::MPSTensor, O::AbstractTensorMap, ACbar::MPSTensor=AC)
90+
function contract_mpo_expval1(AC::MPSTensor, O::AbstractTensorMap, ACbar::MPSTensor = AC)
9291
numin(O) == numout(O) == 1 || throw(ArgumentError("O is not a single-site operator"))
9392
return @plansor conj(ACbar[2 3; 4]) * O[3; 1] * AC[2 1; 4]
9493
end
95-
function contract_mpo_expval1(AC::GenericMPSTensor{S,3}, O::AbstractTensorMap{<:Any,S},
96-
ACbar::GenericMPSTensor{S,3}=AC) where {S}
94+
function contract_mpo_expval1(
95+
AC::GenericMPSTensor{S, 3}, O::AbstractTensorMap{<:Any, S},
96+
ACbar::GenericMPSTensor{S, 3} = AC
97+
) where {S}
9798
numin(O) == numout(O) == 1 || throw(ArgumentError("O is not a single-site operator"))
9899
return @plansor conj(ACbar[2 3 4; 5]) * O[3; 1] * AC[2 1 4; 5]
99100
end
100101

101-
function contract_mpo_expval2(A1::MPSTensor, A2::MPSTensor, O::AbstractTensorMap,
102-
A1bar::MPSTensor=A1, A2bar::MPSTensor=A2)
102+
function contract_mpo_expval2(
103+
A1::MPSTensor, A2::MPSTensor, O::AbstractTensorMap,
104+
A1bar::MPSTensor = A1, A2bar::MPSTensor = A2
105+
)
103106
numin(O) == numout(O) == 2 || throw(ArgumentError("O is not a two-site operator"))
104107
return @plansor conj(A1bar[4 5; 6]) * conj(A2bar[6 7; 8]) * O[5 7; 2 3] * A1[4 2; 1] *
105-
A2[1 3; 8]
108+
A2[1 3; 8]
106109
end
107-
function contract_mpo_expval2(A1::GenericMPSTensor{S,3}, A2::GenericMPSTensor{S,3},
108-
O::AbstractTensorMap{<:Any,S},
109-
A1bar::GenericMPSTensor{S,3}=A1,
110-
A2bar::GenericMPSTensor{S,3}=A2) where {S}
110+
function contract_mpo_expval2(
111+
A1::GenericMPSTensor{S, 3}, A2::GenericMPSTensor{S, 3},
112+
O::AbstractTensorMap{<:Any, S},
113+
A1bar::GenericMPSTensor{S, 3} = A1, A2bar::GenericMPSTensor{S, 3} = A2
114+
) where {S}
111115
numin(O) == numout(O) == 2 || throw(ArgumentError("O is not a two-site operator"))
112116
return @plansor conj(A1bar[8 3 4; 11]) * conj(A2bar[11 12 13; 14]) * τ[9 6; 1 2] *
113-
τ[3 4; 9 10] * A1[8 1 2; 5] * A2[5 7 13; 14] * O[10 12; 6 7]
117+
τ[3 4; 9 10] * A1[8 1 2; 5] * A2[5 7 13; 14] * O[10 12; 6 7]
114118
end
115119

116120
function expectation_value(

src/algorithms/timestep/wii.jl

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,10 @@ $(TYPEDFIELDS)
1919
maxiter::Int = Defaults.maxiter
2020
end
2121

22-
function make_time_mpo(H::InfiniteMPOHamiltonian, dt::Number, alg::WII;
23-
imaginary_evolution::Bool=false)
22+
function make_time_mpo(
23+
H::InfiniteMPOHamiltonian, dt::Number, alg::WII;
24+
imaginary_evolution::Bool = false
25+
)
2426
WA = H.A
2527
WB = H.B
2628
WC = H.C
@@ -84,8 +86,10 @@ function make_time_mpo(H::InfiniteMPOHamiltonian, dt::Number, alg::WII;
8486
end
8587

8688
# Hack to treat FiniteMPOhamiltonians as Infinite
87-
function make_time_mpo(H::FiniteMPOHamiltonian, dt::Number, alg::WII;
88-
imaginary_evolution::Bool=false)
89+
function make_time_mpo(
90+
H::FiniteMPOHamiltonian, dt::Number, alg::WII;
91+
imaginary_evolution::Bool = false
92+
)
8993
H′ = copy(parent(H))
9094

9195
V_left = left_virtualspace(H[1])

src/operators/mpohamiltonian.jl

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -325,8 +325,7 @@ function instantiate_operator(lattice::AbstractArray{<:VectorSpace}, (inds′, O
325325
for j in first(indices):last(indices)
326326
if j == indices[i]
327327
# TODO: fix this check for density matrices
328-
if !(eltype(lattice) <: ProductSpace) &&
329-
physicalspace(operators[i]) != lattice[j]
328+
if !(eltype(lattice) <: ProductSpace) && physicalspace(operators[i]) != lattice[j]
330329
throw(SpaceMismatch("physical space does not match at site $j"))
331330
end
332331
push!(local_mpo, operators[i])

src/states/finitemps.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -626,11 +626,11 @@ TensorKit.normalize(ψ::FiniteMPS) = normalize!(copy(ψ))
626626
Fixedpoints
627627
===========================================================================================#
628628

629-
function r_RR::FiniteMPS, site::Int=length(ψ))
629+
function r_RR::FiniteMPS, site::Int = length(ψ))
630630
Vr = right_virtualspace.AR[site])
631631
return isomorphism(storagetype(site_type(ψ)), Vr Vr)
632632
end
633-
function l_LL::FiniteMPS, site::Int=1)
633+
function l_LL::FiniteMPS, site::Int = 1)
634634
Vl = left_virtualspace.AL[site])
635635
return isomorphism(storagetype(site_type(ψ)), Vl Vl)
636636
end

src/transfermatrix/transfer.jl

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -82,17 +82,19 @@ function transfer_right(v::MPSTensor{S}, A::MPSTensor{S}, Ab::MPSTensor{S}) wher
8282
return @plansor v[-1 -2; -3] := A[-1 2; 1] * τ[-2 4; 2 3] * conj(Ab[-3 4; 5]) * v[1 3; 5]
8383
end
8484
# similar for Matrix Product Density Operators
85-
function transfer_left(v::MPSTensor{S}, A::GenericMPSTensor{S,3},
86-
Ab::GenericMPSTensor{S,3}) where {S}
85+
function transfer_left(
86+
v::MPSTensor{S}, A::GenericMPSTensor{S, 3}, Ab::GenericMPSTensor{S, 3}
87+
) where {S}
8788
check_unambiguous_braiding(space(v, 2))
88-
@plansor v[-1 -2; -3] ≔ v[1 3; 8] * A[8 7 6; -3] * τ[3 2; 7 5] * τ[5 4; 6 -2] *
89-
conj(Ab[1 2 4; -1])
89+
return @plansor v[-1 -2; -3] ≔ v[1 3; 8] * A[8 7 6; -3] * τ[3 2; 7 5] * τ[5 4; 6 -2] *
90+
conj(Ab[1 2 4; -1])
9091
end
91-
function transfer_right(v::MPSTensor{S}, A::GenericMPSTensor{S,3},
92-
Ab::GenericMPSTensor{S,3}) where {S}
92+
function transfer_right(
93+
v::MPSTensor{S}, A::GenericMPSTensor{S, 3}, Ab::GenericMPSTensor{S, 3}
94+
) where {S}
9395
check_unambiguous_braiding(space(v, 2))
94-
@plansor v[-1 -2; -3] ≔ A[-1 4 2; 1] * τ[-2 6; 4 5] * τ[5 7; 2 3] *
95-
conj(Ab[-3 6 7; 8]) * v[1 3; 8]
96+
return @plansor v[-1 -2; -3] ≔ A[-1 4 2; 1] * τ[-2 6; 4 5] * τ[5 7; 2 3] *
97+
conj(Ab[-3 6 7; 8]) * v[1 3; 8]
9698
end
9799

98100
# the transfer operation with a utility leg in both the domain and codomain is also ill defined - only due to the codomain utility space

0 commit comments

Comments
 (0)