Skip to content

Commit 76af7e7

Browse files
Format the code according to the new version of JuliaFormatter.jl
1 parent 5fbce6d commit 76af7e7

File tree

13 files changed

+53
-66
lines changed

13 files changed

+53
-66
lines changed

src/entropy.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ function entropy_vn(
5555
length(indexes) == 0 && return zero(real(T))
5656
nzvals = vals[indexes]
5757
logvals = base != 0 ? log.(base, Complex.(nzvals)) : log.(Complex.(nzvals))
58-
return -real(mapreduce(*, +, nzvals, logvals))
58+
return -real(mapreduce(*,+,nzvals,logvals))
5959
end
6060

6161
@doc raw"""

src/qobj/eigsolve.jl

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -225,7 +225,7 @@ function _eigsolve(
225225

226226
# println( A * view(V, :, 1:k) ≈ view(V, :, 1:k) * M(view(H, 1:k, 1:k)) + qₘ * M(transpose(view(transpose(βeₘ) * Uₘ, 1:k))) ) # SHOULD BE TRUE
227227

228-
for j in k+1:m
228+
for j in (k+1):m
229229
β = arnoldi_step!(A, V, H, j)
230230
if β < tol
231231
numops += j - k - 1
@@ -406,15 +406,14 @@ function eigsolve_al(
406406
kwargs...,
407407
) where {HOpType<:Union{OperatorQuantumObject,SuperOperatorQuantumObject}}
408408
L_evo = _mesolve_make_L_QobjEvo(H, c_ops)
409-
prob =
410-
mesolveProblem(
411-
L_evo,
412-
QuantumObject(ρ0, type = Operator, dims = H.dimensions),
413-
[zero(T), T];
414-
params = params,
415-
progress_bar = Val(false),
416-
kwargs...,
417-
).prob
409+
prob = mesolveProblem(
410+
L_evo,
411+
QuantumObject(ρ0, type = Operator, dims = H.dimensions),
412+
[zero(T), T];
413+
params = params,
414+
progress_bar = Val(false),
415+
kwargs...,
416+
).prob
418417
integrator = init(prob, alg)
419418

420419
Lmap = ArnoldiLindbladIntegratorMap(eltype(H), size(L_evo), integrator)

src/qobj/operators.jl

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ julia> fock(20, 3)' * a * fock(20, 4)
100100
2.0 + 0.0im
101101
```
102102
"""
103-
destroy(N::Int) = QuantumObject(spdiagm(1 => Array{ComplexF64}(sqrt.(1:N-1))), Operator, N)
103+
destroy(N::Int) = QuantumObject(spdiagm(1 => Array{ComplexF64}(sqrt.(1:(N-1)))), Operator, N)
104104

105105
@doc raw"""
106106
create(N::Int)
@@ -126,7 +126,7 @@ julia> fock(20, 4)' * a_d * fock(20, 3)
126126
2.0 + 0.0im
127127
```
128128
"""
129-
create(N::Int) = QuantumObject(spdiagm(-1 => Array{ComplexF64}(sqrt.(1:N-1))), Operator, N)
129+
create(N::Int) = QuantumObject(spdiagm(-1 => Array{ComplexF64}(sqrt.(1:(N-1)))), Operator, N)
130130

131131
@doc raw"""
132132
displace(N::Int, α::Number)
@@ -167,7 +167,7 @@ Bosonic number operator with Hilbert space cutoff `N`.
167167
168168
This operator is defined as ``\hat{N}=\hat{a}^\dagger \hat{a}``, where ``\hat{a}`` is the bosonic annihilation operator.
169169
"""
170-
num(N::Int) = QuantumObject(spdiagm(0 => Array{ComplexF64}(0:N-1)), Operator, N)
170+
num(N::Int) = QuantumObject(spdiagm(0 => Array{ComplexF64}(0:(N-1))), Operator, N)
171171

172172
@doc raw"""
173173
position(N::Int)
@@ -311,11 +311,11 @@ end
311311
jmat(j::Real, ::Val{T}) where {T} = throw(ArgumentError("Invalid spin operator: $(T)"))
312312

313313
function _jm(j::Real)
314-
m = j:(-1):-j
315-
data = sqrt.(j * (j + 1) .- m .* (m .- 1))[1:end-1]
314+
m = j:(-1):(-j)
315+
data = sqrt.(j * (j + 1) .- m .* (m .- 1))[1:(end-1)]
316316
return spdiagm(-1 => Array{ComplexF64}(data))
317317
end
318-
_jz(j::Real) = spdiagm(0 => Array{ComplexF64}(j .- (0:Int(2 * j))))
318+
_jz(j::Real) = spdiagm(0 => Array{ComplexF64}(j .- (0:Int(2*j))))
319319

320320
@doc raw"""
321321
spin_Jx(j::Real)

src/qobj/states.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ Density matrix for a thermal state (generating thermal state probabilities) with
127127
"""
128128
function thermal_dm(N::Int, n::Real; sparse::Union{Bool,Val} = Val(false))
129129
β = log(1.0 / n + 1.0)
130-
N_list = Array{Float64}(0:N-1)
130+
N_list = Array{Float64}(0:(N-1))
131131
data = exp.(-β .* N_list)
132132
if getVal(sparse)
133133
return QuantumObject(spdiagm(0 => data ./ sum(data)), Operator, N)

src/spin_lattice.jl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,11 +53,11 @@ function multisite_operator(dims::Union{AbstractVector,Tuple}, pairs::Pair{<:Int
5353

5454
_dims[sites] == [get_dimensions_to(op)[1].size for op in ops] || throw(ArgumentError("The dimensions of the operators do not match the dimensions of the lattice."))
5555

56-
data = kron(I(prod(_dims[1:sites[1]-1])), ops[1].data)
56+
data = kron(I(prod(_dims[1:(sites[1]-1)])), ops[1].data)
5757
for i in 2:length(sites)
58-
data = kron(data, I(prod(_dims[sites[i-1]+1:sites[i]-1])), ops[i].data)
58+
data = kron(data, I(prod(_dims[(sites[i-1]+1):(sites[i]-1)])), ops[i].data)
5959
end
60-
data = kron(data, I(prod(_dims[sites[end]+1:end])))
60+
data = kron(data, I(prod(_dims[(sites[end]+1):end])))
6161

6262
return QuantumObject(data; type = Operator, dims = dims)
6363
end

src/steadystate.jl

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -367,7 +367,7 @@ function _steadystate_fourier(
367367
N = size(L_0_mat, 1)
368368
Ns = isqrt(N)
369369
n_fourier = 2 * n_max + 1
370-
n_list = -n_max:n_max
370+
n_list = (-n_max):n_max
371371

372372
weight = 1
373373
Mn = sparse(ones(Ns), [Ns * (j - 1) + j for j in 1:Ns], fill(weight, Ns), N, N)
@@ -399,15 +399,15 @@ function _steadystate_fourier(
399399

400400
offset1 = n_max * N
401401
offset2 = (n_max + 1) * N
402-
ρ0 = reshape(ρtot[offset1+1:offset2], Ns, Ns)
402+
ρ0 = reshape(ρtot[(offset1+1):offset2], Ns, Ns)
403403
ρ0_tr = tr(ρ0)
404404
ρ0 = ρ0 / ρ0_tr
405405
ρ0 = QuantumObject((ρ0 + ρ0') / 2, type = Operator, dims = L_0.dimensions)
406406
ρtot = ρtot / ρ0_tr
407407

408408
ρ_list = [ρ0]
409-
for i in 0:n_max-1
410-
ρi_m = reshape(ρtot[offset1-(i+1)*N+1:offset1-i*N], Ns, Ns)
409+
for i in 0:(n_max-1)
410+
ρi_m = reshape(ρtot[(offset1-(i+1)*N+1):(offset1-i*N)], Ns, Ns)
411411
ρi_m = QuantumObject(ρi_m, type = Operator, dims = L_0.dimensions)
412412
push!(ρ_list, ρi_m)
413413
end

src/time_evolution/lr_mesolve.jl

Lines changed: 12 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -55,9 +55,7 @@ lr_mesolve_options_default = (
5555
Δt = 0.0,
5656
)
5757

58-
#=======================================================#
5958
# ADDITIONAL FUNCTIONS
60-
#=======================================================#
6159

6260
select(x::Real, xarr::AbstractArray, retval = false) = retval ? xarr[argmin(abs.(x .- xarr))] : argmin(abs.(x .- xarr))
6361

@@ -133,9 +131,7 @@ function _calculate_expectation!(p, z, B, idx)
133131
end
134132
end
135133

136-
#=======================================================#
137134
# SAVING FUNCTIONS
138-
#=======================================================#
139135

140136
function _periodicsave_func(integrator)
141137
ip = integrator.p
@@ -151,8 +147,8 @@ function _save_affect_lr_mesolve!(integrator)
151147
N, M = ip.N, ip.M
152148
idx = select(integrator.t, ip.times)
153149

154-
@views z = reshape(integrator.u[1:N*M], N, M)
155-
@views B = reshape(integrator.u[N*M+1:end], M, M)
150+
@views z = reshape(integrator.u[1:(N*M)], N, M)
151+
@views B = reshape(integrator.u[(N*M+1):end], M, M)
156152
_calculate_expectation!(ip, z, B, idx)
157153

158154
if integrator.p.opt.progress
@@ -162,9 +158,7 @@ function _save_affect_lr_mesolve!(integrator)
162158
return u_modified!(integrator, false)
163159
end
164160

165-
#=======================================================#
166161
# CALLBACK FUNCTIONS
167-
#=======================================================#
168162

169163
#=
170164
_adjM_condition_ratio(u, t, integrator)
@@ -185,8 +179,8 @@ function _adjM_condition_ratio(u, t, integrator)
185179

186180
C = ip.A0
187181
σ = ip.temp_MM
188-
@views z = reshape(u[1:N*M], N, M)
189-
@views B = reshape(u[N*M+1:end], M, M)
182+
@views z = reshape(u[1:(N*M)], N, M)
183+
@views B = reshape(u[(N*M+1):end], M, M)
190184
mul!(C, z, sqrt(B))
191185
mul!(σ, C', C)
192186
p = abs.(eigvals(σ))
@@ -232,16 +226,16 @@ function _adjM_affect!(integrator)
232226
N, M = ip.N, ip.M
233227

234228
@views begin
235-
z = Δt > 0 ? reshape(ip.u_save[1:N*M], N, M) : reshape(integrator.u[1:N*M], N, M)
236-
B = Δt > 0 ? reshape(ip.u_save[N*M+1:end], M, M) : reshape(integrator.u[N*M+1:end], M, M)
229+
z = Δt > 0 ? reshape(ip.u_save[1:(N*M)], N, M) : reshape(integrator.u[1:(N*M)], N, M)
230+
B = Δt > 0 ? reshape(ip.u_save[(N*M+1):end], M, M) : reshape(integrator.u[(N*M+1):end], M, M)
237231
ψ = ip.L_tilde[:, 1]
238232
normalize!(ψ)
239233

240234
z = hcat(z, ψ)
241235
B = cat(B, opt.p0, dims = (1, 2))
242236
resize!(integrator, length(z) + length(B))
243237
integrator.u[1:length(z)] .= z[:]
244-
integrator.u[length(z)+1:end] .= B[:]
238+
integrator.u[(length(z)+1):end] .= B[:]
245239
end
246240

247241
integrator.p = merge(
@@ -277,9 +271,7 @@ function _adjM_affect!(integrator)
277271
end
278272
end
279273

280-
#=======================================================#
281274
# DYNAMICAL EVOLUTION EQUATIONS
282-
#=======================================================#
283275

284276
#=
285277
dBdz!(du, u, p, t)
@@ -305,10 +297,10 @@ function dBdz!(du, u, p, t)
305297
N, M = p.N, p.M
306298
opt = p.opt
307299

308-
@views z = reshape(u[1:N*M], N, M)
309-
@views dz = reshape(du[1:N*M], N, M)
310-
@views B = reshape(u[N*M+1:end], M, M)
311-
@views dB = reshape(du[N*M+1:end], M, M)
300+
@views z = reshape(u[1:(N*M)], N, M)
301+
@views dz = reshape(du[1:(N*M)], N, M)
302+
@views B = reshape(u[(N*M+1):end], M, M)
303+
@views dB = reshape(du[(N*M+1):end], M, M)
312304

313305
#Assign A0 and S
314306
mul!(S, z', z)
@@ -352,17 +344,13 @@ function dBdz!(du, u, p, t)
352344
return dB .-= temp_MM
353345
end
354346

355-
#=======================================================#
356347
# OUTPUT GENNERATION
357-
#=======================================================#
358348

359-
get_z(u::AbstractArray{T}, N::Integer, M::Integer) where {T} = reshape(view(u, 1:M*N), N, M)
349+
get_z(u::AbstractArray{T}, N::Integer, M::Integer) where {T} = reshape(view(u, 1:(M*N)), N, M)
360350

361351
get_B(u::AbstractArray{T}, N::Integer, M::Integer) where {T} = reshape(view(u, (M*N+1):length(u)), M, M)
362352

363-
#=======================================================#
364353
# PROBLEM FORMULATION
365-
#=======================================================#
366354

367355
@doc raw"""
368356
lr_mesolveProblem(

src/time_evolution/time_evolution.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -397,7 +397,7 @@ end
397397
@generated function update_coefficients!(L::DiffusionOperator, u, p, t)
398398
ops_types = L.parameters[2].parameters
399399
N = length(ops_types)
400-
quote
400+
return quote
401401
Base.@nexprs $N i -> begin
402402
update_coefficients!(L.ops[i], u, p, t)
403403
end
@@ -538,7 +538,7 @@ function _liouvillian_floquet(
538538
S = -(L_0 - 1im * n_max * ω * I) \ L_p_dense
539539
T = -(L_0 + 1im * n_max * ω * I) \ L_m_dense
540540

541-
for n_i in n_max-1:-1:1
541+
for n_i in (n_max-1):-1:1
542542
S = -(L_0 - 1im * n_i * ω * I + L_m * S) \ L_p_dense
543543
T = -(L_0 + 1im * n_i * ω * I + L_p * T) \ L_m_dense
544544
end

src/time_evolution/time_evolution_dynamical.jl

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -39,15 +39,15 @@ function _increase_dims(
3939

4040
if n_d == 1
4141
ρmat = similar(QO, dims_new[1], dims_new[1])
42-
fill!(selectdim(ρmat, 1, dims[1]+1:dims_new[1]), 0)
43-
fill!(selectdim(ρmat, 2, dims[1]+1:dims_new[1]), 0)
42+
fill!(selectdim(ρmat, 1, (dims[1]+1):dims_new[1]), 0)
43+
fill!(selectdim(ρmat, 2, (dims[1]+1):dims_new[1]), 0)
4444
copyto!(view(ρmat, 1:dims[1], 1:dims[1]), QO)
4545
else
4646
ρmat2 = similar(QO, reverse(vcat(dims_new, dims_new))...)
4747
ρmat = reshape(QO, reverse(vcat(dims, dims))...)
4848
for i in eachindex(sel)
49-
fill!(selectdim(ρmat2, n_d - sel[i] + 1, dims[sel[i]]+1:dims_new[sel[i]]), 0)
50-
fill!(selectdim(ρmat2, 2 * n_d - sel[i] + 1, dims[sel[i]]+1:dims_new[sel[i]]), 0)
49+
fill!(selectdim(ρmat2, n_d - sel[i] + 1, (dims[sel[i]]+1):dims_new[sel[i]]), 0)
50+
fill!(selectdim(ρmat2, 2 * n_d - sel[i] + 1, (dims[sel[i]]+1):dims_new[sel[i]]), 0)
5151
end
5252
copyto!(view(ρmat2, reverse!(repeat([1:n for n in dims], 2))...), ρmat)
5353
ρmat = reshape(ρmat2, prod(dims_new), prod(dims_new))
@@ -77,7 +77,7 @@ function _DFDIncreaseReduceCondition(u, t, integrator)
7777
pillow_i = pillow_list[i]
7878
if dim_i < maxdim_i && dim_i > 2 && maxdim_i != 0
7979
ρi = _ptrace_oper(vec2mat(dfd_ρt_cache), dim_list, SVector(i))[1]
80-
@views res = norm(ρi[diagind(ρi)[end-pillow_i:end]], 1) * sqrt(dim_i) / pillow_i
80+
@views res = norm(ρi[diagind(ρi)[(end-pillow_i):end]], 1) * sqrt(dim_i) / pillow_i
8181
if res > tol_list[i]
8282
increase_list[i] = true
8383
elseif res < tol_list[i] * 1e-2 && dim_i > 3

src/wigner.jl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -166,10 +166,10 @@ function _wigner_laguerre(ρ::AbstractArray, A::AbstractArray, W::AbstractArray,
166166
if method.parallel
167167
throw(ArgumentError("Parallel version is not implemented for dense matrices"))
168168
else
169-
for m in 0:M-1
169+
for m in 0:(M-1)
170170
ρmn = ρ[m+1, m+1]
171171
abs(ρmn) > tol && (@. W += real(ρmn * (-1)^m * _genlaguerre(m, 0, B)))
172-
for n in m+1:M-1
172+
for n in (m+1):(M-1)
173173
ρmn = ρ[m+1, n+1]
174174
# Γ_mn = sqrt(gamma(m+1) / gamma(n+1))
175175
Γ_mn = sqrt(exp(loggamma(m + 1) - loggamma(n + 1))) # Is this a good trick?
@@ -197,7 +197,7 @@ function _genlaguerre(n::Int, α::Number, x::T) where {T<:BlasFloat}
197197
α = convert(T, α)
198198
p0, p1 = one(T), -x ++ 1)
199199
n == 0 && return p0
200-
for k in 1:n-1
200+
for k in 1:(n-1)
201201
p1, p0 = ((2k + α + 1) / (k + 1) - x / (k + 1)) * p1 - (k + α) / (k + 1) * p0, p1
202202
end
203203
return p1

0 commit comments

Comments
 (0)