Skip to content

Conversation

@stevengj
Copy link
Member

@stevengj stevengj commented Feb 4, 2025

Fixes the type-instability (but not the allocations) of #103

@stevengj
Copy link
Member Author

stevengj commented Feb 4, 2025

Weird, this fixes the instability when I call mapslices directly, but not via the function:

using Dierckx, Test
import Dierckx: _derivative
spline = ParametricSpline(1:10, rand(2, 10));
x = 5.1; nu = 1; (; t, c, k, bc, wrk) = spline # extract _derivative parameters

# copy of _derivative, with dims=[2] changed to dims=2
my_derivative(t::Vector{Float64}, c::Matrix{Float64}, k::Int, x::Real, nu::Int, bc::Int, wrk::Vector{Float64}) =
    vec(mapslices(v -> _derivative(t, v, k, x, nu, bc, wrk), c, dims=2))

@inferred vec(mapslices(v -> _derivative(t, v, k, x, nu, bc, wrk), c, dims=2)) # succeeds
@inferred my_derivative(spline.t, spline.c, spline.k, x, nu, spline.bc, spline.wrk) # fails

@jakobnissen suggests that @inferred is only checking the vec function in the first case, so mapslices is still unstable.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants