@@ -14,6 +14,7 @@ _p0(A) = one(eltype(A))
1414function initiateforwardrecurrence (N, A, B, C, x, μ)
1515 T = promote_type (eltype (A), eltype (B), eltype (C), typeof (x))
1616 p0 = convert (T, μ)
17+ N == 0 && return zero (T), p0
1718 p1 = convert (T, muladd (A[1 ],x,B[1 ])* p0)
1819 @inbounds for n = 2 : N
1920 p1,p0 = _forwardrecurrence_next (n, A, B, C, x, p0, p1),p1
6970getindex (P:: OrthogonalPolynomial , x:: Number , n:: AbstractVector ) = layout_getindex (P, x, n)
7071getindex (P:: OrthogonalPolynomial , x:: AbstractVector , n:: AbstractVector ) = layout_getindex (P, x, n)
7172getindex (P:: SubArray{<:Any,1,<:OrthogonalPolynomial} , x:: AbstractVector ) = layout_getindex (P, x)
72- getindex (P:: OrthogonalPolynomial , x:: Number , n:: Number ) = P[x,oneto (n)][end ]
73+ Base. @propagate_inbounds function getindex (P:: OrthogonalPolynomial , x:: Number , n:: Number )
74+ @boundscheck checkbounds (P, x, n)
75+ Base. unsafe_getindex (P, x, n)
76+ end
77+
7378
7479unsafe_layout_getindex (A... ) = sub_materialize (Base. unsafe_view (A... ))
7580
@@ -79,7 +84,7 @@ Base.unsafe_getindex(P::OrthogonalPolynomial, x::Number, n::AbstractVector) = Ba
7984Base. unsafe_getindex (P:: OrthogonalPolynomial , x:: AbstractVector , n:: AbstractVector ) = Base. unsafe_getindex (P,x,oneto (maximum (n)))[:,n]
8085Base. unsafe_getindex (P:: OrthogonalPolynomial , x:: AbstractVector , n:: Number ) = Base. unsafe_getindex (P, x, 1 : n)[:,end ]
8186Base. unsafe_getindex (P:: OrthogonalPolynomial , x:: Number , :: Colon ) = Base. unsafe_getindex (P, x, axes (P,2 ))
82- Base. unsafe_getindex (P:: OrthogonalPolynomial , x:: Number , n:: Number ) = Base . unsafe_getindex (P,x, oneto (n ))[end ]
87+ Base. unsafe_getindex (P:: OrthogonalPolynomial , x:: Number , n:: Number ) = initiateforwardrecurrence (n - 1 , recurrencecoefficients (P) ... , x, _p0 (P ))[end ]
8388
8489getindex (P:: OrthogonalPolynomial , x:: Number , jr:: AbstractInfUnitRange{Int} ) = view (P, x, jr)
8590getindex (P:: OrthogonalPolynomial , x:: AbstractVector , jr:: AbstractInfUnitRange{Int} ) = view (P, x, jr)
0 commit comments