About vector / vector behavior in Julia

Given by 3 / [2; 2]

1×2 LinearAlgebra.Transpose{Float64,Array{Float64,1}}:
 0.75  0.75

And 3/ [2; 2] gives

2-element Array{Float64,1}:
 1.5
 1.5

The second one is easy to understand It broadcasts 3 and performs element wise partitioning But what is the reason behind the behavior of the first operation? I assume that it takes the sum of vectors, that is, 2 × 1. Execute 3 × Divide 4 and broadcast it to 1 × 2 transpose vector I can accept dividing the sum of vectors, but why transpose? Or why not return a scalar?

Solution

It just gives the pseudo inverse of the right operand

julia> ?/
...  
Right division operator: multiplication of x by the inverse of y on the right.

Although love at first sight seems surprising, it is actually a natural act Rowvector * columnvector gives a scalar, so scalar divided by column vector should give a row vector, which is the case Please note that rowvector has been deleted in 1.0. What you get is actually the row vector represented by transfer

You can write @ less 1 / [2; 2] to see what actually happens

In addition, please take a look at this GitHub issue to understand the behavior of some use cases and this discover topic

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>