JuliaAlgebra / DynamicPolynomials.jl

Multivariate polynomials implementation of commutative and non-commutative variables
Other
60 stars 21 forks source link

Keep variables for constant zero Polynomials #81

Closed manuelbb-upb closed 3 years ago

manuelbb-upb commented 3 years ago

Fix of issue #80

Overwrite multconstant of MultivariatePolynomials so that in case of α==0 the variables of p are kept. Else do the same as before (see operators.jl in MultivariatePolynomials).

blegat commented 3 years ago

Does this fix https://github.com/JuliaAlgebra/DynamicPolynomials.jl/issues/79 as well ?

manuelbb-upb commented 3 years ago

Does this fix #79 as well ?

No, it doesn't seem to. But I can have a look into it in the near future.

manuelbb-upb commented 3 years ago

It seems that #79 can be tackled by defining

function MA.mutable_operate_to!(p::Polynomial{true, T}, ::typeof(*), q1::Number, q2::MP.AbstractPolynomialLike) where T
    q1 * q2
end

This uses

function Base.:(*)(p::Polynomial, α)
    MP.multconstant(α,p);
end
Base.:(*)(α, p::Polynomial) = p * α;

but I am not familiar enough with the internals of the package to know whether the fix is any good.

blegat commented 3 years ago

Thanks, looking good, could you add some tests ?

manuelbb-upb commented 3 years ago

I have composed some basic tests from the issue descriptions. The nightly built still fails, but this seems to a separate problem.

manuelbb-upb commented 3 years ago

Did so :) Thanks also for reviewing. This was the first time for me to actually try to contribute to another project and a great learning experience.