I would like to propose the addition of a matrix literal syntax, namely

sage: [1, 2; 3, 4]
[1 2]
[3 4]
sage: [1, 2; 3, 4] * [5, 6; 7, 8]
[19 22]
[43 50]

Currently one must write

sage: matrix([[1, 2], [3, 4]])
[1 2]
[3 4]
sage: matrix([[1, 2], [3, 4]]) * matrix([[5, 6], [7, 8]])
[19 22]
[43 50]

This is a followup from the discussion at
https://groups.google.com/forum/#!msg/sage-devel/p-nrpKUBMm8/LUMAfoXsz-UJ
, but brought to the forefront due to a wanting to publish something
with many small matrices as examples. Not all the details need be
fleshed out, but the basic idea is that a semi-colon in within
brackets would create a matrix (row). Nested matrices, trailing
semicolons, spanning lines, etc. would of course be supported
correctly and is not that hard of a challenge. Of course adding to the
preparser should not be done lightly, but I think this is simple,
useful, and intuitive enough to justify the diversion from pure
Python. At this point I'm just looking for an up/down vote on whether
we could count on something like this to go in, though more detailed
design decision would be interesting as well. Preliminary patch at
http://trac.sagemath.org/sage_trac/ticket/12354 .

A second question, what of the basering? Lots of times it's more
convenient to use the fraction field, especially if there was an
easier way to set it "back" to ZZ for those who care about the it. One
could go a step further and create matrices over RDF if the entries
are in RR (as linear algebra over RR is both slow and bad). One of the
main complaints I've heard about Sage from non (pure) mathematicians
is that they feel that the abstract notions of rings, etc. are shoved
in their face, and having to specify QQ every time an matrix is
constructed falls into this...

Thoughts?

- Robert

-- 
To post to this group, send an email to sage-devel@googlegroups.com
To unsubscribe from this group, send an email to 
sage-devel+unsubscr...@googlegroups.com
For more options, visit this group at http://groups.google.com/group/sage-devel
URL: http://www.sagemath.org

Reply via email to