-
-
Notifications
You must be signed in to change notification settings - Fork 528
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
add a method to test whether a polynomial is symmetric #29553
Comments
Commit: |
Branch: u/vdelecroix/29553 |
Author: Vincent Delecroix |
New commits:
|
Branch pushed to git repo; I updated commit sha1. New commits:
|
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
comment:6
It might be good to convert the polynomial to a dictionary first in order to speed up the looking up of coefficients, e.g.: - for e in self.exponents():
- coeff = self[e]
- for g in gens:
- if self[e.permuted(g)] != coeff:
- return False
- return True
+ pd = self.dict()
+ return all(pd[e.permuted(g)] == c for e, c in pd.items() for g in gens) For the example at hand, this is noticeably faster:
and even for small polynomials this seems to be at least as fast:
Secondly, in Also, you will want to merge #29540. |
comment:8
Replying to @mwageringel:
It is sad this is the case. The polynomial datastructure is supposed to be fast in accessing coefficients... I believe it strongly depends on the base ring. But given the time difference I agree that it makes sense.
Sure. That will also be convenient for action of permutations on polynomials.
Indeed. |
comment:9
Replying to @videlec:
The m = p_ISet(1,r)
i = 1
for e in x:
overflow_check(e, r)
p_SetExp(m, i, int(e), r)
i += 1
p_Setm(m, r)
while(p):
if p_ExpVectorEqual(p, m, r) == 1:
p_Delete(&m,r)
return si2sa(p_GetCoeff(p, r), r, self._parent._base)
p = pNext(p) So it looks more like it is going through a list rather than a dict. I don't know how singular does this, but it looks like a very different data structure than the naïve implementation. IIRC, their data structure is solely to be efficient at computing Gröbner bases. TL;DR Converting to a dict is definitely the best option with the current implementation. As a more broader question, it might be worthwhile to consider reimplementing generic multivariate polynomials in Cython and only convert to (lib)singular when wanting a Gröbner basis. |
comment:10
How about generalising it to computing actions of linear group elements and of linear groups on polynomials? It seems to be a bit restrictive to only have methods for fixed point computation, whereas it's only slightly less general, and you compute the action anyway! |
comment:11
Replying to @dimpase:
Feel free to open a ticket for that. The code here is permuting exponents and do not touch the coefficients. The linear action might better be done via a proper action. |
comment:13
Implementation changed to go via action of |
Branch pushed to git repo; I updated commit sha1. New commits:
|
comment:15
Does it work for Laurent polynomials? |
comment:16
looks like a memory leak, as I don't see a matching |
comment:21
Replying to @tscrim:
Indeed. That is exactly what is happening. |
Branch pushed to git repo; I updated commit sha1. New commits:
|
comment:23
beware that monomial.py has been modified recently, in #29540 |
comment:24
To me the naming "on position" suggests a certain way a permutation acts on lists, independently from the notion of left and right (although this action does satisfy the properties of a left action). So I think either the I would probably drop the In any case, left and right seem to be mixed up currently:
|
comment:25
Replying to @tscrim:
This is exactly what the polydict implementation of polynomials does, no? You can construct a polynomial ring via On the other hand, I cannot think of many operations on polynomials for which random access to arbitrary coefficients is important. |
comment:26
Replying to @mwageringel:
I just copied what is in
|
Branch pushed to git repo; I updated commit sha1. New commits:
|
comment:28
Replying to @videlec:
The action of permutations on matrices implemented in
Am I misunderstanding something about left and right actions in Sage? |
comment:29
Replying to @mwageringel:
Sorry, I forgot generic is an overloaded word here and probably not the best word. What I meant was more universally shall we do this for rings that can be converted to (lib)singular, like those over Z.
Perhaps you're right. I can think of a number of things where you want to iterate over the pairs of coefficients and exponents. I don't think we have a method to do that (the default iterator is quite bad, getting the list of coefficients and list of monomials and zipping them together). I will open a ticket tomorrow or the next day to try and improve the iteration. |
comment:30
Replying to @mwageringel:
Here is where it comes from I think:
(An oddity that needs fixing:
So I think the thing that needs to change in the perm group element elif is_Matrix(left):
+ return left.with_permuted_columns(~self)
+ else:
+ if is_Matrix(left):
return left.with_permuted_rows(self) Addendum: Because of this:
|
Reviewer: Travis Scrimshaw, Markus Wageringel |
comment:31
Replying to @tscrim:
So you are suggesting to make the
That would indeed be nice to have, as it is such a common operation. I did not know the Regarding the action on matrices, we could handle that on a new ticket, as it alters existing behavior and is not really related to the aim of this ticket. I am happy with this ticket as it is now. Except maybe there is one little detail from Travis' suggestion:
The conversion |
comment:32
Replying to @tscrim:
Do you know where this |
Branch pushed to git repo; I updated commit sha1. New commits:
|
comment:34
Replying to @mwageringel:
Yes, although I am not sure if this will be a good option. However, IIRC things like multiplying polynomials is really slow and could use another library to speed that up.
This is now #29595.
I agree that it should be a separate ticket.
If we add that conversion, then we can remove the
which I think is not a good thing to enforce. |
comment:35
Replying to @mwageringel:
It comes from the finite Complex reflection group category. This can be easily fixed with an alias in the (finite) Coxeter group category (using the method |
comment:36
Replying to @tscrim:
Indeed, I found this line a bit weird. Though I did not touch since it was beyond the scope of the ticket. |
comment:37
Ok, it seems this is ready to be merged then? Let me set this ticket to positive, but please undo if you disagree. |
Changed branch from u/vdelecroix/29553 to |
As mentioned in this sage-devel thread it is desirable to have a simple check to test whether a given polynomial is symmetric (with respect to a given permutation group).
This ticket aims to implement a generic
is_symmetric(self, group=None)
on multivariate polynomials (where the default group is the full symmetric group).We also update the check of symmetry in
SymmetricFunctions
so that construction from polynomials get faster. The computation time forwent down from a minute to half a second.
CC: @nbruin @tscrim
Component: algebra
Author: Vincent Delecroix
Branch/Commit:
c53ac9b
Reviewer: Travis Scrimshaw, Markus Wageringel
Issue created by migration from https://trac.sagemath.org/ticket/29553
The text was updated successfully, but these errors were encountered: