You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Yeah, this is all about constant propagation through higher order functions. A simple workaround is to place the constant inside a function — "closer" to the getproperty call. These flavors are type stable:
julia>functionchol_func2a(mats::Vector{<:Matrix})
choleskies =cholesky.(mats)
return (x->getproperty(x, :L)).(choleskies)
end
chol_func2a (generic function with 2 methods)
julia>functionchol_func3a(mats::Vector{<:Matrix})
choleskies =cholesky.(mats)
returnmap(x->getproperty(x,:L), choleskies)
end
chol_func3a (generic function with 3 methods)
The following code (thanks @ysfoo) shows that broadcasting can fail to be type stable, even when equivalent map calls/list comprehensions are:
Output:
Version info:
Changing
:L
toRef(:L)
doesn't make a difference for the first two examples. For the third (with map), usingRef(:L)
loses type stability:The text was updated successfully, but these errors were encountered: