It means that you are looking at the way a call to call() is specified, and
that takes a moment to wade through:
let's start at the start:
call{T<:Real}(::Type{Complex{T<:Real}}, re::T<:Real, im::T<:Real)
a b c b b b
e
f g
(a) the function/method of interest (b) a way to talk about the same thing
in different places (c) the named, typed arguments and also a dispatch
matchable type sequence
the actual
type used for re and im have to match
both Int64 or
both Float32 ...
otherwise
----->
-----------> this type
sequence will not match (another one may)
let's look at c more closely
there are three parts (e, f, g), f and g are have names (re, im). e has a
name too, its more difficult to pronounce ::Type than 're' or 'im'.
::Type{
roughly means hey, pay attention! here is a Type (which is a different
thing than the type of a specific variable, like the type of the variable
passed in as re)
and the inner part surrounded by ::Type{ } is used when matching or
avoiding this particular Complex number constructor call
so e.g. that is why this generates an error:
a = Complex(3,4)
b = Complex(5,6)
c = Complex(a,b)
On Tuesday, December 22, 2015 at 9:32:58 AM UTC-5, kleinsplash wrote:
Thanks. Though its more this ::Type{Complex{T<:Real}} that is confusing
me.. what does it mean? Is ::Type{} casting a Complex number? So do you
then have to say something like Complex(self, realpart, imagpart)?
On Tuesday, 22 December 2015 16:27:36 UTC+2, Jeffrey Sarnoff wrote:
>
> 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
>>
>>