See https://github.com/JuliaLang/julia/issues/18466#issuecomment-246713799
On Wed, Sep 14, 2016 at 6:13 PM, Dan wrote:
> Maybe the following is the form you are looking for:
>
> julia> decomplexify{T}(::Type{Complex{T}}) = T
> decomplexify (generic function with 1 method)
>
>
Maybe the following is the form you are looking for:
julia> decomplexify{T}(::Type{Complex{T}}) = T
decomplexify (generic function with 1 method)
julia> type bar{S,T}
sum::S
sumsqr::T
function bar(s,ss)
if typeof(ss) != decomplexify(typeof(s))
I'm not sure then, but hopefully someone here can help you out! Naively
perhaps it feels like this makes the type inference impossible. Your
function decomplexify always produces the same output for the same input,
but what if you had a function that returned a different output (always of
type
Evan Fields wrote:
> How about something like the following?
>
> type CT{T}
> ctsum::Complex{T}
> ctsumsq::T
> end
>
I'm aware that it's easier to make the type parameter the scalar type,
allowing writing as you show, but as a learning exercise I'd like to know
how Julia would go the
How about something like the following?
type CT{T}
ctsum::Complex{T}
ctsumsq::T
end
x = 1 + 2im
ctx = CT(x, convert(decomplexify(typeof(x)), x * conj(x))
You could also make a convenience function so you don't have to do the
converts yourself for the second argument.
Have you seen the