diff --git a/lib/zmodnz.gd b/lib/zmodnz.gd index a8a6b3e26d..409ea3b812 100644 --- a/lib/zmodnz.gd +++ b/lib/zmodnz.gd @@ -127,6 +127,13 @@ InstallTrueMethod( IsFinite, IsZmodnZObjNonprimeCollection and IsDuplicateFree ); +############################################################################# +## +#M IsEuclideanRing( ) . . . . . . . . . . . . method for full ring Z/nZ +## +InstallTrueMethod(IsEuclideanRing, IsZmodnZObjNonprimeCollection and + IsWholeFamily and IsRing); + ############################################################################# ## #V Z_MOD_NZ diff --git a/lib/zmodnz.gi b/lib/zmodnz.gi index f801ab9df7..e9711435e1 100644 --- a/lib/zmodnz.gi +++ b/lib/zmodnz.gi @@ -656,6 +656,45 @@ InstallMethod(ZOp, end); +############################################################################# +## +#M EuclideanDegree( , ) +## +## 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( , , ) +## +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( ) diff --git a/tst/testinstall/euclidean.tst b/tst/testinstall/euclidean.tst index 6cdedfd150..ca3b3285db 100644 --- a/tst/testinstall/euclidean.tst +++ b/tst/testinstall/euclidean.tst @@ -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);