JuliaAlgebra / DynamicPolynomials.jl

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

Make variables independent from their creation date. #20

Open saschatimme opened 6 years ago

saschatimme commented 6 years ago

I really like DynamicPolynomials, but the one thing which I noticed a lot of people stumble on is

julia> @polyvar x;
julia> a = x;
julia> @polyvar x;
julia> a == x
false

Could you @blegat maybe explain the reasoning behind creating always a new variable and not relying on the variable name alone? Is it because of the ordering of the variables? How breaking would it be to change things to a lexicographic ordering of the variables?

blegat commented 6 years ago

Comparing the variables by name will be slower since we need to do string comparison (even comparison of symbol is handled with string comparison if you look into Julia source code). In TypedPolynomials, this is handled at compile time since the name is a type parameter so it does not matter too much but in DynamicPolynomials, it might slow down a lot of operation to compare variables with names. If you convince me otherwise with a benchmark then I am open to change the behavior :)