Skip to content

Commit 39c58fb

Browse files
committed
Also make hessian, gradient stable
1 parent 05e0e3a commit 39c58fb

File tree

1 file changed

+9
-8
lines changed

1 file changed

+9
-8
lines changed

src/b-splines/indexing.jl

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -102,10 +102,12 @@ function weightedindexes(parts::Vararg{Union{Int,GradParts},N}) where N
102102
slot_substitute(parts, map(positions, parts), map(valuecoefs, parts), map(gradcoefs, parts))
103103
end
104104

105-
# Skip over NoInterp dimensions
106-
slot_substitute(kind::Tuple{Int,Vararg{Any}}, p, v, g) = slot_substitute(Base.tail(kind), p, v, g)
107105
# Substitute the dth dimension's gradient coefs for the remaining coefs
108-
slot_substitute(kind, p, v, g) = (map(maybe_weightedindex, p, substitute_ruled(v, kind, g)), slot_substitute(Base.tail(kind), p, v, g)...)
106+
function slot_substitute(kind, p, v, g)
107+
rest = slot_substitute(Base.tail(kind), p, v, g)
108+
kind[1] isa Int && return rest # Skip over NoInterp dimensions
109+
(map(maybe_weightedindex, p, substitute_ruled(v, kind, g)), rest...)
110+
end
109111
# Termination
110112
slot_substitute(kind::Tuple{}, p, v, g) = ()
111113

@@ -132,15 +134,14 @@ function _column(kind1::K, kind2::K, p, v, g, h) where {K<:Tuple}
132134
ss = substitute_ruled(v, kind1, h)
133135
(map(maybe_weightedindex, p, ss), _column(Base.tail(kind1), kind2, p, v, g, h)...)
134136
end
137+
_column(kind1::K, kind2::K, p, v, g, h) where {K<:Tuple{Int,Vararg}} = () # Skip over NoInterp dimensions
135138
function _column(kind1::Tuple, kind2::Tuple, p, v, g, h)
139+
rest = _column(Base.tail(kind1), kind2, p, v, g, h)
140+
kind1[1] isa Int && return rest # Skip over NoInterp dimensions
136141
ss = substitute_ruled(substitute_ruled(v, kind1, g), kind2, g)
137-
(map(maybe_weightedindex, p, ss), _column(Base.tail(kind1), kind2, p, v, g, h)...)
142+
(map(maybe_weightedindex, p, ss), rest...)
138143
end
139144
_column(::Tuple{}, ::Tuple, p, v, g, h) = ()
140-
# Skip over NoInterp dimensions
141-
slot_substitute(kind::Tuple{Int,Vararg{Any}}, p, v, g, h) = slot_substitute(Base.tail(kind), p, v, g, h)
142-
_column(kind1::Tuple{Int,Vararg{Any}}, kind2::Tuple, p, v, g, h) =
143-
_column(Base.tail(kind1), kind2, p, v, g, h)
144145

145146
weightedindex_parts(fs::F, itpflag::BSpline, ax, x) where F =
146147
weightedindex_parts(fs, degree(itpflag), ax, x)

0 commit comments

Comments
 (0)