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

Generalized monomial orders for Laurent polynomials #37196

Draft
wants to merge 17 commits into
base: develop
Choose a base branch
from

Conversation

vilanele
Copy link

Adding an implementation of generalized order defined by a conic decomposition and a compatible total order on $\mathbb{Z}^n$. This will be useful to implement the computation of Gröbner basis of ideals over Laurent polynomials.

📝 Checklist

  • The title is concise, informative, and self-explanatory.
  • The description explains in detail what this PR is about.
  • I have linked a relevant issue or discussion.
  • I have created tests covering the changes.
  • I have updated the documentation accordingly.

@xcaruso xcaruso added the sd125 sage days 125 label Jan 30, 2024
"""
self._n = n
self._n_cones = self._n + 1
self._cones = build_cones(self._n)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is really useful to have this helper function build_cones?

Same remark for get_group_order and get_score_function.

Copy link
Author

@vilanele vilanele Feb 5, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Moved to init.

def greatest_tuple(self,a,b=None):
r"""
Return the greatest of the two tuples ``a`` and ``b`` if ``b`` is not None
Return the greatest tuple in the list ``L`` if ``b`` is not a tuple
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
Return the greatest tuple in the list ``L`` if ``b`` is not a tuple
Return the greatest tuple in the list ``a`` if ``b`` is not a tuple

r"""
Create a generalized monomial order.

INPUTS:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should write INPUTS without S (even if there are multiple inputs).
Moreover, the list of inputs should not be indented.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok

Copy link

github-actions bot commented Feb 8, 2024

Documentation preview for this PR (built with commit e3a87e8; changes) is ready! 🎉

Comment on lines +9 to +11
- Group order: this can be any class with a 'greatest_tuple' method returning
the greatest of two tuples based on a group order on `\ZZ^n`.
Available choices include 'lex'.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's not really the case.
However, I think that accepting any such class sounds like a good idea.

Comment on lines +94 to +97
if group_order in ["lex"]:
self._group_order = TermOrder(name=group_order)
else:
raise ValueError("Available group order are: 'lex'")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As I said above, I would add a test like elif isinstance(group_order, TermOrder): here.

elif score_function == "degmin":
self._score_function = degmin_score_function
else:
raise ValueError("Available score function are: 'min', 'degmin'")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Again, why not giving the option to the user to pass in any score function ?

self._score_function_name = score_function

def _repr_(self):
r"""
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I thnk you should add a description here, something like Return a string representation of this order.
Add you should also add a black line after TESTS::.

return L[0]
else:
a = L[0]
b = self.greatest_tuple(*L[1:])
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't really like this recursive call because it implies all useless checkings.
Why not programming this imperatively with a for loop?

Comment on lines +421 to +425
def min_score_function(t):
return -min(0,*t)

def degmin_score_function(t):
return sum(t) -(len(t)+1)*min(0,*t)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These two functions should be documented.
You also have a problem with identation.

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

Successfully merging this pull request may close these issues.

3 participants