I’m not sure if this is a bug in my understanding or an issue with the macro:
I’m creating a complex array and then scrambling the phases. Here rand(N)
is the only vector-valued thing, so I’d expect all the rest of the operations to automatically dot-broadcast
julia> N = 15
15
julia> X = ones(Complex128, N)
15-element Array{Complex{Float64},1}:
1.0+0.0im
⋮
julia> @. X *= exp(im*π*(rand(N)*2-1))
WARNING: exp(x::AbstractArray{T}) where T <: Number is deprecated, use exp.(x) instead.
Stacktrace:
[1] depwarn(::String, ::Symbol) at .\deprecated.jl:70
[2] exp(::Array{Complex{Float64},1}) at .\deprecated.jl:57
[3] (::##71#72)(::Complex{Float64}, ::Complex{Bool}, ::Irrational{:π}, ::Int64) at .\<missing>:0
[4] macro expansion at .\broadcast.jl:155 [inlined]
⋮
ERROR: MethodError: Cannot `convert` an object of type Array{Complex{Float64},1} to an object of type Complex{Float64}
This may have arisen from a call to the constructor Complex{Float64}(...),
since type constructors fall back to convert methods.
Stacktrace:
[1] setindex! at .\multidimensional.jl:300 [inlined]
[2] macro expansion at .\broadcast.jl:156 [inlined]
[3] macro expansion at .\simdloop.jl:73 [inlined]
[4] macro expansion at .\broadcast.jl:149 [inlined]
[5] _broadcast!(::##71#72, ::Array{Complex{Float64},1},
⋮
Explicitly putting the dots: .*=
and in exp.(...)
works, but I’d thought that the @.
macro should do it for me.