|
129 | 129 | nelements(::Union{Type{NoInterp},Type{Constant}}) = 1
|
130 | 130 | nelements(::Type{Linear}) = 2
|
131 | 131 | nelements{Q<:Quadratic}(::Type{Q}) = 3
|
| 132 | + |
| 133 | +eachvalue_zero{R,BT<:Union{Type{NoInterp},Type{Constant}}}(::Type{R}, ::Type{BT}) = |
| 134 | + (zero(R),) |
| 135 | +eachvalue_zero{R}(::Type{R}, ::Type{Linear}) = (zero(R),zero(R)) |
| 136 | +eachvalue_zero{R,Q<:Quadratic}(::Type{R}, ::Type{Q}) = (zero(R),zero(R),zero(R)) |
| 137 | + |
132 | 138 | """
|
133 | 139 | `eachvalue(sitp)` constructs an iterator for efficiently visiting each
|
134 | 140 | grid point of a ScaledInterpolation object in which a small grid is
|
@@ -159,18 +165,18 @@ which should be more efficient than
|
159 | 165 | end
|
160 | 166 | ```
|
161 | 167 | """
|
162 |
| -@generated function eachvalue{T,N}(sitp::ScaledInterpolation{T,N}) |
| 168 | +function eachvalue{T,N}(sitp::ScaledInterpolation{T,N}) |
163 | 169 | ITPT = basetype(sitp)
|
164 | 170 | IT = itptype(ITPT)
|
165 |
| - itp_tail = ntuple(i->zero(getindex_return_type(ITPT, ntuple(i->Int, N-1))), nelements(bsplinetype(iextract(IT, 1)))) |
166 |
| - quote |
167 |
| - dx_1 = coordlookup(sitp.ranges[1], 2) - coordlookup(sitp.ranges[1], 1) |
168 |
| - ScaledIterator(CartesianRange(ssize(sitp)), sitp, dx_1, 0, zero(dx_1), $itp_tail) |
169 |
| - end |
| 171 | + R = getindex_return_type(ITPT, Int) |
| 172 | + BT = bsplinetype(iextract(IT, 1)) |
| 173 | + itp_tail = eachvalue_zero(R, BT) |
| 174 | + dx_1 = coordlookup(sitp.ranges[1], 2) - coordlookup(sitp.ranges[1], 1) |
| 175 | + ScaledIterator(CartesianRange(ssize(sitp)), sitp, dx_1, 0, zero(dx_1), itp_tail) |
170 | 176 | end
|
171 | 177 |
|
172 |
| -start(iter::ScaledIterator) = start(iter.rng) |
173 |
| -done(iter::ScaledIterator, state) = done(iter.rng, state) |
| 178 | +@inline start(iter::ScaledIterator) = start(iter.rng) |
| 179 | +@inline done(iter::ScaledIterator, state) = done(iter.rng, state) |
174 | 180 |
|
175 | 181 | function index_gen1(::Union{Type{NoInterp}, Type{BSpline{Constant}}})
|
176 | 182 | quote
|
|
0 commit comments