From fefb2130612bc93690bf023f1458e107e3196169 Mon Sep 17 00:00:00 2001 From: Max Horn Date: Tue, 1 Jun 2021 00:36:53 +0200 Subject: [PATCH] Revise printing of IsPlistMatrixRep This fixes printing of 0 x n matrices --- lib/matobjplist.gi | 9 ++------- tst/testinstall/MatrixObj/Matrix.tst | 8 ++++---- tst/testinstall/MatrixObj/NewMatrix.tst | 14 +++++++------- 3 files changed, 13 insertions(+), 18 deletions(-) diff --git a/lib/matobjplist.gi b/lib/matobjplist.gi index 8df450c39f2..c03b8d14f62 100644 --- a/lib/matobjplist.gi +++ b/lib/matobjplist.gi @@ -748,14 +748,9 @@ InstallMethod( Display, "for a plist matrix", [ IsPlistMatrixRep ], local i; Print("<"); if not IsMutable(m) then Print("immutable "); fi; - Print(NrRows(m),"x",NrCols(m),"-matrix over ",m![BDPOS],":\n"); + Print(NrRows(m),"x",NrCols(m),"-matrix over ",m![BDPOS],": [\n"); for i in [1..NrRows(m)] do - if i = 1 then - Print("["); - else - Print(" "); - fi; - Print(m![ROWSPOS][i],"\n"); + Print(" ",m![ROWSPOS][i],"\n"); od; Print("]>\n"); end ); diff --git a/tst/testinstall/MatrixObj/Matrix.tst b/tst/testinstall/MatrixObj/Matrix.tst index dcf299f0e8f..eb473847c13 100644 --- a/tst/testinstall/MatrixObj/Matrix.tst +++ b/tst/testinstall/MatrixObj/Matrix.tst @@ -4,8 +4,8 @@ gap> START_TEST("Matrix.tst"); gap> m := Matrix( [[1,2],[3,4]] ); <2x2-matrix over Rationals> gap> Display(m); -<2x2-matrix over Rationals: -[[ 1, 2 ] +<2x2-matrix over Rationals: [ + [ 1, 2 ] [ 3, 4 ] ]> @@ -34,8 +34,8 @@ gap> Display(m); gap> m := Matrix( IsPlistMatrixRep, GF(2), [[1,2],[3,4]] * Z(2) ); <2x2-matrix over GF(2)> gap> Display(m); -<2x2-matrix over GF(2): -[[ Z(2)^0, 0*Z(2) ] +<2x2-matrix over GF(2): [ + [ Z(2)^0, 0*Z(2) ] [ Z(2)^0, 0*Z(2) ] ]> diff --git a/tst/testinstall/MatrixObj/NewMatrix.tst b/tst/testinstall/MatrixObj/NewMatrix.tst index 250f68f3fca..96bc83fb57c 100644 --- a/tst/testinstall/MatrixObj/NewMatrix.tst +++ b/tst/testinstall/MatrixObj/NewMatrix.tst @@ -1,23 +1,23 @@ # IsPlistMatrixRep gap> NewMatrix(IsPlistMatrixRep, Integers, 3, [ ] ); Display(last); <0x3-matrix over Integers> -<0x3-matrix over Integers: +<0x3-matrix over Integers: [ ]> gap> NewMatrix(IsPlistMatrixRep, Integers, 3, [ 1, 2, 3 ] ); Display(last); <1x3-matrix over Integers> -<1x3-matrix over Integers: -[[ 1, 2, 3 ] +<1x3-matrix over Integers: [ + [ 1, 2, 3 ] ]> gap> NewMatrix(IsPlistMatrixRep, Integers, 3, [ 1, 2, 3, 4, 5, 6 ] ); Display(last); <2x3-matrix over Integers> -<2x3-matrix over Integers: -[[ 1, 2, 3 ] +<2x3-matrix over Integers: [ + [ 1, 2, 3 ] [ 4, 5, 6 ] ]> gap> NewMatrix(IsPlistMatrixRep, Integers, 3, [ [1, 2, 3], [4, 5, 6] ] ); Display(last); <2x3-matrix over Integers> -<2x3-matrix over Integers: -[[ 1, 2, 3 ] +<2x3-matrix over Integers: [ + [ 1, 2, 3 ] [ 4, 5, 6 ] ]>