Structs and parametric constructors

When I only add the Function parameters to the Define type, I get basically 0% to 10% improvement.

My original timings look like this

julia> newton(:(z^3-1);n=500)|>fatou;
  0.240635 seconds (1.69 M allocations: 58.407 MiB)

With the Define{FT<:Function,QT<:Function,CT<:Function} definition, I don’t get much improvement

julia> newton(:(z^3-1);n=500)|>fatou;
  0.221504 seconds (1.53 M allocations: 50.724 MiB)

However, because in my situation there is additional program logic, I added additional Bool type paramters to the Fatou.Define{FT,QT,CT,M,N} object, which gave me a 10x performance improvement. This time the parameters have additionally Bool pair to help decide on Mandelbrot and Newton fractal mode.

julia> newton(:(z^3-1);n=500)|>fatou;
  0.020936 seconds (542 allocations: 36.784 KiB)

This is because of my iteration function definition, which depends on these true or false values, by including them in the Fatou.Define type parameters, the function can specialize on those values

# define function for computing orbit of a z0 input
function nf(K::Define{FT,QT,CT,M,N},z0::Complex{Float64}) where {FT,QT,CT,M,N}
    M ? (z = K.seed) : (z = z0)
    zn = 0x00
    while (N ? (K.Q(z,z0)::Float64>K.ϵ)::Bool : (K.Q(z,z0)::Float64<K.ϵ))::Bool && K.N>zn
        z = K.F(z,z0)::Complex{Float64}
        zn+=0x01
    end; #end
    # return the normalized argument of z or iteration count
    return (zn::UInt8,z::Complex{Float64})
end

So now it computes much, much faster. However, in my case, having a Function parameter alone did not do the trick, it was also necessary to have other parameters also.

Sprechen sie Deutsch?