Skip to content
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

Fix: Expression with square not sorted correctly #20

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

levirs565
Copy link

Expression with square not sorted correctly because square does not get degree 2. You can see the difference before and after this PR in table below.

Expresssion Canocical Form Before this PR Canocical Form After this PR Status
x^2+x^3+x x^{3}+x+x^2 x^{3}+x^2+x After this PR expression sorted correctly
x^2+x^3+\sin(x) x^{3}+x^2+\sin(x) x^{3}+x^2+\sin(x) Sorted correctly.
\sin(x)+x^2+x^3 x^{3}+\sin(x)+x^2 x^{3}+x^2+\sin(x) This expression's cannocial form must equal with above expression's canonical form

Some test's expected result have been changed. You can see changed test in this table.

Expresssion Canocical Form Before this PR Canocical Form After this PR
x^2y^3+x^3y^2+xy^4+x^4y+x^2y^2 x^{4}y+xy^{4}+x^{3}y^2+x^2y^{3}+x^2y^2 x^{4}y+x^{3}y^2+x^2y^{3}+xy^{4}+x^2y^2
(b^3b^2)+(a^3a^2)+(b^6)+(a^5b)+(a^5) a^{5}b+b^{6}+a^{5}+a^2a^{3}+b^2b^{3} a^{5}b+b^{6}+a^2a^{3}+a^{5}+b^2b^{3}

Why I change the test's expected result?. Canocial form of those expression are inconsistent with other expressions that does not have square. You can see this table:

Expresssion Canocical Form Before this PR Canocical Form After this PR Status
x^2y^3+x^3y^2+xy^4+x^4y+x^2y^2 x^{4}y+xy^{4}+x^{3}y^2+x^2y^{3}+x^2y^2 x^{4}y+x^{3}y^2+x^2y^{3}+xy^{4}+x^2y^2 Different
(b^3b^2)+(a^3a^2)+(b^6)+(a^5b)+(a^5) a^{5}b+b^{6}+a^{5}+a^2a^{3}+b^2b^{3} a^{5}b+b^{6}+a^2a^{3}+a^{5}+b^2b^{3} Different
(b^3b^3)+(a^3a^3)+(b^6)+(a^5b)+(a^5) a^{3}a^{3}+a^{5}b+b^{3}b^{3}+b^{6}+a^{5} a^{3}a^{3}+a^{5}b+b^{3}b^{3}+b^{6}+a^{5}` Equal

Also, this change fix some sorting result when there are square in expression and sin function.

@arnog
Copy link
Member

arnog commented Sep 23, 2021

Thank you for investigating this issue and submitting this PR.
The Compute Engine codebase is undergoing a refactor which unfortunately makes merging this PR directly a little bit tricky. However, I will make sure to incorporate your changes and preserve their effect.
Again, thanks for your submission, it is very much appreciated.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants