Skip to content

Commit

Permalink
Merge pull request #91 from jlazar17/patch-1
Browse files Browse the repository at this point in the history
add in-place `evaluate!`
  • Loading branch information
kaarthiksundar authored Sep 27, 2024
2 parents a5406e7 + 0c62fb1 commit 3103e28
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/Dierckx.jl
Original file line number Diff line number Diff line change
Expand Up @@ -952,10 +952,10 @@ function evaluate(spline::Spline2D, x::AbstractVector, y::AbstractVector)
return z
end

function evaluate(spline::Spline2D, x::Real, y::Real)
function evaluate!(wrk::Vector{Float64}, Vspline::Spline2D, x::Real, y::Real)
ier = Ref{Int32}()
lwrk = spline.kx + spline.ky + 2
wrk = Vector{Float64}(undef, lwrk)
length(wrk) == lwrk || throw(ArgumentError("Length of work array not equal to required length of `spline.kx + spline.ky + 2 = $(spline.kx + spline.ky + 2)`"))
z = Ref{Float64}()
ccall((:bispeu_, libddierckx), Nothing,
(Ref{Float64}, Ref{Int32}, # ty, ny
Expand All @@ -974,6 +974,12 @@ function evaluate(spline::Spline2D, x::Real, y::Real)
return z[]
end

function evaluate(spline::Spline2D, x::Real, y::Real)
lwrk = spline.kx + spline.ky + 2
wrk = Vector{Float64}(undef, lwrk)
evaluate!(wrk, spline, x, y)
end

# Evaluate spline on the grid spanned by the input arrays.
function evalgrid(spline::Spline2D, x::AbstractVector, y::AbstractVector)
mx = length(x)
Expand Down

0 comments on commit 3103e28

Please sign in to comment.