AFAICT + 算子不会自动广播:
julia> 1 + [2, 3]
ERROR: MethodError: no method matching +(::Int64, ::Array{Int64,1})
For element-wise addition, use broadcasting with dot syntax: scalar .+ array
julia> [1 2] + [3, 4]
ERROR: DimensionMismatch("dimensions must match: a has dims (Base.OneTo(1), Base.OneTo(2)), b has dims (Base.OneTo(2),), mismatch at 1")
你要分别写:
julia> 1 .+ [2, 3]
2-element Array{Int64,1}:
3
4
julia> [1 2] .+ [3, 4]
2×2 Array{Int64,2}:
4 5
5 6
但重要的是,+ 是对完全相同维度的数组的有效操作(在数学意义上),这就是它起作用的原因:
julia> [2 3 4] + [3 4 5]
1×3 Array{Int64,2}:
5 7 9
请注意,这不是广播,而只是线性代数。
现在关于x / y,您可以检查它是否定义为:
help?> x / y
/(x, y)
Right division operator: multiplication of x by the inverse of y on the right.
所以你有:
julia> using LinearAlgebra
julia> x * pinv(y)
1×1 Array{Float64,2}:
0.7600000000000005
(实际的实现有点不同——我在这里使用了一种简化的方法)