As the author of Polynomial.jl, I'll say that being "a bit
unsatisfied" is a good reason to make pull requests for any and all
improvements :)
While loladiro is now the official maintainer of Polynomials.jl (since
he volunteered to do the badly-needed work to switch the coefficient
order), if I had access, I would accept a pull request for additional
roots() methods (parameterized by an enum type, for overloading, and
possibly also a realroots function), horner method functions, polyfit,
etc.
I would not accept a pull request for allowing a vector instead of a
Polynomial in any method, however. IMHO, this is a completely
unnecessary "optimization", which encourages the user to conflate the
concept of a Vector and a Polynomial without benefit. It could even
potentially lead to subtle bugs (since indexing a polynomial is
different from indexing a vector), or passing in the roots instead of
the polynomial.
I think merging your proposal for a polyfit function with
StatsBase.fit makes sense. You could use a tuple parameter to combine
the Polynomial parameter with the degrees information:
function fit((T::(Type{Polynomial},Int), data)
P, deg = T
return Poly( pfit(deg, data) ) #where pfit represents the
calculation of the polynomial-of-best fit, and may or may not be a
separate function
end
fit((Polynomial,3), data)
David de Laat put together a pull request to add his content to
Polynomial:
https://github.com/vtjnash/Polynomial.jl/pull/25. He also
indicated he would update it for Polynomials.jl so that it could be
merged.