Think of Complex as complex number factory.  As with any factory, this one 
takes in some raw material, one or two numbers that are some subtype of 
Real, and produces its product -- a Complex number.
And this makes sense mathematically; Real numbers are 'real number part' of 
Complex numbers, so we expect Complex(5) to be the Complex number with a 
real number part of 5 and an imaginary number part of 0:

julia> Complex(5)
5 + 0im

Using two Real numbers, one for real part of the Complex number and the 
other for imaginary part also makes sense because once we isolate the real 
and imaginary parts, this happens:

julia> a = Complex(5,4); a, typeof(a)
5 + 4im, Complex{Int64}   # or Complex{Int32}, depending on your system
julia> firstnumber,secondnumber = a.re, a.im
(5,4)
julia> typeof(firstnumber), typeof(secondnumber)
Int64, Int64 

and Integers are a subtype of Real
Try the same steps using 5.0 and 4.0





On Tuesday, December 22, 2015 at 7:49:19 AM UTC-5, kleinsplash wrote:
>
> Hi,
>
>
> I am working through a tutorial and have come across this line: 
>
>
> call{T<:Real}(::Type{Complex{T<:Real}}, re::T<:Real, im::T<:Real) at 
> complex.jl:4
>
> when running: 
>
>
> methods(Complex)
>
> I think it says:
>
>
> when calling Complex() you can provide two inputs either a value T which must 
> be a subtype of type abstract type Real OR ?? 
>
>
> So an example would be:
>
>
> Complex(10) or Complex(5,1)
>
>
> Is this correct?
>
>
> -Thank you
>
>

Reply via email to