From 9452a55607c489eba4e2d96533c1c7235680e74e Mon Sep 17 00:00:00 2001 From: Matt Signorelli <mgs255@cornell.edu> Date: Wed, 22 Jan 2025 08:57:14 -0500 Subject: [PATCH] GTPSA ext new feature compatibility --- Project.toml | 2 +- ext/DiffEqBaseGTPSAExt.jl | 10 +++++----- test/downstream/gtpsa.jl | 6 +++--- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/Project.toml b/Project.toml index 5a56f294f..47f0b481a 100644 --- a/Project.toml +++ b/Project.toml @@ -83,7 +83,7 @@ ForwardDiff = "0.10" FunctionWrappers = "1.0" FunctionWrappersWrappers = "0.1" GeneralizedGenerated = "0.3" -GTPSA = "1.3" +GTPSA = "1.4" LinearAlgebra = "1.9" Logging = "1.9" MPI = "0.20" diff --git a/ext/DiffEqBaseGTPSAExt.jl b/ext/DiffEqBaseGTPSAExt.jl index f0ee539a7..7a27569c0 100644 --- a/ext/DiffEqBaseGTPSAExt.jl +++ b/ext/DiffEqBaseGTPSAExt.jl @@ -11,21 +11,21 @@ else end value(x::TPS) = scalar(x) -value(::Type{TPS{T}}) where {T} = T +value(::Type{<:TPS{T}}) where {T} = T ODE_DEFAULT_NORM(u::TPS, t) = normTPS(u) ODE_DEFAULT_NORM(f::F, u::TPS, t) where {F} = normTPS(f(u)) -function ODE_DEFAULT_NORM(u::AbstractArray{TPS{T}}, t) where {T} - x = zero(real(T)) +function ODE_DEFAULT_NORM(u::AbstractArray{<:TPS}, t) + x = zero(real(GTPSA.numtype(eltype(u)))) @inbounds @fastmath for ui in u x += normTPS(ui)^2 end Base.FastMath.sqrt_fast(x / max(length(u), 1)) end -function ODE_DEFAULT_NORM(f::F, u::AbstractArray{TPS{T}}, t) where {F, T} - x = zero(real(T)) +function ODE_DEFAULT_NORM(f::F, u::AbstractArray{<:TPS}, t) where {F} + x = zero(real(GTPSA.numtype(eltype(u)))) @inbounds @fastmath for ui in u x += normTPS(f(ui))^2 end diff --git a/test/downstream/gtpsa.jl b/test/downstream/gtpsa.jl index f60d1285c..496ebc10d 100644 --- a/test/downstream/gtpsa.jl +++ b/test/downstream/gtpsa.jl @@ -13,8 +13,8 @@ sol = solve(prob, Tsit5(), reltol=1e-16, abstol=1e-16) # Parametric GTPSA map desc = Descriptor(3, 2, 3, 2) # 3 variables 3 parameters, both to 2nd order -dx = vars(desc) -dp = params(desc) +dx = @vars(desc) +dp = @params(desc) prob_GTPSA = ODEProblem(f!, x .+ dx, (0.0, 1.0), p .+ dp) sol_GTPSA = solve(prob_GTPSA, Tsit5(), reltol=1e-16, abstol=1e-16) @@ -50,7 +50,7 @@ prob = DynamicalODEProblem(pdot!, qdot!, [0.0, 0.0, 0.0], [0.0, 0.0, 0.0], (0.0, sol = solve(prob, Yoshida6(), dt = 1.0, reltol=1e-16, abstol=1e-16) desc = Descriptor(6, 2) # 6 variables to 2nd order -dx = vars(desc) # identity map +dx = @vars(desc) # identity map prob_GTPSA = DynamicalODEProblem(pdot!, qdot!, dx[1:3], dx[4:6], (0.0, 25.0)) sol_GTPSA = solve(prob_GTPSA, Yoshida6(), dt = 1.0, reltol=1e-16, abstol=1e-16)