Skip to content

Inconsistency in complex(::Array) vs complex(::Array, ::Array) #624

Open
@stillyslalom

Description

@stillyslalom

There's some inconsistency in the complex(...) methods:

help?> complex

  complex(r, [i])

  Convert real numbers or arrays to complex. i defaults to zero.

julia> complex(rand(3))
3-element Array{Complex{Float64},1}:
 0.7485012418373351 + 0.0im
 0.9146512879195354 + 0.0im
 0.6380568113960479 + 0.0im

julia> complex(rand(3), rand(3))
ERROR: MethodError: no method matching complex(::Array{Float64,1}, ::Array{Float64,1})
Closest candidates are:
  complex(::AbstractArray{T,N} where N) where T at complex.jl:1012
Stacktrace:
 [1] top-level scope at none:0

You can always broadcast, of course: complex.(rand(3), rand(3)) works fine. But it seems like it should either accept arrays for both arguments, or not at all.

Metadata

Metadata

Assignees

No one assigned

    Labels

    arrays[a, r, r, a, y, s]complexComplex numbers

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions