-
Notifications
You must be signed in to change notification settings - Fork 75
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
Missing functionality: converting coefficients #449
Comments
If this is added, it might make sense to also add something analogous for changing variables: with_variable(::Val{y}, p::Polynomial{R, x})::Polynomial{R, y} where {x, y, R <: Number} |
BTW, at first I thought that Happy New Year! |
Hi
I think this is
But
or
Let me know if I didn't understand the use case. |
The crucial difference is that In this way Suppose you have some function like this: In my code the example is like so: I have some type I want to be able to change the coefficient type of an instance of https://gitlab.com/nsajko/PolynomialApproximation.jl/-/blob/main/src/CompressedPolynomials.jl#L27 So to solve this using So, to solve this generically, I introduced a new module called https://gitlab.com/nsajko/PolynomialApproximation.jl/-/blob/main/src/OverRing.jl#L5-L14 It hosts just the function https://gitlab.com/nsajko/PolynomialApproximation.jl/-/blob/main/src/CompressedPolynomials.jl#L53 The important part of the line is this expression:
So in the end I figured out a way to solve this, because now my code supports any I hope I was more clear this time? |
Sorry, you were clear. I just didn't read carefully. I'm thinking of Julia generics for this, and I don't think |
Two issues with the current
Example for the type inference and run time dispatch issue:
|
Thanks. For 2., I don't have a good argument as to why I wrapped the T in |
Yeah, your guess is right. To fix (1), I think you could simply special-case the implementation for https://gitlab.com/nsajko/PolynomialApproximation.jl/-/blob/main/src/OverRing.jl#L12-L14 |
I think #492 is a better take on this issue. Thanks for your help. |
I have some code where I define multiple
AbstractPolynomial
subtypes. In some cases I'd like to be able to turn a polynomial over one ring to a polynomial over another ring, by converting all its coefficients. It would seem appropriate for a function with that functionality to live in thePolynomials
module. Something like this:For example, for
Polynomial
a possible implementation would be this:Usage example:
I'd still need to define a method of this function for each subtype of
AbstractPolynomial
owned by me, but it would be much nicer and tidier if I could overload aPolynomials
function.Would an interface like this would fit well into
Polynomials
?The text was updated successfully, but these errors were encountered: