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

add unexported critical points #458

Merged
merged 4 commits into from
Feb 4, 2023
Merged

Conversation

jverzani
Copy link
Member

An alternate means to address #454

Rather than specialize findmin etc. this utilizes an unexported critical_points function. With this, findmin etc. compose readily enough.

@codecov
Copy link

codecov bot commented Jan 30, 2023

Codecov Report

Base: 83.23% // Head: 83.30% // Increases project coverage by +0.06% 🎉

Coverage data is based on head (3735889) compared to base (efeb466).
Patch coverage: 100.00% of modified lines in pull request are covered.

❗ Current head 3735889 differs from pull request most recent head ad6cb53. Consider uploading reports for the commit ad6cb53 to get more accurate results

Additional details and impacted files
@@            Coverage Diff             @@
##           master     #458      +/-   ##
==========================================
+ Coverage   83.23%   83.30%   +0.06%     
==========================================
  Files          22       22              
  Lines        2994     3006      +12     
==========================================
+ Hits         2492     2504      +12     
  Misses        502      502              
Impacted Files Coverage Δ
src/common.jl 90.12% <100.00%> (+0.26%) ⬆️
src/contrib.jl 82.47% <100.00%> (+0.36%) ⬆️

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

☔ View full report at Codecov.
📢 Do you have feedback about the report comment? Let us know in this issue.

@jverzani
Copy link
Member Author

Maybe better to have this one function with a keyword argument:

function critical_points(p::AbstractPolynomial{T}, I=domain(p); endpoints=true) where {T <: Real}
    l, r = extrema(I)

    q = Polynomials.ngcd(derivative(p), derivative(p,2)).v

    pts = sort(real.(filter(isreal, roots(q))))
    !endpoints && return pts

    collect(Iterators.filter(x -> l ≤ x ≤ r,
                             Iterators.flatten((l, pts, r))))

end

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.

1 participant