On 20/06/15 23:21, Nils Bruin wrote:
On Saturday, June 20, 2015 at 11:55:02 AM UTC-7, Martin R wrote:
Yes, that's quite clear. _matrix_constructor determines nrows (2) and
ncols (3) and the ring (Symbolic Ring) and calls
matrix_space.MatrixSpace(ring, nrows, ncols)(entries). This fails, since
entries is a single element. But the bug is, I'd say, that
_matrix_constructor calls MatrixSpace with a single element.
What is the bug here? Do you think matrix(2,3,1) should succeed? Do you
think it should produce a different error message? The following behaviour
seems quite reasonable to me:
sage: MatrixSpace(ZZ,2,2)(5)
[5 0]
[0 5]
sage: MatrixSpace(ZZ,2,3)(5)
TypeError: nonzero scalar matrix must be square
Although:
This is definitely reasonable. The very same way it is for polynomial rings.
sage: MatrixSpace(ZZ,2,3)(0)
[0 0 0]
[0 0 0]
suggests this should perhaps be a ValueError
Why? This is not the same as the example with square matrices. zero is
very special in the coercion framework. And if you break it for matrix
you *need* to break it for vectors for consistency.
sage: VectorSpace(QQ,3)(0)
(0, 0, 0)
sage: VectorSpace(QQ,3)(2)
...
TypeError: can't initialize vector from nonzero non-list
Vincent
--
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 [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/sage-devel.
For more options, visit https://groups.google.com/d/optout.