gap
gap copied to clipboard
`ZmodpZObj(1, p)` is "normalized" to `Z(p)^0` if and only if `p < 256`; should it be `p < 2^16`?
Compare this:
gap> ZmodpZObj(1, PrevPrimeInt(256));
Z(251)^0
gap> ZmodpZObj(1, NextPrimeInt(256));
ZmodpZObj( 1, 257 )
The cut-off point for Z(p)
currently is 2^16:
gap> Z(PrevPrimeInt(2^16));
Z(65521)
gap> Z(NextPrimeInt(2^16));
ZmodpZObj( 3, 65537 )
Note that we still have this:
gap> Z(251)^0 = ZmodpZObj( 1, 251 );
true
gap> Z(257)^0 = ZmodpZObj( 1, 257 );
true
It seems this is driven by the variable PRIMES_COMPACT_FIELDS
:
InstallMethod( ZmodnZObj,
"for a positive integer, and an integer -- check small primes",
[ IsInt, IsPosInt ],
function( residue, n )
if n in PRIMES_COMPACT_FIELDS then
return residue*Z(n)^0;
fi;
return ZmodnZObj( ElementsFamily( FamilyObj( ZmodnZ( n ) ) ), residue );
end );
and
#############################################################################
##
#V PRIMES_COMPACT_FIELDS primes for which a compact representation exists
##
BIND_GLOBAL("PRIMES_COMPACT_FIELDS",SSortedList(
[2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53,59,61,67,71,73,79,83,89,97,
101,103,107,109,113,127,131,137,139,149,151,157,163,167,173,179,181,191,
193,197,199,211,223,227,229,233,239,241,251] ));
MakeImmutable(PRIMES_COMPACT_FIELDS);
I am not sure why this is done that way. I would expect that either ZmodnZObj
uses IsPrimeInt
to check; or else never uses the residue*Z(n)^0
code. But the current behavior seems just arbitrary to me...?