Skip to content

Commit 3103e28

Browse files
Merge pull request #91 from jlazar17/patch-1
add in-place `evaluate!`
2 parents a5406e7 + 0c62fb1 commit 3103e28

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

src/Dierckx.jl

+8-2
Original file line numberDiff line numberDiff line change
@@ -952,10 +952,10 @@ function evaluate(spline::Spline2D, x::AbstractVector, y::AbstractVector)
952952
return z
953953
end
954954

955-
function evaluate(spline::Spline2D, x::Real, y::Real)
955+
function evaluate!(wrk::Vector{Float64}, Vspline::Spline2D, x::Real, y::Real)
956956
ier = Ref{Int32}()
957957
lwrk = spline.kx + spline.ky + 2
958-
wrk = Vector{Float64}(undef, lwrk)
958+
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)`"))
959959
z = Ref{Float64}()
960960
ccall((:bispeu_, libddierckx), Nothing,
961961
(Ref{Float64}, Ref{Int32}, # ty, ny
@@ -974,6 +974,12 @@ function evaluate(spline::Spline2D, x::Real, y::Real)
974974
return z[]
975975
end
976976

977+
function evaluate(spline::Spline2D, x::Real, y::Real)
978+
lwrk = spline.kx + spline.ky + 2
979+
wrk = Vector{Float64}(undef, lwrk)
980+
evaluate!(wrk, spline, x, y)
981+
end
982+
977983
# Evaluate spline on the grid spanned by the input arrays.
978984
function evalgrid(spline::Spline2D, x::AbstractVector, y::AbstractVector)
979985
mx = length(x)

0 commit comments

Comments
 (0)