Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions src/qobj/dimensions.jl
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,11 @@ Base.:(==)(dims::AbstractDimensions, vect::AbstractVector{T}) where {T} = vect =

Base.length(::AbstractDimensions{N}) where {N} = N

# need to specify return type `Int` for `_get_space_size`
# otherwise the type of `prod(::Dimensions)` will be unstable
_get_space_size(s::AbstractSpace)::Int = s.size
Base.prod(dims::Dimensions) = prod(dims.to)
Base.prod(spaces::SVector{N,AbstractSpace}) where {N} = prod(_get_space_size, spaces)

LinearAlgebra.transpose(dims::Dimensions) = dims
LinearAlgebra.transpose(dims::CompoundDimensions) = CompoundDimensions(dims.from, dims.to) # switch `to` and `from`
2 changes: 1 addition & 1 deletion src/qobj/quantum_object_base.jl
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ function _check_QuantumObject(type::BraQuantumObject, dims::Dimensions, m::Int,
end

function _check_QuantumObject(type::OperatorQuantumObject, dims::Dimensions, m::Int, n::Int)
L = prod(dims.to)
L = prod(dims)
(L == m == n) || throw(DimensionMismatch("Operator with dims = $(dims) does not fit the array size = $((m, n))."))
return nothing
end
Expand Down
5 changes: 0 additions & 5 deletions src/qobj/space.jl
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,3 @@ struct Space <: AbstractSpace
end
end
Base.string(s::Space) = string(s.size) # this is only used when printing AbstractDimensions

# for `prod(::Dimensions)`
Base.:(*)(i::Int, s::AbstractSpace) = i * s.size
Base.:(*)(s1::AbstractSpace, s2::AbstractSpace) = s1.size * s2.size
Base.prod(spaces::SVector{1,AbstractSpace}) = spaces[1].size # for `Dimensions.to` has only a single Space
3 changes: 1 addition & 2 deletions test/core-test/correlations_and_spectrum.jl
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,7 @@
@test all(spec2 .≈ spec3)

@testset "Type Inference spectrum" begin
# TODO: fix this type inference issue (originally from `steadystate`)
# @inferred correlation_2op_1t(H, nothing, t_l, c_ops, a', a; progress_bar = Val(false))
@inferred correlation_2op_1t(H, nothing, t_l, c_ops, a', a; progress_bar = Val(false))
@inferred spectrum_correlation_fft(t_l, corr1)
@inferred spectrum(H, ω_l2, c_ops, a', a)
@inferred spectrum(H, ω_l2, c_ops, a', a; solver = PseudoInverse())
Expand Down
10 changes: 4 additions & 6 deletions test/core-test/steady_state.jl
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,7 @@
@inferred steadystate(H, psi0, t_l[end], c_ops, solver = solver)
@inferred steadystate(L, psi0, t_l[end], solver = solver)

# TODO: fix the following type inference issues
#= solver = SteadyStateDirectSolver()
solver = SteadyStateDirectSolver()
@inferred steadystate(H, c_ops, solver = solver)
@inferred steadystate(L, solver = solver)

Expand All @@ -52,7 +51,7 @@
@inferred steadystate(L, solver = solver)

@inferred steadystate(H, c_ops)
@inferred steadystate(L) =#
@inferred steadystate(L)
end

H = a_d * a
Expand All @@ -74,15 +73,14 @@
@test abs(sum(sol_me.expect[1, end-100:end]) / 101 - expect(e_ops[1], ρ_ss2)) < 1e-3

@testset "Type Inference (steadystate_floquet)" begin
# TODO: fix the following type inference issues
#= @inferred steadystate_floquet(H, -1im * 0.5 * H_t, 1im * 0.5 * H_t, 1, c_ops, solver = SSFloquetLinearSystem())
@inferred steadystate_floquet(H, -1im * 0.5 * H_t, 1im * 0.5 * H_t, 1, c_ops, solver = SSFloquetLinearSystem())
@inferred steadystate_floquet(
H,
-1im * 0.5 * H_t,
1im * 0.5 * H_t,
1,
c_ops,
solver = SSFloquetEffectiveLiouvillian(),
) =#
)
end
end
Loading