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)
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)
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
.