On Saturday, June 20, 2015 at 9:15:06 AM UTC-7, Martin R wrote: > > I don't understand this. I just traced matrix(2,2,x) and this is handled > by _matrix_constructor. I don't see why matrix(2,2,x) needs to return a > diagonal matrix. Could you please explain what you mean with > "matrix(n,n,c) is coming from matrix rings"? > > See the error that arises if you do matrix(2,3,1). It stumbles because it discovers that the number of rows doesn't equal the number of columns in constructing an identity matrix (i.e., the matrix space in question isn't a ring).
I don't know how exactly the matrix code is structured to distinguish square from non-square matrices, but the difference is recognized on category level: sage: category(parent(matrix(2,3))) Category of modules over (euclidean domains and infinite enumerated sets) sage: category(parent(matrix(2,2))) Category of algebras over (euclidean domains and infinite enumerated sets) The fact that scalars probably should coerce into square matrix spaces is suggested by the fact that they don't just form a module--they form an algebra. I think that's why we support constructing a square matrix from a scalar. sage: matrix(2,2,[1,0,0,1])+1 [2 0] [0 2] I don't think it's entirely required, but the map from a base ring to a unitary algebra (by mapping to the appropriate scalar multiple of unity) is pretty canonical. This is also the coercion map Z->Z/nZ and the map Z->Z[x], so I imagine some people might be unhappy if it were pulled. -- 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 http://groups.google.com/group/sage-devel. For more options, visit https://groups.google.com/d/optout.