|
108 | 108 | for R in [:Real, :Any]
|
109 | 109 | @eval @generated function gradient(itp::AbstractInterpolation{T,N}, xs::$R...) where {T,N}
|
110 | 110 | n = count_interp_dims(itp, N)
|
111 |
| - Tg = promote_type(T, [x <: AbstractArray ? eltype(x) : x for x in xs]...) |
112 | 111 | xargs = [:(xs[$d]) for d in 1:length(xs)]
|
113 |
| - :(gradient!(Array{$Tg, 1}($n), itp, $(xargs...))) |
| 112 | + quote |
| 113 | + Tg = $(Expr(:call, :promote_type, T, [x <: AbstractArray ? eltype(x) : x for x in xs]...)) |
| 114 | + gradient!(Array{Tg, 1}($n), itp, $(xargs...)) |
| 115 | + end |
114 | 116 | end
|
115 | 117 | end
|
116 | 118 |
|
|
158 | 160 |
|
159 | 161 | @generated function hessian(itp::AbstractInterpolation{T,N}, xs...) where {T,N}
|
160 | 162 | n = count_interp_dims(itp,N)
|
161 |
| - TH = promote_type(T, [x <: AbstractArray ? eltype(x) : x for x in xs]...) |
162 | 163 | xargs = [:(xs[$d]) for d in 1:length(xs)]
|
163 |
| - :(hessian!(Array{TH, 2}($n,$n), itp, $(xargs...))) |
| 164 | + quote |
| 165 | + TH = $(Expr(:call, :promote_type, T, [x <: AbstractArray ? eltype(x) : x for x in xs]...)) |
| 166 | + hessian!(Array{TH, 2}($n,$n), itp, $(xargs...)) |
| 167 | + end |
164 | 168 | end
|
165 | 169 |
|
166 | 170 | hessian1(itp::AbstractInterpolation{T,1}, x) where {T} = hessian(itp, x)[1,1]
|
0 commit comments