If there is no speed penalty or any other kind of penalty, it would be nice that Unicode characters × (00D7) and − (2212) be recognized by Julia as multiplication and minus operators as they are by Google.
Sometimes I copy a formula written in a word processor to a piece of code or an arithmetic computation to Google. In the case of a code I have to replace the multiplication sign by an asterix.
Finally, using the multiplication operator makes the code nicer.
1 Like
x × y
is already in use for cross(x,y)
and x − y
is the same as the standard x - y
starting from v1.7
!
6 Likes
The ×
is already exported by the LinearAlgebra
stdlib and it means cross product as it does in most mathematical texts:
julia> using LinearAlgebra
julia> [1, 2, 3] × [3, 2, 1]
3-element Vector{Int64}:
-4
8
-4
The unicode minus is already an alias for -
in the upcoming Julia release.
7 Likes
Thanks for the replies!
The dot operator is not recognized. Is there a reason for that?
It’s exported by the LinearAlgebra
stdlib like the ×
operator.
2 Likes
Using LinearAlgebra, a dot operator is equivalent to an Asterix. Why not without the LinearAlgebra standard library?
They are not the same
julia> using LinearAlgebra
julia> x = rand(5); y = rand(5);
julia> x ⋅ y
0.9319630238212403
julia> x * y
ERROR: MethodError: no method matching *(::Vector{Float64}, ::Vector{Float64})
4 Likes