Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

add in-place evaluate! #91

Merged
merged 2 commits into from
Sep 27, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Copy link
Member

@giordano giordano Jan 14, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This spline is undefined. Was CI not run on this PR?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like a typo - the argument passed to evaluate! should probably be changed.

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