diff --git a/lib/cyclotom.gi b/lib/cyclotom.gi index 5aeefe77fe..1e0a8236e8 100644 --- a/lib/cyclotom.gi +++ b/lib/cyclotom.gi @@ -2065,6 +2065,26 @@ function (A,B) end ); +InstallMethod( IsSubset, "for a cyclotomic semiring and a range", + [IsCyclotomicCollection and IsSemiringWithOne, + IsRange], +function (D, R) + if IsEmpty(R) then return true; fi; + # Since D is a semiring-with-one, and thus in particular an additive magma, + # it suffices to check whether the start and end point of the given range + # are contained in it. Actually it suffices if the smaller one is contained + # in it, but figuring out which end is smaller is more work than just + # directly checking both end points. + return First(R) in D and Last(R) in D; +end ); + + +InstallMethod( IsSubset, "for a list and a cyclotomic semiring", + [IsList, + IsCyclotomicCollection and IsSemiringWithOne], + ReturnFalse ); + + InstallMethod( Intersection2, "for certain cyclotomic semirings", [IsCyclotomicCollection and IsSemiringWithOne, IsCyclotomicCollection and IsSemiringWithOne], diff --git a/tst/testinstall/cyclotom.tst b/tst/testinstall/cyclotom.tst index 3763995c43..bd6e7d3803 100644 --- a/tst/testinstall/cyclotom.tst +++ b/tst/testinstall/cyclotom.tst @@ -1,4 +1,4 @@ -#@local a,cyc,gm,i,l1,l2,l3,mat,n,r,x,y,z,sets +#@local a,b,cyc,gm,i,l1,l2,l3,mat,n,r,ranges,s,x,y,z,sets gap> START_TEST("cyclotom.tst"); # Check basic arithmetic operations. @@ -352,5 +352,16 @@ gap> SetX(r, r, {i,j} -> IsSubset(sets[i],sets[j]) = (i>=j)); gap> SetX(r, r, {i,j} -> (sets[i]=sets[j]) = (i=j)); [ true ] +# +# IsSubset for cyclotomic semirings and ranges for large bounds +# +gap> sets:=[ PositiveIntegers, NonnegativeIntegers, Integers, GaussianIntegers, GaussianRationals, Cyclotomics ];; +gap> b:=2^(8*GAPInfo.BytesPerVariable - 6);; +gap> ranges:=[ [-2..-1], [-1..0], [-1..1], [0..1], [1..2], [-b..-1], [-b..0], [-b..1], [-1..b], [0..b], [1..b], [-b,b]];; +gap> SetX(ranges, sets, {r,s} -> IsSubset(s,r) = (IsEmpty(r) or (First(r) in s and Last(r) in s))); +[ true ] +gap> SetX(ranges, sets, {r,s} -> not IsSubset(r,s)); +[ true ] + # gap> STOP_TEST("cyclotom.tst");