Open
Description
We have them (or some of them) in lib/matobj.gi
, starting around line 1393:
BindGlobal( "ViewStringForVectorObj",
v -> Concatenation( "<vector object of length ", String( Length( v ) ),
" over ", String( BaseDomain( v ) ), ">" ) );
InstallMethod( ViewString,
[ IsVectorObj ],
ViewStringForVectorObj );
InstallMethod( DisplayString,
[ IsVectorObj ],
ViewStringForVectorObj );
InstallMethod( String,
[ IsVectorObj ],
v -> Concatenation( "NewVector( ",
NameFunction( ConstructingFilter( v ) ), ", ",
String( BaseDomain( v ) ), ", ",
String( Unpack( v ) ), " )" ) );
BindGlobal( "ViewStringForMatrixObj",
M -> Concatenation( "<matrix object of dimensions ",
String( NumberRows( M ) ), "x", String( NumberColumns( M ) ),
" over ", String( BaseDomain( M ) ), ">" ) );
InstallMethod( ViewString,
[ IsMatrixOrMatrixObj ],
ViewStringForMatrixObj );
InstallMethod( DisplayString,
[ IsMatrixOrMatrixObj ],
ViewStringForMatrixObj );
InstallMethod( String,
[ IsMatrixObj ],
M -> Concatenation( "NewMatrix( ",
NameFunction( ConstructingFilter( M ) ), ", ",
String( BaseDomain( M ) ), ", ",
String( NumberColumns( M ) ), ", ",
String( Unpack( M ) ), " )" ) );
Some thoughts:
- these don't print any elements. I think it would be nice to be able to see the elements in the matrices, too. At least for
Print
and forDisplay
. Perhaps it is OK ifViewObj
only shows the current output, so that casually typing a matrix does not spam things... Dunnp Print
is meant to output code which can be read in back; I am not sure whether we can do that in general, but if we want to try it, it could start with something likeNewMatrix(FILTER, BASEDOMAIN, MAT)
whereMAT
is the result ofUnpack
for the original matrixViewObj
and/orDisplay
could replace zeros by.
and generally produce something more for humans, e.g.
gap> some_matobj;
A 2x3 matrix over GF(5):
. 1 3
3 . 2
- Julia has a nice feature were matrices are printed with elements; but if the number of rows and/or columns is too large, then it hides some rows/columns, and replaces them by some characters indicating this ... like in
[1 2 ... 999 1000]
or even using Unicode, e.g.[ 1 2 ⋯ 999 1000 ]