Ask Your Question
2

How well print a list of matrices ?

asked 2013-09-10 01:18:10 -0600

updated 2013-09-10 01:20:09 -0600

In a program, I use the function "print" for printing lists of matrices.
Unfortunately, the displaying is not as well as it could, see the following example :

sage: MM=[identity_matrix(QQ,3) for i in range(3)]
sage: MM
[
[1 0 0]  [1 0 0]  [1 0 0]
[0 1 0]  [0 1 0]  [0 1 0]
[0 0 1], [0 0 1], [0 0 1]
]
sage: print(MM)
[[1 0 0]
[0 1 0]
[0 0 1], [1 0 0]
[0 1 0]
[0 0 1], [1 0 0]
[0 1 0]
[0 0 1]]

Is there a way to print a list of matrices as the first above ?

(Perhaps by saving it on an external file, what would be the line code for that ?)

edit retag flag offensive close merge delete

1 answer

Sort by » oldest newest most voted
1

answered 2013-09-10 01:33:02 -0600

tmonteil gravatar image

You can do:

sage: print sage.misc.displayhook.format_obj(MM)
[
[1 0 0]  [1 0 0]  [1 0 0]
[0 1 0]  [0 1 0]  [0 1 0]
[0 0 1], [0 0 1], [0 0 1]
]

You can also have a look at this question.

edit flag offensive delete link more

Comments

Seems to not be possible anymore (in SageMath 7.2)

Daniel Krenn gravatar imageDaniel Krenn ( 2016-08-06 09:57:47 -0600 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

Stats

Asked: 2013-09-10 01:18:10 -0600

Seen: 136 times

Last updated: Sep 10 '13