Opened 7 years ago
Last modified 4 days ago
#19391 needs_work enhancement
Move invariant_generators to libsingular
Reported by:  mmarco  Owned by:  

Priority:  major  Milestone:  
Component:  group theory  Keywords:  
Cc:  SimonKing, wdj  Merged in:  
Authors:  Miguel Marco  Reviewers:  
Report Upstream:  N/A  Work issues:  
Branch:  public/ticket/19391 (Commits, GitHub, GitLab)  Commit:  ea82aa9af5af77fa7c98576987b40f77724367af 
Dependencies:  Stopgaps: 
Description
This patch moves the .invariant_generators() method of finite matrix groups to libsingular, which simplifies much the code.
It also adds the possibility of defining the ring in which the result should be:
sage: m1 = matrix(QQ, [[0, 1], [1, 0]]) sage: G = MatrixGroup([m1]) sage: G.invariant_generators() [x0^2 + x1^2, x0^4 + x1^4, x0^3*x1  x0*x1^3] sage: R.<x,y> = QQ[] sage: G.invariant_generators(R) [x^2 + y^2, x^4 + y^4, x^3*y  x*y^3]
Change History (22)
comment:1 Changed 7 years ago by
Status:  new → needs_review 

comment:2 Changed 7 years ago by
Branch:  → u/mmarco/invariants 

comment:3 Changed 7 years ago by
Commit:  → 24817f2e6d63c25ad45f0628bb7a45ffaa6c724f 

comment:4 Changed 7 years ago by
Ok, i read in the header that you moved the computation of the reynolds operator to gap, but i didn't see any call to gap in the code. Now i see it, you mean this part, right?:
ReyName = 't'+singular._next_var_name() singular.eval('matrix %s[%d][%d]'%(ReyName,self.cardinality(),n)) for i in range(1,self.cardinality()+1): M = Matrix(elements[i1],F) D = [{} for foobar in range(self.degree())] for x,y in M.dict().items(): D[x[0]][x[1]] = y for row in range(self.degree()): for t in D[row].items(): singular.eval('%s[%d,%d]=%s[%d,%d]+(%s)*var(%d)' %(ReyName,i,row+1,ReyName,i,row+1, repr(t[1]),t[0]+1))
What i don't understand is this part:
else: ReyName = 't'+singular._next_var_name() singular.eval('list %s=group_reynolds((%s))'%(ReyName,Lgens)) IRName = 't'+singular._next_var_name() singular.eval('matrix %s = invariant_algebra_reynolds(%s[1])'%(IRName,ReyName))
If i am getting it right, it is supposed to cover the case where there are no elements in the group. In that case we should just return the ring itself.
comment:5 Changed 7 years ago by
Commit:  24817f2e6d63c25ad45f0628bb7a45ffaa6c724f → 6a025ba30f71b0fa6da03d526ab0879a4df6d355 

Branch pushed to git repo; I updated commit sha1. New commits:
6a025ba  Compute reynolds operator before passing it to singular

comment:6 Changed 7 years ago by
Ok, now it computes the reynolds operator before passing it to singular.
I am now working on the modular case. I having trouble getting the output of invariant_ring from libsingular. The singular command is supposed to return three matrices, but calling it through libsingular only gets the first one:
sage: from sage.libs.singular.function import singular_function sage: import sage.libs.singular.function_factory sage: sage.libs.singular.function_factory.lib('finvar.lib') sage: inring = singular_function('invariant_ring') sage: F=FiniteField(2) sage: R.<x,y> = F[] sage: m1 = matrix(R, 2, [0,1,1,0]) sage: inring(m1) [x + y x*y]
Any clue about how to get around this?
comment:7 Changed 7 years ago by
Commit:  6a025ba30f71b0fa6da03d526ab0879a4df6d355 → 2fa234ad8ef3fe4a264617ca79ecadc88c134a67 

Branch pushed to git repo; I updated commit sha1. New commits:
2fa234a  Modular case

comment:8 Changed 7 years ago by
Ok, i think it should be ok now. I added the modular case.
I think that this code should be faster than the previous one, since it does the same, but using the faster libsingular interface rather than the string based one. If you have some interesting examples to test, please benchmark them.
comment:10 Changed 15 months ago by
Commit:  2fa234ad8ef3fe4a264617ca79ecadc88c134a67 → 90b47cec9c30b8dff86f566460be4d4f35263f66 

Branch pushed to git repo; I updated commit sha1. New commits:
90b47ce  Merge branch 'develop' into t/19391/invariants

comment:11 Changed 15 months ago by
Status:  needs_work → needs_review 

comment:12 Changed 9 months ago by
Milestone:  sage6.10 → sage9.7 

comment:14 Changed 9 months ago by
Branch:  u/mmarco/invariants → public/ticket/19391 

Commit:  90b47cec9c30b8dff86f566460be4d4f35263f66 → 31d3c8492345735ec2f60e59e4f9dcca7fb737a1 
comment:15 Changed 8 months ago by
is there anybody around still interested in this ticket ? It now passes the doctests. It may deserve some benchmarking.
comment:17 Changed 8 months ago by
I would like to have at least one benchmark here (before / after), please.
comment:18 Changed 8 months ago by
Commit:  31d3c8492345735ec2f60e59e4f9dcca7fb737a1 → ea82aa9af5af77fa7c98576987b40f77724367af 

Branch pushed to git repo; I updated commit sha1. New commits:
ea82aa9  Force base ring to be a field, to prevent singular segfault

comment:19 Changed 8 months ago by
Surprisingly, I have found that the new code is actually a few miliseconds slower that the older one.
While at profiling, I also caught a possible source of segfaults.
New commits:
ea82aa9  Force base ring to be a field, to prevent singular segfault

comment:21 Changed 5 months ago by
Milestone:  sage9.7 → sage9.8 

comment:22 Changed 4 days ago by
Milestone:  sage9.8 

The code now is simpler. But there was a reason to have it like that: Singular isn't good at listing the elements of a group (which is needed for the Reynolds operator).
If I recall correctly, there were examples for which the computation of the Reynolds operator in Singular was too slow. Apparently these examples didn't go into the doctests. But perhaps they are available at the trac ticket for the original version of the code?
New commits:
Moved invariant_generators to libsingular, added option to fix the ring