ASKSAGE: Sage Q&A Forum - Individual question feedhttp://ask.sagemath.org/questions/Q&A Forum for SageenCopyright Sage, 2010. Some rights reserved under creative commons license.Sat, 01 Dec 2012 00:22:03 -0600creating a matrix from blockshttp://ask.sagemath.org/question/9588/creating-a-matrix-from-blocks/I am new to SAGE. I need to create a matrix by using matrices of different sizes. For example:
Abar= [(A + B), C]
[ D , E]
where A and B are 2x2's, C is a 2x1, D is a 1x2, and E is a 1x1. I do not need Abar to be a partitioned matrix. Thanks much.Thu, 29 Nov 2012 12:30:58 -0600http://ask.sagemath.org/question/9588/creating-a-matrix-from-blocks/Answer by fidbc for <p>I am new to SAGE. I need to create a matrix by using matrices of different sizes. For example:</p>
<pre><code>Abar= [(A + B), C]
[ D , E]
</code></pre>
<p>where A and B are 2x2's, C is a 2x1, D is a 1x2, and E is a 1x1. I do not need Abar to be a partitioned matrix. Thanks much.</p>
http://ask.sagemath.org/question/9588/creating-a-matrix-from-blocks/?answer=14326#post-id-14326Here is a way of getting `Abar`
sage: Abar=block_matrix([[(A+B),C],[D,E]])
Update:
Using @calc314's suggestion for no subdivisions:
sage: Abar=block_matrix([[(A+B),C],[D,E]], subdivide=False)Thu, 29 Nov 2012 13:32:19 -0600http://ask.sagemath.org/question/9588/creating-a-matrix-from-blocks/?answer=14326#post-id-14326Comment by Dionysus for <p>Here is a way of getting <code>Abar</code></p>
<pre><code>sage: Abar=block_matrix([[(A+B),C],[D,E]])
</code></pre>
<p>Update:
Using <a href="/users/218/calc314/">@calc314</a>'s suggestion for no subdivisions:</p>
<pre><code>sage: Abar=block_matrix([[(A+B),C],[D,E]], subdivide=False)
</code></pre>
http://ask.sagemath.org/question/9588/creating-a-matrix-from-blocks/?comment=18600#post-id-18600Thanks much, but I still get a syntax error. I have double checked the matrices A,B,C,D, and E by using print and dimensions are correct. The matrices do contain symbolic variables that have been defined using var. Any suggestions? Thanks.Fri, 30 Nov 2012 17:39:31 -0600http://ask.sagemath.org/question/9588/creating-a-matrix-from-blocks/?comment=18600#post-id-18600Comment by fidbc for <p>Here is a way of getting <code>Abar</code></p>
<pre><code>sage: Abar=block_matrix([[(A+B),C],[D,E]])
</code></pre>
<p>Update:
Using <a href="/users/218/calc314/">@calc314</a>'s suggestion for no subdivisions:</p>
<pre><code>sage: Abar=block_matrix([[(A+B),C],[D,E]], subdivide=False)
</code></pre>
http://ask.sagemath.org/question/9588/creating-a-matrix-from-blocks/?comment=18612#post-id-18612Nice! I'll update the answer above.Thu, 29 Nov 2012 13:40:11 -0600http://ask.sagemath.org/question/9588/creating-a-matrix-from-blocks/?comment=18612#post-id-18612Comment by calc314 for <p>Here is a way of getting <code>Abar</code></p>
<pre><code>sage: Abar=block_matrix([[(A+B),C],[D,E]])
</code></pre>
<p>Update:
Using <a href="/users/218/calc314/">@calc314</a>'s suggestion for no subdivisions:</p>
<pre><code>sage: Abar=block_matrix([[(A+B),C],[D,E]], subdivide=False)
</code></pre>
http://ask.sagemath.org/question/9588/creating-a-matrix-from-blocks/?comment=18613#post-id-18613If you don't want the subdivisions, you can use: `block_matrix([[a+b,c],[d,e]],subdivide=False)`Thu, 29 Nov 2012 13:36:29 -0600http://ask.sagemath.org/question/9588/creating-a-matrix-from-blocks/?comment=18613#post-id-18613Answer by Dionysus for <p>I am new to SAGE. I need to create a matrix by using matrices of different sizes. For example:</p>
<pre><code>Abar= [(A + B), C]
[ D , E]
</code></pre>
<p>where A and B are 2x2's, C is a 2x1, D is a 1x2, and E is a 1x1. I do not need Abar to be a partitioned matrix. Thanks much.</p>
http://ask.sagemath.org/question/9588/creating-a-matrix-from-blocks/?answer=14302#post-id-14302Thanks much, but I still get a syntax error. I have double checked the matrices A,B,C,D, and E by using print and dimensions are correct. The matrices do contain symbolic variables that have been defined using var. Any suggestions? Thanks.Fri, 30 Nov 2012 13:16:53 -0600http://ask.sagemath.org/question/9588/creating-a-matrix-from-blocks/?answer=14302#post-id-14302Comment by calc314 for <p>Thanks much, but I still get a syntax error. I have double checked the matrices A,B,C,D, and E by using print and dimensions are correct. The matrices do contain symbolic variables that have been defined using var. Any suggestions? Thanks.</p>
http://ask.sagemath.org/question/9588/creating-a-matrix-from-blocks/?comment=18599#post-id-18599Please post all of your code or a simplified example so we can take a look at the situation.Sat, 01 Dec 2012 00:22:03 -0600http://ask.sagemath.org/question/9588/creating-a-matrix-from-blocks/?comment=18599#post-id-18599