1
+ resizedata! (P:: OrthogonalPolynomial , x, n) = P # default is no-op
2
+
1
3
2
4
# Assume 1 normalization
3
5
_p0 (A) = one (eltype (A))
16
18
function copyto! (dest:: AbstractVector , V:: SubArray{<:Any,1,<:OrthogonalPolynomial,<:Tuple{<:Number,<:OneTo}} )
17
19
P = parent (V)
18
20
x,n = parentindices (V)
21
+ resizedata! (P, :, last (n))
19
22
A,B,C = recurrencecoefficients (P)
20
23
forwardrecurrence! (dest, A, B, C, x, _p0 (P))
21
24
end
@@ -24,6 +27,7 @@ function forwardrecurrence_copyto!(dest::AbstractMatrix, V)
24
27
checkbounds (dest, axes (V)... )
25
28
P = parent (V)
26
29
xr,jr = parentindices (V)
30
+ resizedata! (P, :, maximum (jr))
27
31
A,B,C = recurrencecoefficients (P)
28
32
shift = first (jr)
29
33
Ã,B̃,C̃ = A[shift: ∞],B[shift: ∞],C[shift: ∞]
@@ -40,6 +44,7 @@ function copyto!(dest::AbstractVector, V::SubArray{<:Any,1,<:OrthogonalPolynomia
40
44
checkbounds (dest, axes (V)... )
41
45
P = parent (V)
42
46
x,jr = parentindices (V)
47
+ resizedata! (P, :, last (jr))
43
48
A,B,C = recurrencecoefficients (P)
44
49
shift = first (jr)
45
50
Ã,B̃,C̃ = A[shift: ∞],B[shift: ∞],C[shift: ∞]
@@ -65,7 +70,10 @@ Base.unsafe_getindex(P::OrthogonalPolynomial, x::Number, n::AbstractVector) = Ba
65
70
Base. unsafe_getindex (P:: OrthogonalPolynomial , x:: AbstractVector , n:: AbstractVector ) = Base. unsafe_getindex (P,x,oneto (maximum (n)))[:,n]
66
71
Base. unsafe_getindex (P:: OrthogonalPolynomial , x:: AbstractVector , n:: Number ) = Base. unsafe_getindex (P, x, 1 : n)[:,end ]
67
72
Base. 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
69
77
70
78
getindex (P:: OrthogonalPolynomial , x:: Number , jr:: AbstractInfUnitRange{Int} ) = view (P, x, jr)
71
79
getindex (P:: OrthogonalPolynomial , x:: AbstractVector , jr:: AbstractInfUnitRange{Int} ) = view (P, x, jr)
83
91
84
92
function unsafe_getindex (f:: Mul{<:AbstractOPLayout,<:AbstractPaddedLayout} , x:: Number )
85
93
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)
87
97
end
88
98
89
99
function unsafe_getindex (f:: Mul{<:AbstractOPLayout,<:AbstractPaddedLayout} , x:: Number , jr)
90
100
P,c = f. A,f. B
101
+ data = paddeddata (c)
102
+ resizedata! (P, :, maximum (jr))
91
103
_p0 (P)* clenshaw (view (paddeddata (c),:,jr), recurrencecoefficients (P)... , x)
92
104
end
93
105
0 commit comments