ASKSAGE: Sage Q&A Forum - RSS feedhttps://ask.sagemath.org/questions/Q&A Forum for SageenCopyright Sage, 2010. Some rights reserved under creative commons license.Tue, 25 Mar 2014 16:24:31 +0100Direct sum of matrix spaceshttps://ask.sagemath.org/question/11169/direct-sum-of-matrix-spaces/Is it possible to construct a direct sum of matrix spaces?
For example:
M1 = MatrixSpace(QQ, 1)
M2 = MatrixSpace(QQ, 2)
M = DirectSum(M1, M1, M2) # doesnt work
ThanksSun, 23 Mar 2014 09:09:32 +0100https://ask.sagemath.org/question/11169/direct-sum-of-matrix-spaces/Answer by tmonteil for <p>Is it possible to construct a direct sum of matrix spaces?</p>
<p>For example:</p>
<pre><code>M1 = MatrixSpace(QQ, 1)
M2 = MatrixSpace(QQ, 2)
M = DirectSum(M1, M1, M2) # doesnt work
</code></pre>
<p>Thanks</p>
https://ask.sagemath.org/question/11169/direct-sum-of-matrix-spaces/?answer=16103#post-id-16103You can do:
sage: M = CartesianProduct(M1, M1, M2)
sage: M
Cartesian product of Full MatrixSpace of 1 by 1 dense matrices over Rational Field, Full MatrixSpace of 1 by 1 dense matrices over Rational Field, Full MatrixSpace of 2 by 2 dense matrices over Rational Field
But then you will lose the algebra structure:
sage: M.category()
Category of enumerated sets
sage: M1.category()
Category of algebras over Rational Field
It should be possible to keep this structure by doing something like:
sage: M1.cartesian_product(M1,M2)
But then you will get an
AttributeError: type object 'MatrixSpace' has no attribute 'CartesianProduct'Tue, 25 Mar 2014 16:24:31 +0100https://ask.sagemath.org/question/11169/direct-sum-of-matrix-spaces/?answer=16103#post-id-16103