-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
real_arr_type
not type stable
#12
Comments
In this specific case you could also pass similar(arr, real(eltype(arr)), ...) |
|
Yup. But the point is, that there are functions (like |
But as I said, it needs to perform the runtime dispatch and hence can cause performance issues: Something like this would be better: ulia> function similar_arr_type_4(::Type{TA}, ::Type{ET}, dims=Val(2)) where {TA, ET}
typeof(similar(TA{ET}, ntuple(x->0, dims)))
end
similar_arr_type_4 (generic function with 2 methods)
julia> similar_arr_type_4(Array, Float64)
Matrix{Float64} (alias for Array{Float64, 2})
julia> similar_arr_type_4(Array, Float64)^C
julia> @code_warntype similar_arr_type_4(Array, Float64)
MethodInstance for similar_arr_type_4(::Type{Array}, ::Type{Float64})
from similar_arr_type_4(::Type{TA}, ::Type{ET}) where {TA, ET} in Main at REPL[47]:1
Static Parameters
TA = Array
ET = Float64
Arguments
#self#::Core.Const(similar_arr_type_4)
@_2::Type{Array}
@_3::Core.Const(Float64)
Body::Type{Matrix{Float64}}
1 ─ %1 = Main.Val(2)::Core.Const(Val{2}())
│ %2 = (#self#)(@_2, @_3, %1)::Core.Const(Matrix{Float64})
└── return %2
|
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Where did you need those functions?
The text was updated successfully, but these errors were encountered: