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

Implement Union(Rationals,Integers) and more, add tests #2181

Merged
merged 1 commit into from
Feb 15, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 17 additions & 2 deletions lib/cyclotom.gi
Original file line number Diff line number Diff line change
Expand Up @@ -2002,8 +2002,8 @@ BindGlobal("CompareCyclotomicCollectionHelper_Filters", [
BindGlobal("CompareCyclotomicCollectionHelper_Proxies", [
[ 1 ], [ 0, 1 ],
[ -1, 0, 1 ], [ -1, 0, 1, E(4) ],
[ -1, 0, 1/2, 1 ], [ -1, 0, 1, 1/2, E(4) ],
[ -1, 0, 1, 1/2, E(4), E(9) ], fail
[ -1, 0, 1/2, 1 ], [ -1, 0, 1/2, 1, E(4), 1/2+E(4) ],
[ -1, 0, 1/2, 1, E(4), 1/2+E(4), E(9) ], fail
] );

if IsHPCGAP then
Expand Down Expand Up @@ -2033,6 +2033,7 @@ function (A,B)
return ab[1] = ab[2];
end );


InstallMethod( IsSubset, "for certain cyclotomic semirings",
[IsCyclotomicCollection and IsSemiringWithOne,
IsCyclotomicCollection and IsSemiringWithOne],
Expand All @@ -2058,6 +2059,20 @@ function (A,B)
end );


InstallMethod( Union2, "for certain cyclotomic semirings",
[IsCyclotomicCollection and IsSemiringWithOne,
IsCyclotomicCollection and IsSemiringWithOne],
function (A,B)
local ab, i;
ab := CompareCyclotomicCollectionHelper(A, B);
# Verify that we recognized both A and B, otherwise give up.
if fail in ab then TryNextMethod(); fi;
i := Position( CompareCyclotomicCollectionHelper_Proxies, Union2( ab[1], ab[2] ) );
if i = fail then TryNextMethod(); fi;
return CompareCyclotomicCollectionHelper_Semirings[i];
end );


#############################################################################
##
#E
Expand Down
29 changes: 29 additions & 0 deletions tst/testinstall/cyclotom.tst
Original file line number Diff line number Diff line change
Expand Up @@ -317,6 +317,35 @@ Error, COEFFSCYC: <cyc> must be a cyclotomic (not a boolean or fail)
gap> CycList([1,fail]);
Error, CycList: each entry must be a rational (not a boolean or fail)

#
# Some tests for some operations on certain pre-defined infinite collections
# of cyclotomics, which are implemented using CompareCyclotomicCollectionHelper.
# For the tests, we exploit that the supported collections can be grouped into
# two totally ordered chains.
#
gap> sets:=[ PositiveIntegers, NonnegativeIntegers, Integers, Rationals, GaussianRationals, Cyclotomics ];;
gap> r:=[1..Length(sets)];;
gap> SetX(r, r, {i,j} -> Intersection(sets[i],sets[j]) = sets[Minimum(i,j)]);
[ true ]
gap> SetX(r, r, {i,j} -> Union(sets[i],sets[j]) = sets[Maximum(i,j)]);
[ true ]
gap> SetX(r, r, {i,j} -> IsSubset(sets[i],sets[j]) = (i>=j));
[ true ]
gap> SetX(r, r, {i,j} -> (sets[i]=sets[j]) = (i=j));
[ true ]

#
gap> sets:=[ PositiveIntegers, NonnegativeIntegers, Integers, GaussianIntegers, GaussianRationals, Cyclotomics ];;
gap> r:=[1..Length(sets)];;
gap> SetX(r, r, {i,j} -> Intersection(sets[i],sets[j]) = sets[Minimum(i,j)]);
[ true ]
gap> SetX(r, r, {i,j} -> Union(sets[i],sets[j]) = sets[Maximum(i,j)]);
[ true ]
gap> SetX(r, r, {i,j} -> IsSubset(sets[i],sets[j]) = (i>=j));
[ true ]
gap> SetX(r, r, {i,j} -> (sets[i]=sets[j]) = (i=j));
[ true ]

#
gap> STOP_TEST( "cyclotom.tst", 1);

Expand Down