ASKSAGE: Sage Q&A Forum - RSS feedhttps://ask.sagemath.org/questions/Q&A Forum for SageenCopyright Sage, 2010. Some rights reserved under creative commons license.Tue, 10 Jul 2018 18:24:06 +0200How to force a matrix display accordingly?https://ask.sagemath.org/question/42874/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”Tue, 10 Jul 2018 00:55:28 +0200https://ask.sagemath.org/question/42874/how-to-force-a-matrix-display-accordingly/Comment by slelievre for <p>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.</p>
<pre><code>CoxeterGroup([‘A20’]).gens()[0]
“21 x 21 matrix over Integer Ring”
</code></pre>
https://ask.sagemath.org/question/42874/how-to-force-a-matrix-display-accordingly/?comment=42879#post-id-42879Could you include a very concrete example of the desired input and output?Tue, 10 Jul 2018 12:42:01 +0200https://ask.sagemath.org/question/42874/how-to-force-a-matrix-display-accordingly/?comment=42879#post-id-42879Comment by slelievre for <p>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.</p>
<pre><code>CoxeterGroup([‘A20’]).gens()[0]
“21 x 21 matrix over Integer Ring”
</code></pre>
https://ask.sagemath.org/question/42874/how-to-force-a-matrix-display-accordingly/?comment=42890#post-id-42890Thanks for your edit, adding an example. It helps understanding and answering the question.
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]Tue, 10 Jul 2018 18:24:06 +0200https://ask.sagemath.org/question/42874/how-to-force-a-matrix-display-accordingly/?comment=42890#post-id-42890Answer by slelievre for <p>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.</p>
<pre><code>CoxeterGroup([‘A20’]).gens()[0]
“21 x 21 matrix over Integer Ring”
</code></pre>
https://ask.sagemath.org/question/42874/how-to-force-a-matrix-display-accordingly/?answer=42889#post-id-42889Define 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.
Tue, 10 Jul 2018 18:20:10 +0200https://ask.sagemath.org/question/42874/how-to-force-a-matrix-display-accordingly/?answer=42889#post-id-42889