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

work on polynomial_composition. Close #520 #524

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
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
10 changes: 10 additions & 0 deletions src/polynomials/standard-basis/immutable-polynomial.jl
Original file line number Diff line number Diff line change
Expand Up @@ -106,8 +106,18 @@
cs = evalpoly(q, p.coeffs)
convert(P, cs)
end
function polynomial_composition(p::AbstractUnivariatePolynomial{B,T,X}, q::ImmutableDensePolynomial{B,S,Y,0}) where {B<:StandardBasis,T,S,X,Y}
P = ImmutableDensePolynomial{B,promote_type(T,S), Y,0}
zero(P)

Check warning on line 111 in src/polynomials/standard-basis/immutable-polynomial.jl

View check run for this annotation

Codecov / codecov/patch

src/polynomials/standard-basis/immutable-polynomial.jl#L109-L111

Added lines #L109 - L111 were not covered by tests
Copy link
Contributor

Choose a reason for hiding this comment

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

A polynomial composed with zero is the polynomial's constant term, not always zero. For example, if we have f(x) = 1 and g(x) = 0, f∘g is 1, not 0.

Copy link
Contributor

Choose a reason for hiding this comment

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

Apart from that, I don't think the promotion is necessary, that is, I think you could just ignore S, because the value of q is always zero, independently of S.

end

function polynomial_composition(p::AbstractUnivariatePolynomial{B,T,X}, q::ImmutableDensePolynomial{B,S,Y,1}) where {B<:StandardBasis,T,S,X,Y}
P = ImmutableDensePolynomial{B,promote_type(T,S), Y,1}
P(evalpoly(constantterm(q),p))

Check warning on line 116 in src/polynomials/standard-basis/immutable-polynomial.jl

View check run for this annotation

Codecov / codecov/patch

src/polynomials/standard-basis/immutable-polynomial.jl#L114-L116

Added lines #L114 - L116 were not covered by tests
end

# special cases of polynomial composition

# ... TBD ...


Expand Down
Loading