1+ resizedata! (P:: OrthogonalPolynomial , x, n) = P # default is no-op
2+
13
24# Assume 1 normalization
35_p0 (A) = one (eltype (A))
1618function copyto! (dest:: AbstractVector , V:: SubArray{<:Any,1,<:OrthogonalPolynomial,<:Tuple{<:Number,<:OneTo}} )
1719 P = parent (V)
1820 x,n = parentindices (V)
21+ resizedata! (P, :, last (n))
1922 A,B,C = recurrencecoefficients (P)
2023 forwardrecurrence! (dest, A, B, C, x, _p0 (P))
2124end
@@ -24,6 +27,7 @@ function forwardrecurrence_copyto!(dest::AbstractMatrix, V)
2427 checkbounds (dest, axes (V)... )
2528 P = parent (V)
2629 xr,jr = parentindices (V)
30+ resizedata! (P, :, maximum (jr))
2731 A,B,C = recurrencecoefficients (P)
2832 shift = first (jr)
2933 Ã,B̃,C̃ = A[shift: ∞],B[shift: ∞],C[shift: ∞]
@@ -40,6 +44,7 @@ function copyto!(dest::AbstractVector, V::SubArray{<:Any,1,<:OrthogonalPolynomia
4044 checkbounds (dest, axes (V)... )
4145 P = parent (V)
4246 x,jr = parentindices (V)
47+ resizedata! (P, :, last (jr))
4348 A,B,C = recurrencecoefficients (P)
4449 shift = first (jr)
4550 Ã,B̃,C̃ = A[shift: ∞],B[shift: ∞],C[shift: ∞]
@@ -65,7 +70,10 @@ Base.unsafe_getindex(P::OrthogonalPolynomial, x::Number, n::AbstractVector) = Ba
6570Base. unsafe_getindex (P:: OrthogonalPolynomial , x:: AbstractVector , n:: AbstractVector ) = Base. unsafe_getindex (P,x,oneto (maximum (n)))[:,n]
6671Base. unsafe_getindex (P:: OrthogonalPolynomial , x:: AbstractVector , n:: Number ) = Base. unsafe_getindex (P, x, 1 : n)[:,end ]
6772Base. unsafe_getindex (P:: OrthogonalPolynomial , x:: Number , :: Colon ) = Base. unsafe_getindex (P, x, axes (P,2 ))
68- Base. unsafe_getindex (P:: OrthogonalPolynomial , x:: Number , n:: Number ) = initiateforwardrecurrence (n- 1 , recurrencecoefficients (P)... , x, _p0 (P))[end ]
73+ function Base. unsafe_getindex (P:: OrthogonalPolynomial , x:: Number , n:: Number )
74+ resizedata! (P, :, n)
75+ initiateforwardrecurrence (n- 1 , recurrencecoefficients (P)... , x, _p0 (P))[end ]
76+ end
6977
7078getindex (P:: OrthogonalPolynomial , x:: Number , jr:: AbstractInfUnitRange{Int} ) = view (P, x, jr)
7179getindex (P:: OrthogonalPolynomial , x:: AbstractVector , jr:: AbstractInfUnitRange{Int} ) = view (P, x, jr)
8391
8492function unsafe_getindex (f:: Mul{<:AbstractOPLayout,<:AbstractPaddedLayout} , x:: Number )
8593 P,c = f. A,f. B
86- _p0 (P)* clenshaw (paddeddata (c), recurrencecoefficients (P)... , x)
94+ data = paddeddata (c)
95+ resizedata! (P, :, length (data))
96+ _p0 (P)* clenshaw (data, recurrencecoefficients (P)... , x)
8797end
8898
8999function unsafe_getindex (f:: Mul{<:AbstractOPLayout,<:AbstractPaddedLayout} , x:: Number , jr)
90100 P,c = f. A,f. B
101+ data = paddeddata (c)
102+ resizedata! (P, :, maximum (jr))
91103 _p0 (P)* clenshaw (view (paddeddata (c),:,jr), recurrencecoefficients (P)... , x)
92104end
93105
0 commit comments