Skip to content

Commit

Permalink
Fix CyclotomicPol(501) and others
Browse files Browse the repository at this point in the history
... by ensuring the content of CYCPOLCache is immutable, and
CYCPOLCache.CPdiffodd returns a copy (so we can't accidentally
modify the cache content)
  • Loading branch information
fingolfin authored and ChrisJefferson committed May 28, 2024
1 parent 7e07b99 commit 19ae178
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/upoly.gi
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ CYCPOLCache.CPdiffodd := function(ps)
blowup{iv} := blowup{iv} - c*a;
iv := iv-1;
od;
CYCPOLCache.(str) := res;
CYCPOLCache.(str) := Immutable(res);
return res;
end;
InstallGlobalFunction( CyclotomicPol, function(n)
Expand Down
44 changes: 44 additions & 0 deletions tst/testinstall/upoly.tst
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
gap> START_TEST("upoly.tst");

#
gap> CyclotomicPol(501);
[ 1, -1, 0, 1, -1, 0, 1, -1, 0, 1, -1, 0, 1, -1, 0, 1, -1, 0, 1, -1, 0, 1,
-1, 0, 1, -1, 0, 1, -1, 0, 1, -1, 0, 1, -1, 0, 1, -1, 0, 1, -1, 0, 1, -1,
0, 1, -1, 0, 1, -1, 0, 1, -1, 0, 1, -1, 0, 1, -1, 0, 1, -1, 0, 1, -1, 0, 1,
-1, 0, 1, -1, 0, 1, -1, 0, 1, -1, 0, 1, -1, 0, 1, -1, 0, 1, -1, 0, 1, -1,
0, 1, -1, 0, 1, -1, 0, 1, -1, 0, 1, -1, 0, 1, -1, 0, 1, -1, 0, 1, -1, 0, 1,
-1, 0, 1, -1, 0, 1, -1, 0, 1, -1, 0, 1, -1, 0, 1, -1, 0, 1, -1, 0, 1, -1,
0, 1, -1, 0, 1, -1, 0, 1, -1, 0, 1, -1, 0, 1, -1, 0, 1, -1, 0, 1, -1, 0, 1,
-1, 0, 1, -1, 0, 1, -1, 0, 1, -1, 1, 0, -1, 1, 0, -1, 1,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0, 0, -1, 0, 1, 0, 0, 0, 0, 1, 0, -1, 0, 0, 0, 0, -1, 0,
1, 0, 0, 0, 0, 1, 0, -1, 0, 0, 0, 0, -1, -1, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0,
0, 0, -1, -1, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, -1, -1, 0, 0, 0, 0, 0, 1,
1 ]
gap> CyclotomicPol(606);
[ 1, 1, 0, -1, -1, 0, 1, 1, 0, -1, -1, 0, 1, 1, 0, -1, -1, 0, 1, 1, 0, -1,
-1, 0, 1, 1, 0, -1, -1, 0, 1, 1, 0, -1, -1, 0, 1, 1, 0, -1, -1, 0, 1, 1, 0,
-1, -1, 0, 1, 1, 0, -1, -1, 0, 1, 1, 0, -1, -1, 0, 1, 1, 0, -1, -1, 0, 1,
1, 0, -1, -1, 0, 1, 1, 0, -1, -1, 0, 1, 1, 0, -1, -1, 0, 1, 1, 0, -1, -1,
0, 1, 1, 0, -1, -1, 0, 1, 1, 0, -1, -1, -1, 0, 1, 1, 0, -1, -1, 0, 1, 1, 0,
-1, -1, 0, 1, 1, 0, -1, -1, 0, 1, 1, 0, -1, -1, 0, 1, 1, 0, -1, -1, 0, 1,
1, 0, -1, -1, 0, 1, 1, 0, -1, -1, 0, 1, 1, 0, -1, -1, 0, 1, 1, 0, -1, -1,
0, 1, 1, 0, -1, -1, 0, 1, 1, 0, -1, -1, 0, 1, 1, 0, -1, -1, 0, 1, 1, 0, -1,
-1, 0, 1, 1, 0, -1, -1, 0, 1, 1, 0, -1, -1, 0, 1, 1, 0, -1, -1, 0, 1, 1 ]

#
gap> STOP_TEST( "upoly.tst" );

0 comments on commit 19ae178

Please sign in to comment.