Skip to content

Commit

Permalink
Implement euclidean ring operations for ZmodnZ
Browse files Browse the repository at this point in the history
  • Loading branch information
fingolfin committed Aug 19, 2019
1 parent f8d625d commit 0f9c104
Show file tree
Hide file tree
Showing 3 changed files with 58 additions and 0 deletions.
7 changes: 7 additions & 0 deletions lib/zmodnz.gd
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,13 @@ InstallTrueMethod( IsFinite,
IsZmodnZObjNonprimeCollection and IsDuplicateFree );


#############################################################################
##
#M IsEuclideanRing( <R> ) . . . . . . . . . . . . method for full ring Z/nZ
##
InstallTrueMethod(IsEuclideanRing, IsZmodnZObjNonprimeCollection and
IsWholeFamily and IsRing);

#############################################################################
##
#V Z_MOD_NZ
Expand Down
39 changes: 39 additions & 0 deletions lib/zmodnz.gi
Original file line number Diff line number Diff line change
Expand Up @@ -656,6 +656,45 @@ InstallMethod(ZOp,
end);


#############################################################################
##
#M EuclideanDegree( <R>, <n> )
##
## For an overview on the theory of euclidean rings which are not domains,
## see Pierre Samuel, "About Euclidean rings", J. Algebra, 1971 vol. 19 pp. 282-301.
## http://dx.doi.org/10.1016/0021-8693(71)90110-4

InstallMethod( EuclideanDegree,
"for Z/nZ and an element in Z/nZ",
IsCollsElms,
[ IsZmodnZObjNonprimeCollection and IsWholeFamily and IsRing, IsZmodnZObj and IsModulusRep ],
function ( R, n )
return GcdInt( n![1], Characteristic( n ) );
end );


#############################################################################
##
#M QuotientRemainder( <R>, <n>, <m> )
##
InstallMethod( QuotientRemainder,
"for Z/nZ and two elements in Z/nZ",
IsCollsElmsElms,
[ IsZmodnZObjNonprimeCollection and IsWholeFamily and IsRing,
IsZmodnZObj and IsModulusRep, IsZmodnZObj and IsModulusRep ],
function ( R, n, m )
local u, s, q, r;
#Error("TODO");
# HACK / WIP
u := StandardAssociateUnit(R, m);
s := u * m; # the standard associate of m
q := QuoInt(n![1], s![1]);
r := n![1] - q * s![1];
return [ ZmodnZObj( FamilyObj( n ), (q * u![1]) mod Characteristic(R) ),
ZmodnZObj( FamilyObj( n ), r ) ];
end );


#############################################################################
##
#M StandardAssociate( <r> )
Expand Down
12 changes: 12 additions & 0 deletions tst/testinstall/euclidean.tst
Original file line number Diff line number Diff line change
Expand Up @@ -44,5 +44,17 @@ true
gap> ForAll(Filtered([2..50], IsPrimePowerInt), q->checkEuclideanRing(GF(q)));
true

# ZmodnZ
gap> ForAll([1..50], m -> checkEuclideanRing(Integers mod m));
true
gap> checkEuclideanRing(Integers mod ((2*3*5)^2));
true
gap> checkEuclideanRing(Integers mod ((2*3*5)^3));
true
gap> checkEuclideanRing(Integers mod ((2*3*5*7)^2));
true
gap> checkEuclideanRing(Integers mod ((2*3*5*7)^3));
true

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

0 comments on commit 0f9c104

Please sign in to comment.