# Broadcasting with vectors of static vectors

**URL:** <https://discourse.julialang.org/t/broadcasting-with-vectors-of-static-vectors/12693>\
**Category:** General Usage\
**Tags:** broadcast\
**Created:** [July 27, 2018, 9:47pm UTC](https://discourse.julialang.org/t/broadcasting-with-vectors-of-static-vectors/12693 "2018-07-27T21:47:12Z")\
**Posts on this page:** 1\
**Showing post:** 2

<div class="post-metadata">

**Author:** ![mbauman](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mbauman/32/31082_2.png) [@mbauman](https://discourse.julialang.org/u/mbauman)\
**Post date:** [July 27, 2018, 9:59pm UTC](https://discourse.julialang.org/t/broadcasting-with-vectors-of-static-vectors/12693/2 "2018-07-27T21:59:02Z")

</div>

Broadcasting works only on the outermost shape of each and every argument. As you’ve written it, you’re attempting to broadcast a 5-element vector and a 3-element vector.

Now, what you want is for the 3-element vector to behave like a “scalar” — that is, broadcast should repeat it for each element of the 5-element vector. To do that, you can “protect” it inside a 1-element container like a tuple:

```julia
julia> a .+ (Vec(2,2,2),)
5-element Array{SArray{Tuple{3},Float64,1,3},1}:
 [3.0, 3.0, 3.0]
 [4.0, 4.0, 4.0]
 [5.0, 5.0, 5.0]
 [6.0, 6.0, 6.0]
 [7.0, 7.0, 7.0]

```

Note that this doesn’t really have anything to do with StaticArrays — except for the fact that you might be slightly more likely to think of a static vector as a “scalar-like” thing unto itself.

---

_[View the full topic](https://discourse.julialang.org/t/broadcasting-with-vectors-of-static-vectors/12693)._
