Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use set_state! in lyapunov rescale! #289

Closed
wants to merge 2 commits into from
Closed
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
35 changes: 17 additions & 18 deletions src/chaosdetection/lyapunovs/lyapunov.jl
Original file line number Diff line number Diff line change
Expand Up @@ -157,26 +157,25 @@ function λdist(integ::AbstractODEIntegrator{Alg, IIP, Vector{S}}) where {Alg, I
return norm(integ.u[1] - integ.u[2])
end

# Rescales:
function rescale!(integ::MinimalDiscreteIntegrator{true, Vector{S}}, a) where {S<:SVector}
integ.u[2] = integ.u[1] + (integ.u[2] - integ.u[1])/a
u_modified!(integ, true)
function isinplace(integ::AbstractODEIntegrator{Alg, IIP, S}) where {Alg, IIP, S}
return IIP
end
function rescale!(integ::MinimalDiscreteIntegrator{true, Vector{S}}, a) where {S<:Vector}
@. integ.u[2] = integ.u[1] + (integ.u[2] - integ.u[1])/a
u_modified!(integ, true)
function isinplace(integ::MinimalDiscreteIntegrator{IIP, S}) where {IIP, S}
return IIP
end
function rescale!(integ::AbstractODEIntegrator{Alg, IIP, M}, a) where {Alg, IIP, M<:Matrix}
for i in 1:size(integ.u)[1]
integ.u[i, 2] = integ.u[i,1] + (integ.u[i,2] - integ.u[i,1])/a
end
u_modified!(integ, true)

function rescale_iip!(integ, a)
get_state(integ, 2) .= get_state(integ, 1) .+ (get_state(integ, 2) .- get_state(integ, 1)) ./ a
end
function rescale!(integ::AbstractODEIntegrator{Alg, IIP, Vector{S}}, a) where {Alg, IIP, S<:Vector}
@. integ.u[2] = integ.u[1] + (integ.u[2] - integ.u[1])/a
u_modified!(integ, true)
function rescale_oop(integ, a)
r = get_state(integ, 1) .+ (get_state(integ, 2) .- get_state(integ, 1)) ./ a
set_state!(integ, r, 2)
Datseris marked this conversation as resolved.
Show resolved Hide resolved
end
function rescale!(integ::AbstractODEIntegrator{Alg, IIP, Vector{S}}, a) where {Alg, IIP, S<:SVector}
integ.u[2] = integ.u[1] + (integ.u[2] - integ.u[1])/a
u_modified!(integ, true)
function rescale!(integ, a)
iip = isinplace(integ)
if iip
rescale_iip!(integ, a)
else
rescale_oop(integ, a)
end
end