JuliaMath / JuliaMath/Polynomials.jl
Missing functionality: converting coefficients
- Dominant language
- Julia
- Stars
- 320
- Forks
- 80
- Avg merge
- 8h 46m
- Merged PRs (30d)
- 3
Description
I have some [code](https://gitlab.com/nsajko/PolynomialApproximation.jl) 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 the `Polynomials` module. Something like this:
```julia
over_ring(::Type{New}, p::AbstractPolynomial{Old, x})::AbstractPolynomial{New, x} where {New <: Number, Old <: Number, x}
```
For example, for `Polynomial` a possible implementation would be this:
```julia
over_ring(::Type{New}, p::Polynomial{Old, x}) where {New <: Number, Old <: Number, x} =
Polynomial{New, x}(p)
```
Usage example:
```
julia> over_ring(Float64, Polynomial([3, 2, 1]))
Polynomial(3.0 + 2.0*x + 1.0*x^2)
```
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 a `Polynomials` function.
Would an interface like this would fit well into `Polynomials`?
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.