Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Correct bugs in the b-spline's hessian calculation (fixes #180) #181

Closed
wants to merge 1 commit into from
Closed
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
6 changes: 3 additions & 3 deletions src/b-splines/indexing.jl
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@ function gradient_coefficients(::Type{IT}, N, dim) where IT<:DimSpec{BSpline}
end
function hessian_coefficients(::Type{IT}, N, dim1, dim2) where IT<:DimSpec{BSpline}
exs = if dim1 == dim2
Expr[d==dim1==dim2 ? hessian_coefficients(iextract(IT, dim), d) :
Expr[d==dim1==dim2 ? hessian_coefficients(iextract(IT, d), d) :
coefficients(iextract(IT, d), N, d) for d in 1:N]
else
Expr[d==dim1 || d==dim2 ? gradient_coefficients(iextract(IT, dim), d) :
Expr[d==dim1 || d==dim2 ? gradient_coefficients(iextract(IT, d), d) :
coefficients(iextract(IT, d), N, d) for d in 1:N]
end
Expr(:block, exs...)
Expand Down Expand Up @@ -160,7 +160,7 @@ end
n = count_interp_dims(itp,N)
TH = promote_type(T, [x <: AbstractArray ? eltype(x) : x for x in xs]...)
xargs = [:(xs[$d]) for d in 1:length(xs)]
:(hessian!(Array{TH, 2}($n,$n), itp, $(xargs...)))
:(hessian!(Array{$TH, 2}($n,$n), itp, $(xargs...)))
end

hessian1(itp::AbstractInterpolation{T,1}, x) where {T} = hessian(itp, x)[1,1]