Skip to content

Commit 35de5f9

Browse files
authored
Merge pull request #276 from JuliaMath/teh/map
More broadcast->map transformations
2 parents 2e1108f + 2f35789 commit 35de5f9

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

src/b-splines/indexing.jl

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,8 @@ weightedindexes(i::Vararg{Int,N}) where N = i # the all-NoInterp case
6363

6464
const PositionCoefs{P,C} = NamedTuple{(:position,:coefs),Tuple{P,C}}
6565
const ValueParts{P,W} = PositionCoefs{P,Tuple{W}}
66-
@inline weightedindexes(parts::Vararg{Union{Int,ValueParts},N}) where N = maybe_weightedindex.(positions.(parts), valuecoefs.(parts))
66+
@inline weightedindexes(parts::Vararg{Union{Int,ValueParts},N}) where N =
67+
map(maybe_weightedindex, map(positions, parts), map(valuecoefs, parts))
6768
maybe_weightedindex(i::Integer, _::Integer) = Int(i)
6869
maybe_weightedindex(pos, coefs::Tuple) = WeightedIndex(pos, coefs)
6970

@@ -86,13 +87,13 @@ function weightedindexes(parts::Vararg{Union{Int,GradParts},N}) where N
8687
# i2 is the integer index along dimension 2
8788
# These will result in a 2-vector gradient.
8889
# TODO: check whether this is inferrable
89-
slot_substitute(parts, positions.(parts), valuecoefs.(parts), gradcoefs.(parts))
90+
slot_substitute(parts, map(positions, parts), map(valuecoefs, parts), map(gradcoefs, parts))
9091
end
9192

9293
# Skip over NoInterp dimensions
9394
slot_substitute(kind::Tuple{Int,Vararg{Any}}, p, v, g) = slot_substitute(Base.tail(kind), p, v, g)
9495
# Substitute the dth dimension's gradient coefs for the remaining coefs
95-
slot_substitute(kind, p, v, g) = (maybe_weightedindex.(p, substitute_ruled(v, kind, g)), slot_substitute(Base.tail(kind), p, v, g)...)
96+
slot_substitute(kind, p, v, g) = (map(maybe_weightedindex, p, substitute_ruled(v, kind, g)), slot_substitute(Base.tail(kind), p, v, g)...)
9697
# Termination
9798
slot_substitute(kind::Tuple{}, p, v, g) = ()
9899

@@ -109,7 +110,7 @@ function weightedindexes(parts::Vararg{Union{Int,HessParts},N}) where N
109110
# hc1 = coefs[hwi1, i2, wi3]
110111
# hc2 = coefs[gwi1, i2, gwi3]
111112
# hc3 = coefs[wi1, i2, hwi3]
112-
slot_substitute(parts, parts, positions.(parts), valuecoefs.(parts), gradcoefs.(parts), hesscoefs.(parts))
113+
slot_substitute(parts, parts, map(positions, parts), map(valuecoefs, parts), map(gradcoefs, parts), map(hesscoefs, parts))
113114
end
114115

115116
# Skip over NoInterp dimensions

0 commit comments

Comments
 (0)