From d1cde0a3ceb080b069f11f2fef8c6759585c2291 Mon Sep 17 00:00:00 2001 From: Christopher Rackauckas Date: Tue, 28 Jan 2025 09:19:38 -0500 Subject: [PATCH 1/2] Remove hardcoded Float64s in AkimaInterpolation Just doing this from my phone to see if that's it. Missing tests and such, if someone can help that would be great. --- src/interpolation_caches.jl | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/interpolation_caches.jl b/src/interpolation_caches.jl index ad2e1eb0..aa51f262 100644 --- a/src/interpolation_caches.jl +++ b/src/interpolation_caches.jl @@ -280,7 +280,7 @@ function AkimaInterpolation( m[end - 1] = 2m[end - 2] - m[end - 3] m[end] = 2m[end - 1] - m[end - 2] - b = 0.5 .* (m[4:end] .+ m[1:(end - 3)]) + b = (m[4:end] .+ m[1:(end - 3)]) ./ 2 dm = abs.(diff(m)) f1 = dm[3:(n + 2)] f2 = dm[1:n] @@ -288,8 +288,8 @@ function AkimaInterpolation( ind = findall(f12 .> 1e-9 * maximum(f12)) b[ind] = (f1[ind] .* m[ind .+ 1] .+ f2[ind] .* m[ind .+ 2]) ./ f12[ind] - c = (3.0 .* m[3:(end - 2)] .- 2.0 .* b[1:(end - 1)] .- b[2:end]) ./ dt - d = (b[1:(end - 1)] .+ b[2:end] .- 2.0 .* m[3:(end - 2)]) ./ dt .^ 2 + c = (3 .* m[3:(end - 2)] .- 2 .* b[1:(end - 1)] .- b[2:end]) ./ dt + d = (b[1:(end - 1)] .+ b[2:end] .- 2 .* m[3:(end - 2)]) ./ dt .^ 2 A = AkimaInterpolation( u, t, nothing, b, c, d, extrapolation_left, From bbfa7d64302c86f689b33df38e9f8fb6b7938919 Mon Sep 17 00:00:00 2001 From: Christopher Rackauckas Date: Thu, 30 Jan 2025 07:58:08 -0500 Subject: [PATCH 2/2] Update interface.jl --- test/interface.jl | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/test/interface.jl b/test/interface.jl index b0e48d06..2a13a2e1 100644 --- a/test/interface.jl +++ b/test/interface.jl @@ -55,3 +55,15 @@ end @inferred QuinticHermiteSpline(ddu, du, u, t) end end + +@testset "Output Type" begin + # Test consistency between eltype(u) and type of the output + u = Float32[-0.676367f0, 0.8449812f0, 1.2366607f0, -0.13347931f0, 1.9928657f0, + -0.63596356f0, 0.76009744f0, -0.30632544f0, 0.34649512f0, -0.3846099f0] + t = 0.1f0:0.1f0:1.0f0 + for extrapolation_flag in instances(ExtrapolationType.T) + (extrapolation_flag == ExtrapolationType.None) && continue + aki = AkimaInterpolation(u, t; extrapolation = extrapolation_flag) + @test eltype(aki.([-2.0f0, 0.5f0, 3.0f0])) == Float32 + end +end