Skip to content

Commit 893ce1d

Browse files
authored
Performance improvements in gradient computation (#362)
1 parent 15d85fb commit 893ce1d

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

src/b-splines/indexing.jl

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,10 @@ end
2525
@propagate_inbounds function gradient(itp::BSplineInterpolation{T,N}, x::Vararg{Number,N}) where {T,N}
2626
@boundscheck checkbounds(Bool, itp, x...) || Base.throw_boundserror(itp, x)
2727
wis = weightedindexes((value_weights, gradient_weights), itpinfo(itp)..., x)
28-
return _gradient(itp.coefs, wis) # work around #311
28+
return SVector(_gradient(itp.coefs, wis...)) # work around #311
2929
end
30-
@noinline _gradient(coefs, wis) = SVector(map(inds->coefs[inds...], wis))
30+
@inline _gradient(coefs, inds, moreinds...) = (coefs[inds...], _gradient(coefs, moreinds...)...)
31+
_gradient(coefs) = ()
3132

3233
@propagate_inbounds function gradient!(dest, itp::BSplineInterpolation{T,N}, x::Vararg{Number,N}) where {T,N}
3334
dest .= gradient(itp, x...)

0 commit comments

Comments
 (0)