Skip to content

Commit 38bb168

Browse files
committed
make TupleVec a broadcasting 'atom', not container
1 parent 2121e7f commit 38bb168

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

src/iteration.jl

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,9 @@ Base.map(f, v::TupleVec) = TupleVec(map(x -> map(f, x), _t(v)))
3535
Base.map(f, v::TupleVec, w::TupleVec) = TupleVec(map((x,y) -> map(f, x, y), _t(v), _t(w)))
3636
Base.map(f, v1::TupleVec, v2::TupleVec, vs::TupleVec...) = TupleVec(map((x...) -> map(f, x...), map(v -> _t(v), (v1, v2, vs...))...))
3737

38-
# default broadcast uses "collect" … change this?
38+
##############################################################
39+
# broadcasting: treat as "atom", not container:
40+
Base.broadcastable(v::TupleVec) = Ref(v)
3941

4042
##############################################################
4143
# iteration on adjoint vectors
@@ -51,3 +53,9 @@ end
5153
# (given an instance, or a type if size information is in the type)
5254

5355
##############################################################
56+
# todo: support indexing
57+
58+
Base.ndims(v::TupleVec) = 1 # needed by DifferentialEquations
59+
Base.ndims(v::Type{<:TupleVec}) = 1 # needed by DifferentialEquations
60+
61+
##############################################################

0 commit comments

Comments
 (0)