Skip to content

Commit fb155a5

Browse files
committed
add general forwardrecurrence!
1 parent ead3d88 commit fb155a5

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

src/bases/orthogonalpolynomials.jl

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,17 @@ abstract type OrthogonalPolynomial{T} <: Basis{T} end
2222
# return v[r.+1]
2323
# end
2424

25+
function forwardrecurrence!(v::AbstractVector{T}, b::AbstractVector, a::AbstractVector, c::AbstractVector, x) where T
26+
isempty(v) && return v
27+
v[1] = one(T) # assume OPs are normalized to one for now
28+
length(v) == 1 && return v
29+
v[2] = (x-a[1])/c[1]
30+
@inbounds for n=3:length(v)
31+
v[n] = muladd(x-a[n-1],v[n-1],-b[n-1]*v[n-2])/c[n-1]
32+
end
33+
v
34+
end
35+
2536
function forwardrecurrence!(v::AbstractVector{T}, b::AbstractVector, ::Zeros{<:Any,1}, c::AbstractVector, x) where T
2637
isempty(v) && return v
2738
v[1] = one(T) # assume OPs are normalized to one for now

0 commit comments

Comments
 (0)