From c18dc3c938e27409379a681634988d8dffbdda3f Mon Sep 17 00:00:00 2001 From: Jeffrey Lazar Date: Mon, 6 Jun 2022 15:53:24 -0400 Subject: [PATCH 1/2] add in-place `evaluate!` --- src/Dierckx.jl | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/Dierckx.jl b/src/Dierckx.jl index 4f78138..d569d39 100644 --- a/src/Dierckx.jl +++ b/src/Dierckx.jl @@ -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) + @assert length(wrk) == lwrk z = Ref{Float64}() ccall((:bispeu_, libddierckx), Nothing, (Ref{Float64}, Ref{Int32}, # ty, ny @@ -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) From 0c62fb178b3ea38e41924770da5a827ebf9d99ce Mon Sep 17 00:00:00 2001 From: Jeffrey Lazar Date: Tue, 7 Jun 2022 10:09:11 -0400 Subject: [PATCH 2/2] Update src/Dierckx.jl Co-authored-by: Sukera <11753998+Seelengrab@users.noreply.github.com> --- src/Dierckx.jl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Dierckx.jl b/src/Dierckx.jl index d569d39..aac4a34 100644 --- a/src/Dierckx.jl +++ b/src/Dierckx.jl @@ -955,7 +955,7 @@ end function evaluate!(wrk::Vector{Float64}, Vspline::Spline2D, x::Real, y::Real) ier = Ref{Int32}() lwrk = spline.kx + spline.ky + 2 - @assert length(wrk) == 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