# How to force a matrix display accordingly?

I am working with matrix groups in small and large dimensions (>20 or >100). Is there a way to fleece sage to make a matrix display as “ d x d matrix over <ring>” where d>20? It does not do this for any matrix groups like Coxeter/Affine/Weyl/Braid TL Rep. etc.

CoxeterGroup([‘A20’]).gens()[0]
“21 x 21 matrix over Integer Ring”

edit retag close merge delete

Could you include a very concrete example of the desired input and output?

( 2018-07-10 05:42:01 -0500 )edit

Please also fix the "curly quotes" (maybe "smart quotes" is turned on in your operating system).

Copy pasting the current

CoxeterGroup([‘A20’]).gens()[0]


results in an error, while with straight quotes it works:

CoxeterGroup(['A20']).gens()[0]

( 2018-07-10 11:24:06 -0500 )edit

Sort by » oldest newest most voted

Define the example in the question and call it a:

sage: a = CoxeterGroup(['A20']).gens()[0]


It displays as

sage: a
[-1  1  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0]
[ 0  1  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0]
[ 0  0  1  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0]
[ 0  0  0  1  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0]
[ 0  0  0  0  1  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0]
[ 0  0  0  0  0  1  0  0  0  0  0  0  0  0  0  0  0  0  0  0]
[ 0  0  0  0  0  0  1  0  0  0  0  0  0  0  0  0  0  0  0  0]
[ 0  0  0  0  0  0  0  1  0  0  0  0  0  0  0  0  0  0  0  0]
[ 0  0  0  0  0  0  0  0  1  0  0  0  0  0  0  0  0  0  0  0]
[ 0  0  0  0  0  0  0  0  0  1  0  0  0  0  0  0  0  0  0  0]
[ 0  0  0  0  0  0  0  0  0  0  1  0  0  0  0  0  0  0  0  0]
[ 0  0  0  0  0  0  0  0  0  0  0  1  0  0  0  0  0  0  0  0]
[ 0  0  0  0  0  0  0  0  0  0  0  0  1  0  0  0  0  0  0  0]
[ 0  0  0  0  0  0  0  0  0  0  0  0  0  1  0  0  0  0  0  0]
[ 0  0  0  0  0  0  0  0  0  0  0  0  0  0  1  0  0  0  0  0]
[ 0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  1  0  0  0  0]
[ 0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  1  0  0  0]
[ 0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  1  0  0]
[ 0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  1  0]
[ 0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  1]


Define the same matrix starting from the identity matrix and modifying the first two entries; call that b:

sage: b = identity_matrix(20)
sage: b[0:2, 0:0] = (-1, 1)


Check that a and b define the same matrix:

sage: b == a
True


However b displays differently:

sage: b
20 x 20 dense matrix over Integer Ring
(use the '.str()' method to see the entries)


Get the fuller display of b, showing all its entries, using print:

sage: print(b)
[-1  1  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0]
[ 0  1  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0]
[ 0  0  1  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0]
[ 0  0  0  1  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0]
[ 0  0  0  0  1  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0]
[ 0  0  0  0  0  1  0  0  0  0  0  0  0  0  0  0  0  0  0  0]
[ 0  0  0  0  0  0  1  0  0  0  0  0  0  0  0  0  0  0  0  0]
[ 0  0  0  0  0  0  0  1  0  0  0  0  0  0  0  0  0  0  0  0]
[ 0  0  0  0  0  0  0  0  1  0  0  0  0  0  0  0  0  0  0  0]
[ 0  0  0  0  0  0  0  0  0  1  0  0  0  0  0  0  0  0  0  0]
[ 0  0  0  0  0  0  0  0  0  0  1  0  0  0  0  0  0  0  0  0]
[ 0  0  0  0  0  0  0  0  0  0  0  1  0  0  0  0  0  0  0  0]
[ 0  0  0  0  0  0  0  0  0  0  0  0  1  0  0  0  0  0  0  0]
[ 0  0  0  0  0  0  0  0  0  0  0  0  0  1  0  0  0  0  0  0]
[ 0  0  0  0  0  0  0  0  0  0  0  0  0  0  1  0  0  0  0  0]
[ 0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  1  0  0  0  0]
[ 0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  1  0  0  0]
[ 0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  1  0  0]
[ 0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  1  0]
[ 0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  1]


Let us explain this difference in display, and how to get the summary display for a.

Even though a and b have the same entries, they don't have the same "parent"; a is an element in a matrix group while b is an element in a matrix space.

sage: a.parent()
Finite Coxeter group over Integer Ring with Coxeter matrix:
20 x 20 dense matrix over Integer Ring
sage: b.parent()
Full MatrixSpace of 20 by 20 dense matrices over Integer Ring


The difference in display comes from a different implementation of the __repr__ method for elements of matrix groups and elements of matrix spaces: compare a.__repr__?? and b.__repr__??.

To get the summary version for a, one solution is to convert it to a matrix space element.

sage: c = matrix(a)
sage: c
20 x 20 dense matrix over Integer Ring
(use the '.str()' method to see the entries)


To get elements of matrix groups to consistently use the shorter display when they reach 20 rows, one would have to change the __repr__ method of matrix group elements.

more