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

type stability: (::Polynomial)(::ImmutablePolynomial) composition yields ImmutablePolynomial #520

Open
nsajko opened this issue Aug 15, 2023 · 2 comments

Comments

@nsajko
Copy link
Contributor

nsajko commented Aug 15, 2023

With v4.0.0:

julia> using Test, Polynomials

julia> p = ImmutablePolynomial((1,))
ImmutablePolynomial(1)

julia> q = Polynomial([10, 20])
Polynomial(10 + 20*x)

julia> @inferred q(p)
ERROR: return type Polynomials.ImmutableDensePolynomial{Polynomials.StandardBasis, Int64, :x, 1} does not match inferred return type Any

It doesn't make sense for this composition to return an ImmutableDensePolynomial, because that makes type stability impossible, because the degree of q is not available in the type domain.

@jverzani
Copy link
Member

Hmm, not sure what is right here, as q(p) will return something with container type of p in other cases. The mixed case is tricky with immutable polynomials.

@jverzani
Copy link
Member

I just put in a PR to start addressing issue like this. I'd also like to special case a path for p(q) when both are immutable.

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

No branches or pull requests

2 participants