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

Rational function #335

Merged
merged 52 commits into from
Apr 20, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
52 commits
Select commit Hold shift + click to select a range
657112d
WIP
jverzani Feb 5, 2021
2f5080e
WIP
jverzani Feb 6, 2021
154052f
WIP
jverzani Feb 7, 2021
c52febd
move symbol into type
jverzani Feb 9, 2021
409d49e
clean up
jverzani Feb 9, 2021
2f91ef3
change what iteration means for a polynomial
jverzani Feb 9, 2021
5a84d9f
adjust integrate to return polynomial of same type, even if NaN
jverzani Feb 10, 2021
a2fc233
clean up offset vector tests
jverzani Feb 11, 2021
5a47053
drop OffsetArrays dependency; clean up scalar operations for Immutabl…
jverzani Feb 14, 2021
7a350ca
cleanup
jverzani Feb 14, 2021
166522b
change error into ArgumentError
jverzani Feb 14, 2021
b398f03
replace isnothing; standardize check for same variable
jverzani Feb 15, 2021
1426b38
registerN, bug
jverzani Feb 15, 2021
b3ca9c0
update documentation
jverzani Feb 15, 2021
fc3014b
minor edits
jverzani Feb 17, 2021
206de82
cleanup, docfix
jverzani Feb 18, 2021
5d52918
clean up integration
jverzani Feb 19, 2021
a031b8e
adjust doc string
jverzani Feb 19, 2021
93c15ea
WIP
jverzani Feb 20, 2021
264189d
WIP
jverzani Feb 22, 2021
b9324b6
WIP
jverzani Feb 22, 2021
5349be1
work on promotion for + and * operations
jverzani Feb 22, 2021
c0d688c
edits
jverzani Feb 23, 2021
38110e0
laurent polynomial depwarns removed
jverzani Feb 23, 2021
dfe1d73
run doctests
jverzani Feb 23, 2021
dff6629
WIP
jverzani Feb 24, 2021
65a7c92
fix basis symbol handling
jverzani Feb 24, 2021
e57784d
WIP
jverzani Feb 25, 2021
7470f25
WIP
jverzani Feb 25, 2021
316a1ff
adjust evaluation so that implemented evalpoly instead of call syntax…
jverzani Feb 25, 2021
3cfb7f8
add example to extending; specialize evalpoly rather than call syntax
jverzani Feb 25, 2021
226ac83
Merge branch 'v2.0.0-add-examples' into v2.0.0
jverzani Feb 25, 2021
456bc09
refactor truncate! chop!
jverzani Feb 26, 2021
c5e155e
oops
jverzani Feb 26, 2021
1e89476
move things into common (truncate, chop, zero, one,variable, basis)
jverzani Mar 2, 2021
8d30e68
merge changes
jverzani Mar 23, 2021
75d3805
fix conflict
jverzani Mar 23, 2021
2f8884c
Merge branch 'master' of git://github.com/Keno/Polynomials.jl
jverzani Mar 24, 2021
b83cd77
Merge branch 'master' of git://github.com/Keno/Polynomials.jl
jverzani Mar 29, 2021
180c0db
Merge branch 'master' of git://github.com/Keno/Polynomials.jl
jverzani Mar 30, 2021
e93be7e
Merge branch 'master' of git://github.com/Keno/Polynomials.jl
jverzani Mar 31, 2021
0be9b5a
Merge branch 'master' of https://github.com/JuliaMath/Polynomials.jl
jverzani Mar 31, 2021
60f68d5
Merge branch 'master' of https://github.com/JuliaMath/Polynomials.jl
jverzani Apr 10, 2021
15ab70d
Merge branch 'master' of https://github.com/JuliaMath/Polynomials.jl
jverzani Apr 10, 2021
416d076
Merge branch 'master' of https://github.com/JuliaMath/Polynomials.jl
jverzani Apr 11, 2021
7796819
add rational-function type; fix bug with ngcd; plot recipe
jverzani Apr 11, 2021
9412139
fix bugs with ngcd; add tests; rename to lowest_terms
jverzani Apr 12, 2021
ac232f0
cleanup explicit module names
jverzani Apr 12, 2021
4258a2d
get working on v1.0
jverzani Apr 13, 2021
5c0d6a6
bug fix
jverzani Apr 13, 2021
371200c
Revert "bug fix"
jverzani Apr 13, 2021
fa950a6
use VERSION check for rational functions
jverzani Apr 13, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name = "Polynomials"
uuid = "f27b6e38-b328-58d1-80ce-0feddd5e7a45"
license = "MIT"
author = "JuliaMath"
version = "2.0.8"
version = "2.0.9"

