Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Given n recurrence compute up to Pn #16

Merged
merged 1 commit into from
Dec 23, 2024

Conversation

agerlach
Copy link
Contributor

Fixes #15

@agerlach agerlach marked this pull request as draft December 20, 2024 17:59
Comment on lines +47 to 51
evaluates the first `N` orthogonal polynomials at point `x`,
where `A`, `B`, and `C` are `AbstractVector`s containing the first form recurrence coefficients as defined in
[DLMF](https://dlmf.nist.gov/18.9), i.e. it returns Pᵢ(x) for i = 0, 1, ..., N-1
"""
forwardrecurrence(N::Integer, A::AbstractVector, B::AbstractVector, C::AbstractVector, x) =
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should the meaning of N change here? Currently it means compute the first N (including P0) vs compute up to PN. To me, the later makes more sense.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Julia uses 1-based indexing so I think N specifying the length of the vector is more natural

@test clenshaw(vec(clenshaw(coeffs, x; dims=1)), A, B, C, y) ≈ clenshaw(vec(clenshaw(coeffs, A, B, C, y; dims=2)), x) ≈
only(clenshaw!([0.0], clenshaw!(Matrix{Float64}(undef,1,n), coeffs, x), A, B, C, y)) ≈
only(clenshaw!([0.0], clenshaw!(Matrix{Float64}(undef,m,1), coeffs, A, B, C, y), x)) ≈
forwardrecurrence(A_T, B_T, C_T, x)'coeffs*forwardrecurrence(A, B, C, y)
forwardrecurrence(A_T, B_T, C_T, x)'coeffs*forwardrecurrence(A, B, C, y)[1:end-1]
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't understand the clenshaw code enough to know if a similar change is needed there. In order to pass tests I am dropping the last element of forwardrecurrence to replicate the previous behavior.

From looking at clenshaw it seems that P0 isn't explicitly included, while it is in forwardrecurrence. Ideally, they would be consistent, but I'm not familiar with this domain enough to address it.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since clenshaw returns a single value there's no point in including p0 as you can just multiply the returned value by p0

Copy link

codecov bot commented Dec 21, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 100.00%. Comparing base (82125b0) to head (0ba7d4e).
Report is 4 commits behind head on main.

Additional details and impacted files
@@             Coverage Diff             @@
##             main       #16      +/-   ##
===========================================
+ Coverage   99.44%   100.00%   +0.55%     
===========================================
  Files           7         7              
  Lines         181       186       +5     
===========================================
+ Hits          180       186       +6     
+ Misses          1         0       -1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@agerlach agerlach marked this pull request as ready for review December 23, 2024 16:10
@agerlach
Copy link
Contributor Author

@dlfivefifty I took this "PR" out of draft mode. If you are happy with it, it is ready to merge.

@dlfivefifty dlfivefifty merged commit 363799b into JuliaApproximation:main Dec 23, 2024
12 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Coefficient Length and Polynomial Order Discrepencies
2 participants