Skip to content

Commit

Permalink
promote only if Dual
Browse files Browse the repository at this point in the history
  • Loading branch information
AmitRotem authored Dec 24, 2023
1 parent a478010 commit dc52f9f
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions src/schroedinger.jl
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,13 @@ end

function schroedinger_dynamic(tspan, psi0::T, H::AbstractTimeDependentOperator;
kwargs...) where {B,Bp,T<:Union{AbstractOperator{B,Bp},StateVector{B}}}
tspan, psi0 = _promote_time_and_state(psi0, H, tspan)
Ht = TimeDependentSum(H.coefficients, H.static_op.operators; init_time=zero(promote_type(eltype(tspan), typeof(current_time(H)))))
schroedinger_dynamic(tspan, psi0, schroedinger_dynamic_function(Ht); kwargs...)
promoted_tspan, psi0 = _promote_time_and_state(psi0, H, tspan)
if promoted_tspan !== tspan # promote H
promoted_H = schroedinger_dynamic_function( TimeDependentSum(H.coefficients, H.static_op.operators; init_time=zero(promote_type(eltype(tspan), typeof(current_time(H))))) )
return schroedinger_dynamic(promoted_tspan, psi0, schroedinger_dynamic_function(promoted_H); kwargs...)
else
return schroedinger_dynamic(promoted_tspan, psi0, schroedinger_dynamic_function(H); kwargs...)
end
end

"""
Expand Down

0 comments on commit dc52f9f

Please sign in to comment.