# Broadcasting matrix/vector

**URL:** <https://discourse.julialang.org/t/broadcasting-matrix-vector/16683>\
**Category:** New to Julia\
**Created:** [October 23, 2018, 2:15pm UTC](https://discourse.julialang.org/t/broadcasting-matrix-vector/16683 "2018-10-23T14:15:30Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![ndbecker](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ndbecker/32/10829_2.png) [@ndbecker](https://discourse.julialang.org/u/ndbecker)\
**Post date:** [October 23, 2018, 2:15pm UTC](https://discourse.julialang.org/t/broadcasting-matrix-vector/16683/1 "2018-10-23T14:15:30Z")

</div>

a = np.zeros(2,3)  
b = np.ones(3)  
a .+ b  
ERROR: DimensionMismatch(“arrays could not be broadcast to a common size”)

OK, what’s the preferred way to force broadcasting here?

This is one way  
a .+ reshape(b,1,3)

---

<div class="post-metadata">

**Author:** ![favba](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/favba/32/2735_2.png) [@favba](https://discourse.julialang.org/u/favba)\
**Post date:** [October 23, 2018, 2:23pm UTC](https://discourse.julialang.org/t/broadcasting-matrix-vector/16683/2 "2018-10-23T14:23:15Z")

</div>

```julia
julia> a = zeros(2,3)
2×3 Array{Float64,2}:
 0.0 0.0 0.0
 0.0 0.0 0.0

julia> b = ones(3)
3-element Array{Float64,1}:
 1.0
 1.0
 1.0

julia> a .+ b'
2×3 Array{Float64,2}:
 1.0 1.0 1.0
 1.0 1.0 1.0

```

I’m assuming you want to broadcast the rows…

`b'` is taking the transpose (actually the adjoint) of `b`.
