Mon 2017-09-11 10:07:01 UTC-5, Martin R: > Is there a recommended (fast) way to turn input > into a (square) matrix (with entries in ZZ)? > Currently I do "corner = matrix(corner)"
Suppose you defined m_list = [[0, 1, 2], [3, 4, 5], [6, 7, 8]] and you want to turn m_list into a 3 by 3 matrix over ZZ. Then I recommend this: m = matrix(ZZ, 3, m_list) By comparison, if you do the more lazy m = matrix(m_list) Sage will have to figure out by itself what is the appropriate base ring and dimension to use. Figuring out the dimension is fast enough but for figuring out the base ring means looking for a common parent for all the elements, a waste of time if you already know what base ring you want. Note that m = matrix(ZZ, 3, m_list) will also work if you defined m_list using m_list = [0, 1, 2, 3, 4, 5, 6, 7, 8] If you need to construct a lot of matrices in the same matrix space, you might want to first define M = MatrixSpace(ZZ, 3) and then for each matrix you create, do m = M(m_list) Thus you avoid creating an instance of the matrix space each time you create a matrix. -- You received this message because you are subscribed to the Google Groups "sage-devel" group. To unsubscribe from this group and stop receiving emails from it, send an email to sage-devel+unsubscr...@googlegroups.com. To post to this group, send email to sage-devel@googlegroups.com. Visit this group at https://groups.google.com/group/sage-devel. For more options, visit https://groups.google.com/d/optout.