Skip to content

Commit

Permalink
Bugfix and test for IsIntegralRing
Browse files Browse the repository at this point in the history
This fixes an off-by-one error causing missing the case
when zero appears in the diagonal in the multiplication table.

Closes gap-system#3975.
  • Loading branch information
Alexander Konovalov authored and fingolfin committed Oct 14, 2024
1 parent 8182d3c commit ec32edb
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/ring.gi
Original file line number Diff line number Diff line change
Expand Up @@ -702,7 +702,7 @@ InstallMethod( IsIntegralRing,
zero := Zero( R );
for i in [1..Length(elms)] do
if elms[i] = zero then continue; fi;
for k in [i+1..Length(elms)] do
for k in [i..Length(elms)] do
if elms[k] = zero then continue; fi;
if elms[i] * elms[k] = zero then
return false;
Expand Down
30 changes: 30 additions & 0 deletions tst/testinstall/ring.tst
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
gap> START_TEST("ring.tst");

#####################################################################
#
# Tests for IsIntegralRing
#
# Trivial ring
gap> IsIntegralRing( SmallRing(1,1) );
false

# Non-commutative ring
gap> IsIntegralRing( SmallRing(4,7) );
false

# Zero divisors on the diagonal
gap> IsIntegralRing( SmallRing(4,3) );
false

# Integral rings
gap> IsIntegralRing( GF(5) );
true
gap> IsIntegralRing( Integers );
true
gap> IsIntegralRing( Rationals );
true
gap> IsIntegralRing( CF(4) );
true

#
gap> STOP_TEST( "ring.tst" );

0 comments on commit ec32edb

Please sign in to comment.