Skip to content

Evaluating SemiclassicalJacobi is not type stable #124

@DanielVandH

Description

@DanielVandH
julia> P = SemiclassicalJacobi(2.0, 1/2, 1/2, 1/2)
SemiclassicalJacobi with weight x^0.5 * (1-x)^0.5 * (2.0-x)^0.5 on 0..1

julia> @inferred P[0.2, 1]
ERROR: return type Float64 does not match inferred return type Any
Stacktrace:
 [1] error(s::String)
   @ Base .\error.jl:35
 [2] top-level scope
   @ REPL[14]:

Probably because

julia> @inferred recurrencecoefficients(P)
ERROR: return type Tuple{BroadcastVector{Float64, typeof(inv), Tuple{ClassicalOrthogonalPolynomials.LanczosJacobiBand{Float64}}}, BroadcastVector{Float64, typeof(-), Tuple{BroadcastVector{Float64, typeof(/), Tuple{ClassicalOrthogonalPolynomials.LanczosJacobiBand{Float64}, ClassicalOrthogonalPolynomials.LanczosJacobiBand{Float64}}}}}, BroadcastVector{Float64, typeof(/), Tuple{ApplyArray{Float64, 1, typeof(vcat), Tuple{Float64, ClassicalOrthogonalPolynomials.LanczosJacobiBand{Float64}}}, ClassicalOrthogonalPolynomials.LanczosJacobiBand{Float64}}}} does not match inferred return type Tuple{Any, Any, Any}
Stacktrace:
 [1] error(s::String)
   @ Base .\error.jl:35
 [2] top-level scope
   @ REPL[15]:1

since

julia> @inferred jacobimatrix(P)
ERROR: return type LazyBandedMatrices.SymTridiagonal{Float64, ClassicalOrthogonalPolynomials.LanczosJacobiBand{Float64}, ClassicalOrthogonalPolynomials.LanczosJacobiBand{Float64}} does not match inferred return type AbstractMatrix{Float64}
Stacktrace:
 [1] error(s::String)
   @ Base .\error.jl:35
 [2] top-level scope
   @ REPL[24]:1

I don't think it's possible to make jacobimatrix type stable in the current setup so probably the easiest approach is to slap a ::T in a view areas of wherever this all gets evaluated

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions