-
Notifications
You must be signed in to change notification settings - Fork 23
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
Multiplication of Polynomial{C1,Polynomial{C1,T}} #69
Comments
This seem to resolve one design decision I had to make and I apparently did wrong ^^
Would you like to give it a try ? |
Sorry for the delay, GitHub somehow did not send me a notification email :) Base.:*(t1::Term{C1,T1}, t2::Term{C2,T2}) where {C1, C2, T1<:Union{AbstractPolynomial,AbstractTerm}, T2<:Union{AbstractPolynomial,AbstractTerm}} = Term(t1.α*t2.α,t1.x*t2.x)
Base.:*(p1::Polynomial{C1, T1}, t2::Term{C2, T2}) where {C1, C2, T1<:Union{AbstractPolynomial,AbstractTerm}, T2<:Union{AbstractPolynomial,AbstractTerm}} = Polynomial(p1.a*t2.α,p1.x*t2.x)
Base.:*(t2::Term{C2, T2}, p1::Polynomial{C1, T1}) where {C1, C2, T1<:Union{AbstractPolynomial,AbstractTerm}, T2<:Union{AbstractPolynomial,AbstractTerm}} = Polynomial(t2.α*p1.a,t2.x*p1.x)
function Base.:*(p1::Polynomial{C1, T1}, p2::Polynomial{C2, T2}) where {C1, C2, T1<:Union{AbstractPolynomial,AbstractTerm}, T2<:Union{AbstractPolynomial,AbstractTerm}}
res = 0
@inbounds for i = 1:length(p1.a)
@inbounds for j = 1:length(p2.a)
res += Term(p1.a[i]*p2.a[j],p1.x[i]*p2.x[j])
end
end
return res
end This workaround is probably not the most efficient way though... |
It should work with #75 and JuliaAlgebra/MultivariatePolynomials.jl#149 |
Since you have defined the coefficient vectors of polynomials as arbitrary types, I have been playing around with "polynomials over polynomials". Although this type of usage was probably not intended by you, many functionalities of this are actually already supported:
As you can see however, multiplication of these objects is not possible at this point. I could obviously write a custom function to deal with this concrete scenario, however I wonder if you would be interested to add this functionality to your library :)
Best and thanks in advance,
David
The text was updated successfully, but these errors were encountered: