Is it possible to define a ``+!`` function?

4 posts were merged into an existing topic: Less than approx equals? <โ‰ˆ

I think you have a fundamental misunderstanding here of linear algebra or are using the word โ€˜correctโ€™ to instead mean โ€˜the thing that I meantโ€™.

What you are seeing is no different from * versus .*.

julia> A = [1 2; 3 4]; B = [5 6; 7 8];

julia> A * B
2ร—2 Array{Int64,2}:
 19  22
 43  50

julia> A .* B
2ร—2 Array{Int64,2}:
  5  12
 21  32
3 Likes

OK, I see what you mean. Itโ€™s computing the acos matrix of the type array member, though I was expecting to get the composite type on output as well.

julia> acos(G2.z)
2ร—2 Array{Complex{Float64},2}:
 0.651095+5.55112e-17im  -0.71526+5.55112e-17im
  1.01153+0.0im           1.66263-2.22045e-16im

julia> acos(G2)
2ร—2 Array{Complex{Float64},2}:
 0.651095+5.55112e-17im  -0.71526+5.55112e-17im
  1.01153+0.0im           1.66263-2.22045e-16im

but then why the same does not hold with cos?

julia> cos(G2.z)
2ร—2 Array{Float64,2}:
 0.827518  -0.365429
 0.516794   1.34431

julia> cos(G2)
ERROR: MethodError: no method matching GMT.GMTgrid(::String, ::String, ::Int64, ::Array{Float64,1}, ::Array{Float64,1}, ::Int64, ::Float64, ::String, ::String, ::String, ::Array{Float64,1}, ::Array{Float64,1}, ::Array{Complex{Float64},2}, ::String, ::String, ::String, ::String)
Closest candidates are:
  GMT.GMTgrid(::String, ::String, ::Int64, ::Array{Float64,1}, ::Array{Float64,1}, ::Int64, ::Union{Float32, Float64}, ::String, ::String, ::String, ::Array{Float64,1}, ::Array{Float64,1}, ::Array{T,N}, ::String, ::String, ::String, ::String) where {T<:Real, N} at C:\Users\joaqu\.julia\dev\GMT\src\gmt_main.jl:2
Stacktrace:

Broadcasting is most likely still the best solution here, but note that in Julia 1.6, ๊œ will be a valid operator suffix, so you can use +๊œ, -๊œ, *๊œ, etc. as infix or prefix operators, without resorting to any hacks:

3 Likes