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.Fri, 29 Mar 2019 04:11:33 -0500How do I get the result of right_kernel into a matrix?http://ask.sagemath.org/question/45935/how-do-i-get-the-result-of-right_kernel-into-a-matrix/Hello,
I have a simple program I am running where I define a matrix C, then define
B=C.right_kernel()
I would then like to create another matrix, D, that is a block matrix with C and B as blocks, C on top of B. So far my code for that is
Dlist = []
for i in range(len(rowsofmatrix)):
Dlist.append(C[i,:])
for i in range(20-len(rowsofmatrix)):
Dlist.append(B[i,:])
where rowsofmatrix is a list I used to define the matrix C. The Dlist.append(C[I,:]) works just fine, but the second one involving B does not, and I imagine this has something to do with the form of B. Is there a way I can express B as a regular matrix? Or, alternatively, is there a better way to do this altogether?
ThanksThu, 28 Mar 2019 20:00:40 -0500http://ask.sagemath.org/question/45935/how-do-i-get-the-result-of-right_kernel-into-a-matrix/Answer by rburing for <p>Hello,
I have a simple program I am running where I define a matrix C, then define</p>
<p>B=C.right_kernel()</p>
<p>I would then like to create another matrix, D, that is a block matrix with C and B as blocks, C on top of B. So far my code for that is </p>
<p>Dlist = []</p>
<p>for i in range(len(rowsofmatrix)):</p>
<pre><code>Dlist.append(C[i,:])
</code></pre>
<p>for i in range(20-len(rowsofmatrix)):</p>
<pre><code>Dlist.append(B[i,:])
</code></pre>
<p>where rowsofmatrix is a list I used to define the matrix C. The Dlist.append(C[I,:]) works just fine, but the second one involving B does not, and I imagine this has something to do with the form of B. Is there a way I can express B as a regular matrix? Or, alternatively, is there a better way to do this altogether?</p>
<p>Thanks</p>
http://ask.sagemath.org/question/45935/how-do-i-get-the-result-of-right_kernel-into-a-matrix/?answer=45936#post-id-45936Yes, you can do this:
sage: B = C.right_kernel().matrix()
sage: D = block_matrix([[C],[B]], subdivide=True)Fri, 29 Mar 2019 04:11:33 -0500http://ask.sagemath.org/question/45935/how-do-i-get-the-result-of-right_kernel-into-a-matrix/?answer=45936#post-id-45936