Open TSGut opened 1 year ago
This follow from the type instability of global variable. From your example
julia> typeof(K.(α,x,y))
BroadcastQuasiVector{Float64, typeof(K), Tuple{Float64, BroadcastQuasiVector{Float64, typeof(first), Tuple{Inclusion{SVector{2, Float64}, EuclideanUnitSimplex{2, Float64, :closed}}}}, BroadcastQuasiVector{Float64, typeof(last), Tuple{Inclusion{SVector{2, Float64}, EuclideanUnitSimplex{2, Float64, :closed}}}}}}
whereas
julia> typeof(K.(x,y))
BroadcastQuasiVector{Any, typeof(K), Tuple{BroadcastQuasiVector{Float64, typeof(first), Tuple{Inclusion{SVector{2, Float64}, EuclideanUnitSimplex{2, Float64, :closed}}}}, BroadcastQuasiVector{Float64, typeof(last), Tuple{Inclusion{SVector{2, Float64}, EuclideanUnitSimplex{2, Float64, :closed}}}}}}
Note the Any
in the second line of code. However if α is declare as a constant
const α =2.0
it works
julia> T \ (@. K(x,y))
ℵ₀-blocked ℵ₀-element LazyBandedMatrices.DiagTrav{Float64, 2, LazyArrays.ApplyArray{Float64, 2, typeof(Base.setindex), Tuple{FillArrays.Zeros{Float64, 2, Tuple{InfiniteArrays.OneToInf{Int64}, InfiniteArrays.OneToInf{Int64}}}, Matrix{Float64}, Base.OneTo{Int64}, Base.OneTo{Int64}}}}:
0.1666666666666667
───────────────────────
0.06666666666666667
0.19999999999999998
───────────────────────
-0.09999999999999999
0.19999999999999993
-6.699811370772778e-18
───────────────────────
0.0
-6.148984834775253e-18
-1.6452652161292338e-18
0.0
───────────────────────
⋮
Note I fixed essentially the same bug back in August: https://github.com/JuliaApproximation/ClassicalOrthogonalPolynomials.jl/commit/2e33f50b7326706775597c75f284eb57e3dc0597
So I suspect something similar needs to be done here, just need to step through the transforms and see where the promotion to Any
happens.
There is some strange behavior when expanding functions on triangles, apparently when it comes to globally defined variables? Here is a minimal example:
Any idea what is happening here?