[deps]
Intervals = "d8418881-c3e1-53bb-8760-2df7ec849ed5"
Expand Down
10 changes: 10 additions & 0 deletions src/Polynomials.jl
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,16 @@ include("polynomials/multroot.jl")

include("polynomials/ChebyshevT.jl")

# Rational functions
if VERSION >= v"1.2.0"
include("rational-functions/common.jl")
include("rational-functions/rational-function.jl")
include("rational-functions/fit.jl")
#include("rational-transfer-function.jl")
include("rational-functions/plot-recipes.jl")
end


# compat; opt-in with `using Polynomials.PolyCompat`
include("polynomials/Poly.jl")

Expand Down
1 change: 1 addition & 0 deletions src/common.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1019,6 +1019,7 @@ function Base.isapprox(p1::AbstractPolynomial{T,X},
rtol::Real = (Base.rtoldefault(T, S, 0)),
atol::Real = 0,) where {T,X,S,Y}
assert_same_variable(p1, p2)
(hasnan(p1) || hasnan(p2)) && return false # NaN poisons comparisons
# copy over from abstractarray.jl
Δ = norm(p1-p2)
if isfinite(Δ)
Expand Down
5 changes: 4 additions & 1 deletion src/polynomials/multroot.jl
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,9 @@ is misidentified.
function multroot(p::Polynomials.StandardBasisPolynomial{T}; verbose=false,
kwargs...) where {T}

# degenerate case, constant
degree(p) == 0 && return (values=T[], multiplicities=Int[], κ=NaN, ϵ=NaN)

# degenerate case, all zeros
if (nz = findfirst(!iszero, coeffs(p))) == length(coeffs(p))
return (values=zeros(T,1), multiplicities=[nz-1], κ=NaN, ϵ=NaN)
Expand Down Expand Up @@ -202,7 +205,7 @@ function pejorative_root(p, zs::Vector{S}, ls::Vector{Int};
The multiplicity count may be in error: the initial guess for the roots failed
to converge to a pejorative root.
""")
return(zₘs)
return(zₖs)
end

end
Expand Down
22 changes: 19 additions & 3 deletions src/polynomials/ngcd.jl
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ function ngcd(p::P, q::Q,
a,b = divrem(p,q)
return ngcd(q,b, args...; λ=100, kwargs...)
end

# easy cases
degree(p) < 0 && return (u=q, v=p, w=one(q), θ=NaN, κ=NaN)
degree(p) == 0 && return (u=one(q), v=p, w=q, θ=NaN, κ=NaN)
Expand All @@ -28,15 +29,30 @@ function ngcd(p::P, q::Q,
Polynomials.assert_same_variable(p,q)

R = promote_type(float(T), float(S))
𝑷 = Polynomials.constructorof(promote_type(P,Q)){R,X}

ps = R[pᵢ for pᵢ ∈ coeffs(p)]
qs = R[qᵢ for qᵢ ∈ coeffs(q)]
p′ = PnPolynomial(ps)
q′ = PnPolynomial(qs)

# cancel zeros
nz = min(findfirst(!iszero, ps), findfirst(!iszero, qs))
if nz == length(qs)
x = variable(p)
u = x^(nz-1)
v,w = 𝑷(ps[nz:end]), 𝑷(qs[nz:end])
return (u=u, v=v, w=w, Θ=NaN, κ=NaN)
end

## call ngcd
p′ = PnPolynomial{R,X}(ps[nz:end])
q′ = PnPolynomial{R,X}(qs[nz:end])
out = NGCD.ngcd(p′, q′, args...; kwargs...)

𝑷 = Polynomials.constructorof(promote_type(P,Q)){R,X}
𝑷 = Polynomials.constructorof(promote_type(P,Q)){R,X}
u,v,w = convert.(𝑷, (out.u,out.v,out.w))
if nz > 1
u *= variable(u)^(nz-1)
end
(u=u,v=v,w=w, Θ=out.Θ, κ = out.κ)

end
Expand Down
Loading